Provide SHA3 length related defines.
authorjsing <jsing@openbsd.org>
Sat, 15 Apr 2023 19:22:34 +0000 (19:22 +0000)
committerjsing <jsing@openbsd.org>
Sat, 15 Apr 2023 19:22:34 +0000 (19:22 +0000)
These will make EVP integration easier, as well as being used in the SHA3
implementation itself.

lib/libcrypto/sha/sha3_internal.h

index 889f12c..05a02c8 100644 (file)
@@ -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)
  *
 #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. */