summaryrefslogtreecommitdiffstats
path: root/crypto/hmac/hmac_local.h
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-01-03 09:37:19 +0000
committerMatt Caswell <matt@openssl.org>2020-01-06 10:46:05 +0000
commitb1558c0bc895afd93170378053bae800efacee1e (patch)
treecd7317791df8a195c14afdc8dec5ca92f9f04f89 /crypto/hmac/hmac_local.h
parent60a3399721a48931b137ae4d966a9ef4b6a85d11 (diff)
Don't store an HMAC key for longer than we need
The HMAC_CTX structure stores the original key in case the ctx is reused without changing the key. However, HMAC_Init_ex() checks its parameters such that the only code path where the stored key is ever used is in the case where HMAC_Init_ex is called with a NULL key and an explicit md is provided which is the same as the md that was provided previously. But in that case we can actually reuse the pre-digested key that we calculated last time, so we can refactor the code not to use the stored key at all. With that refactor done it is no longer necessary to store the key in the ctx at all. This means that long running ctx's will not keep the key in memory for any longer than required. Note though that the digested key *is* still kept in memory for the duration of the life of the ctx. Fixes #10743 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/10747)
Diffstat (limited to 'crypto/hmac/hmac_local.h')
-rw-r--r--crypto/hmac/hmac_local.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/crypto/hmac/hmac_local.h b/crypto/hmac/hmac_local.h
index 788721ef1f..d6fd4f39e0 100644
--- a/crypto/hmac/hmac_local.h
+++ b/crypto/hmac/hmac_local.h
@@ -18,8 +18,6 @@ struct hmac_ctx_st {
EVP_MD_CTX *md_ctx;
EVP_MD_CTX *i_ctx;
EVP_MD_CTX *o_ctx;
- unsigned int key_length;
- unsigned char key[HMAC_MAX_MD_CBLOCK_SIZE];
};
#endif