diff --git a/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c b/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c index b775921e..14f16e42 100644 --- a/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +++ b/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c @@ -39,3 +39,10 @@ size_t crypto_generichash_blake2b_personalbytes(void) { return crypto_generichash_blake2b_PERSONALBYTES; } + +size_t +crypto_generichash_blake2b_statebytes(void) +{ + return (sizeof(crypto_generichash_blake2b_state) + (size_t) 63U) + & ~(size_t) 63U; +} diff --git a/src/libsodium/include/sodium/crypto_generichash_blake2b.h b/src/libsodium/include/sodium/crypto_generichash_blake2b.h index 1708813e..3998e1bd 100644 --- a/src/libsodium/include/sodium/crypto_generichash_blake2b.h +++ b/src/libsodium/include/sodium/crypto_generichash_blake2b.h @@ -67,6 +67,9 @@ size_t crypto_generichash_blake2b_saltbytes(void); SODIUM_EXPORT size_t crypto_generichash_blake2b_personalbytes(void); +SODIUM_EXPORT +size_t crypto_generichash_blake2b_statebytes(void); + SODIUM_EXPORT int crypto_generichash_blake2b(unsigned char *out, size_t outlen, const unsigned char *in, diff --git a/test/default/generichash3.c b/test/default/generichash3.c index e430b725..fa0045e2 100644 --- a/test/default/generichash3.c +++ b/test/default/generichash3.c @@ -20,6 +20,7 @@ main(void) size_t i; size_t j; + assert(crypto_generichash_blake2b_statebytes() >= sizeof st); for (h = 0; h < crypto_generichash_blake2b_KEYBYTES_MAX; ++h) { k[h] = (unsigned char) h; }