From eeb31af5783dcc0867590076e084bce05ef2483f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 18 Oct 2015 00:16:05 +0200 Subject: [PATCH] Let crypto_generichash_statebytes() return a size rounded to the alignment Add similar check in the aead_aes256gcm test. --- src/libsodium/crypto_generichash/crypto_generichash.c | 2 +- test/default/aead_aes256gcm.c | 2 +- test/default/generichash2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsodium/crypto_generichash/crypto_generichash.c b/src/libsodium/crypto_generichash/crypto_generichash.c index e4547088..0af49448 100644 --- a/src/libsodium/crypto_generichash/crypto_generichash.c +++ b/src/libsodium/crypto_generichash/crypto_generichash.c @@ -46,7 +46,7 @@ crypto_generichash_primitive(void) size_t crypto_generichash_statebytes(void) { - return sizeof(crypto_generichash_state); + return (sizeof(crypto_generichash_state) + (size_t) 63U) & ~(size_t) 63U; } int diff --git a/test/default/aead_aes256gcm.c b/test/default/aead_aes256gcm.c index 675050df..5e56d56b 100644 --- a/test/default/aead_aes256gcm.c +++ b/test/default/aead_aes256gcm.c @@ -3177,7 +3177,7 @@ main(void) assert(crypto_aead_aes256gcm_nsecbytes() == crypto_aead_aes256gcm_NSECBYTES); assert(crypto_aead_aes256gcm_npubbytes() == crypto_aead_aes256gcm_NPUBBYTES); assert(crypto_aead_aes256gcm_abytes() == crypto_aead_aes256gcm_ABYTES); - assert(crypto_aead_aes256gcm_statebytes() > (size_t) 0U); + assert(crypto_aead_aes256gcm_statebytes() >= sizeof(crypto_aead_aes256gcm_state)); printf("OK\n"); return 0; diff --git a/test/default/generichash2.c b/test/default/generichash2.c index 1458d484..8ff326d3 100644 --- a/test/default/generichash2.c +++ b/test/default/generichash2.c @@ -10,7 +10,7 @@ int main(void) k[crypto_generichash_KEYBYTES_MAX]; size_t h, i, j; - assert(crypto_generichash_statebytes() == sizeof st); + assert(crypto_generichash_statebytes() >= sizeof st); for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) k[h] = h;