From: Dr. Stephen Henson Date: Mon, 9 Oct 2017 13:37:21 +0000 (+0100) Subject: Don't ignore passed ENGINE. X-Git-Tag: OpenSSL_1_1_1-pre1~572 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c2976edf4b22691d8bebb0e3ca2db18b3d0c71c6;p=oweals%2Fopenssl.git Don't ignore passed ENGINE. If we are passed an ENGINE to use in int_ctx_new e.g. via EVP_PKEY_CTX_new() use it instead of the default. Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/4503) --- diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index 2b9b8a92f8..31ec09261f 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -105,7 +105,7 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) id = pkey->ameth->pkey_id; } #ifndef OPENSSL_NO_ENGINE - if (pkey && pkey->engine) + if (e == NULL && pkey != NULL) e = pkey->engine; /* Try to find an ENGINE which implements this method */ if (e) { @@ -113,8 +113,9 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) EVPerr(EVP_F_INT_CTX_NEW, ERR_R_ENGINE_LIB); return NULL; } - } else + } else { e = ENGINE_get_pkey_meth_engine(id); + } /* * If an ENGINE handled this method look it up. Otherwise use internal