diff options
author | Robert Relyea <rrelyea@redhat.com> | 2023-02-27 15:19:20 -0800 |
---|---|---|
committer | Robert Relyea <rrelyea@redhat.com> | 2023-02-27 15:19:20 -0800 |
commit | f4262a3db99a22b38fc8d6d9e8103ad31a697f9f (patch) | |
tree | 8b77dde21c43c846e9312de578887c0492469da3 /lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c | |
parent | 9a7e1bc157adb261651fefb791901614460843a1 (diff) | |
download | nss-hg-f4262a3db99a22b38fc8d6d9e8103ad31a697f9f.tar.gz |
This change was supposed to be pushed to nss-try,
but something went out of wack. Back this change out of the tip
Diffstat (limited to 'lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c')
-rw-r--r-- | lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c b/lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c deleted file mode 100644 index ed4a6541f..000000000 --- a/lib/liboqs/src/kem/kyber/pqcrystals-kyber_kyber512_ref/verify.c +++ /dev/null @@ -1,47 +0,0 @@ -#include <stddef.h> -#include <stdint.h> -#include "verify.h" - -/************************************************* -* Name: verify -* -* Description: Compare two arrays for equality in constant time. -* -* Arguments: const uint8_t *a: pointer to first byte array -* const uint8_t *b: pointer to second byte array -* size_t len: length of the byte arrays -* -* Returns 0 if the byte arrays are equal, 1 otherwise -**************************************************/ -int verify(const uint8_t *a, const uint8_t *b, size_t len) -{ - size_t i; - uint8_t r = 0; - - for(i=0;i<len;i++) - r |= a[i] ^ b[i]; - - return (-(uint64_t)r) >> 63; -} - -/************************************************* -* Name: cmov -* -* Description: Copy len bytes from x to r if b is 1; -* don't modify x if b is 0. Requires b to be in {0,1}; -* assumes two's complement representation of negative integers. -* Runs in constant time. -* -* Arguments: uint8_t *r: pointer to output byte array -* const uint8_t *x: pointer to input byte array -* size_t len: Amount of bytes to be copied -* uint8_t b: Condition bit; has to be in {0,1} -**************************************************/ -void cmov(uint8_t *r, const uint8_t *x, size_t len, uint8_t b) -{ - size_t i; - - b = -b; - for(i=0;i<len;i++) - r[i] ^= b & (r[i] ^ x[i]); -} |