diff options
author | Dirkjan Bussink <d.bussink@gmail.com> | 2020-12-12 17:25:09 +0100 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2021-01-11 10:45:22 +0100 |
commit | b6bf5bfd15a1f6559aad554ce169c9238ca45e52 (patch) | |
tree | fe47077fe2a4f0e6859de4a932670b0da87466e2 | |
parent | d1806a523cbe866ff2b3a0ae94562106921e85d5 (diff) | |
download | libssh-b6bf5bfd15a1f6559aad554ce169c9238ca45e52.tar.gz libssh-b6bf5bfd15a1f6559aad554ce169c9238ca45e52.tar.xz libssh-b6bf5bfd15a1f6559aad554ce169c9238ca45e52.zip |
Improve cleanup logic for HMAC
Older OpenSSL version have a cleanup function that can be used here.
This removes a whole bunch of now no longer needed logic and custom
conditionals.
These functions have existed since 0.9.8 and can be used here.
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
-rw-r--r-- | src/libcrypto-compat.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/src/libcrypto-compat.c b/src/libcrypto-compat.c index a42b3073..1d1bb10d 100644 --- a/src/libcrypto-compat.c +++ b/src/libcrypto-compat.c @@ -291,25 +291,10 @@ HMAC_CTX *HMAC_CTX_new(void) return ctx; } -static void hmac_ctx_cleanup(HMAC_CTX *ctx) -{ - EVP_MD_CTX_reset(&ctx->i_ctx); - EVP_MD_CTX_reset(&ctx->o_ctx); - EVP_MD_CTX_reset(&ctx->md_ctx); - ctx->md = NULL; - ctx->key_length = 0; - OPENSSL_cleanse(ctx->key, sizeof(ctx->key)); -} - void HMAC_CTX_free(HMAC_CTX *ctx) { if (ctx != NULL) { - hmac_ctx_cleanup(ctx); -#if OPENSSL_VERSION_NUMBER > 0x10100000L - EVP_MD_CTX_free(&ctx->i_ctx); - EVP_MD_CTX_free(&ctx->o_ctx); - EVP_MD_CTX_free(&ctx->md_ctx); -#endif + HMAC_CTX_cleanup(ctx); OPENSSL_free(ctx); } } |