Skip to content

Commit

Permalink
Start introducing optblockers to prevent unwanted conditional jumps
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Aug 1, 2024
1 parent 8c54312 commit 92611e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ slide_vartime(signed char *r, const unsigned char *a)
}
}

static volatile unsigned char optblocker_u8;

int
ge25519_frombytes(ge25519_p3 *h, const unsigned char *s)
{
Expand Down Expand Up @@ -353,7 +355,7 @@ ge25519_frombytes(ge25519_p3 *h, const unsigned char *s)
fe25519_cmov(h->X, x_sqrtm1, 1 - has_m_root);

fe25519_neg(negx, h->X);
fe25519_cmov(h->X, negx, fe25519_isnegative(h->X) ^ (s[31] >> 7));
fe25519_cmov(h->X, negx, fe25519_isnegative(h->X) ^ (((s[31] >> 5) ^ optblocker_u8) >> 2));
fe25519_mul(h->T, h->X, h->Y);

return (has_m_root | has_p_root) - 1;
Expand Down

0 comments on commit 92611e3

Please sign in to comment.