From 8d6623f407c47a136271b11ce94339ca2ff4cea2 Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:30:51 -0700 Subject: [PATCH 1/2] Allow sha3_HashBuffer to accept `size_t inBytes` instead of `uint inBytes` --- source/sha3iuf_d/sha3.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sha3iuf_d/sha3.d b/source/sha3iuf_d/sha3.d index a5e68cc..64e5207 100755 --- a/source/sha3iuf_d/sha3.d +++ b/source/sha3iuf_d/sha3.d @@ -437,7 +437,7 @@ public const (void)* sha3_Finalize(return scope void* priv) */ extern (C) pure nothrow @trusted @nogc @live -public .sha3_return_t sha3_HashBuffer(uint bitSize, .SHA3_FLAGS flags, scope const void* in_, uint inBytes, return scope void* out_, uint outBytes) +public .sha3_return_t sha3_HashBuffer(uint bitSize, .SHA3_FLAGS flags, scope const void* in_, size_t inBytes, return scope void* out_, uint outBytes) in { From 4ecd52105669133440a424f1ecf3635ea88fe2a5 Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:32:09 -0700 Subject: [PATCH 2/2] Update sha3iuf-d.h to match sha3.d --- include/sha3iuf-d.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/sha3iuf-d.h b/include/sha3iuf-d.h index c05eb3e..4dab2f6 100755 --- a/include/sha3iuf-d.h +++ b/include/sha3iuf-d.h @@ -48,19 +48,19 @@ typedef struct sha3_context_ * 0..7--the next byte after the set one * (starts from 0; 0--none are buffered) */ - uint8_t byteIndex; + uint32_t byteIndex; /* * 0..24--the next word to integrate input * (starts from 0) */ - uint8_t wordIndex; + uint32_t wordIndex; /* * the double size of the hash output in * words (e.g. 16 for Keccak 512) */ - uint8_t capacityWords; + uint32_t capacityWords; } sha3_context; enum SHA3_FLAGS @@ -78,7 +78,7 @@ enum SHA3_RETURN typedef enum SHA3_RETURN sha3_return_t; /* For Init or Reset call these: */ -sha3_return_t sha3_Init(void* priv, uint8_t bitSize); +sha3_return_t sha3_Init(void* priv, uint32_t bitSize); void sha3_Init256(void* priv); void sha3_Init384(void* priv); @@ -91,9 +91,9 @@ void sha3_Update(void* priv, void const* bufIn, size_t len); void const* sha3_Finalize(void* priv); /* Single-call hashing */ -sha3_return_t sha3_HashBuffer(uint8_t bitSize, /* 256, 384, 512 */ +sha3_return_t sha3_HashBuffer(uint32_t bitSize, /* 256, 384, 512 */ enum SHA3_FLAGS flags, /* SHA3_FLAGS_NONE or SHA3_FLAGS_KECCAK */ - const void* in_, uint8_t inBytes, void* out_, uint8_t outBytes); /* up to bitSize/8; truncation OK */ + const void* in_, size_t inBytes, void* out_, uint32_t outBytes); /* up to bitSize/8; truncation OK */ #ifdef __cplusplus }