From a7bada8b86b8edeedcfdd6dd687dd825322177ed Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 15 Apr 2023 19:22:34 +0000 Subject: [PATCH] Provide SHA3 length related defines. These will make EVP integration easier, as well as being used in the SHA3 implementation itself. --- lib/libcrypto/sha/sha3_internal.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/libcrypto/sha/sha3_internal.h b/lib/libcrypto/sha/sha3_internal.h index 889f12c8e9f..05a02c8e2c1 100644 --- a/lib/libcrypto/sha/sha3_internal.h +++ b/lib/libcrypto/sha/sha3_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sha3_internal.h,v 1.8 2023/04/15 18:32:55 jsing Exp $ */ +/* $OpenBSD: sha3_internal.h,v 1.9 2023/04/15 19:22:34 jsing Exp $ */ /* * The MIT License (MIT) * @@ -29,6 +29,32 @@ #ifndef HEADER_SHA3_INTERNAL_H #define HEADER_SHA3_INTERNAL_H +#define KECCAK_BIT_WIDTH 1600 +#define KECCAK_BYTE_WIDTH (KECCAK_BIT_WIDTH / 8) + +#define SHA3_224_BIT_LENGTH 224 +#define SHA3_224_BITRATE (2 * SHA3_224_BIT_LENGTH) +#define SHA3_224_CAPACITY (KECCAK_BIT_WIDTH - SHA3_224_BITRATE) +#define SHA3_224_BLOCK_SIZE (SHA3_224_CAPACITY / 8) +#define SHA3_224_DIGEST_LENGTH (SHA3_224_BIT_LENGTH / 8) + +#define SHA3_256_BIT_LENGTH 256 +#define SHA3_256_BITRATE (2 * SHA3_256_BIT_LENGTH) +#define SHA3_256_CAPACITY (KECCAK_BIT_WIDTH - SHA3_256_BITRATE) +#define SHA3_256_BLOCK_SIZE (SHA3_256_CAPACITY / 8) +#define SHA3_256_DIGEST_LENGTH (SHA3_256_BIT_LENGTH / 8) + +#define SHA3_384_BIT_LENGTH 384 +#define SHA3_384_BITRATE (2 * SHA3_384_BIT_LENGTH) +#define SHA3_384_CAPACITY (KECCAK_BIT_WIDTH - SHA3_384_BITRATE) +#define SHA3_384_BLOCK_SIZE (SHA3_384_CAPACITY / 8) +#define SHA3_384_DIGEST_LENGTH (SHA3_384_BIT_LENGTH / 8) + +#define SHA3_512_BIT_LENGTH 512 +#define SHA3_512_BITRATE (2 * SHA3_512_BIT_LENGTH) +#define SHA3_512_CAPACITY (KECCAK_BIT_WIDTH - SHA3_512_BITRATE) +#define SHA3_512_BLOCK_SIZE (SHA3_512_CAPACITY / 8) + typedef struct { union { uint8_t b[200]; /* State as 8 bit bytes. */ -- 2.20.1