1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 01:55:02 -07:00

Use an optblocker in crypto_verify_n()

This commit is contained in:
Frank Denis 2024-10-23 19:58:33 +02:00
parent 51d2455cd8
commit 0c1a25e9d1

View File

@ -58,6 +58,8 @@ crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
#else
static volatile uint16_t optblocker_u16;
static inline int
crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
const int n)
@ -66,13 +68,19 @@ crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
(const volatile unsigned char *volatile) x_;
const volatile unsigned char *volatile y =
(const volatile unsigned char *volatile) y_;
volatile uint_fast16_t d = 0U;
int i;
volatile uint16_t d = 0U;
int i;
for (i = 0; i < n; i++) {
d |= x[i] ^ y[i];
}
return (1 & ((d - 1) >> 8)) - 1;
# ifdef HAVE_INLINE_ASM
__asm__ __volatile__("" : "+r"(d) :);
# endif
d--;
d = ((d >> 13) ^ optblocker_u16) >> 2;
return (int) d - 1;
}
#endif