From ded346fad2f2c86bc13ac3beaf5e00e969f04442 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Thu, 14 May 2020 21:09:49 +0200 Subject: Add libctx and propq param to ASN.1 sign/verify/HMAC/decrypt Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/11808) --- crypto/evp/digest.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crypto/evp/digest.c') diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 7476efd9bc..7caab8a5f7 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -73,6 +74,37 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) return 1; } +#ifndef FIPS_MODULE +EVP_MD_CTX *evp_md_ctx_new_with_libctx(EVP_PKEY *pkey, + const ASN1_OCTET_STRING *id, + OPENSSL_CTX *libctx, const char *propq) +{ + EVP_MD_CTX *ctx; + EVP_PKEY_CTX *pctx = NULL; + + if ((ctx = EVP_MD_CTX_new()) == NULL + || (pctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, propq)) == NULL) { + ASN1err(0, ERR_R_MALLOC_FAILURE); + goto err; + } + +# ifndef OPENSSL_NO_EC + if (id != NULL && EVP_PKEY_CTX_set1_id(pctx, id->data, id->length) <= 0) { + ASN1err(0, ERR_R_MALLOC_FAILURE); + goto err; + } +# endif + + EVP_MD_CTX_set_pkey_ctx(ctx, pctx); + return ctx; + + err: + EVP_PKEY_CTX_free(pctx); + EVP_MD_CTX_free(ctx); + return NULL; +} +#endif + EVP_MD_CTX *EVP_MD_CTX_new(void) { return OPENSSL_zalloc(sizeof(EVP_MD_CTX)); -- cgit v1.2.3