diff --git a/src/libsodium/crypto_hash/sha256/hash_sha256_api.c b/src/libsodium/crypto_hash/sha256/hash_sha256_api.c index 5d2f4783..ca208fff 100644 --- a/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +++ b/src/libsodium/crypto_hash/sha256/hash_sha256_api.c @@ -4,3 +4,8 @@ size_t crypto_hash_sha256_bytes(void) { return crypto_hash_sha256_BYTES; } + +size_t +crypto_hash_sha256_statebytes(void) { + return sizeof(crypto_hash_sha256_state); +} diff --git a/src/libsodium/crypto_hash/sha512/hash_sha512_api.c b/src/libsodium/crypto_hash/sha512/hash_sha512_api.c index 75971bc2..b2629a83 100644 --- a/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +++ b/src/libsodium/crypto_hash/sha512/hash_sha512_api.c @@ -4,3 +4,8 @@ size_t crypto_hash_sha512_bytes(void) { return crypto_hash_sha512_BYTES; } + +size_t +crypto_hash_sha512_statebytes(void) { + return sizeof(crypto_hash_sha512_state); +} diff --git a/src/libsodium/include/sodium/crypto_hash_sha256.h b/src/libsodium/include/sodium/crypto_hash_sha256.h index 449ddf22..2bc33efe 100644 --- a/src/libsodium/include/sodium/crypto_hash_sha256.h +++ b/src/libsodium/include/sodium/crypto_hash_sha256.h @@ -26,6 +26,8 @@ typedef struct crypto_hash_sha256_state { uint32_t count[2]; unsigned char buf[64]; } crypto_hash_sha256_state; +SODIUM_EXPORT +size_t crypto_hash_sha256_statebytes(void); #define crypto_hash_sha256_BYTES 32U SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_hash_sha512.h b/src/libsodium/include/sodium/crypto_hash_sha512.h index e8ef2e36..12df0334 100644 --- a/src/libsodium/include/sodium/crypto_hash_sha512.h +++ b/src/libsodium/include/sodium/crypto_hash_sha512.h @@ -26,6 +26,8 @@ typedef struct crypto_hash_sha512_state { uint64_t count[2]; unsigned char buf[128]; } crypto_hash_sha512_state; +SODIUM_EXPORT +size_t crypto_hash_sha512_statebytes(void); #define crypto_hash_sha512_BYTES 64U SODIUM_EXPORT diff --git a/test/default/hash.c b/test/default/hash.c index c220bd4f..00c07231 100644 --- a/test/default/hash.c +++ b/test/default/hash.c @@ -36,6 +36,8 @@ int main(void) assert(crypto_hash_sha256_bytes() > 0U); assert(crypto_hash_sha512_bytes() >= crypto_hash_sha256_bytes()); assert(crypto_hash_sha512_bytes() == crypto_hash_bytes()); + assert(crypto_hash_sha256_statebytes() == sizeof(crypto_hash_sha256_state)); + assert(crypto_hash_sha512_statebytes() == sizeof(crypto_hash_sha512_state)); return 0; }