Made one more cast explicit
This commit is contained in:
parent
393c7a3cde
commit
bab1d185cd
@ -84,25 +84,25 @@ int PQCLEAN_KYBER768_crypto_kem_dec(unsigned char *ss, const unsigned char *ct,
|
|||||||
unsigned char cmp[KYBER_CIPHERTEXTBYTES];
|
unsigned char cmp[KYBER_CIPHERTEXTBYTES];
|
||||||
unsigned char buf[2 * KYBER_SYMBYTES];
|
unsigned char buf[2 * KYBER_SYMBYTES];
|
||||||
unsigned char
|
unsigned char
|
||||||
kr[2 * KYBER_SYMBYTES]; /* Will contain key, coins, qrom-hash */
|
kr[2 * KYBER_SYMBYTES]; /* Will contain key, coins, qrom-hash */
|
||||||
const unsigned char *pk = sk + KYBER_INDCPA_SECRETKEYBYTES;
|
const unsigned char *pk = sk + KYBER_INDCPA_SECRETKEYBYTES;
|
||||||
|
|
||||||
PQCLEAN_KYBER768_indcpa_dec(buf, ct, sk);
|
PQCLEAN_KYBER768_indcpa_dec(buf, ct, sk);
|
||||||
|
|
||||||
for (i = 0; i < KYBER_SYMBYTES; i++) { /* Multitarget countermeasure for coins + contributory KEM */
|
for (i = 0; i < KYBER_SYMBYTES; i++) { /* Multitarget countermeasure for coins + contributory KEM */
|
||||||
buf[KYBER_SYMBYTES + i] = sk[KYBER_SECRETKEYBYTES - 2 * KYBER_SYMBYTES + i]; /* Save hash by storing H(pk) in sk */
|
buf[KYBER_SYMBYTES + i] = sk[KYBER_SECRETKEYBYTES - 2 * KYBER_SYMBYTES + i]; /* Save hash by storing H(pk) in sk */
|
||||||
}
|
}
|
||||||
sha3_512(kr, buf, 2 * KYBER_SYMBYTES);
|
sha3_512(kr, buf, 2 * KYBER_SYMBYTES);
|
||||||
|
|
||||||
PQCLEAN_KYBER768_indcpa_enc(cmp, buf, pk, kr + KYBER_SYMBYTES); /* coins are in kr+KYBER_SYMBYTES */
|
PQCLEAN_KYBER768_indcpa_enc(cmp, buf, pk, kr + KYBER_SYMBYTES); /* coins are in kr+KYBER_SYMBYTES */
|
||||||
|
|
||||||
fail = PQCLEAN_KYBER768_verify(ct, cmp, KYBER_CIPHERTEXTBYTES);
|
fail = PQCLEAN_KYBER768_verify(ct, cmp, KYBER_CIPHERTEXTBYTES);
|
||||||
|
|
||||||
sha3_256(kr + KYBER_SYMBYTES, ct, KYBER_CIPHERTEXTBYTES); /* overwrite coins in kr with H(c) */
|
sha3_256(kr + KYBER_SYMBYTES, ct, KYBER_CIPHERTEXTBYTES); /* overwrite coins in kr with H(c) */
|
||||||
|
|
||||||
PQCLEAN_KYBER768_cmov(kr, sk + KYBER_SECRETKEYBYTES - KYBER_SYMBYTES, KYBER_SYMBYTES, fail); /* Overwrite pre-k with z on re-encryption failure */
|
PQCLEAN_KYBER768_cmov(kr, sk + KYBER_SECRETKEYBYTES - KYBER_SYMBYTES, KYBER_SYMBYTES, (unsigned char)fail); /* Overwrite pre-k with z on re-encryption failure */
|
||||||
|
|
||||||
sha3_256(ss, kr, 2 * KYBER_SYMBYTES); /* hash concatenation of pre-k and H(c) to k */
|
sha3_256(ss, kr, 2 * KYBER_SYMBYTES); /* hash concatenation of pre-k and H(c) to k */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user