ENCODER: Drop OSSL_ENCODER_PARAM_INPUT_TYPE

This was a poor substitute for using the name of the decoder implementation,
and since there is functionality to get the latter now, this parameter
can be dropped.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15570)
This commit is contained in:
Richard Levitte 2021-06-02 06:32:00 +02:00 committed by Pauli
parent 6462a4f050
commit 73c02a6201
9 changed files with 15 additions and 65 deletions

View File

@ -36,6 +36,8 @@ struct encoder_process_data_st {
OSSL_ENCODER_INSTANCE *prev_encoder_inst;
unsigned char *running_output;
size_t running_output_length;
/* Data type = the name of the first succeeding encoder implementation */
const char *data_type;
};
static int encoder_process(struct encoder_process_data_st *data);
@ -207,10 +209,7 @@ static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder,
OSSL_PARAM_construct_utf8_ptr(OSSL_ENCODER_PARAM_OUTPUT_STRUCTURE,
(char **)&encoder_inst->output_structure,
0);
params[2] =
OSSL_PARAM_construct_utf8_ptr(OSSL_ENCODER_PARAM_INPUT_TYPE,
(char **)&encoder_inst->input_type, 0);
params[3] = OSSL_PARAM_construct_end();
params[2] = OSSL_PARAM_construct_end();
if (!encoder->get_params(params)
|| !OSSL_PARAM_modified(&params[0]))
@ -260,8 +259,8 @@ static int ossl_encoder_ctx_add_encoder_inst(OSSL_ENCODER_CTX *ctx,
"(ctx %p) Added encoder instance %p (encoder %p) with:\n",
(void *)ctx, (void *)ei, (void *)ei->encoder);
BIO_printf(trc_out,
" output type: %s, output structure: %s, input type :%s\n",
ei->output_type, ei->output_structure, ei->input_type);
" output type: %s, output structure: %s\n",
ei->output_type, ei->output_structure);
} OSSL_TRACE_END(ENCODER);
}
return ok;
@ -362,14 +361,6 @@ OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst)
return encoder_inst->encoderctx;
}
const char *
OSSL_ENCODER_INSTANCE_get_input_type(OSSL_ENCODER_INSTANCE *encoder_inst)
{
if (encoder_inst == NULL)
return NULL;
return encoder_inst->input_type;
}
const char *
OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst)
{
@ -566,6 +557,9 @@ static int encoder_process(struct encoder_process_data_st *data)
data->ctx->construct(current_encoder_inst,
data->ctx->construct_data);
/* Also set the data type, using the encoder implementation name */
data->data_type = OSSL_ENCODER_get0_name(current_encoder);
/* Assume that the constructor recorded an error */
if (original_data != NULL)
ok = 1;
@ -586,15 +580,12 @@ static int encoder_process(struct encoder_process_data_st *data)
*/
OSSL_PARAM *abstract_p = abstract;
const char *prev_input_type =
OSSL_ENCODER_INSTANCE_get_input_type(data->prev_encoder_inst);
const char *prev_output_structure =
OSSL_ENCODER_INSTANCE_get_output_structure(data->prev_encoder_inst);
if (prev_input_type != NULL)
*abstract_p++ =
OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,
(char *)prev_input_type, 0);
*abstract_p++ =
OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,
(char *)data->data_type, 0);
if (prev_output_structure != NULL)
*abstract_p++ =
OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,

View File

@ -59,7 +59,6 @@ struct ossl_decoder_st {
struct ossl_encoder_instance_st {
OSSL_ENCODER *encoder; /* Never NULL */
void *encoderctx; /* Never NULL */
const char *input_type; /* May be NULL */
const char *output_type; /* Never NULL */
const char *output_structure; /* May be NULL */
};

View File

@ -16,7 +16,6 @@ OSSL_ENCODER_CTX_get_num_encoders,
OSSL_ENCODER_INSTANCE,
OSSL_ENCODER_INSTANCE_get_encoder,
OSSL_ENCODER_INSTANCE_get_encoder_ctx,
OSSL_ENCODER_INSTANCE_get_input_type,
OSSL_ENCODER_INSTANCE_get_output_type,
OSSL_ENCODER_INSTANCE_get_output_structure,
OSSL_ENCODER_CONSTRUCT,
@ -55,8 +54,6 @@ OSSL_ENCODER_CTX_set_cleanup
void *
OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_input_type(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst);
@ -161,14 +158,6 @@ implementation of the encoder instance I<encoder_inst>.
OSSL_ENCODER_INSTANCE_get_encoder_ctx() can be used to get the encoder
implementation's provider context of the encoder instance I<encoder_inst>.
OSSL_ENCODER_INSTANCE_get_input_type() can be used to get the input type for
the encoder implementation of the encoder instance I<encoder_inst>.
This may be NULL.
OSSL_ENCODER_INSTANCE_get_output_type() can be used to get the output type
for the encoder implementation of the encoder instance I<encoder_inst>.
This will never be NULL.
OSSL_ENCODER_INSTANCE_get_output_type() can be used to get the output type
for the encoder implementation of the encoder instance I<encoder_inst>.
This will never be NULL.

View File

@ -247,15 +247,6 @@ determine how it fits in a chain of encoders:
=over 4
=item "input-type" (B<OSSL_ENCODER_PARAM_INPUT_TYPE>) <UTF8 string>
This is used to specify a distinct type name for the object passed as
I<obj_raw> to OSSL_FUNC_encoder_encode.
This parameter is an optional parameter, to be used if the name of the
implementation can be ambiguous because of aliases, and something more
deterministic is needed.
=item "output-type" (B<OSSL_ENCODER_PARAM_OUTPUT_TYPE>) <UTF8 string>
This is used to specify the output type for an ENCODER implementation.

View File

@ -468,7 +468,6 @@ extern "C" {
*/
#define OSSL_ENCODER_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER
#define OSSL_ENCODER_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES
#define OSSL_ENCODER_PARAM_INPUT_TYPE "input-type"
#define OSSL_ENCODER_PARAM_OUTPUT_TYPE "output-type"
#define OSSL_ENCODER_PARAM_OUTPUT_STRUCTURE "output-structure"
/* Currently PVK only, but reusable for others as needed */

View File

@ -84,8 +84,6 @@ OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst);
void *
OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_input_type(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst);
const char *
OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst);

View File

@ -884,13 +884,11 @@ static void key2any_freectx(void *vctx)
static const OSSL_PARAM *key2any_gettable_params(void *provctx, int structure)
{
static const OSSL_PARAM gettables[] = {
{ OSSL_ENCODER_PARAM_INPUT_TYPE, OSSL_PARAM_UTF8_PTR, NULL, 0, 0 },
{ OSSL_ENCODER_PARAM_OUTPUT_TYPE, OSSL_PARAM_UTF8_PTR, NULL, 0, 0 },
OSSL_PARAM_END,
};
static const OSSL_PARAM gettables_w_structure[] = {
{ OSSL_ENCODER_PARAM_INPUT_TYPE, OSSL_PARAM_UTF8_PTR, NULL, 0, 0 },
{ OSSL_ENCODER_PARAM_OUTPUT_TYPE, OSSL_PARAM_UTF8_PTR, NULL, 0, 0 },
{ OSSL_ENCODER_PARAM_OUTPUT_STRUCTURE, OSSL_PARAM_UTF8_PTR, NULL, 0, 0 },
OSSL_PARAM_END,
@ -899,16 +897,11 @@ static const OSSL_PARAM *key2any_gettable_params(void *provctx, int structure)
return structure ? gettables_w_structure : gettables;
}
static int key2any_get_params(OSSL_PARAM params[], const char *input_type,
const char *output_type,
static int key2any_get_params(OSSL_PARAM params[], const char *output_type,
const char *output_struct)
{
OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_ENCODER_PARAM_INPUT_TYPE);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, input_type))
return 0;
p = OSSL_PARAM_locate(params, OSSL_ENCODER_PARAM_OUTPUT_TYPE);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, output_type))
return 0;
@ -1234,8 +1227,7 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout,
static int \
impl##_to_##kind##_##output##_get_params(OSSL_PARAM params[]) \
{ \
return key2any_get_params(params, impl##_input_type, \
output##_output_type, \
return key2any_get_params(params, output##_output_type, \
kind##_output_structure); \
} \
static void * \

View File

@ -805,14 +805,10 @@ static const OSSL_PARAM *key2text_gettable_params(void *provctx)
return gettables;
}
static int key2text_get_params(OSSL_PARAM params[], const char *input_type)
static int key2text_get_params(OSSL_PARAM params[])
{
OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_ENCODER_PARAM_INPUT_TYPE);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, input_type))
return 0;
p = OSSL_PARAM_locate(params, OSSL_ENCODER_PARAM_OUTPUT_TYPE);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "TEXT"))
return 0;
@ -847,10 +843,6 @@ static int key2text_encode(void *vctx, const void *key, int selection,
impl##2text_free_object; \
static OSSL_FUNC_encoder_encode_fn impl##2text_encode; \
\
static int impl##2text_get_params(OSSL_PARAM params[]) \
{ \
return key2text_get_params(params, impl##_input_type); \
} \
static void *impl##2text_import_object(void *ctx, int selection, \
const OSSL_PARAM params[]) \
{ \
@ -884,7 +876,7 @@ static int key2text_encode(void *vctx, const void *key, int selection,
{ OSSL_FUNC_ENCODER_GETTABLE_PARAMS, \
(void (*)(void))key2text_gettable_params }, \
{ OSSL_FUNC_ENCODER_GET_PARAMS, \
(void (*)(void))impl##2text_get_params }, \
(void (*)(void))key2text_get_params }, \
{ OSSL_FUNC_ENCODER_IMPORT_OBJECT, \
(void (*)(void))impl##2text_import_object }, \
{ OSSL_FUNC_ENCODER_FREE_OBJECT, \

View File

@ -5249,7 +5249,6 @@ OSSL_ENCODER_CTX_get_num_encoders ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_CTX_set_selection ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_INSTANCE_get_encoder ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_INSTANCE_get_encoder_ctx ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_INSTANCE_get_input_type ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_INSTANCE_get_output_type ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_CTX_set_construct ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_CTX_set_construct_data ? 3_0_0 EXIST::FUNCTION: