diff options
author | Richard Levitte <levitte@openssl.org> | 2020-09-14 10:42:05 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-20 17:31:22 +0200 |
commit | 97bb8dff1f4915def454c702d07102924b60b254 (patch) | |
tree | d05b68c0fd37cfa7f225394e339bc504bf83447c /crypto/x509/x_pubkey.c | |
parent | 111dc4b0f1e961afd6fc998ef443d9004356c046 (diff) |
ENCODER: Adapt calls to the changed OSSL_ENCODER_CTX_new_by_EVP_PKEY()
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12873)
Diffstat (limited to 'crypto/x509/x_pubkey.c')
-rw-r--r-- | crypto/x509/x_pubkey.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index cb47f917ad..a4d3c9fa5e 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -23,6 +23,7 @@ #include <openssl/rsa.h> #include <openssl/dsa.h> #include <openssl/encoder.h> +#include "internal/provider.h" struct X509_pubkey_st { X509_ALGOR *algor; @@ -96,10 +97,14 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) goto error; } } else if (pkey->keymgmt != NULL) { + const OSSL_PROVIDER *pkprov = EVP_KEYMGMT_provider(pkey->keymgmt); + OPENSSL_CTX *libctx = ossl_provider_library_context(pkprov); BIO *bmem = BIO_new(BIO_s_mem()); - const char *encprop = OSSL_ENCODER_PUBKEY_TO_DER_PQ; + int selection = (OSSL_KEYMGMT_SELECT_PUBLIC_KEY + | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS); OSSL_ENCODER_CTX *ectx = - OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, encprop); + OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, "DER", selection, + libctx, NULL); if (OSSL_ENCODER_to_bio(ectx, bmem)) { const unsigned char *der = NULL; @@ -303,15 +308,17 @@ int i2d_PUBKEY(const EVP_PKEY *a, unsigned char **pp) } X509_PUBKEY_free(xpk); } else if (a->keymgmt != NULL) { - const char *encprop = OSSL_ENCODER_PUBKEY_TO_DER_PQ; + const OSSL_PROVIDER *pkprov = EVP_KEYMGMT_provider(a->keymgmt); + OPENSSL_CTX *libctx = ossl_provider_library_context(pkprov); + int selection = (OSSL_KEYMGMT_SELECT_PUBLIC_KEY + | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS); OSSL_ENCODER_CTX *ctx = - OSSL_ENCODER_CTX_new_by_EVP_PKEY(a, encprop); + OSSL_ENCODER_CTX_new_by_EVP_PKEY(a, "DER", selection, libctx, NULL); BIO *out = BIO_new(BIO_s_mem()); BUF_MEM *buf = NULL; - if (ctx != NULL + if (OSSL_ENCODER_CTX_get_num_encoders(ctx) != 0 && out != NULL - && OSSL_ENCODER_CTX_get_encoder(ctx) != NULL && OSSL_ENCODER_to_bio(ctx, out) && BIO_get_mem_ptr(out, &buf) > 0) { ret = buf->length; |