mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
Remove preprocessor ignored codepath for Kyber
This commit is contained in:
parent
5853cb8e50
commit
dfe9508551
@ -32,32 +32,6 @@ static uint64_t load_littleendian(const unsigned char *x, int bytes) {
|
||||
* - const unsigned char *buf: pointer to input byte array
|
||||
**************************************************/
|
||||
void PQCLEAN_KYBER768_CLEAN_cbd(poly *r, const unsigned char *buf) {
|
||||
#if KYBER_ETA == 3
|
||||
uint32_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < KYBER_N / 4; i++) {
|
||||
t = (uint32_t)load_littleendian(buf + 3 * i, 3);
|
||||
d = 0;
|
||||
for (j = 0; j < 3; j++) {
|
||||
d += (t >> j) & 0x249249;
|
||||
}
|
||||
|
||||
a[0] = d & 0x7;
|
||||
b[0] = (d >> 3) & 0x7;
|
||||
a[1] = (d >> 6) & 0x7;
|
||||
b[1] = (d >> 9) & 0x7;
|
||||
a[2] = (d >> 12) & 0x7;
|
||||
b[2] = (d >> 15) & 0x7;
|
||||
a[3] = (d >> 18) & 0x7;
|
||||
b[3] = (d >> 21);
|
||||
|
||||
r->coeffs[4 * i + 0] = (uint16_t)(a[0] + KYBER_Q - b[0]);
|
||||
r->coeffs[4 * i + 1] = (uint16_t)(a[1] + KYBER_Q - b[1]);
|
||||
r->coeffs[4 * i + 2] = (uint16_t)(a[2] + KYBER_Q - b[2]);
|
||||
r->coeffs[4 * i + 3] = (uint16_t)(a[3] + KYBER_Q - b[3]);
|
||||
}
|
||||
#elif KYBER_ETA == 4
|
||||
uint32_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
@ -82,32 +56,4 @@ void PQCLEAN_KYBER768_CLEAN_cbd(poly *r, const unsigned char *buf) {
|
||||
r->coeffs[4 * i + 2] = (uint16_t)(a[2] + KYBER_Q - b[2]);
|
||||
r->coeffs[4 * i + 3] = (uint16_t)(a[3] + KYBER_Q - b[3]);
|
||||
}
|
||||
#elif KYBER_ETA == 5
|
||||
uint64_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < KYBER_N / 4; i++) {
|
||||
t = load_littleendian(buf + 5 * i, 5);
|
||||
d = 0;
|
||||
for (j = 0; j < 5; j++) {
|
||||
d += (t >> j) & 0x0842108421UL;
|
||||
}
|
||||
|
||||
a[0] = d & 0x1f;
|
||||
b[0] = (d >> 5) & 0x1f;
|
||||
a[1] = (d >> 10) & 0x1f;
|
||||
b[1] = (d >> 15) & 0x1f;
|
||||
a[2] = (d >> 20) & 0x1f;
|
||||
b[2] = (d >> 25) & 0x1f;
|
||||
a[3] = (d >> 30) & 0x1f;
|
||||
b[3] = (d >> 35);
|
||||
|
||||
r->coeffs[4 * i + 0] = (uint16_t)(a[0] + KYBER_Q - b[0]);
|
||||
r->coeffs[4 * i + 1] = (uint16_t)(a[1] + KYBER_Q - b[1]);
|
||||
r->coeffs[4 * i + 2] = (uint16_t)(a[2] + KYBER_Q - b[2]);
|
||||
r->coeffs[4 * i + 3] = (uint16_t)(a[3] + KYBER_Q - b[3]);
|
||||
}
|
||||
#else
|
||||
#error "poly_getnoise in poly.c only supports eta in {3,4,5}"
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user