From 0912b1821cbdc2d66c46c4f1d26da31e8d82b980 Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Wed, 19 Feb 2020 14:51:19 -0500 Subject: [PATCH] Fix memory leaks in NewHope --- crypto_kem/newhope1024cca/clean/poly.c | 1 + crypto_kem/newhope1024cpa/clean/poly.c | 1 + crypto_kem/newhope512cca/clean/poly.c | 1 + crypto_kem/newhope512cpa/clean/poly.c | 1 + 4 files changed, 4 insertions(+) diff --git a/crypto_kem/newhope1024cca/clean/poly.c b/crypto_kem/newhope1024cca/clean/poly.c index 10ec5535..efa8fbb5 100644 --- a/crypto_kem/newhope1024cca/clean/poly.c +++ b/crypto_kem/newhope1024cca/clean/poly.c @@ -225,6 +225,7 @@ void PQCLEAN_NEWHOPE1024CCA_CLEAN_poly_uniform(poly *a, const unsigned char *see } } } + shake128_ctx_release(&state); } } diff --git a/crypto_kem/newhope1024cpa/clean/poly.c b/crypto_kem/newhope1024cpa/clean/poly.c index f9b4cce8..3f64de42 100644 --- a/crypto_kem/newhope1024cpa/clean/poly.c +++ b/crypto_kem/newhope1024cpa/clean/poly.c @@ -225,6 +225,7 @@ void PQCLEAN_NEWHOPE1024CPA_CLEAN_poly_uniform(poly *a, const unsigned char *see } } } + shake128_ctx_release(&state); } } diff --git a/crypto_kem/newhope512cca/clean/poly.c b/crypto_kem/newhope512cca/clean/poly.c index aa3175f0..39ec8e59 100644 --- a/crypto_kem/newhope512cca/clean/poly.c +++ b/crypto_kem/newhope512cca/clean/poly.c @@ -221,6 +221,7 @@ void PQCLEAN_NEWHOPE512CCA_CLEAN_poly_uniform(poly *a, const unsigned char *seed } } } + shake128_ctx_release(&state); } } diff --git a/crypto_kem/newhope512cpa/clean/poly.c b/crypto_kem/newhope512cpa/clean/poly.c index 6bd47ae6..3f03fdcf 100644 --- a/crypto_kem/newhope512cpa/clean/poly.c +++ b/crypto_kem/newhope512cpa/clean/poly.c @@ -221,6 +221,7 @@ void PQCLEAN_NEWHOPE512CPA_CLEAN_poly_uniform(poly *a, const unsigned char *seed } } } + shake128_ctx_release(&state); } }