diff options
author | Dirkjan Bussink <d.bussink@gmail.com> | 2020-12-12 17:41:42 +0100 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2021-01-11 10:45:22 +0100 |
commit | 41c08986ae39940b177ad80cc9375b190b6ad560 (patch) | |
tree | 8d55e8c653dd7540d7b0477c37d71880f9a530b9 /src | |
parent | b6bf5bfd15a1f6559aad554ce169c9238ca45e52 (diff) | |
download | libssh-41c08986ae39940b177ad80cc9375b190b6ad560.tar.gz libssh-41c08986ae39940b177ad80cc9375b190b6ad560.tar.xz libssh-41c08986ae39940b177ad80cc9375b190b6ad560.zip |
Remove unneeded EVP_MD_CTX_reset custom cleanup
The EVP_MD_CTX_reset function is not used anywhere outside of the compat
layer and is not needed there. The only usage in the compat layer is for
cleanup, but EVP_MD_CTX_cleanup can be used for that which is availble
at least since OpenSSL 0.9.8.
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcrypto-compat.c | 41 | ||||
-rw-r--r-- | src/libcrypto-compat.h | 1 |
2 files changed, 1 insertions, 41 deletions
diff --git a/src/libcrypto-compat.c b/src/libcrypto-compat.c index 1d1bb10d..d9857463 100644 --- a/src/libcrypto-compat.c +++ b/src/libcrypto-compat.c @@ -12,10 +12,6 @@ #include <string.h> #include "libcrypto-compat.h" -#ifndef OPENSSL_NO_ENGINE -#include <openssl/engine.h> -#endif - int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { /* If the fields n and e in r are NULL, the corresponding input @@ -234,44 +230,9 @@ EVP_MD_CTX *EVP_MD_CTX_new(void) return ctx; } -static void OPENSSL_clear_free(void *str, size_t num) -{ - if (str == NULL) - return; - if (num) - OPENSSL_cleanse(str, num); - OPENSSL_free(str); -} - -/* This call frees resources associated with the context */ -int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) -{ - if (ctx == NULL) - return 1; - - /* - * Don't assume ctx->md_data was cleaned in EVP_Digest_Final, because - * sometimes only copies of the context are ever finalised. - */ - if (ctx->digest && ctx->digest->cleanup - && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_CLEANED)) - ctx->digest->cleanup(ctx); - if (ctx->digest && ctx->digest->ctx_size && ctx->md_data - && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) { - OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size); - } - EVP_PKEY_CTX_free(ctx->pctx); -#ifndef OPENSSL_NO_ENGINE - ENGINE_finish(ctx->engine); -#endif - OPENSSL_cleanse(ctx, sizeof(*ctx)); - - return 1; -} - void EVP_MD_CTX_free(EVP_MD_CTX *ctx) { - EVP_MD_CTX_reset(ctx); + EVP_MD_CTX_cleanup(ctx); OPENSSL_free(ctx); } diff --git a/src/libcrypto-compat.h b/src/libcrypto-compat.h index 0082e207..31f361e8 100644 --- a/src/libcrypto-compat.h +++ b/src/libcrypto-compat.h @@ -30,7 +30,6 @@ int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); -int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); EVP_MD_CTX *EVP_MD_CTX_new(void); void EVP_MD_CTX_free(EVP_MD_CTX *ctx); |