Fix leak of secrecy in ecdh_compute_key()
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Sat, 15 Oct 2016 22:53:33 +0000 (00:53 +0200)
committerMatt Caswell <matt@openssl.org>
Tue, 25 Oct 2016 21:04:36 +0000 (22:04 +0100)
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 <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/ecdh/ech_ossl.c

index df115cc262e51947602b26913b81d70f4c5b0a7d..d3b05247fe37d068d259702d09a422646fd2764f 100644 (file)
@@ -212,7 +212,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);
 }