From: Richard Levitte Date: Mon, 30 Aug 2021 11:19:30 +0000 (+0200) Subject: PEM to DER decoder: Specify object type and data structure more consistently X-Git-Tag: openssl-3.2.0-alpha1~3604 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=98408852c167d895a662dcda824fd5170cad3f7d PEM to DER decoder: Specify object type and data structure more consistently The data structure wasn't given for recognised certificates or CRLs. It's better, though, to specify it for those objects as well, so they can be used to filter what actually gets decoded, which will be helpful for our OSSL_STORE 'file:' scheme implementation. Fixes #16224 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/16466) --- diff --git a/providers/implementations/encode_decode/decode_pem2der.c b/providers/implementations/encode_decode/decode_pem2der.c index 5db3689f30..6c537d26ae 100644 --- a/providers/implementations/encode_decode/decode_pem2der.c +++ b/providers/implementations/encode_decode/decode_pem2der.c @@ -123,10 +123,10 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, * though there is no provider interface to handle such objects, yet. * However, this is beneficial for the OSSL_STORE result handler. */ - { PEM_STRING_X509, OSSL_OBJECT_CERT, NULL, NULL }, - { PEM_STRING_X509_TRUSTED, OSSL_OBJECT_CERT, NULL, NULL }, - { PEM_STRING_X509_OLD, OSSL_OBJECT_CERT, NULL, NULL }, - { PEM_STRING_X509_CRL, OSSL_OBJECT_CRL, NULL, NULL } + { PEM_STRING_X509, OSSL_OBJECT_CERT, NULL, "Certificate" }, + { PEM_STRING_X509_TRUSTED, OSSL_OBJECT_CERT, NULL, "Certificate" }, + { PEM_STRING_X509_OLD, OSSL_OBJECT_CERT, NULL, "Certificate" }, + { PEM_STRING_X509_CRL, OSSL_OBJECT_CRL, NULL, "CertificateList" } }; struct pem2der_ctx_st *ctx = vctx; char *pem_name = NULL, *pem_header = NULL; @@ -178,6 +178,7 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, char *data_type = (char *)pem_name_map[i].data_type; char *data_structure = (char *)pem_name_map[i].data_structure; + objtype = pem_name_map[i].object_type; if (data_type != NULL) *p++ = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,