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

Decrement and shift in separate steps

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

View File

@ -621,9 +621,10 @@ equal(signed char b, signed char c)
return z;
#else
const unsigned char x = (unsigned char) b ^ (unsigned char) c; /* 0: yes; 1..255: no */
const uint32_t y = (uint32_t) x; /* 0: yes; 1..255: no */
uint32_t y = (uint32_t) x; /* 0: yes; 1..255: no */
return (((y - 1) >> 29) ^ optblocker_u8) >> 2; /* 1: yes; 0: no */
y--;
return ((y >> 29) ^ optblocker_u8) >> 2; /* 1: yes; 0: no */
#endif
}