From 70793dbbb983b0f95da30b79e8c8744289062499 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Sat, 13 Feb 2021 14:24:15 +0000 Subject: Pass the object type and data structure from the pem2der decoder The pem2der decoder can infer certain information about the endoded der data based on the PEM headers. This information should be passed to the next decoders in the chain to ensure we end up loading the correct type of thing. Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/14191) --- crypto/store/store_result.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crypto/store') diff --git a/crypto/store/store_result.c b/crypto/store/store_result.c index b79126e1cb..64b0e814b3 100644 --- a/crypto/store/store_result.c +++ b/crypto/store/store_result.c @@ -62,6 +62,7 @@ struct extracted_param_data_st { int object_type; const char *data_type; + const char *data_structure; const char *utf8_data; const void *octet_data; size_t octet_data_size; @@ -128,6 +129,10 @@ int ossl_store_handle_load_result(const OSSL_PARAM params[], void *arg) &helper_data.octet_data_size) && !OSSL_PARAM_get_utf8_string_ptr(p, &helper_data.utf8_data)) return 0; + p = OSSL_PARAM_locate_const(params, OSSL_OBJECT_PARAM_DATA_STRUCTURE); + if (p != NULL + && !OSSL_PARAM_get_utf8_string_ptr(p, &helper_data.data_structure)) + return 0; p = OSSL_PARAM_locate_const(params, OSSL_OBJECT_PARAM_REFERENCE); if (p != NULL && !OSSL_PARAM_get_octet_string_ptr(p, &helper_data.ref, &helper_data.ref_size)) @@ -274,8 +279,9 @@ static EVP_PKEY *try_key_value(struct extracted_param_data_st *data, } decoderctx = - OSSL_DECODER_CTX_new_for_pkey(&pk, "DER", NULL, data->data_type, - selection, libctx, propq); + OSSL_DECODER_CTX_new_for_pkey(&pk, "DER", data->data_structure, + data->data_type, selection, libctx, + propq); (void)OSSL_DECODER_CTX_set_passphrase_cb(decoderctx, cb, cbarg); /* No error if this couldn't be decoded */ -- cgit v1.2.3