Commit 13b0be7cb6 for openssl.org
commit 13b0be7cb62e21c23916937999446c00a6cd31f9
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Mon Jul 20 22:59:41 2026 +0200
encoder: pass the data type up through the encoder chain
In encoder_process(), the data type (the name of the encoder
implementation that produced the current encoding) is determined at the
deepest recursion level, but was not propagated up through the
recursion together with the other results of the recursive call. As a
consequence, the abstract object handed to a chained encoder
implementation contained an OSSL_OBJECT_PARAM_DATA_TYPE parameter with
NULL data, in violation of provider-object(7), which specifies it as a
UTF8 string carrying the type of the object content.
This went unnoticed because no encoders provided by OpenSSL itself are
ever chained.
Also extend endecode_api_test to verify that a chained encoder
implementation receives the correct data type.
Assisted-by: Claude:claude-fable-5
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Merge-date: Thu Aug 27 13:45:07 2026
Merged-from: https://github.com/openssl/openssl/pull/32019
diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c
index 375c98188c..98b9255b82 100644
--- a/crypto/encode_decode/encoder_lib.c
+++ b/crypto/encode_decode/encoder_lib.c
@@ -583,6 +583,7 @@ static int encoder_process(struct encoder_process_data_st *data)
data->prev_encoder_inst = new_data.prev_encoder_inst;
data->running_output = new_data.running_output;
data->running_output_length = new_data.running_output_length;
+ data->data_type = new_data.data_type;
/*
* ok == -1 means that the recursion call above gave no further
diff --git a/test/endecode_api_test.c b/test/endecode_api_test.c
index 768bf215c0..44d45fa19d 100644
--- a/test/endecode_api_test.c
+++ b/test/endecode_api_test.c
@@ -119,6 +119,13 @@ static int inter2pem_encode(void *vctx, OSSL_CORE_BIO *cout,
|| memcmp(p->data, STRUCTURE_NAME, p->data_size) != 0)
return 0;
+ /* Likewise the data type, naming the encoder that produced the data */
+ p = OSSL_PARAM_locate_const(obj_abstract, OSSL_OBJECT_PARAM_DATA_TYPE);
+ if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING
+ || p->data == NULL || p->data_size != strlen(KEY_NAME)
+ || memcmp(p->data, KEY_NAME, p->data_size) != 0)
+ return 0;
+
p = OSSL_PARAM_locate_const(obj_abstract, OSSL_OBJECT_PARAM_DATA);
if (p == NULL || p->data_type != OSSL_PARAM_OCTET_STRING)
return 0;