Skip to content

Commit

Permalink
Using incremental API for rkprf
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptojedi committed May 7, 2023
1 parent e3f99cb commit ae8aa2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
14 changes: 0 additions & 14 deletions ref/fips202.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
*/
12 changes: 6 additions & 6 deletions ref/symmetric-shake.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit ae8aa2e

Please sign in to comment.