From e4eff1029750add10d2fdce13cc8531d929834a6 Mon Sep 17 00:00:00 2001 From: Kris Kwiatkowski Date: Thu, 24 Jun 2021 08:06:19 +0100 Subject: [PATCH] memsan: enable kyber in bench --- src/kem/kyber/kyber512/avx2/indcpa.c | 2 +- src/kem/kyber/kyber512/avx2/kem.c | 4 ++-- src/kem/kyber/kyber512/avx2/polyvec.c | 2 +- test/bench/kyber.cc | 4 ---- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/kem/kyber/kyber512/avx2/indcpa.c b/src/kem/kyber/kyber512/avx2/indcpa.c index 80990ca3..70c983a3 100644 --- a/src/kem/kyber/kyber512/avx2/indcpa.c +++ b/src/kem/kyber/kyber512/avx2/indcpa.c @@ -289,7 +289,7 @@ void PQCLEAN_KYBER512_AVX2_indcpa_enc(uint8_t c[KYBER_INDCPA_BYTES], const uint8_t coins[KYBER_SYMBYTES]) { unsigned int i; uint8_t seed[KYBER_SYMBYTES]; - polyvec sp, pkpv, ep, at[KYBER_K], b; + polyvec sp, pkpv, ep, at[KYBER_K], b = {0}; poly v, k, epp; unpack_pk(&pkpv, seed, pk); diff --git a/src/kem/kyber/kyber512/avx2/kem.c b/src/kem/kyber/kyber512/avx2/kem.c index 290f1f61..736af59d 100644 --- a/src/kem/kyber/kyber512/avx2/kem.c +++ b/src/kem/kyber/kyber512/avx2/kem.c @@ -51,9 +51,9 @@ int PQCLEAN_KYBER512_AVX2_crypto_kem_keypair(unsigned char pk[KYBER_PUBLICKEYBYT int PQCLEAN_KYBER512_AVX2_crypto_kem_enc(unsigned char ct[KYBER_CIPHERTEXTBYTES], unsigned char ss[KYBER_SSBYTES], const unsigned char pk[KYBER_PUBLICKEYBYTES]) { - uint8_t buf[2 * KYBER_SYMBYTES]; + uint8_t buf[2 * KYBER_SYMBYTES] = {0}; /* Will contain key, coins */ - uint8_t kr[2 * KYBER_SYMBYTES]; + uint8_t kr[2 * KYBER_SYMBYTES] = {0}; randombytes(buf, KYBER_SYMBYTES); /* Don't release system RNG output */ diff --git a/src/kem/kyber/kyber512/avx2/polyvec.c b/src/kem/kyber/kyber512/avx2/polyvec.c index 90b28695..fb0ce283 100644 --- a/src/kem/kyber/kyber512/avx2/polyvec.c +++ b/src/kem/kyber/kyber512/avx2/polyvec.c @@ -182,7 +182,7 @@ void PQCLEAN_KYBER512_AVX2_polyvec_invntt_tomont(polyvec *r) { **************************************************/ void PQCLEAN_KYBER512_AVX2_polyvec_basemul_acc_montgomery(poly *r, const polyvec *a, const polyvec *b) { size_t i; - poly tmp; + poly tmp = {0}; PQCLEAN_KYBER512_AVX2_poly_basemul_montgomery(r, &a->vec[0], &b->vec[0]); for (i = 1; i < KYBER_K; i++) { diff --git a/test/bench/kyber.cc b/test/bench/kyber.cc index 593b6855..1663677f 100644 --- a/test/bench/kyber.cc +++ b/test/bench/kyber.cc @@ -59,7 +59,6 @@ static void BenchKyberKeygen(benchmark::State &st) { cpucycle(st, total); } -#ifndef PQC_MEMSAN_BUILD static void BenchKyberEncaps(benchmark::State &st) { int64_t t, total = 0; uint8_t sk[1632]; @@ -92,7 +91,6 @@ static void BenchKyberDecaps(benchmark::State &st) { } cpucycle(st, total); } -#endif static void BenchKyberBaseMulAVX(benchmark::State &st) { int64_t t, total = 0; @@ -126,7 +124,5 @@ BENCHMARK(BenchKyberBaseMulAVX); BENCHMARK(BenchKyberNttAVX); // TODO: not sure why but memcheck fails in INDCPA encryption -#ifndef PQC_MEMSAN_BUILD BENCHMARK(BenchKyberEncaps); BENCHMARK(BenchKyberDecaps); -#endif