ristretto255_is_canonical(): sync with wasm-crypto

Reject string with the top bit set.
This commit is contained in:
Frank Denis 2020-04-25 12:15:30 +02:00
parent 8fbe4ceb64
commit be00e8d72b

View File

@ -2675,6 +2675,7 @@ ristretto255_is_canonical(const unsigned char *s)
{
unsigned char c;
unsigned char d;
unsigned char e;
unsigned int i;
c = (s[31] & 0x7f) ^ 0x7f;
@ -2683,8 +2684,9 @@ 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;
return 1 - (((c & d) | s[0]) & 1);
return 1 - (((c & d) | e | s[0]) & 1);
}
int