]> git.codecow.com Git - Monocypher.git/commitdiff
fe_ccopy() now works the same as fe_cswap()
authorLoup Vaillant <loup@loup-vaillant.fr>
Mon, 20 Aug 2018 16:58:19 +0000 (18:58 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Mon, 20 Aug 2018 16:58:19 +0000 (18:58 +0200)
src/monocypher.c

index 1143fd9855e3ad59a93d802cde1119bd2d9ed593..fd402d37b61d2f219b9fc1e6e6f24cf3be32663c 100644 (file)
@@ -1026,10 +1026,10 @@ static void fe_cswap(fe f, fe g, int b)
     }
 }
 
-static void fe_ccopy(fe f, const fe g, i32 b)
+static void fe_ccopy(fe f, const fe g, int b)
 {
     FOR (i, 0, 10) {
-        i32 x = (f[i] ^ g[i]) & ~(u32)b;
+        i32 x = (f[i] ^ g[i]) & -b;
         f[i] = f[i] ^ x;
     }
 }
@@ -1804,7 +1804,7 @@ static void ge_scalarmult_base(ge *p, const u8 scalar[32])
         u8 high  = teeth >> 4;
         u8 index = (teeth ^ (high - 1)) & 15;
         FOR (j, 0, 16) {
-            i32 select = (1 & (((j ^ index) - 1) >> 8)) - 1;
+            i32 select = 1 & (((j ^ index) - 1) >> 8);
             fe_ccopy(yp, comb_Yp[j], select);
             fe_ccopy(ym, comb_Ym[j], select);
             fe_ccopy(t2, comb_T2[j], select);