From f1db3f57b0f679d878bab3a7072ac6be5f3d00a6 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Thu, 22 Mar 2018 21:51:06 +0100 Subject: [PATCH] Adjusted the number of test vectors There were too many tests vectors. This is redundant, takes more time to test, and bloats the generated vectors header file, which then takes longer to compile. I reduced their numbers, while making sure they were as effective as they used to be (maximum code coverage, and every relevant lengths still tested). For those who worry about dangerously reducing the number of tests for Poly1305: don't. There is nothing the random tests can catch that the official, hand crafted test vectors cannot. The random tests don't really test the core algorithm, they test the loading code. --- tests/gen/argon2i.c | 6 +++--- tests/gen/chacha20.c | 12 ++++++------ tests/gen/poly1305.c | 6 +++--- tests/gen/xchacha20.c | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/gen/argon2i.c b/tests/gen/argon2i.c index b5b36d8..108c021 100644 --- a/tests/gen/argon2i.c +++ b/tests/gen/argon2i.c @@ -30,8 +30,8 @@ void test(size_t nb_blocks, size_t hash_size, size_t nb_iterations) int main(void) { SODIUM_INIT; - FOR (nb_blocks , 8, 1024) { test(nb_blocks, 32 , 3 ); } - FOR (hash_size , 16, 256) { test(8 , hash_size, 3 ); } - FOR (nb_iterations, 3, 10) { test(8 , 32 , nb_iterations); } + FOR (nb_blocks , 384, 640) { test(nb_blocks, 32 , 3 ); } + FOR (hash_size , 16, 256) { test(8 , hash_size, 3 ); } + FOR (nb_iterations, 3, 10) { test(8 , 32 , nb_iterations); } return 0; } diff --git a/tests/gen/chacha20.c b/tests/gen/chacha20.c index 96b4c81..b936293 100644 --- a/tests/gen/chacha20.c +++ b/tests/gen/chacha20.c @@ -5,8 +5,8 @@ static void test(size_t size, u64 ctr) { RANDOM_INPUT(key , 32); RANDOM_INPUT(nonce, 8); - RANDOM_INPUT(in , 256); // size <= 256 - u8 out [256]; // size <= 256 + RANDOM_INPUT(in , 128); // size <= 128 + u8 out [128]; // size <= 128 crypto_stream_chacha20_xor_ic(out, in, size, nonce, ctr, key); @@ -22,10 +22,10 @@ int main(void) { SODIUM_INIT; // regular tests - FOR (size, 0, 256) { test(size, rand64()); } + FOR (size, 0, 128) { test(size, rand64()); } // counter overflow (should wrap around) - test(256, -1); - test(256, -2); - test(256, -3); + test(128, -1); + test(128, -2); + test(128, -3); return 0; } diff --git a/tests/gen/poly1305.c b/tests/gen/poly1305.c index 6c8fbe6..ad57eda 100644 --- a/tests/gen/poly1305.c +++ b/tests/gen/poly1305.c @@ -3,8 +3,8 @@ void test(size_t size) { - RANDOM_INPUT(key, 32); - RANDOM_INPUT(in , 256); + RANDOM_INPUT(key, 32); + RANDOM_INPUT(in , 32); u8 tag[ 16]; crypto_onetimeauth(tag, in, size, key); @@ -18,6 +18,6 @@ void test(size_t size) int main(void) { SODIUM_INIT; - FOR (size, 0, 256) { test(size); } + FOR (size, 0, 32) { test(size); } return 0; } diff --git a/tests/gen/xchacha20.c b/tests/gen/xchacha20.c index b1584e4..480c390 100644 --- a/tests/gen/xchacha20.c +++ b/tests/gen/xchacha20.c @@ -5,8 +5,8 @@ static void test(size_t size, u64 ctr) { RANDOM_INPUT(key , 32); RANDOM_INPUT(nonce, 24); - RANDOM_INPUT(in , 256); // size <= 256 - u8 out [256]; // size <= 256 + RANDOM_INPUT(in , 128); // size <= 128 + u8 out [128]; // size <= 128 crypto_stream_xchacha20_xor_ic(out, in, size, nonce, ctr, key); @@ -22,10 +22,10 @@ int main(void) { SODIUM_INIT; // regular tests - FOR (size, 0, 256) { test(size, rand64()); } + FOR (size, 0, 128) { test(size, rand64()); } // counter overflow (should wrap around) - test(256, -1); - test(256, -2); - test(256, -3); + test(128, -1); + test(128, -2); + test(128, -3); return 0; } -- 2.47.3