From: Matt Caswell Date: Tue, 24 Sep 2019 14:17:15 +0000 (+0100) Subject: Make EVP_MD_CTX_[gettable|settable]_params() take an EVP_MD_CTX X-Git-Tag: openssl-3.0.0-alpha1~1284 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=e6879a31ef597f1b9608c7897087203d829d47c2;hp=5a2a2f66c5e79895400c6e895ce7f8d48db96bb8 Make EVP_MD_CTX_[gettable|settable]_params() take an EVP_MD_CTX 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 (Merged from https://github.com/openssl/openssl/pull/9998) --- diff --git a/apps/list.c b/apps/list.c index 2b44cac71b..5348cc68dd 100644 --- a/apps/list.c +++ b/apps/list.c @@ -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); diff --git a/apps/provider.c b/apps/provider.c index fe5ca1d1f7..29afdcef48 100644 --- a/apps/provider.c +++ b/apps/provider.c @@ -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); } diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 92012f917e..9c6aa42887 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -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; } diff --git a/doc/man3/EVP_DigestInit.pod b/doc/man3/EVP_DigestInit.pod index 8270d7040b..f4d3e58268 100644 --- a/doc/man3/EVP_DigestInit.pod +++ b/doc/man3/EVP_DigestInit.pod @@ -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 below for more information. Sets the list of B into a MD context B. See L 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 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 for the use of B as parameter descriptor. =item EVP_MD_CTX_set_flags(), EVP_MD_CTX_clear_flags(), EVP_MD_CTX_test_flags() diff --git a/include/openssl/evp.h b/include/openssl/evp.h index bbdc2b75c1..b65328df6d 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -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); diff --git a/util/libcrypto.num b/util/libcrypto.num index 1b14b440dc..567b00631f 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -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: