]> git.codecow.com Git - Monocypher.git/commitdiff
Better test for crypto_x25519_inverse()
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 5 Jul 2020 09:46:13 +0000 (11:46 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 5 Jul 2020 09:46:13 +0000 (11:46 +0200)
tests/test.c

index 271fd9706e4fe367eb3af387a89ead1945b3194f..a6cb629ce4304281b82bef7855d86e6fa4bda43d 100644 (file)
@@ -1009,13 +1009,15 @@ static int p_elligator_key_pair_overlap()
 static int p_x25519_inverse()
 {
     int status = 0;
-    const u8 base [32] = {9};
+    RANDOM_INPUT(b, 32);
+    u8 base[32];  // random point (cofactor is cleared).
+    crypto_x25519_public_key(base, b);
     // check round trip
     FOR (i, 0, 50) {
         RANDOM_INPUT(sk, 32);
         u8 pk   [32];
         u8 blind[32];
-        crypto_x25519_public_key(pk, sk);
+        crypto_x25519(pk, sk, base);
         crypto_x25519_inverse(blind, sk, pk);
         status |= memcmp(blind, base, 32);
     }