summaryrefslogtreecommitdiffstats
path: root/crypto/store
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-02-13 14:24:15 +0000
committerMatt Caswell <matt@openssl.org>2021-02-18 16:05:22 +0000
commit70793dbbb983b0f95da30b79e8c8744289062499 (patch)
tree1085227e419574bb7a5f9297c1ed67db342bb2ca /crypto/store
parent3a2171f6aa0f72ca95210fa80d92214315d1e744 (diff)
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 <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14191)
Diffstat (limited to 'crypto/store')
-rw-r--r--crypto/store/store_result.c10
1 files changed, 8 insertions, 2 deletions
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 */