c6a44a0dbb6735caf40ad4856063282feab56d98 diff --git a/avx2/indcpa.c b/avx2/indcpa.c index 926f6e87..b8840863 100644 --- a/avx2/indcpa.c +++ b/avx2/indcpa.c @@ -178,7 +178,7 @@ void gen_matrix(polyvec *a, const uint8_t seed[32], int transposed) ALIGNED_UINT8(REJ_UNIFORM_AVX_NBLOCKS*AES256CTR_BLOCKBYTES) buf; aes256ctr_ctx state; - aes256ctr_init(&state, seed, 0); + aes256ctr_init_key(&state, seed); for(i=0;i #include #include "align.h" +#include "fips202x4.h" #include "params.h" #include "poly.h" #include "ntt.h" @@ -360,6 +361,7 @@ void poly_tomsg(uint8_t msg[KYBER_INDCPA_MSGBYTES], const poly * restrict a) } } +#ifndef KYBER_90S /************************************************* * Name: poly_getnoise_eta1 * @@ -397,6 +399,7 @@ void poly_getnoise_eta2(poly *r, const uint8_t seed[KYBER_SYMBYTES], uint8_t non prf(buf.coeffs, KYBER_ETA2*KYBER_N/4, seed, nonce); poly_cbd_eta2(r, buf.vec); } +#endif #ifndef KYBER_90S #define NOISE_NBLOCKS ((KYBER_ETA1*KYBER_N/4+SHAKE256_RATE-1)/SHAKE256_RATE) @@ -412,7 +415,7 @@ void poly_getnoise_eta1_4x(poly *r0, { ALIGNED_UINT8(NOISE_NBLOCKS*SHAKE256_RATE) buf[4]; __m256i f; - keccakx4_state state; + shake256x4incctx state; f = _mm256_loadu_si256((__m256i *)seed); _mm256_store_si256(buf[0].vec, f); @@ -425,8 +428,10 @@ void poly_getnoise_eta1_4x(poly *r0, buf[2].coeffs[32] = nonce2; buf[3].coeffs[32] = nonce3; + shake256x4_inc_init(&state); shake256x4_absorb_once(&state, buf[0].coeffs, buf[1].coeffs, buf[2].coeffs, buf[3].coeffs, 33); shake256x4_squeezeblocks(buf[0].coeffs, buf[1].coeffs, buf[2].coeffs, buf[3].coeffs, NOISE_NBLOCKS, &state); + shake256x4_inc_ctx_release(&state); poly_cbd_eta1(r0, buf[0].vec); poly_cbd_eta1(r1, buf[1].vec); @@ -447,7 +452,7 @@ void poly_getnoise_eta1122_4x(poly *r0, { ALIGNED_UINT8(NOISE_NBLOCKS*SHAKE256_RATE) buf[4]; __m256i f; - keccakx4_state state; + shake256x4incctx state; f = _mm256_loadu_si256((__m256i *)seed); _mm256_store_si256(buf[0].vec, f); @@ -460,8 +465,10 @@ void poly_getnoise_eta1122_4x(poly *r0, buf[2].coeffs[32] = nonce2; buf[3].coeffs[32] = nonce3; + shake256x4_inc_init(&state); shake256x4_absorb_once(&state, buf[0].coeffs, buf[1].coeffs, buf[2].coeffs, buf[3].coeffs, 33); shake256x4_squeezeblocks(buf[0].coeffs, buf[1].coeffs, buf[2].coeffs, buf[3].coeffs, NOISE_NBLOCKS, &state); + shake256x4_inc_ctx_release(&state); poly_cbd_eta1(r0, buf[0].vec); poly_cbd_eta1(r1, buf[1].vec); diff --git a/avx2/symmetric.h b/avx2/symmetric.h index b99fe91..483eabc 100644 --- a/avx2/symmetric.h +++ b/avx2/symmetric.h @@ -33,10 +33,10 @@ typedef aes256ctr_ctx xof_state; #include "fips202.h" #include "fips202x4.h" -typedef keccak_state xof_state; +typedef shake128incctx xof_state; #define kyber_shake128_absorb KYBER_NAMESPACE(kyber_shake128_absorb) -void kyber_shake128_absorb(keccak_state *s, +void kyber_shake128_absorb(shake128incctx *s, const uint8_t seed[KYBER_SYMBYTES], uint8_t x, uint8_t y);