Skip to content

Commit 91f3435

Browse files
committed
Kyber ARMv8: change keygen to be FIPS 203 compliant
Signed-off-by: Stephan Mueller <smueller@chronox.de>
1 parent a8ae045 commit 91f3435

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kem/src/armv8/kyber_indcpa_armv8.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ int indcpa_keypair_armv8(uint8_t pk[LC_KYBER_INDCPA_PUBLICKEYBYTES],
230230
uint8_t poly_getnoise_eta1_buf[POLY_GETNOISE_ETA1_BUFSIZE];
231231
polyvec a[LC_KYBER_K], e, pkpv, skpv;
232232
};
233+
static const uint8_t kval = LC_KYBER_K;
233234
unsigned int i;
234235
uint8_t *buf;
235236
const uint8_t *publicseed, *noiseseed;
236237
uint8_t nonce = 0, nonce2 = LC_KYBER_K;
237238
int ret;
239+
LC_HASH_CTX_ON_STACK(sha3_512_ctx, lc_sha3_512);
238240
LC_DECLARE_MEM(ws, struct workspace, 32);
239241

240242
buf = ws->buf;
@@ -245,7 +247,12 @@ int indcpa_keypair_armv8(uint8_t pk[LC_KYBER_INDCPA_PUBLICKEYBYTES],
245247
poison(noiseseed, LC_KYBER_SYMBYTES);
246248

247249
CKINT(lc_rng_generate(rng_ctx, NULL, 0, buf, LC_KYBER_SYMBYTES));
248-
lc_hash(lc_sha3_512, buf, LC_KYBER_SYMBYTES, buf);
250+
lc_hash_init(sha3_512_ctx);
251+
lc_hash_update(sha3_512_ctx, buf, LC_KYBER_SYMBYTES);
252+
lc_hash_update(sha3_512_ctx, &kval, sizeof(kval));
253+
lc_hash_final(sha3_512_ctx, buf);
254+
lc_hash_zero(sha3_512_ctx);
255+
249256
gen_a(ws->a, publicseed);
250257

251258
for (i = 0; i < LC_KYBER_K; i++) {

0 commit comments

Comments
 (0)