OSSL_ENCODER / OSSL_DECODER post-rename cleanup
authorRichard Levitte <levitte@openssl.org>
Fri, 21 Aug 2020 11:08:18 +0000 (13:08 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 3 Sep 2020 15:48:31 +0000 (17:48 +0200)
There are a few remaining spots where 'deser' wasn't changed to 'decoder'

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)

crypto/encode_decode/decoder_lib.c
crypto/encode_decode/decoder_meth.c
crypto/encode_decode/decoder_pkey.c
crypto/encode_decode/encoder_local.h
crypto/encode_decode/encoder_meth.c
crypto/encode_decode/encoder_pkey.c

index 5d18ef1eff6ff2b8944ce347a4882cc9c5c829dc..17dca0fc229d5cde46f0939bc80ad65103dab6ca 100644 (file)
@@ -22,7 +22,7 @@ struct decoder_process_data_st {
     BIO *bio;
 
     /* Index of the current decoder instance to be processed */
-    size_t current_deser_inst_index;
+    size_t current_decoder_inst_index;
 };
 
 static int decoder_process(const OSSL_PARAM params[], void *arg);
@@ -136,7 +136,7 @@ int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
         || !OSSL_PARAM_modified(&params[0]))
         goto err;
 
-    if ((decoder_inst->deserctx = decoder_inst->decoder->newctx(provctx))
+    if ((decoder_inst->decoderctx = decoder_inst->decoder->newctx(provctx))
         == NULL)
         goto err;
 
@@ -147,7 +147,7 @@ int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
  err:
     if (decoder_inst != NULL) {
         if (decoder_inst->decoder != NULL)
-            decoder_inst->decoder->freectx(decoder_inst->deserctx);
+            decoder_inst->decoder->freectx(decoder_inst->decoderctx);
         OSSL_DECODER_free(decoder_inst->decoder);
         OPENSSL_free(decoder_inst);
     }
@@ -344,7 +344,7 @@ int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst,
         return 0;
     }
 
-    return decoder_inst->decoder->export_object(decoder_inst->deserctx,
+    return decoder_inst->decoder->export_object(decoder_inst->decoderctx,
                                                 reference, reference_sz,
                                                 export_cb, export_cbarg);
 }
@@ -360,7 +360,7 @@ void *OSSL_DECODER_INSTANCE_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst)
 {
     if (decoder_inst == NULL)
         return NULL;
-    return decoder_inst->deserctx;
+    return decoder_inst->decoderctx;
 }
 
 static int decoder_process(const OSSL_PARAM params[], void *arg)
@@ -382,7 +382,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
     if (params == NULL) {
         /* First iteration, where we prepare for what is to come */
 
-        data->current_deser_inst_index =
+        data->current_decoder_inst_index =
             OSSL_DECODER_CTX_num_decoders(ctx);
 
         bio = data->bio;
@@ -391,7 +391,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
 
         decoder_inst =
             sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts,
-                                           data->current_deser_inst_index);
+                                           data->current_decoder_inst_index);
         decoder = OSSL_DECODER_INSTANCE_decoder(decoder_inst);
 
         if (ctx->construct != NULL
@@ -422,7 +422,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
      * If we have no more decoders to look through at this point,
      * we failed
      */
-    if (data->current_deser_inst_index == 0)
+    if (data->current_decoder_inst_index == 0)
         goto end;
 
     if ((loc = BIO_tell(bio)) < 0) {
@@ -430,11 +430,11 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
         goto end;
     }
 
-    for (i = data->current_deser_inst_index; i-- > 0;) {
-        OSSL_DECODER_INSTANCE *new_deser_inst =
+    for (i = data->current_decoder_inst_index; i-- > 0;) {
+        OSSL_DECODER_INSTANCE *new_decoder_inst =
             sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
-        OSSL_DECODER *new_deser =
-            OSSL_DECODER_INSTANCE_decoder(new_deser_inst);
+        OSSL_DECODER *new_decoder =
+            OSSL_DECODER_INSTANCE_decoder(new_decoder_inst);
 
         /*
          * If |decoder| is NULL, it means we've just started, and the caller
@@ -443,7 +443,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
          */
         if (decoder == NULL && ctx->start_input_type != NULL
             && strcasecmp(ctx->start_input_type,
-                          new_deser_inst->input_type) != 0)
+                          new_decoder_inst->input_type) != 0)
             continue;
 
         /*
@@ -453,7 +453,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
          * value for that decoder.
          */
         if (decoder != NULL
-            && !OSSL_DECODER_is_a(decoder, new_deser_inst->input_type))
+            && !OSSL_DECODER_is_a(decoder, new_decoder_inst->input_type))
             continue;
 
         /*
@@ -471,11 +471,12 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
             goto end;
 
         /* Recurse */
-        new_data.current_deser_inst_index = i;
-        ok = new_deser->decode(new_deser_inst->deserctx, (OSSL_CORE_BIO *)bio,
-                               decoder_process, &new_data,
-                               ossl_pw_passphrase_callback_dec,
-                               &new_data.ctx->pwdata);
+        new_data.current_decoder_inst_index = i;
+        ok = new_decoder->decode(new_decoder_inst->decoderctx,
+                                 (OSSL_CORE_BIO *)bio,
+                                 decoder_process, &new_data,
+                                 ossl_pw_passphrase_callback_dec,
+                                 &new_data.ctx->pwdata);
         if (ok)
             break;
     }
index 409bb1aa54f02c2fef9ea2b9b82b735b09583fd5..21cd53e32b066c267cff2f55013b36b3e82c6080 100644 (file)
@@ -514,10 +514,11 @@ int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx,
         OSSL_DECODER_INSTANCE *decoder_inst =
             sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
 
-        if (decoder_inst->deserctx == NULL
+        if (decoder_inst->decoderctx == NULL
             || decoder_inst->decoder->set_ctx_params == NULL)
             continue;
-        if (!decoder_inst->decoder->set_ctx_params(decoder_inst->deserctx, params))
+        if (!decoder_inst->decoder->set_ctx_params(decoder_inst->decoderctx,
+                                                   params))
             return 0;
     }
     return 1;
@@ -528,8 +529,8 @@ OSSL_DECODER_INSTANCE_free(OSSL_DECODER_INSTANCE *decoder_inst)
 {
     if (decoder_inst != NULL) {
         if (decoder_inst->decoder->freectx != NULL)
-            decoder_inst->decoder->freectx(decoder_inst->deserctx);
-        decoder_inst->deserctx = NULL;
+            decoder_inst->decoder->freectx(decoder_inst->decoderctx);
+        decoder_inst->decoderctx = NULL;
         OSSL_DECODER_free(decoder_inst->decoder);
         decoder_inst->decoder = NULL;
         OPENSSL_free(decoder_inst);
index 0bb548abceefb5f6aa13e22a55d3f1452064de11..11b087203b69e72c124d8037153f6d0bceb6f016 100644 (file)
@@ -63,7 +63,7 @@ static int decoder_construct_EVP_PKEY(OSSL_DECODER_INSTANCE *decoder_inst,
     struct decoder_EVP_PKEY_data_st *data = construct_data;
     OSSL_DECODER *decoder =
         OSSL_DECODER_INSTANCE_decoder(decoder_inst);
-    void *deserctx = OSSL_DECODER_INSTANCE_decoder_ctx(decoder_inst);
+    void *decoderctx = OSSL_DECODER_INSTANCE_decoder_ctx(decoder_inst);
     size_t i, end_i;
     /*
      * |object_ref| points to a provider reference to an object, its exact
@@ -150,7 +150,8 @@ static int decoder_construct_EVP_PKEY(OSSL_DECODER_INSTANCE *decoder_inst,
                  * No need to check for errors here, the value of
                  * |import_data.keydata| is as much an indicator.
                  */
-                (void)decoder->export_object(deserctx, object_ref, object_ref_sz,
+                (void)decoder->export_object(decoderctx,
+                                             object_ref, object_ref_sz,
                                              &evp_keymgmt_util_try_import,
                                              &import_data);
                 keydata = import_data.keydata;
index 749b2688e4570f116799be1a80a292c647bfad18..e707be19ffc26ff703f88b88d6dd3305a2cc6939 100644 (file)
@@ -16,7 +16,7 @@
 #include "internal/passphrase.h"
 #include "internal/refcount.h"
 
-struct ossl_serdes_base_st {
+struct ossl_endecode_base_st {
     OSSL_PROVIDER *prov;
     int id;
     const char *propdef;
@@ -26,7 +26,7 @@ struct ossl_serdes_base_st {
 };
 
 struct ossl_encoder_st {
-    struct ossl_serdes_base_st base;
+    struct ossl_endecode_base_st base;
     OSSL_FUNC_encoder_newctx_fn *newctx;
     OSSL_FUNC_encoder_freectx_fn *freectx;
     OSSL_FUNC_encoder_set_ctx_params_fn *set_ctx_params;
@@ -36,7 +36,7 @@ struct ossl_encoder_st {
 };
 
 struct ossl_decoder_st {
-    struct ossl_serdes_base_st base;
+    struct ossl_endecode_base_st base;
     OSSL_FUNC_decoder_newctx_fn *newctx;
     OSSL_FUNC_decoder_freectx_fn *freectx;
     OSSL_FUNC_decoder_get_params_fn *get_params;
@@ -49,7 +49,7 @@ struct ossl_decoder_st {
 
 struct ossl_encoder_ctx_st {
     OSSL_ENCODER *encoder;
-    void *serctx;
+    void *encoderctx;
 
     int selection;
 
@@ -69,8 +69,8 @@ struct ossl_encoder_ctx_st {
 };
 
 struct ossl_decoder_instance_st {
-    OSSL_DECODER *decoder;    /* Never NULL */
-    void *deserctx;              /* Never NULL */
+    OSSL_DECODER *decoder;       /* Never NULL */
+    void *decoderctx;            /* Never NULL */
     const char *input_type;      /* Never NULL */
 };
 
index 81bc5c47b9cfc4e3167b7936769977cbe26271ac..62342f511a79ebd220c05252201fbd87072afc07 100644 (file)
@@ -475,7 +475,7 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new(OSSL_ENCODER *encoder)
         void *provctx = ossl_provider_ctx(prov);
 
         if (OSSL_ENCODER_up_ref(encoder)) {
-            ctx->serctx = encoder->newctx(provctx);
+            ctx->encoderctx = encoder->newctx(provctx);
         } else {
             OSSL_ENCODER_free(encoder);
             OPENSSL_free(ctx);
@@ -507,7 +507,7 @@ int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx,
     }
 
     if (ctx->encoder != NULL && ctx->encoder->set_ctx_params != NULL)
-        return ctx->encoder->set_ctx_params(ctx->serctx, params);
+        return ctx->encoder->set_ctx_params(ctx->encoderctx, params);
     return 0;
 }
 
@@ -515,7 +515,7 @@ void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx)
 {
     if (ctx != NULL) {
         if (ctx->encoder != NULL && ctx->encoder->freectx != NULL)
-            ctx->encoder->freectx(ctx->serctx);
+            ctx->encoder->freectx(ctx->encoderctx);
         OSSL_ENCODER_free(ctx->encoder);
         ossl_pw_clear_passphrase_data(&ctx->pwdata);
         OPENSSL_free(ctx);
index 6664f589b4a81e5f126320234243ccf7b184b9f3..176f4fab957ca9dec00ac69e0b2a3c4748c4b6e7 100644 (file)
@@ -96,7 +96,8 @@ static int encoder_write_cb(const OSSL_PARAM params[], void *arg)
     OSSL_ENCODER_CTX *ctx = write_data->ctx;
     BIO *out = write_data->out;
 
-    return ctx->encoder->encode_data(ctx->serctx, params, (OSSL_CORE_BIO *)out,
+    return ctx->encoder->encode_data(ctx->encoderctx, params,
+                                     (OSSL_CORE_BIO *)out,
                                      ossl_pw_passphrase_callback_enc,
                                      &ctx->pwdata);
 }
@@ -135,7 +136,7 @@ static int encoder_EVP_PKEY_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out)
                                   &encoder_write_cb, &write_data);
     }
 
-    return ctx->encoder->encode_object(ctx->serctx, keydata,
+    return ctx->encoder->encode_object(ctx->encoderctx, keydata,
                                        (OSSL_CORE_BIO *)out,
                                        ossl_pw_passphrase_callback_enc,
                                        &ctx->pwdata);
@@ -172,8 +173,8 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey,
          * Select the encoder in two steps.  First, get the names of all of
          * the encoders.  Then determine which is the best one to use.
          * This has to be broken because it isn't possible to fetch the
-         * serialisers inside EVP_KEYMGMT_names_do_all() due to locking
-         * order inversions with the store lock.
+         * encoders inside EVP_KEYMGMT_names_do_all() due to locking order
+         * inversions with the store lock.
          */
         sel_data.error = 0;
         sel_data.names = sk_OPENSSL_CSTRING_new_null();