]> git.codecow.com Git - Monocypher.git/commitdiff
Adjusted the number of test vectors
authorLoup Vaillant <loup@loup-vaillant.fr>
Thu, 22 Mar 2018 20:51:06 +0000 (21:51 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Thu, 22 Mar 2018 20:51:06 +0000 (21:51 +0100)
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
tests/gen/chacha20.c
tests/gen/poly1305.c
tests/gen/xchacha20.c

index b5b36d8bed6e3c0a2f674b54ab5dfe841b9e9edc..108c021264dfe21cde4f64b8f84f7697b159b5b0 100644 (file)
@@ -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;
 }
index 96b4c81e5416121fc06b5bd46d9e0106c153b455..b936293453d7033b5910f464e2642168dc4a101e 100644 (file)
@@ -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;
 }
index 6c8fbe61b57ba1acd6dc4ca4c0e24811acb87699..ad57eda0810ec21d72023e1d9e4d0027e5deaddc 100644 (file)
@@ -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;
 }
index b1584e4df3292f63844f39a200edadd85518217b..480c390fdbc2af70568f640af64db8cba374368d 100644 (file)
@@ -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;
 }