Make EVP_MD_CTX_[gettable|settable]_params() take an EVP_MD_CTX
authorMatt Caswell <matt@openssl.org>
Tue, 24 Sep 2019 14:17:15 +0000 (15:17 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 25 Sep 2019 11:06:21 +0000 (12:06 +0100)
EVP_MD_CTX_gettable_params() and EVP_MD_CTX_settable_params() were
confusingly named because they did not take an EVP_MD_CTX parameter.

In addition we add the functions EVP_MD_gettable_ctx_params() and
EVP_MD_settable_ctx_params() which do the same thing but are passed
an EVP_MD object instead.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9998)

apps/list.c
apps/provider.c
crypto/evp/digest.c
doc/man3/EVP_DigestInit.pod
include/openssl/evp.h
util/libcrypto.num

index 2b44cac71bb4dca2007bdac7182461a6f26b33ad..5348cc68dd3f487ed5643a9bd2c7e2d49bdcfb4a 100644 (file)
@@ -139,9 +139,9 @@ static void list_digests(void)
             print_param_types("retrievable algorithm parameters",
                               EVP_MD_gettable_params(m), 4);
             print_param_types("retrievable operation parameters",
-                              EVP_MD_CTX_gettable_params(m), 4);
+                              EVP_MD_gettable_ctx_params(m), 4);
             print_param_types("settable operation parameters",
-                              EVP_MD_CTX_settable_params(m), 4);
+                              EVP_MD_settable_ctx_params(m), 4);
         }
     }
     sk_EVP_MD_pop_free(digests, EVP_MD_free);
index fe5ca1d1f72a9eb9a9f171f010483a6477bd1dce..29afdcef48cfeff26175666edb15b68a8f960f4b 100644 (file)
@@ -117,8 +117,8 @@ static void do_digest(EVP_MD *digest, void *meta)
 {
     do_method(digest, EVP_MD_name(digest),
               EVP_MD_gettable_params(digest),
-              EVP_MD_CTX_gettable_params(digest),
-              EVP_MD_CTX_settable_params(digest),
+              EVP_MD_gettable_ctx_params(digest),
+              EVP_MD_settable_ctx_params(digest),
               meta);
 }
 
index 92012f917e00dcc03ec479202e90d97b0d0e18ed..9c6aa42887d778fae747a448a1366f2ad251eb32 100644 (file)
@@ -550,10 +550,20 @@ int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[])
     return 0;
 }
 
-const OSSL_PARAM *EVP_MD_CTX_settable_params(const EVP_MD *digest)
+const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md)
 {
-    if (digest != NULL && digest->settable_ctx_params != NULL)
-        return digest->settable_ctx_params();
+    if (md != NULL && md->settable_ctx_params != NULL)
+        return md->settable_ctx_params();
+    return NULL;
+}
+
+const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx)
+{
+    if (ctx != NULL
+            && ctx->digest != NULL
+            && ctx->digest->settable_ctx_params != NULL)
+        return ctx->digest->settable_ctx_params();
+
     return NULL;
 }
 
@@ -564,10 +574,20 @@ int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[])
     return 0;
 }
 
-const OSSL_PARAM *EVP_MD_CTX_gettable_params(const EVP_MD *digest)
+const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md)
 {
-    if (digest != NULL && digest->gettable_ctx_params != NULL)
-        return digest->gettable_ctx_params();
+    if (md != NULL && md->gettable_ctx_params != NULL)
+        return md->gettable_ctx_params();
+    return NULL;
+}
+
+const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx)
+{
+    if (ctx != NULL
+            && ctx->digest != NULL
+            && ctx->digest->gettable_ctx_params != NULL)
+        return ctx->digest->gettable_ctx_params();
+
     return NULL;
 }
 
index 8270d7040b3662c00c19bcf5fde76527331bcb4a..f4d3e582685779d12d79079cc6157a6e77e651fd 100644 (file)
@@ -7,6 +7,7 @@ EVP_MD_get_params, EVP_MD_gettable_params,
 EVP_MD_CTX_new, EVP_MD_CTX_reset, EVP_MD_CTX_free, EVP_MD_CTX_copy,
 EVP_MD_CTX_copy_ex, EVP_MD_CTX_ctrl,
 EVP_MD_CTX_set_params, EVP_MD_CTX_get_params,
+EVP_MD_settable_ctx_params, EVP_MD_gettable_ctx_params,
 EVP_MD_CTX_settable_params, EVP_MD_CTX_gettable_params,
 EVP_MD_CTX_set_flags, EVP_MD_CTX_clear_flags, EVP_MD_CTX_test_flags,
 EVP_Digest, EVP_DigestInit_ex, EVP_DigestInit, EVP_DigestUpdate,
@@ -38,8 +39,10 @@ EVP_MD_do_all_ex
  void EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void* p2);
  int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
  int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
- const OSSL_PARAM *EVP_MD_CTX_settable_params(const EVP_MD *digest);
- const OSSL_PARAM *EVP_MD_CTX_gettable_params(const EVP_MD *digest);
+ const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md);
+ const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md);
+ const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx);
+ const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx);
  void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
  void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
  int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
@@ -158,12 +161,17 @@ See L</PARAMETERS> below for more information.
 Sets the list of B<params> into a MD context B<ctx>.
 See L</PARAMETERS> below for more information.
 
-=item EVP_MD_gettable_params(), EVP_MD_CTX_gettable_params(),
+=item EVP_MD_gettable_params(), EVP_MD_gettable_ctx_params(),
+EVP_MD_settable_ctx_params(), EVP_MD_CTX_gettable_params(),
 EVP_MD_CTX_settable_params()
 
 Get a B<OSSL_PARAM> array that describes the retrievable and settable
-parameters, i.e. parameters that can be used with EVP_MD_get_params(),
-EVP_MD_CTX_get_params() and EVP_MD_CTX_set_params(), respectively.
+parameters. EVP_MD_gettable_params() returns parameters that can be used with
+EVP_MD_get_params(). EVP_MD_gettable_ctx_params() and
+EVP_MD_CTX_gettable_params() return parameters that can be used with
+EVP_MD_CTX_get_params(). EVP_MD_settable_ctx_params() and
+EVP_MD_CTX_settable_params() return parameters that can be used with
+EVP_MD_CTX_set_params().
 See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
 
 =item EVP_MD_CTX_set_flags(), EVP_MD_CTX_clear_flags(), EVP_MD_CTX_test_flags()
index bbdc2b75c187baf5529184cf340bf67cc05d95f9..b65328df6d81cc28330b0ff572b76503461ba321 100644 (file)
@@ -555,8 +555,10 @@ int EVP_MD_get_params(const EVP_MD *digest, OSSL_PARAM params[]);
 int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
 int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
 const OSSL_PARAM *EVP_MD_gettable_params(const EVP_MD *digest);
-const OSSL_PARAM *EVP_MD_CTX_settable_params(const EVP_MD *digest);
-const OSSL_PARAM *EVP_MD_CTX_gettable_params(const EVP_MD *digest);
+const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md);
+const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md);
+const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx);
+const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx);
 int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
 EVP_MD_CTX *EVP_MD_CTX_new(void);
 int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
index 1b14b440dc7c42e2ae7dc73462d8ba43a225f074..567b00631fd19accc71bdfa75e05d3046194d9c0 100644 (file)
@@ -4764,3 +4764,5 @@ ERR_peek_last_error_data                4880      3_0_0   EXIST::FUNCTION:
 ERR_peek_last_error_all                 4881   3_0_0   EXIST::FUNCTION:
 EVP_CIPHER_is_a                         4882   3_0_0   EXIST::FUNCTION:
 EVP_MAC_is_a                            4883   3_0_0   EXIST::FUNCTION:
+EVP_MD_settable_ctx_params              4884   3_0_0   EXIST::FUNCTION:
+EVP_MD_gettable_ctx_params              4885   3_0_0   EXIST::FUNCTION: