diff --git a/ref/fips202.c b/ref/fips202.c index d4b50a43..ab3d2a12 100644 --- a/ref/fips202.c +++ b/ref/fips202.c @@ -772,17 +772,3 @@ void sha3_512(uint8_t h[64], const uint8_t *in, size_t inlen) for(i=0;i<8;i++) store64(h+8*i,s[i]); } - - -/* -void sha3_512_init(keccak_state *s) { -} - -void sha3_512_update(keccak_state *s, const uint8_t *in, size_t inlen) { - state->pos = keccak_absorb(state->s, state->pos, SHA3_RATE, in, inlen); -} - -void sha3_512_finalize(uint8_t h[64], const keccak_state *s) { - state->pos = keccak_squeeze(out, outlen, state->s, state->pos, SHAKE128_RATE); -} -*/ diff --git a/ref/symmetric-shake.c b/ref/symmetric-shake.c index 67633173..6a990719 100644 --- a/ref/symmetric-shake.c +++ b/ref/symmetric-shake.c @@ -63,11 +63,11 @@ void kyber_shake256_prf(uint8_t *out, size_t outlen, const uint8_t key[KYBER_SYM **************************************************/ void kyber_shake256_rkprf(uint8_t out[KYBER_SSBYTES], const uint8_t key[KYBER_SYMBYTES], const uint8_t input[KYBER_CIPHERTEXTBYTES]) { - uint8_t buf[KYBER_SYMBYTES+KYBER_CIPHERTEXTBYTES]; + keccak_state s; - /* XXX: Instead of memcpy, use incremental API here */ - memcpy(buf, key, KYBER_SYMBYTES); - memcpy(buf+KYBER_SYMBYTES, input, KYBER_CIPHERTEXTBYTES); - - shake256(out, KYBER_SSBYTES, buf, sizeof(buf)); + shake256_init(&s); + shake256_absorb(&s, key, KYBER_SYMBYTES); + shake256_absorb(&s, input, KYBER_CIPHERTEXTBYTES); + shake256_finalize(&s); + shake256_squeeze(out, KYBER_SSBYTES, &s); }