From d95fb70b0e784d7c2a15d5ef5e42b0aa614e5045 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Tue, 19 Mar 2019 14:07:37 +0300 Subject: [PATCH] Providing missing accessor to EVP_PKEY.engine Reviewed-by: Richard Levitte Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/8526) --- crypto/evp/p_lib.c | 5 +++++ doc/man3/EVP_PKEY_set1_RSA.pod | 5 ++++- include/openssl/evp.h | 1 + util/libcrypto.num | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 148df90f84..0fe71161bd 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -394,6 +394,11 @@ int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e) pkey->pmeth_engine = e; return 1; } + +ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey) +{ + return pkey->engine; +} #endif int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key) { diff --git a/doc/man3/EVP_PKEY_set1_RSA.pod b/doc/man3/EVP_PKEY_set1_RSA.pod index d10fc59d8b..352e068c23 100644 --- a/doc/man3/EVP_PKEY_set1_RSA.pod +++ b/doc/man3/EVP_PKEY_set1_RSA.pod @@ -9,7 +9,7 @@ EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY, EVP_PKEY_assign_POLY1305, EVP_PKEY_assign_SIPHASH, EVP_PKEY_get0_hmac, EVP_PKEY_get0_poly1305, EVP_PKEY_get0_siphash, EVP_PKEY_type, EVP_PKEY_id, EVP_PKEY_base_id, EVP_PKEY_set_alias_type, -EVP_PKEY_set1_engine - EVP_PKEY assignment functions +EVP_PKEY_set1_engine, EVP_PKEY_get0_engine - EVP_PKEY assignment functions =head1 SYNOPSIS @@ -45,6 +45,7 @@ EVP_PKEY_set1_engine - EVP_PKEY assignment functions int EVP_PKEY_type(int type); int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type); + ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *engine); =head1 DESCRIPTION @@ -81,6 +82,8 @@ often seen in practice. EVP_PKEY_type() returns the underlying type of the NID B. For example EVP_PKEY_type(EVP_PKEY_RSA2) will return B. +EVP_PKEY_get0_engine() returns a reference to the ENGINE handling B. + EVP_PKEY_set1_engine() sets the ENGINE handling B to B. It must be called after the key algorithm and components are set up. If B does not include an B for B an diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 9f05b5a3b7..dd1117d0fe 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -995,6 +995,7 @@ int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type); # ifndef OPENSSL_NO_ENGINE int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e); +ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); # endif int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); void *EVP_PKEY_get0(const EVP_PKEY *pkey); diff --git a/util/libcrypto.num b/util/libcrypto.num index 32c64cb2c7..474f9f950d 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4579,3 +4579,4 @@ EVP_PKEY_meth_set_digest_custom 4532 1_1_1 EXIST::FUNCTION: EVP_PKEY_meth_get_digest_custom 4533 1_1_1 EXIST::FUNCTION: OPENSSL_INIT_set_config_filename 4534 1_1_1b EXIST::FUNCTION:STDIO OPENSSL_INIT_set_config_file_flags 4535 1_1_1b EXIST::FUNCTION:STDIO +EVP_PKEY_get0_engine 4536 1_1_1c EXIST::FUNCTION:ENGINE