From 605f02d601de985d5ccbb3e5d900a9f09fb1724d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 27 Aug 2025 20:27:02 +0200 Subject: [PATCH] Add an optblocker in ge25519_from_hash --- src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c index 6f3bc2f5..4534ec05 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c +++ b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c @@ -2629,7 +2629,7 @@ ge25519_from_hash(unsigned char s[32], const unsigned char h[64]) gl[31] &= 0x7f; fe25519_frombytes(fe_f, fl); fe25519_frombytes(fe_g, gl); - fe_f[0] += (h[32] >> 7) * 19; + fe_f[0] += (((h[32] >> 5) ^ optblocker_u8) >> 2) * 19; for (i = 0; i < sizeof (fe25519) / sizeof fe_f[0]; i++) { fe_f[i] += 38 * fe_g[i]; } @@ -2689,7 +2689,7 @@ ristretto255_is_canonical(const unsigned char *s) } c = (((unsigned int) c) - 1U) >> 8; d = (0xed - 1U - (unsigned int) s[0]) >> 8; - e = s[31] >> 7; + e = ((s[31] >> 5) ^ optblocker_u8) >> 2; return 1 - (((c & d) | e | s[0]) & 1); }