Cleanup of some of the EVP_PKEY_CTX_ctrl related TODOs
authorTomas Mraz <tomas@openssl.org>
Tue, 23 Feb 2021 15:52:49 +0000 (16:52 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 24 Feb 2021 16:55:20 +0000 (17:55 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14290)

crypto/evp/dsa_ctrl.c
crypto/evp/ec_ctrl.c
crypto/rsa/rsa_lib.c

index cb7e543e027f01bd94bbd4641e40d3fcb9e9f554..5fa2300abb1b49337ee9b5a3047303fbcc087d66 100644 (file)
@@ -82,13 +82,6 @@ int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits)
     if ((ret = dsa_paramgen_check(ctx)) <= 0)
         return ret;
 
-#if !defined(FIPS_MODULE)
-    /* TODO(3.0): Remove this eventually when no more legacy */
-    if (ctx->op.keymgmt.genctx == NULL)
-        return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA,  EVP_PKEY_OP_PARAMGEN,
-                                 EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL);
-#endif
-
     *p++ = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_FFC_PBITS, &bits);
     *p++ = OSSL_PARAM_construct_end();
 
@@ -104,13 +97,6 @@ int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits)
     if ((ret = dsa_paramgen_check(ctx)) <= 0)
         return ret;
 
-#if !defined(FIPS_MODULE)
-    /* TODO(3.0): Remove this eventually when no more legacy */
-    if (ctx->op.keymgmt.genctx == NULL)
-        return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA,  EVP_PKEY_OP_PARAMGEN,
-                                 EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL);
-#endif
-
     *p++ = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_FFC_QBITS, &bits2);
     *p++ = OSSL_PARAM_construct_end();
 
@@ -127,16 +113,6 @@ int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx,
     if ((ret = dsa_paramgen_check(ctx)) <= 0)
         return ret;
 
-#if !defined(FIPS_MODULE)
-    /* TODO(3.0): Remove this eventually when no more legacy */
-    if (ctx->op.keymgmt.genctx == NULL) {
-        const EVP_MD *md = EVP_get_digestbyname(md_name);
-
-         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN,
-                           EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md));
-    }
-#endif
-
     *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_FFC_DIGEST,
                                             (char *)md_name, 0);
     if (md_properties != NULL)
@@ -148,10 +124,10 @@ int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx,
 }
 
 #if !defined(FIPS_MODULE)
+/* TODO(3.0): deprecate as this is needed only for legacy? */
 int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md)
 {
-    const char *md_name = (md == NULL) ? "" : EVP_MD_name(md);
-
-    return EVP_PKEY_CTX_set_dsa_paramgen_md_props(ctx, md_name, NULL);
+    return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN,
+                             EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md));
 }
 #endif
index ff0c55d0232098c9182ed72b637ae7054f4c9a79..b8b5434ee61840e8d4ddcba5e7873ab602e743e0 100644 (file)
@@ -9,8 +9,6 @@
 
 #include "internal/deprecated.h"
 
-#include <string.h>
-
 #include <openssl/core_names.h>
 #include <openssl/err.h>
 #include <openssl/ec.h>
@@ -254,13 +252,6 @@ int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **pukm)
     if (ret != 1)
         return ret;
 
-    /* TODO(3.0): Remove this eventually when no more legacy */
-    if (ctx->op.kex.exchprovctx == NULL)
-        return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC,
-                                 EVP_PKEY_OP_DERIVE,
-                                 EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0,
-                                 (void *)(pukm));
-
     *p++ = OSSL_PARAM_construct_octet_ptr(OSSL_EXCHANGE_PARAM_KDF_UKM,
                                           (void **)pukm, 0);
     *p++ = OSSL_PARAM_construct_end();
index 817372cbb769af4bb1d84321e26c768963c53292..530fdaa035f2d0c2cbaf9b7135210d91b5deb188 100644 (file)
  */
 #include "internal/deprecated.h"
 
-#include <stdio.h>
 #include <openssl/crypto.h>
 #include <openssl/core_names.h>
 #include <openssl/engine.h>
 #include <openssl/evp.h>
+#include <openssl/param_build.h>
 #include "internal/cryptlib.h"
 #include "internal/refcount.h"
-#include "openssl/param_build.h"
 #include "crypto/bn.h"
 #include "crypto/evp.h"
 #include "crypto/rsa.h"
@@ -1067,8 +1066,6 @@ int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen)
     if (!EVP_PKEY_CTX_is_a(ctx, "RSA"))
         return -1;
 
-    /* TODO(3.0) Shouldn't a set0 translate into setting an OCTET_PTR? */
-
     /* Cast away the const. This is read only so should be safe */
     *p++ = OSSL_PARAM_construct_octet_string(OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL,
                                              (void *)label, (size_t)llen);
@@ -1077,7 +1074,7 @@ int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen)
     if (!evp_pkey_ctx_set_params_strict(ctx, rsa_params))
         return 0;
 
-    /* TODO(3.0) ????? */
+    /* Ownership is supposed to be transfered to the callee. */
     OPENSSL_free(label);
     return 1;
 }