]> git.codecow.com Git - Monocypher.git/commitdiff
Tests for crypto_verify*() catch more errors
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 17 Jun 2018 18:05:36 +0000 (20:05 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 17 Jun 2018 18:05:36 +0000 (20:05 +0200)
The test had a symmetry that caused them to miss a possible error, where
the implementer would replace an `|` operator by an `&` operator.
Breaking that symmetry allow them to catch that error.

The other errors are caught all the same.

tests/test.c

index 8722e6eb7704927188dad372162d6daa63826023..8ee4a78360286b8e71728ccec321854eeb197f89 100644 (file)
@@ -262,8 +262,8 @@ static int p_verify(size_t size, int (*compare)(const u8*, const u8*))
                     a[l] = 0;
                     b[l] = 0;
                 }
-                a[k] = i; a[k + size/2] = i;
-                b[k] = j; b[k + size/2] = j;
+                a[k] = i; a[k + size/2 - 1] = i;
+                b[k] = j; b[k + size/2 - 1] = j;
                 int cmp = compare(a, b);
                 status |= (i == j ? cmp : ~cmp);
             }