1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-23 07:59:01 +00:00
pqcrypto/crypto_kem/ntrulpr857/avx2/crypto_verify_1312.c
John M. Schanck 431dbada45 Add sntrup{653,761,857} and ntrulpr{653,761,857}
Exported from SUPERCOP-20200826 using the scripts at:
https://github.com/jschanck/pqclean-package-ntruprime
2021-03-24 21:02:46 +00:00

37 lines
1.0 KiB
C

#include "crypto_verify_1312.h"
#include <immintrin.h>
int PQCLEAN_NTRULPR857_AVX2_crypto_verify_1312(const unsigned char *x, const unsigned char *y) {
__m256i diff = _mm256_set1_epi8(0);
unsigned int differentbits = 0;
int i = PQCLEAN_NTRULPR857_AVX2_crypto_verify_1312_BYTES;
i -= 32;
for (;;) {
do {
__m256i x0 = _mm256_loadu_si256((__m256i *) x);
__m256i y0 = _mm256_loadu_si256((__m256i *) y);
diff |= x0 ^ y0;
i -= 32;
x += 32;
y += 32;
} while (i >= 0);
if (i <= -32) {
break;
}
x += i;
y += i;
}
diff |= _mm256_srli_epi16(diff, 8);
diff |= _mm256_srli_epi32(diff, 16);
diff |= _mm256_srli_epi64(diff, 32);
differentbits = _mm256_extract_epi8(diff, 0);
differentbits |= _mm256_extract_epi8(diff, 8);
differentbits |= _mm256_extract_epi8(diff, 16);
differentbits |= _mm256_extract_epi8(diff, 24);
return (int) (1 & ((differentbits - 1) >> 8)) - 1;
}