ENCODER: Drop OSSL_ENCODER_PARAM_INPUT_TYPE
authorRichard Levitte <levitte@openssl.org>
Wed, 2 Jun 2021 04:32:00 +0000 (06:32 +0200)
committerPauli <pauli@openssl.org>
Sat, 5 Jun 2021 10:30:47 +0000 (20:30 +1000)
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)

crypto/encode_decode/encoder_lib.c
crypto/encode_decode/encoder_local.h
doc/man3/OSSL_ENCODER_CTX.pod
doc/man7/provider-encoder.pod
include/openssl/core_names.h
include/openssl/encoder.h
providers/implementations/encode_decode/encode_key2any.c
providers/implementations/encode_decode/encode_key2text.c
util/libcrypto.num

index 448177361073bffb93e04ef0a1b6095377233fa9..d90ce72528a02836eacbbbb3f7c8826e2bbec428 100644 (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,
index 0678fc201418dce49e827e2dc80019b19c8dc447..44bd39b7572020d3c61659afc26ae0f06369f447 100644 (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 */
 };
index d4ea01060ff0d8fddf4b6e0ed5747fe8d5645081..9dc9b71ab1e5e8e11db295a58bc195fad087e210 100644 (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.
index 9032036a6ea938dc1fff586eb4b8b5bf174707d3..2f2e8ef6c6293d21d262d5301d97899eef492d39 100644 (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.
index 5bb284d6586462bf45d040ab07c3dd727c71dee1..5fa222507184c73a09e833a2da94977c71175627 100644 (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 */
index e62e33fc895933c42857ea16d34a465252d0b5ce..c37a6f16f23cc47f92a176b54ed7382780a41f9e 100644 (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);
index 8d32c64fbf9f850102b554ad5648fff1932bff0f..7efd88caee9a20230bf585dd3ff173879ed682ff 100644 (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 *                                                           \
index 9bdbe526569cce26aaf2e70415e941465169e487..6adbacaca6da1211f6b468657e46116392b46d11 100644 (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,                                \
index 5c36c4d44a424dd573bb47e165e3c997150e5d49..182cd2b15861e9ed2a68dd8a858b754650d4179c 100644 (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: