From 251e610ce4479913e593f9f7a9a711115e6cf1a3 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 23 Sep 2019 10:33:26 +0200 Subject: [PATCH] EVP: add missing common functionality This adds the missing functions that should be common for all fetchable EVP sub-APIs: EVP_KEYMGMT_is_a(), EVP_KEYMGMT_do_all_provided(), EVP_KEYEXCH_is_a(), EVP_KEYEXCH_do_all_provided(), EVP_KDF_is_a(), EVP_MD_is_a(), EVP_SIGNATURE_do_all_provided(), EVP_SIGNATURE_is_a(). This also renames EVP_MD_do_all_ex(), EVP_CIPHER_do_all_ex(), EVP_KDF_do_all_ex(), EVP_MAC_do_all_ex() to change '_ex' to '_provided'. Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/9979) --- crypto/evp/digest.c | 6 +++--- crypto/evp/evp_enc.c | 6 +++--- crypto/evp/evp_lib.c | 5 +++++ crypto/evp/exchange.c | 19 +++++++++++++++++++ crypto/evp/kdf_lib.c | 5 +++++ crypto/evp/kdf_meth.c | 6 +++--- crypto/evp/keymgmt_meth.c | 14 ++++++++++++++ crypto/evp/mac_lib.c | 5 +++++ crypto/evp/mac_meth.c | 11 +++-------- crypto/evp/pmeth_fn.c | 20 ++++++++++++++++++++ doc/man3/EVP_DigestInit.pod | 21 ++++++++++++++------- doc/man3/EVP_EncryptInit.pod | 15 ++++++++------- doc/man3/EVP_KDF.pod | 23 ++++++++++++++--------- doc/man3/EVP_KEYEXCH_free.pod | 18 +++++++++++++++++- doc/man3/EVP_KEYMGMT.pod | 19 ++++++++++++++++++- doc/man3/EVP_MAC.pod | 12 ++++++------ doc/man3/EVP_SIGNATURE_free.pod | 15 ++++++++++++++- include/openssl/evp.h | 32 +++++++++++++++++++++++--------- include/openssl/kdf.h | 7 ++++--- util/libcrypto.num | 16 ++++++++++++---- 20 files changed, 210 insertions(+), 65 deletions(-) diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index e59f082818..a8e8326237 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -902,9 +902,9 @@ void EVP_MD_free(EVP_MD *md) OPENSSL_free(md); } -void EVP_MD_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MD *mac, void *arg), - void *arg) +void EVP_MD_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MD *mac, void *arg), + void *arg) { evp_generic_do_all(libctx, OSSL_OP_DIGEST, (void (*)(void *, void *))fn, arg, diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 86506d3a4c..4406b7f032 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -1521,9 +1521,9 @@ void EVP_CIPHER_free(EVP_CIPHER *cipher) OPENSSL_free(cipher); } -void EVP_CIPHER_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_CIPHER *mac, void *arg), - void *arg) +void EVP_CIPHER_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_CIPHER *mac, void *arg), + void *arg) { evp_generic_do_all(libctx, OSSL_OP_CIPHER, (void (*)(void *, void *))fn, arg, diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index c567b2efee..f87793d3ed 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -573,6 +573,11 @@ int EVP_CIPHER_mode(const EVP_CIPHER *cipher) return ok != 0 ? (int)v : 0; } +int EVP_MD_is_a(const EVP_MD *md, const char *name) +{ + return evp_is_a(md->prov, md->name_id, name); +} + const char *EVP_MD_name(const EVP_MD *md) { if (md->prov != NULL) diff --git a/crypto/evp/exchange.c b/crypto/evp/exchange.c index 4c02c8a6a0..437d6a5cd6 100644 --- a/crypto/evp/exchange.c +++ b/crypto/evp/exchange.c @@ -386,3 +386,22 @@ int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen) M_check_autoarg(ctx, key, pkeylen, EVP_F_EVP_PKEY_DERIVE) return ctx->pmeth->derive(ctx, key, pkeylen); } + +int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name) +{ + return evp_is_a(keyexch->prov, keyexch->name_id, name); +} + +void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYEXCH *keyexch, void *arg), + void *arg) +{ + struct keymgmt_data_st keymgmt_data; + + keymgmt_data.ctx = libctx; + keymgmt_data.properties = NULL; + evp_generic_do_all(libctx, OSSL_OP_KEYEXCH, + (void (*)(void *, void *))fn, arg, + evp_keyexch_from_dispatch, &keymgmt_data, + (void (*)(void *))EVP_KEYEXCH_free); +} diff --git a/crypto/evp/kdf_lib.c b/crypto/evp/kdf_lib.c index 7163de397f..b85f0e0eb8 100644 --- a/crypto/evp/kdf_lib.c +++ b/crypto/evp/kdf_lib.c @@ -88,6 +88,11 @@ const char *EVP_KDF_name(const EVP_KDF *kdf) return evp_first_name(kdf->prov, kdf->name_id); } +int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name) +{ + return evp_is_a(kdf->prov, kdf->name_id, name); +} + const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf) { return kdf->prov; diff --git a/crypto/evp/kdf_meth.c b/crypto/evp/kdf_meth.c index e6185e9255..576dde6805 100644 --- a/crypto/evp/kdf_meth.c +++ b/crypto/evp/kdf_meth.c @@ -187,9 +187,9 @@ const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf) return kdf->settable_ctx_params(); } -void EVP_KDF_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_KDF *kdf, void *arg), - void *arg) +void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KDF *kdf, void *arg), + void *arg) { evp_generic_do_all(libctx, OSSL_OP_KDF, (void (*)(void *, void *))fn, arg, diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c index a5df564605..990f899159 100644 --- a/crypto/evp/keymgmt_meth.c +++ b/crypto/evp/keymgmt_meth.c @@ -200,3 +200,17 @@ const OSSL_PROVIDER *EVP_KEYMGMT_provider(const EVP_KEYMGMT *keymgmt) return keymgmt->prov; } +int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name) +{ + return evp_is_a(keymgmt->prov, keymgmt->name_id, name); +} + +void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), + void *arg) +{ + evp_generic_do_all(libctx, OSSL_OP_KEYMGMT, + (void (*)(void *, void *))fn, arg, + keymgmt_from_dispatch, NULL, + (void (*)(void *))EVP_KEYMGMT_free); +} diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index 8b8c9a5067..b6df6a594b 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -157,3 +157,8 @@ int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]) return ctx->meth->set_ctx_params(ctx->data, params); return 1; } + +int EVP_MAC_is_a(const EVP_MAC *mac, const char *name) +{ + return evp_is_a(mac->prov, mac->name_id, name); +} diff --git a/crypto/evp/mac_meth.c b/crypto/evp/mac_meth.c index f35c2d157e..86f5434654 100644 --- a/crypto/evp/mac_meth.c +++ b/crypto/evp/mac_meth.c @@ -168,11 +168,6 @@ void EVP_MAC_free(EVP_MAC *mac) evp_mac_free(mac); } -int EVP_MAC_is_a(const EVP_MAC *mac, const char *name) -{ - return evp_is_a(mac->prov, mac->name_id, name); -} - const char *EVP_MAC_name(const EVP_MAC *mac) { return evp_first_name(mac->prov, mac->name_id); @@ -204,9 +199,9 @@ const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac) return mac->settable_ctx_params(); } -void EVP_MAC_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MAC *mac, void *arg), - void *arg) +void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MAC *mac, void *arg), + void *arg) { evp_generic_do_all(libctx, OSSL_OP_MAC, (void (*)(void *, void *))fn, arg, diff --git a/crypto/evp/pmeth_fn.c b/crypto/evp/pmeth_fn.c index c7940e8e38..2b4bca5727 100644 --- a/crypto/evp/pmeth_fn.c +++ b/crypto/evp/pmeth_fn.c @@ -312,6 +312,26 @@ EVP_SIGNATURE *EVP_SIGNATURE_fetch(OPENSSL_CTX *ctx, const char *algorithm, (void (*)(void *))EVP_SIGNATURE_free); } +int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name) +{ + return evp_is_a(signature->prov, signature->name_id, name); +} + +void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_SIGNATURE *signature, + void *arg), + void *arg) +{ + struct keymgmt_data_st keymgmt_data; + + keymgmt_data.ctx = libctx; + keymgmt_data.properties = NULL; + evp_generic_do_all(libctx, OSSL_OP_SIGNATURE, + (void (*)(void *, void *))fn, arg, + evp_signature_from_dispatch, &keymgmt_data, + (void (*)(void *))EVP_SIGNATURE_free); +} + static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *signature, int operation) { diff --git a/doc/man3/EVP_DigestInit.pod b/doc/man3/EVP_DigestInit.pod index dfc63eba49..6a9100b583 100644 --- a/doc/man3/EVP_DigestInit.pod +++ b/doc/man3/EVP_DigestInit.pod @@ -12,7 +12,7 @@ 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, EVP_DigestFinal_ex, EVP_DigestFinalXOF, EVP_DigestFinal, -EVP_MD_name, EVP_MD_provider, +EVP_MD_is_a, EVP_MD_name, EVP_MD_provider, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, EVP_MD_flags, EVP_MD_CTX_name, EVP_MD_CTX_md, EVP_MD_CTX_type, EVP_MD_CTX_size, EVP_MD_CTX_block_size, @@ -20,7 +20,7 @@ EVP_MD_CTX_md_data, EVP_MD_CTX_update_fn, EVP_MD_CTX_set_update_fn, EVP_md_null, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj, EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx, -EVP_MD_do_all_ex +EVP_MD_do_all_provided - EVP digest routines =head1 SYNOPSIS @@ -62,6 +62,7 @@ EVP_MD_do_all_ex int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in); const char *EVP_MD_name(const EVP_MD *md); + int EVP_MD_is_a(const EVP_MD *md, const char *name); const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md); int EVP_MD_type(const EVP_MD *md); int EVP_MD_pkey_type(const EVP_MD *md); @@ -90,9 +91,9 @@ EVP_MD_do_all_ex EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx); void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx); - void EVP_MD_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MD *mac, void *arg), - void *arg); + void EVP_MD_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MD *mac, void *arg), + void *arg); =head1 DESCRIPTION @@ -238,10 +239,16 @@ automatically cleaned up. Similar to EVP_MD_CTX_copy_ex() except the destination B does not have to be initialized. +=item EVP_MD_is_a() + +Returns 1 if I is an implementation of an algorithm that's +identifiable with I, otherwise 0. + =item EVP_MD_name(), EVP_MD_CTX_name() -Return the name of the given message digest. +Return the name of the given message digest. For fetched message +digests with multiple names, only one of them is returned. =item EVP_MD_provider() @@ -330,7 +337,7 @@ by the caller. A NULL B pointer is also allowed to clear the B. In such case, freeing the cleared B or not depends on how the B is created. -=item EVP_MD_do_all_ex() +=item EVP_MD_do_all_provided() Traverses all messages digests implemented by all activated providers in the given library context I, and for each of the implementations, diff --git a/doc/man3/EVP_EncryptInit.pod b/doc/man3/EVP_EncryptInit.pod index 722a8e3d36..c5c2c5ab39 100644 --- a/doc/man3/EVP_EncryptInit.pod +++ b/doc/man3/EVP_EncryptInit.pod @@ -61,7 +61,7 @@ EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param, EVP_CIPHER_CTX_set_padding, EVP_enc_null, -EVP_CIPHER_do_all_ex +EVP_CIPHER_do_all_provided - EVP cipher routines =head1 SYNOPSIS @@ -153,9 +153,9 @@ EVP_CIPHER_do_all_ex int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - void EVP_CIPHER_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_CIPHER *cipher, void *arg), - void *arg); + void EVP_CIPHER_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_CIPHER *cipher, void *arg), + void *arg); =head1 DESCRIPTION @@ -330,11 +330,12 @@ IDENTIFIER as such it ignores the cipher parameters and 40 bit RC2 and identifier or does not have ASN1 support this function will return B. -EVP_CIPHER_is_a() returns 1 if the given I is an implementation of an +EVP_CIPHER_is_a() returns 1 if I is an implementation of an algorithm that's identifiable with I, otherwise 0. EVP_CIPHER_name() and EVP_CIPHER_CTX_name() return the name of the passed -cipher or context. +cipher or context. For fetched ciphers with multiple names, only one +of them is returned. EVP_CIPHER_provider() returns an B pointer to the provider that implements the given B. @@ -377,7 +378,7 @@ based on the cipher context. The EVP_CIPHER can provide its own random key generation routine to support keys of a specific form. B must point to a buffer at least as big as the value returned by EVP_CIPHER_CTX_key_length(). -EVP_CIPHER_do_all_ex() traverses all ciphers implemented by all activated +EVP_CIPHER_do_all_provided() traverses all ciphers implemented by all activated providers in the given library context I, and for each of the implementations, calls the given function I with the implementation method and the given I as argument. diff --git a/doc/man3/EVP_KDF.pod b/doc/man3/EVP_KDF.pod index f3d80a1757..306961f3f1 100644 --- a/doc/man3/EVP_KDF.pod +++ b/doc/man3/EVP_KDF.pod @@ -2,11 +2,11 @@ =head1 NAME -EVP_KDF, EVP_KDF_fetch, EVP_KDF_free, EVP_KDF_provider, EVP_KDF_up_ref, -EVP_KDF_name, -EVP_KDF_CTX, EVP_KDF_CTX_new, EVP_KDF_CTX_free, EVP_KDF_CTX_kdf, -EVP_KDF_reset, EVP_KDF_size, EVP_KDF_derive, EVP_KDF_CTX_dup, -EVP_KDF_CTX_get_params, EVP_KDF_CTX_set_params, EVP_KDF_do_all_ex, +EVP_KDF, EVP_KDF_fetch, EVP_KDF_free, EVP_KDF_up_ref, +EVP_KDF_CTX, EVP_KDF_CTX_new, EVP_KDF_CTX_free, EVP_KDF_CTX_dup, +EVP_KDF_reset, EVP_KDF_derive, +EVP_KDF_size, EVP_KDF_provider, EVP_KDF_CTX_kdf, EVP_KDF_is_a, +EVP_KDF_CTX_get_params, EVP_KDF_CTX_set_params, EVP_KDF_do_all_provided, EVP_KDF_get_params, EVP_KDF_gettable_ctx_params, EVP_KDF_settable_ctx_params, EVP_KDF_gettable_params - EVP KDF routines @@ -29,9 +29,11 @@ EVP_KDF_gettable_params - EVP KDF routines void EVP_KDF_free(EVP_KDF *kdf); EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm, const char *properties); - void EVP_KDF_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_KDF *kdf, void *arg), - void *arg); + int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name); + const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf); + void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KDF *kdf, void *arg), + void *arg); int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]); int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]); int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]); @@ -130,10 +132,13 @@ calculate a fixed output size have not yet been supplied. EVP_KDF_name() returns the name of the given KDF implementation. +EVP_KDF_is_a() returns 1 if I is an implementation of an +algorithm that's identifiable with I, otherwise 0. + EVP_KDF_provider() returns the provider that holds the implementation of the given I. -EVP_KDF_do_all_ex() traverses all KDF implemented by all activated +EVP_KDF_do_all_provided() traverses all KDF implemented by all activated providers in the given library context I, and for each of the implementations, calls the given function I with the implementation method and the given I as argument. diff --git a/doc/man3/EVP_KEYEXCH_free.pod b/doc/man3/EVP_KEYEXCH_free.pod index 6571f9c111..5e81d249e2 100644 --- a/doc/man3/EVP_KEYEXCH_free.pod +++ b/doc/man3/EVP_KEYEXCH_free.pod @@ -2,7 +2,8 @@ =head1 NAME -EVP_KEYEXCH_fetch, EVP_KEYEXCH_free, EVP_KEYEXCH_up_ref, EVP_KEYEXCH_provider +EVP_KEYEXCH_fetch, EVP_KEYEXCH_free, EVP_KEYEXCH_up_ref, EVP_KEYEXCH_provider, +EVP_KEYEXCH_is_a, EVP_KEYEXCH_do_all_provided, - Functions to manage EVP_KEYEXCH algorithm objects =head1 SYNOPSIS @@ -14,6 +15,10 @@ EVP_KEYEXCH_fetch, EVP_KEYEXCH_free, EVP_KEYEXCH_up_ref, EVP_KEYEXCH_provider void EVP_KEYEXCH_free(EVP_KEYEXCH *exchange); int EVP_KEYEXCH_up_ref(EVP_KEYEXCH *exchange); OSSL_PROVIDER *EVP_KEYEXCH_provider(const EVP_KEYEXCH *exchange); + int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *exchange, const char *name); + void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYEXCH *exchange, void *arg), + void *arg); =head1 DESCRIPTION @@ -34,6 +39,14 @@ structure. EVP_KEYEXCH_provider() returns the provider that I was fetched from. +EVP_KEYEXCH_is_a() checks if I is an implementation of an +algorithm that's identifiable with I. + +EVP_KEYEXCH_do_all_provided() traverses all key exchange implementations by +all activated providers in the library context I, and for each +of the implementations, calls I with the implementation method and +I as arguments. + =head1 RETURN VALUES EVP_KEYEXCH_fetch() returns a pointer to a B for success @@ -41,6 +54,9 @@ or NULL for failure. EVP_KEYEXCH_up_ref() returns 1 for success or 0 otherwise. +EVP_KEYEXCH_is_a() returns 1 of I was identifiable, +otherwise 0. + =head1 SEE ALSO L, L diff --git a/doc/man3/EVP_KEYMGMT.pod b/doc/man3/EVP_KEYMGMT.pod index ab209da768..3b5a1c5763 100644 --- a/doc/man3/EVP_KEYMGMT.pod +++ b/doc/man3/EVP_KEYMGMT.pod @@ -6,7 +6,9 @@ EVP_KEYMGMT, EVP_KEYMGMT_fetch, EVP_KEYMGMT_up_ref, EVP_KEYMGMT_free, -EVP_KEYMGMT_provider +EVP_KEYMGMT_provider, +EVP_KEYMGMT_is_a, +EVP_KEYMGMT_do_all_provided, - EVP key management routines =head1 SYNOPSIS @@ -20,6 +22,10 @@ EVP_KEYMGMT_provider int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt); void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt); const OSSL_PROVIDER *EVP_KEYMGMT_provider(const EVP_KEYMGMT *keymgmt); + int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name); + void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), + void *arg); =head1 DESCRIPTION @@ -45,6 +51,14 @@ B I, and when the count reaches zero, frees it. EVP_KEYMGMT_provider() returns the provider that has this particular implementation. +EVP_KEYMGMT_is_a() checks if I is an implementation of an +algorithm that's identifiable with I. + +EVP_KEYMGMT_do_all_provided() traverses all key keymgmt implementations by +all activated providers in the library context I, and for each +of the implementations, calls I with the implementation method and +I as arguments. + =head1 NOTES EVP_KEYMGMT_fetch() may be called implicitly by other fetching @@ -64,6 +78,9 @@ EVP_KEYMGMT_free() doesn't return any value. EVP_KEYMGMT_provider() returns a pointer to a provider object, or NULL on error. +EVP_KEYMGMT_is_a() returns 1 of I was identifiable, +otherwise 0. + =head1 SEE ALSO L, L diff --git a/doc/man3/EVP_MAC.pod b/doc/man3/EVP_MAC.pod index 256605b508..ab2e1e7334 100644 --- a/doc/man3/EVP_MAC.pod +++ b/doc/man3/EVP_MAC.pod @@ -9,7 +9,7 @@ EVP_MAC_CTX, EVP_MAC_CTX_new, EVP_MAC_CTX_free, EVP_MAC_CTX_dup, EVP_MAC_CTX_mac, EVP_MAC_CTX_get_params, EVP_MAC_CTX_set_params, EVP_MAC_size, EVP_MAC_init, EVP_MAC_update, EVP_MAC_final, EVP_MAC_gettable_ctx_params, EVP_MAC_settable_ctx_params, -EVP_MAC_do_all_ex - EVP MAC routines +EVP_MAC_do_all_provided - EVP MAC routines =head1 SYNOPSIS @@ -44,9 +44,9 @@ EVP_MAC_do_all_ex - EVP MAC routines const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac); - void EVP_MAC_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MAC *mac, void *arg), - void *arg); + void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MAC *mac, void *arg), + void *arg); =head1 DESCRIPTION @@ -165,7 +165,7 @@ algorithm that's identifiable with I. EVP_MAC_provider() returns the provider that holds the implementation of the given I. -EVP_MAC_do_all_ex() traverses all MAC implemented by all activated +EVP_MAC_do_all_provided() traverses all MAC implemented by all activated providers in the given library context I, and for each of the implementations, calls the given function I with the implementation method and the given I as argument. @@ -278,7 +278,7 @@ EVP_MAC_size() returns the expected output size, or 0 if it isn't set. If it isn't set, a call to EVP_MAC_init() should get it set. -EVP_MAC_do_all_ex() returns nothing at all. +EVP_MAC_do_all_provided() returns nothing at all. =head1 EXAMPLES diff --git a/doc/man3/EVP_SIGNATURE_free.pod b/doc/man3/EVP_SIGNATURE_free.pod index 3e39b915e7..3fb741622d 100644 --- a/doc/man3/EVP_SIGNATURE_free.pod +++ b/doc/man3/EVP_SIGNATURE_free.pod @@ -3,7 +3,7 @@ =head1 NAME EVP_SIGNATURE_fetch, EVP_SIGNATURE_free, EVP_SIGNATURE_up_ref, -EVP_SIGNATURE_provider +EVP_SIGNATURE_is_a, EVP_SIGNATURE_provider, EVP_SIGNATURE_do_all_provided - Functions to manage EVP_SIGNATURE algorithm objects =head1 SYNOPSIS @@ -14,7 +14,12 @@ EVP_SIGNATURE_provider const char *properties); void EVP_SIGNATURE_free(EVP_SIGNATURE *signature); int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature); + int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name); OSSL_PROVIDER *EVP_SIGNATURE_provider(const EVP_SIGNATURE *signature); + void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_SIGNATURE *signature, + void *arg), + void *arg); =head1 DESCRIPTION @@ -35,8 +40,16 @@ structure is freed. EVP_SIGNATURE_up_ref() increments the reference count for an B structure. +EVP_SIGNATURE_is_a() returns 1 if I is an implementation of an +algorithm that's identifiable with I, otherwise 0. + EVP_SIGNATURE_provider() returns the provider that I was fetched from. +EVP_SIGNATURE_do_all_provided() traverses all SIGNATURE implemented by all +activated roviders in the given library context I, and for each of the +implementations, calls the given function I with the implementation method +and the given I as argument. + =head1 RETURN VALUES EVP_SIGNATURE_fetch() returns a pointer to an B for success diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 9223df2f78..8e452443ff 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -462,6 +462,7 @@ typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass, int EVP_MD_type(const EVP_MD *md); # define EVP_MD_nid(e) EVP_MD_type(e) const char *EVP_MD_name(const EVP_MD *md); +int EVP_MD_is_a(const EVP_MD *md, const char *name); const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md); int EVP_MD_pkey_type(const EVP_MD *md); int EVP_MD_size(const EVP_MD *md); @@ -1031,9 +1032,9 @@ void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph, void EVP_CIPHER_do_all_sorted(void (*fn) (const EVP_CIPHER *ciph, const char *from, const char *to, void *x), void *arg); -void EVP_CIPHER_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_CIPHER *cipher, void *arg), - void *arg); +void EVP_CIPHER_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_CIPHER *cipher, void *arg), + void *arg); void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph, const char *from, const char *to, void *x), @@ -1041,9 +1042,9 @@ void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph, void EVP_MD_do_all_sorted(void (*fn) (const EVP_MD *ciph, const char *from, const char *to, void *x), void *arg); -void EVP_MD_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MD *md, void *arg), - void *arg); +void EVP_MD_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MD *md, void *arg), + void *arg); /* MAC stuff */ @@ -1072,9 +1073,9 @@ const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac); -void EVP_MAC_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_MAC *mac, void *arg), - void *arg); +void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_MAC *mac, void *arg), + void *arg); /* PKEY stuff */ int EVP_PKEY_decrypt_old(unsigned char *dec_key, @@ -1438,6 +1439,10 @@ EVP_KEYMGMT *EVP_KEYMGMT_fetch(OPENSSL_CTX *ctx, const char *algorithm, int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt); void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt); const OSSL_PROVIDER *EVP_KEYMGMT_provider(const EVP_KEYMGMT *keymgmt); +int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name); +void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), + void *arg); EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); @@ -1495,6 +1500,11 @@ int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature); OSSL_PROVIDER *EVP_SIGNATURE_provider(const EVP_SIGNATURE *signature); EVP_SIGNATURE *EVP_SIGNATURE_fetch(OPENSSL_CTX *ctx, const char *algorithm, const char *properties); +int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name); +void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_SIGNATURE *signature, + void *data), + void *data); int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *signature); int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); @@ -1755,6 +1765,10 @@ int EVP_KEYEXCH_up_ref(EVP_KEYEXCH *exchange); EVP_KEYEXCH *EVP_KEYEXCH_fetch(OPENSSL_CTX *ctx, const char *algorithm, const char *properties); OSSL_PROVIDER *EVP_KEYEXCH_provider(const EVP_KEYEXCH *exchange); +int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name); +void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KEYEXCH *keyexch, void *data), + void *data); void EVP_add_alg_module(void); diff --git a/include/openssl/kdf.h b/include/openssl/kdf.h index 2193eaeec0..4a53b4c30e 100644 --- a/include/openssl/kdf.h +++ b/include/openssl/kdf.h @@ -34,6 +34,7 @@ EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf); void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx); EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src); const char *EVP_KDF_name(const EVP_KDF *kdf); +int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name); const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf); const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx); @@ -47,9 +48,9 @@ const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf); const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf); const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf); -void EVP_KDF_do_all_ex(OPENSSL_CTX *libctx, - void (*fn)(EVP_KDF *kdf, void *arg), - void *arg); +void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx, + void (*fn)(EVP_KDF *kdf, void *arg), + void *arg); # define EVP_KDF_CTRL_SET_PASS 0x01 /* unsigned char *, size_t */ # define EVP_KDF_CTRL_SET_SALT 0x02 /* unsigned char *, size_t */ diff --git a/util/libcrypto.num b/util/libcrypto.num index 032936ed40..7b04958baa 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4683,8 +4683,8 @@ EVP_CIPHER_name 4799 3_0_0 EXIST::FUNCTION: EVP_MD_provider 4800 3_0_0 EXIST::FUNCTION: EVP_CIPHER_provider 4801 3_0_0 EXIST::FUNCTION: OSSL_PROVIDER_name 4802 3_0_0 EXIST::FUNCTION: -EVP_CIPHER_do_all_ex 4803 3_0_0 EXIST::FUNCTION: -EVP_MD_do_all_ex 4804 3_0_0 EXIST::FUNCTION: +EVP_CIPHER_do_all_provided 4803 3_0_0 EXIST::FUNCTION: +EVP_MD_do_all_provided 4804 3_0_0 EXIST::FUNCTION: EVP_KEYEXCH_provider 4805 3_0_0 EXIST::FUNCTION: OSSL_PROVIDER_available 4806 3_0_0 EXIST::FUNCTION: ERR_new 4807 3_0_0 EXIST::FUNCTION: @@ -4722,7 +4722,7 @@ EVP_MAC_name 4838 3_0_0 EXIST::FUNCTION: EVP_MAC_get_params 4839 3_0_0 EXIST::FUNCTION: EVP_MAC_gettable_params 4840 3_0_0 EXIST::FUNCTION: EVP_MAC_provider 4841 3_0_0 EXIST::FUNCTION: -EVP_MAC_do_all_ex 4842 3_0_0 EXIST::FUNCTION: +EVP_MAC_do_all_provided 4842 3_0_0 EXIST::FUNCTION: EVP_MD_free 4843 3_0_0 EXIST::FUNCTION: EVP_CIPHER_free 4844 3_0_0 EXIST::FUNCTION: EVP_KDF_up_ref 4845 3_0_0 EXIST::FUNCTION: @@ -4737,7 +4737,7 @@ EVP_KDF_CTX_set_params 4853 3_0_0 EXIST::FUNCTION: EVP_KDF_gettable_params 4854 3_0_0 EXIST::FUNCTION: EVP_KDF_gettable_ctx_params 4855 3_0_0 EXIST::FUNCTION: EVP_KDF_settable_ctx_params 4856 3_0_0 EXIST::FUNCTION: -EVP_KDF_do_all_ex 4857 3_0_0 EXIST::FUNCTION: +EVP_KDF_do_all_provided 4857 3_0_0 EXIST::FUNCTION: EVP_SIGNATURE_free 4858 3_0_0 EXIST::FUNCTION: EVP_SIGNATURE_up_ref 4859 3_0_0 EXIST::FUNCTION: EVP_SIGNATURE_provider 4860 3_0_0 EXIST::FUNCTION: @@ -4828,3 +4828,11 @@ EVP_DigestVerifyInit_ex 4944 3_0_0 EXIST::FUNCTION: EVP_DigestVerifyUpdate 4945 3_0_0 EXIST::FUNCTION: BN_check_prime 4946 3_0_0 EXIST::FUNCTION: EVP_PKEY_CTX_new_provided 4947 3_0_0 EXIST::FUNCTION: +EVP_KEYMGMT_is_a 4948 3_0_0 EXIST::FUNCTION: +EVP_KEYMGMT_do_all_provided 4949 3_0_0 EXIST::FUNCTION: +EVP_KEYEXCH_is_a 4950 3_0_0 EXIST::FUNCTION: +EVP_KEYEXCH_do_all_provided 4951 3_0_0 EXIST::FUNCTION: +EVP_KDF_is_a 4952 3_0_0 EXIST::FUNCTION: +EVP_MD_is_a 4953 3_0_0 EXIST::FUNCTION: +EVP_SIGNATURE_is_a 4954 3_0_0 EXIST::FUNCTION: +EVP_SIGNATURE_do_all_provided 4955 3_0_0 EXIST::FUNCTION: -- 2.25.1