mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 18:15:18 -07:00
Use an optblocker in crypto_verify_n()
This commit is contained in:
parent
51d2455cd8
commit
0c1a25e9d1
@ -58,6 +58,8 @@ crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
static volatile uint16_t optblocker_u16;
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
|
crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
|
||||||
const int n)
|
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) x_;
|
||||||
const volatile unsigned char *volatile y =
|
const volatile unsigned char *volatile y =
|
||||||
(const volatile unsigned char *volatile) y_;
|
(const volatile unsigned char *volatile) y_;
|
||||||
volatile uint_fast16_t d = 0U;
|
volatile uint16_t d = 0U;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
d |= x[i] ^ y[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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user