From dc49ae0491bbe8b5fcc93dd2b723dcec6f70d16c Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 14 Sep 2014 12:56:32 -0700 Subject: [PATCH] Add tests for invalid generichash parameters --- test/default/generichash.c | 6 ++++++ test/default/generichash2.c | 6 ++++++ test/default/generichash3.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/test/default/generichash.c b/test/default/generichash.c index e0599394..62faeb10 100644 --- a/test/default/generichash.c +++ b/test/default/generichash.c @@ -22,6 +22,12 @@ int main(void) printf("\n"); } + assert(crypto_generichash(out, 0U, in, sizeof in, k, sizeof k) == -1); + assert(crypto_generichash(out, crypto_generichash_BYTES_MAX + 1U, in, sizeof in, + k, sizeof k) == -1); + assert(crypto_generichash(out, sizeof out, in, sizeof in, + k, crypto_generichash_KEYBYTES_MAX + 1U) == -1); + assert(crypto_generichash_bytes_min() > 0U); assert(crypto_generichash_bytes_max() > 0U); assert(crypto_generichash_bytes() > 0U); diff --git a/test/default/generichash2.c b/test/default/generichash2.c index 1f301f48..81480ca9 100644 --- a/test/default/generichash2.c +++ b/test/default/generichash2.c @@ -27,5 +27,11 @@ int main(void) } printf("\n"); } + + assert(crypto_generichash_init(&st, k, sizeof k, 0U) == -1); + assert(crypto_generichash_init(&st, k, sizeof k, + crypto_generichash_BYTES_MAX + 1U) == -1); + assert(crypto_generichash_init(&st, k, crypto_generichash_KEYBYTES_MAX + 1U, + sizeof out) == -1); return 0; } diff --git a/test/default/generichash3.c b/test/default/generichash3.c index 3c023501..29ffd61e 100644 --- a/test/default/generichash3.c +++ b/test/default/generichash3.c @@ -32,5 +32,13 @@ int main(void) } printf("\n"); } + assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, 0U, + salt, personal) == -1); + assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, + crypto_generichash_BYTES_MAX + 1U, + salt, personal) == -1); + assert(crypto_generichash_blake2b_init_salt_personal(&st, k, + crypto_generichash_KEYBYTES_MAX + 1U, + sizeof out, salt, personal) == -1); return 0; }