From 72ff0a540059633b7906a78d5d06087d5ce7b7ad Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 1 Jun 2018 14:30:50 +0100 Subject: [PATCH] Add function for setting the EVP_PKEY_ASN1_METHOD raw key getter functions EVP_PKEY_asn1_set_get_priv_key() and EVP_PKEY_asn1_set_get_pub_key() Reviewed-by: Rich Salz Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/6394) --- crypto/asn1/ameth_lib.c | 16 ++++++++++++++++ doc/man3/EVP_PKEY_ASN1_METHOD.pod | 17 +++++++++++++++-- include/openssl/evp.h | 8 ++++++++ util/libcrypto.num | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index b5f0293fc0..9b3274bc4e 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -417,3 +417,19 @@ void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth, { ameth->set_pub_key = set_pub_key; } + +void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_priv_key) (const EVP_PKEY *pk, + unsigned char *priv, + size_t *len)) +{ + ameth->get_priv_key = get_priv_key; +} + +void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_pub_key) (const EVP_PKEY *pk, + unsigned char *pub, + size_t *len)) +{ + ameth->get_pub_key = get_pub_key; +} diff --git a/doc/man3/EVP_PKEY_ASN1_METHOD.pod b/doc/man3/EVP_PKEY_ASN1_METHOD.pod index cb9375abd6..3c2ffd94e8 100644 --- a/doc/man3/EVP_PKEY_ASN1_METHOD.pod +++ b/doc/man3/EVP_PKEY_ASN1_METHOD.pod @@ -21,6 +21,8 @@ EVP_PKEY_asn1_set_param_check, EVP_PKEY_asn1_set_security_bits, EVP_PKEY_asn1_set_set_priv_key, EVP_PKEY_asn1_set_set_pub_key, +EVP_PKEY_asn1_set_get_priv_key, +EVP_PKEY_asn1_set_get_pub_key, EVP_PKEY_get0_asn1 - manipulating and registering EVP_PKEY_ASN1_METHOD structure @@ -125,6 +127,16 @@ EVP_PKEY_get0_asn1 const unsigned char *pub, size_t len)); + void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_priv_key) (const EVP_PKEY *pk, + unsigned char *priv, + size_t *len)); + + void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_pub_key) (const EVP_PKEY *pk, + unsigned char *pub, + size_t *len)); + const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); =head1 DESCRIPTION @@ -390,8 +402,9 @@ EVP_PKEY_asn1_set_param(), EVP_PKEY_asn1_set_free(), EVP_PKEY_asn1_set_ctrl(), EVP_PKEY_asn1_set_item(), EVP_PKEY_asn1_set_siginf(), EVP_PKEY_asn1_set_check(), EVP_PKEY_asn1_set_public_check(), EVP_PKEY_asn1_set_param_check(), -EVP_PKEY_asn1_set_security_bits(), EVP_PKEY_asn1_set_set_priv_key() and -EVP_PKEY_asn1_set_set_pub_key() set the diverse methods of the given +EVP_PKEY_asn1_set_security_bits(), EVP_PKEY_asn1_set_set_priv_key(), +EVP_PKEY_asn1_set_set_pub_key(), EVP_PKEY_asn1_set_get_priv_key() and +EVP_PKEY_asn1_set_get_pub_key() set the diverse methods of the given B object. EVP_PKEY_get0_asn1() finds the B associated diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 8e4e3fe227..33ff674668 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1238,6 +1238,14 @@ void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth, int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len)); +void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_priv_key) (const EVP_PKEY *pk, + unsigned char *priv, + size_t *len)); +void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, + int (*get_pub_key) (const EVP_PKEY *pk, + unsigned char *pub, + size_t *len)); void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_security_bits) (const EVP_PKEY diff --git a/util/libcrypto.num b/util/libcrypto.num index 50dcd36a37..a25f65fb0d 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4565,3 +4565,5 @@ X509_LOOKUP_meth_set_init 4516 1_1_0i EXIST::FUNCTION: X509_OBJECT_set1_X509_CRL 4517 1_1_0i EXIST::FUNCTION: EVP_PKEY_get_raw_public_key 4518 1_1_1 EXIST::FUNCTION: EVP_PKEY_get_raw_private_key 4519 1_1_1 EXIST::FUNCTION: +EVP_PKEY_asn1_set_get_priv_key 4520 1_1_1 EXIST::FUNCTION: +EVP_PKEY_asn1_set_get_pub_key 4521 1_1_1 EXIST::FUNCTION: -- 2.25.1