diff options
author | Matt Caswell <matt@openssl.org> | 2018-10-26 12:19:43 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-10-29 14:11:40 +0000 |
commit | 070ce40be1dce27cf321b437a4a5446add17e945 (patch) | |
tree | 6da99a3c7f119ccc40aa131219ab57273a11309c /crypto | |
parent | 7e01266fa69db90533e53a37cc83d0df99b1c08f (diff) |
Reset the HKDF state between operations
Fixes #7497
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7501)
(cherry picked from commit ca55d70be031746daddd8bd0611db54ed81f1737)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/kdf/hkdf.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crypto/kdf/hkdf.c b/crypto/kdf/hkdf.c index ec6090ad6a..ae46fad609 100644 --- a/crypto/kdf/hkdf.c +++ b/crypto/kdf/hkdf.c @@ -175,6 +175,18 @@ static int pkey_hkdf_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, return -2; } +static int pkey_hkdf_derive_init(EVP_PKEY_CTX *ctx) +{ + HKDF_PKEY_CTX *kctx = ctx->data; + + OPENSSL_clear_free(kctx->key, kctx->key_len); + OPENSSL_clear_free(kctx->salt, kctx->salt_len); + OPENSSL_cleanse(kctx->info, kctx->info_len); + memset(kctx, 0, sizeof(*kctx)); + + return 1; +} + static int pkey_hkdf_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) { @@ -236,7 +248,7 @@ const EVP_PKEY_METHOD hkdf_pkey_meth = { 0, 0, - 0, + pkey_hkdf_derive_init, pkey_hkdf_derive, pkey_hkdf_ctrl, pkey_hkdf_ctrl_str |