From a100602d58b0a2cfba1c0419470e637bb5fd227d Mon Sep 17 00:00:00 2001 From: "Dr. Matthias St. Pierre" Date: Sun, 16 Oct 2016 00:53:33 +0200 Subject: [PATCH] Fix leak of secrecy in ecdh_compute_key() A temporary buffer containing g^xy was not cleared in ecdh_compute_key() before freeing it, so the shared secret was leaked in memory. Reviewed-by: Kurt Roeckx Reviewed-by: Matt Caswell (cherry picked from commit 0e4690165b4beb6777b747b0aeb1646a301f41d9) --- crypto/ecdh/ech_ossl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/ecdh/ech_ossl.c b/crypto/ecdh/ech_ossl.c index d448b19a52..2d14252dce 100644 --- a/crypto/ecdh/ech_ossl.c +++ b/crypto/ecdh/ech_ossl.c @@ -202,7 +202,9 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, BN_CTX_end(ctx); if (ctx) BN_CTX_free(ctx); - if (buf) + if (buf) { + OPENSSL_cleanse(buf, buflen); OPENSSL_free(buf); + } return (ret); } -- 2.25.1