openssl/crypto/hmac
Matt Caswell 16d92fa873 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: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10763)
2020-01-07 11:53:29 +00:00
..
build.info
hm_ameth.c Reorganize private crypto header files 2019-09-27 23:57:58 +02:00
hm_pmeth.c Reorganize private crypto header files 2019-09-27 23:57:58 +02:00
hmac.c Don't store an HMAC key for longer than we need 2020-01-07 11:53:29 +00:00
hmac_local.h Don't store an HMAC key for longer than we need 2020-01-07 11:53:29 +00:00