From de20a02d9f022dcc480a97381666a2bcc5b0fc78 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Mon, 20 Aug 2018 18:58:19 +0200 Subject: [PATCH] fe_ccopy() now works the same as fe_cswap() --- src/monocypher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monocypher.c b/src/monocypher.c index 1143fd9..fd402d3 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -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); -- 2.47.3