]> git.codecow.com Git - Monocypher.git/commitdiff
Tests: fixed tweak coverage for Elligator.
authorLoup Vaillant <loup@loup-vaillant.fr>
Sat, 7 Nov 2020 23:22:09 +0000 (00:22 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sat, 7 Nov 2020 23:22:09 +0000 (00:22 +0100)
Shifting the index by 6 caused a reuse of one bit, leading to 4
different configurations instead of 8.
Shifting by 5 means we are using the 3 least significant bits of the
index, as was always intended.

tests/test.c

index a241157a9738d7bbbac47bf3bf8cfa2b2209db79..5099634e71ff69dd492da920665461239ca2a548 100644 (file)
@@ -975,7 +975,7 @@ static int p_elligator_x25519()
 
         // Maximise tweak diversity.
         // We want to set the bits 1 (sign) and 6-7 (padding)
-        u8 tweak = (u8)((i & 1) + (i << 6));
+        u8 tweak = (u8)((i & 1) + (i << 5));
         u8 r[32];
         if (crypto_curve_to_hidden(r, pkf, tweak)) {
             continue; // retry untill success (doesn't increment the tweak)