From d8c9c431cf4db98f77568c3cfc0166d2b15e9ae6 Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Wed, 19 Feb 2020 14:56:02 -0500 Subject: [PATCH] Fix memory leaks in LEDAkem --- crypto_kem/ledakemlt12/leaktime/rng.c | 5 +++-- crypto_kem/ledakemlt32/leaktime/rng.c | 3 ++- crypto_kem/ledakemlt52/leaktime/rng.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crypto_kem/ledakemlt12/leaktime/rng.c b/crypto_kem/ledakemlt12/leaktime/rng.c index f9d22b97..cf0b1014 100644 --- a/crypto_kem/ledakemlt12/leaktime/rng.c +++ b/crypto_kem/ledakemlt12/leaktime/rng.c @@ -81,7 +81,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s memcpy(x + offset, ctx->buffer + ctx->buffer_pos, xlen); ctx->buffer_pos += xlen; - return RNG_SUCCESS; + goto end; } // take what's in the buffer @@ -103,7 +103,8 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s } } - aes256_ctx_release(&ctx256); +end: + aes256_ctx_release(&ctx256); return RNG_SUCCESS; } diff --git a/crypto_kem/ledakemlt32/leaktime/rng.c b/crypto_kem/ledakemlt32/leaktime/rng.c index 3c12deb4..99193987 100644 --- a/crypto_kem/ledakemlt32/leaktime/rng.c +++ b/crypto_kem/ledakemlt32/leaktime/rng.c @@ -81,7 +81,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s memcpy(x + offset, ctx->buffer + ctx->buffer_pos, xlen); ctx->buffer_pos += xlen; - return RNG_SUCCESS; + goto end; } // take what's in the buffer @@ -103,6 +103,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s } } +end: aes256_ctx_release(&ctx256); return RNG_SUCCESS; diff --git a/crypto_kem/ledakemlt52/leaktime/rng.c b/crypto_kem/ledakemlt52/leaktime/rng.c index 760bb2b4..7354c8e0 100644 --- a/crypto_kem/ledakemlt52/leaktime/rng.c +++ b/crypto_kem/ledakemlt52/leaktime/rng.c @@ -81,7 +81,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s memcpy(x + offset, ctx->buffer + ctx->buffer_pos, xlen); ctx->buffer_pos += xlen; - return RNG_SUCCESS; + goto end; } // take what's in the buffer @@ -103,6 +103,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_seedexpander(AES_XOF_struct *ctx, uint8_t *x, s } } +end: aes256_ctx_release(&ctx256); return RNG_SUCCESS;