Remove some of the TODO 3.0 in crypto/evp related to legacy support.
authorTomas Mraz <tomas@openssl.org>
Tue, 2 Mar 2021 15:16:06 +0000 (16:16 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 4 Mar 2021 13:15:01 +0000 (14:15 +0100)
The legacy support stays in 3.0. The TODOs are dropped.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14404)

crypto/evp/digest.c
crypto/evp/evp_enc.c
crypto/evp/evp_lib.c
crypto/evp/pmeth_lib.c

index 858a9926cf4f9e4e6680a021ae622164646643cc..069eb192c103eb62f1a7b46687b859f672e1bee1 100644 (file)
@@ -32,7 +32,7 @@ void evp_md_ctx_clear_digest(EVP_MD_CTX *ctx, int force)
         EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);
     }
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
 
     /*
      * Don't assume ctx->md_data was cleaned in EVP_Digest_Final, because
@@ -177,7 +177,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
         type = ctx->digest;
     }
 
-    /* TODO(3.0): Legacy work around code below. Remove this */
+    /* Code below to be removed when legacy support is dropped. */
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
     /*
      * Whether it's nice or not, "Inits" can be used on "Final"'d contexts so
@@ -225,7 +225,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
         ctx->md_data = NULL;
     }
 
-    /* TODO(3.0): Start of non-legacy code below */
+    /* Start of non-legacy code below */
 
     if (type->prov == NULL) {
 #ifdef FIPS_MODULE
@@ -274,7 +274,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
 
     return ctx->digest->dinit(ctx->provctx);
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
@@ -381,7 +381,7 @@ int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
     }
     return ctx->digest->dupdate(ctx->provctx, data, count);
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
     return ctx->update(ctx, data, count);
 }
@@ -430,7 +430,7 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize)
 
     return ret;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
     OPENSSL_assert(mdsize <= EVP_MAX_MD_SIZE);
     ret = ctx->digest->final(ctx, md);
@@ -542,7 +542,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
 
     return 1;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
     /* Make sure it's safe to copy a digest context using an ENGINE */
@@ -787,7 +787,7 @@ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
     goto conclude;
 
 
-/* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
     if (ctx->digest->md_ctrl == NULL) {
         ERR_raise(ERR_LIB_EVP, EVP_R_CTRL_NOT_IMPLEMENTED);
index 851c6d5d9a0d6c4cc4907e7f05ee1b424688d714..40e9f0b6c3892541018a00666258ecf4678f014b 100644 (file)
@@ -43,7 +43,7 @@ int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
 
     return 1;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Remove legacy code below when legacy support is removed. */
  legacy:
 
     if (ctx->cipher != NULL) {
@@ -105,7 +105,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
         return 0;
     }
 
-    /* TODO(3.0): Legacy work around code below. Remove this */
+    /* Code below to be removed when legacy support is dropped. */
 
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
     /*
@@ -148,7 +148,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
     }
 
 
-    /* TODO(3.0): Start of non-legacy code below */
+    /* Start of non-legacy code below */
 
     /* Ensure a context left lying around from last time is cleared */
     if (cipher != NULL && ctx->cipher != NULL) {
@@ -237,7 +237,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
                               iv == NULL ? 0
                                          : EVP_CIPHER_CTX_iv_length(ctx));
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
     if (cipher != NULL) {
@@ -597,7 +597,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
 
     return ret;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
     return evp_EncryptDecryptUpdate(ctx, out, outl, in, inl);
@@ -657,7 +657,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
 
     return ret;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
     if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
@@ -744,7 +744,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
 
     return ret;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
     b = ctx->cipher->block_size;
@@ -879,7 +879,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
 
     return ret;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
     *outl = 0;
@@ -953,7 +953,7 @@ int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen)
         return ok > 0 ? 1 : 0;
     }
 
-    /* TODO(3.0) legacy code follows */
+    /* Code below to be removed when legacy support is dropped. */
 
     /*
      * Note there have never been any built-in ciphers that define this flag
@@ -1021,7 +1021,7 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 
     case EVP_CTRL_INIT:
         /*
-         * TODO(3.0) EVP_CTRL_INIT is purely legacy, no provider counterpart
+         * EVP_CTRL_INIT is purely legacy, no provider counterpart.
          * As a matter of fact, this should be dead code, but some caller
          * might still do a direct control call with this command, so...
          * Legacy methods return 1 except for exceptional circumstances, so
@@ -1172,7 +1172,7 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
         ret = evp_do_ciph_ctx_getparams(ctx->cipher, ctx->provctx, params);
     goto end;
 
-/* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
 legacy:
     if (ctx->cipher->ctrl == NULL) {
         ERR_raise(ERR_LIB_EVP, EVP_R_CTRL_NOT_IMPLEMENTED);
@@ -1329,7 +1329,7 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
 
     return 1;
 
-    /* TODO(3.0): Remove legacy code below */
+    /* Code below to be removed when legacy support is dropped. */
  legacy:
 
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
index fc2c65b578cacb9f0811d9a46a77e848ec545dd1..dd3173ddd52ba1e2c2729dc912abf2d348214e82 100644 (file)
@@ -477,7 +477,7 @@ int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
     if (rv == EVP_CTRL_RET_UNSUPPORTED)
         goto legacy;
     return rv != 0 ? (int)v : -1;
-    /* TODO (3.0) Remove legacy support */
+    /* Code below to be removed when legacy support is dropped. */
 legacy:
     if ((EVP_CIPHER_flags(ctx->cipher) & EVP_CIPH_CUSTOM_IV_LENGTH) != 0) {
         rv = EVP_CIPHER_CTX_ctrl((EVP_CIPHER_CTX *)ctx, EVP_CTRL_GET_IVLEN,
index 2cc30f1af41067b5c2064ba77acaf3c826e225d2..b08d0d2e3c4cdae171edc4946092b61414b21446 100644 (file)
@@ -197,10 +197,7 @@ static EVP_PKEY_CTX *int_ctx_new(OSSL_LIB_CTX *libctx,
     }
 
 #ifndef FIPS_MODULE
-    /*
-     * TODO(3.0) This legacy code section should be removed when we stop
-     * supporting engines
-     */
+    /* Code below to be removed when legacy support is dropped. */
     /* BEGIN legacy */
     if (id == -1) {
         if (pkey != NULL)
@@ -879,6 +876,7 @@ int evp_pkey_ctx_get_params_strict(EVP_PKEY_CTX *ctx, OSSL_PARAM *params)
     return EVP_PKEY_CTX_get_params(ctx, params);
 }
 
+/* TODO(3.0): Deprecate in favour of get_signature_md_name */
 int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md)
 {
     OSSL_PARAM sig_md_params[2], *p = sig_md_params;
@@ -892,7 +890,6 @@ int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md)
         return -2;
     }
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
     if (ctx->op.sig.sigprovctx == NULL)
         return EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,
                                  EVP_PKEY_CTRL_GET_MD, 0, (void *)(md));
@@ -914,6 +911,10 @@ int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md)
     return 1;
 }
 
+/*
+ * TODO(3.0): Deprecate functions calling this in favour of
+ * functions setting md name.
+ */
 static int evp_pkey_ctx_set_md(EVP_PKEY_CTX *ctx, const EVP_MD *md,
                                int fallback, const char *param, int op,
                                int ctrl)
@@ -927,7 +928,6 @@ static int evp_pkey_ctx_set_md(EVP_PKEY_CTX *ctx, const EVP_MD *md,
         return -2;
     }
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
     if (fallback)
         return EVP_PKEY_CTX_ctrl(ctx, -1, op, ctrl, 0, (void *)(md));
 
@@ -975,9 +975,10 @@ static int evp_pkey_ctx_set1_octet_string(EVP_PKEY_CTX *ctx, int fallback,
         return -2;
     }
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
+    /* Code below to be removed when legacy support is dropped. */
     if (fallback)
         return EVP_PKEY_CTX_ctrl(ctx, -1, op, ctrl, datalen, (void *)(data));
+    /* end of legacy support */
 
     if (datalen < 0) {
         ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_LENGTH);
@@ -1063,11 +1064,11 @@ int EVP_PKEY_CTX_hkdf_mode(EVP_PKEY_CTX *ctx, int mode)
         return -2;
     }
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
+    /* Code below to be removed when legacy support is dropped. */
     if (ctx->op.kex.exchprovctx == NULL)
         return EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_DERIVE,
                                  EVP_PKEY_CTRL_HKDF_MODE, mode, NULL);
-
+    /* end of legacy support */
 
     if (mode < 0) {
         ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_VALUE);
@@ -1111,9 +1112,10 @@ static int evp_pkey_ctx_set_uint64(EVP_PKEY_CTX *ctx, const char *param,
         return -2;
     }
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
+    /* Code below to be removed when legacy support is dropped. */
     if (ctx->op.kex.exchprovctx == NULL)
         return EVP_PKEY_CTX_ctrl_uint64(ctx, -1, op, ctrl, val);
+    /* end of legacy support */
 
     *p++ = OSSL_PARAM_construct_uint64(param, &val);
     *p = OSSL_PARAM_construct_end();