EVP: add name traversal functions to all fetchable types
authorRichard Levitte <levitte@openssl.org>
Mon, 23 Sep 2019 08:56:13 +0000 (10:56 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 17 Oct 2019 07:16:45 +0000 (09:16 +0200)
The following new functions all do the same thing; they traverse
the set of names assigned to implementations of each algorithm type:

EVP_MD_names_do_all(), EVP_CIPHER_names_do_all(),
EVP_MAC_names_do_all(), EVP_KEYMGMT_names_do_all(),
EVP_KEYEXCH_names_do_all(), EVP_KDF_names_do_all(),
EVP_SIGNATURE_names_do_all()

We add a warning to the documentation of EVP_CIPHER_name() and
EVP_MD_name(), as they aren't suitable to use with multiple-name
implementation.

We also remove EVP_MAC_name() and evp_KDF_name(), as they serve no
useful purpose.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9979)

22 files changed:
crypto/evp/digest.c
crypto/evp/evp_enc.c
crypto/evp/evp_fetch.c
crypto/evp/evp_lib.c
crypto/evp/evp_local.h
crypto/evp/exchange.c
crypto/evp/kdf_lib.c
crypto/evp/keymgmt_meth.c
crypto/evp/mac_lib.c
crypto/evp/mac_meth.c
crypto/evp/pmeth_fn.c
doc/man3/EVP_DigestInit.pod
doc/man3/EVP_EncryptInit.pod
doc/man3/EVP_KDF.pod
doc/man3/EVP_KEYEXCH_free.pod
doc/man3/EVP_KEYMGMT.pod
doc/man3/EVP_MAC.pod
doc/man3/EVP_SIGNATURE_free.pod
include/openssl/evp.h
include/openssl/kdf.h
test/evp_test.c
util/libcrypto.num

index a8e8326237588ba182cbcc54c17e44c424edc151..11c334cc5e9a20fadb110bed867bca2faa4cd690 100644 (file)
@@ -760,7 +760,7 @@ static void *evp_md_from_dispatch(int name_id,
 #ifndef FIPS_MODE
     /* TODO(3.x) get rid of the need for legacy NIDs */
     md->type = NID_undef;
-    evp_doall_names(prov, name_id, set_legacy_nid, &md->type);
+    evp_names_do_all(prov, name_id, set_legacy_nid, &md->type);
     if (md->type == -1) {
         ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
         EVP_MD_free(md);
index 4406b7f0324e1920bb95d82207fa9eaad23a18f5..efcb7e509a497639f39a323b577533a0dad57394 100644 (file)
@@ -1365,7 +1365,7 @@ static void *evp_cipher_from_dispatch(const int name_id,
 #ifndef FIPS_MODE
     /* TODO(3.x) get rid of the need for legacy NIDs */
     cipher->nid = NID_undef;
-    evp_doall_names(prov, name_id, set_legacy_nid, &cipher->nid);
+    evp_names_do_all(prov, name_id, set_legacy_nid, &cipher->nid);
     if (cipher->nid == -1) {
         ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
         EVP_CIPHER_free(cipher);
index 2404dfca30a3a790672a1ced88f68ffbff62fe65..e2039df3ef7e4a9dcdaa44aba6f69cf312f5fe15 100644 (file)
@@ -468,9 +468,9 @@ int evp_is_a(OSSL_PROVIDER *prov, int number, const char *name)
     return ossl_namemap_name2num(namemap, name) == number;
 }
 
-void evp_doall_names(OSSL_PROVIDER *prov, int number,
-                     void (*fn)(const char *name, void *data),
-                     void *data)
+void evp_names_do_all(OSSL_PROVIDER *prov, int number,
+                      void (*fn)(const char *name, void *data),
+                      void *data)
 {
     OPENSSL_CTX *libctx = ossl_provider_library_context(prov);
     OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
index f87793d3ed1f972be6fd90a03448ddb06e153e49..f5e2505e0a5599d76bacb835857b1e723bcb7a73 100644 (file)
@@ -556,6 +556,14 @@ const char *EVP_CIPHER_name(const EVP_CIPHER *cipher)
 #endif
 }
 
+void EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher,
+                             void (*fn)(const char *name, void *data),
+                             void *data)
+{
+    if (cipher->prov != NULL)
+        evp_names_do_all(cipher->prov, cipher->name_id, fn, data);
+}
+
 const OSSL_PROVIDER *EVP_CIPHER_provider(const EVP_CIPHER *cipher)
 {
     return cipher->prov;
@@ -589,6 +597,14 @@ const char *EVP_MD_name(const EVP_MD *md)
 #endif
 }
 
+void EVP_MD_names_do_all(const EVP_MD *md,
+                         void (*fn)(const char *name, void *data),
+                         void *data)
+{
+    if (md->prov != NULL)
+        evp_names_do_all(md->prov, md->name_id, fn, data);
+}
+
 const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md)
 {
     return md->prov;
index b14d27c8bae88e2f79a9bc5f37c7ac2871b4af2b..9b208190fbe387a82e0467c7494eb85c4f225200 100644 (file)
@@ -261,6 +261,6 @@ void evp_pkey_ctx_free_old_ops(EVP_PKEY_CTX *ctx);
 /* OSSL_PROVIDER * is only used to get the library context */
 const char *evp_first_name(OSSL_PROVIDER *prov, int name_id);
 int evp_is_a(OSSL_PROVIDER *prov, int number, const char *name);
-void evp_doall_names(OSSL_PROVIDER *prov, int number,
-                     void (*fn)(const char *name, void *data),
-                     void *data);
+void evp_names_do_all(OSSL_PROVIDER *prov, int number,
+                      void (*fn)(const char *name, void *data),
+                      void *data);
index 437d6a5cd629b630bc14ee75ac9426076bafc846..e9d7c6d1fb5309f79bbdb9a555a478950b85484a 100644 (file)
@@ -405,3 +405,11 @@ void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx,
                        evp_keyexch_from_dispatch, &keymgmt_data,
                        (void (*)(void *))EVP_KEYEXCH_free);
 }
+
+void EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch,
+                              void (*fn)(const char *name, void *data),
+                              void *data)
+{
+    if (keyexch->prov != NULL)
+        evp_names_do_all(keyexch->prov, keyexch->name_id, fn, data);
+}
index b85f0e0eb813cf7fb136ab27657aee7af57b5570..90c43e984a0caba74492c0989e3b7e2d5cbb691d 100644 (file)
@@ -83,11 +83,6 @@ EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src)
     return dst;
 }
 
-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);
@@ -164,3 +159,11 @@ int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[])
         return ctx->meth->set_ctx_params(ctx->data, params);
     return 1;
 }
+
+void EVP_KDF_names_do_all(const EVP_KDF *kdf,
+                          void (*fn)(const char *name, void *data),
+                          void *data)
+{
+    if (kdf->prov != NULL)
+        evp_names_do_all(kdf->prov, kdf->name_id, fn, data);
+}
index 990f89915951fabdc865cdbbe557af82f5c14397..6a1c15ae24eea821e03413ffb54ef609246293ca 100644 (file)
@@ -214,3 +214,11 @@ void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx,
                        keymgmt_from_dispatch, NULL,
                        (void (*)(void *))EVP_KEYMGMT_free);
 }
+
+void EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt,
+                              void (*fn)(const char *name, void *data),
+                              void *data)
+{
+    if (keymgmt->prov != NULL)
+        evp_names_do_all(keymgmt->prov, keymgmt->name_id, fn, data);
+}
index b6df6a594b165d15d4a82fae667c2483e0a3e2d1..8581853802c25d1f74d133ff77ac886d6ae3d1f6 100644 (file)
@@ -162,3 +162,11 @@ int EVP_MAC_is_a(const EVP_MAC *mac, const char *name)
 {
     return evp_is_a(mac->prov, mac->name_id, name);
 }
+
+void EVP_MAC_names_do_all(const EVP_MAC *mac,
+                          void (*fn)(const char *name, void *data),
+                          void *data)
+{
+    if (mac->prov != NULL)
+        evp_names_do_all(mac->prov, mac->name_id, fn, data);
+}
index 86f5434654db7d9e6970129b70905e5553eb37e9..2c124aef6a6aaaaf2a5cd94d715b5c221d7089c6 100644 (file)
@@ -168,11 +168,6 @@ void EVP_MAC_free(EVP_MAC *mac)
     evp_mac_free(mac);
 }
 
-const char *EVP_MAC_name(const EVP_MAC *mac)
-{
-    return evp_first_name(mac->prov, mac->name_id);
-}
-
 const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac)
 {
     return mac->prov;
index 2b4bca5727821e9e12adbab14a849d06b14ca308..685b6886c0ca2b305a99c2d64b2b8a44f7ab238e 100644 (file)
@@ -332,6 +332,15 @@ void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx,
                        (void (*)(void *))EVP_SIGNATURE_free);
 }
 
+
+void EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
+                                void (*fn)(const char *name, void *data),
+                                void *data)
+{
+    if (signature->prov != NULL)
+        evp_names_do_all(signature->prov, signature->name_id, fn, data);
+}
+
 static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *signature,
                                    int operation)
 {
index 6a9100b5830c3c7c66b3d50e369f8f05d7aebfb0..c00a07671c1b27e9e665a36ed61d85a63cbeb5ff 100644 (file)
@@ -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_is_a, EVP_MD_name, EVP_MD_provider,
+EVP_MD_is_a, EVP_MD_name, EVP_MD_names_do_all, 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,
@@ -63,6 +63,9 @@ EVP_MD_do_all_provided
 
  const char *EVP_MD_name(const EVP_MD *md);
  int EVP_MD_is_a(const EVP_MD *md, const char *name);
+ void EVP_MD_names_do_all(const EVP_MD *md,
+                          void (*fn)(const char *name, void *data),
+                          void *data);
  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);
@@ -248,7 +251,13 @@ identifiable with I<name>, otherwise 0.
 EVP_MD_CTX_name()
 
 Return the name of the given message digest.  For fetched message
-digests with multiple names, only one of them is returned.
+digests with multiple names, only one of them is returned; it's
+recommended to use EVP_MD_names_do_all() instead.
+
+=item EVP_MD_names_do_all()
+
+Traverses all names for the I<md>, and calls I<fn> with each name and
+I<data>.  This is only useful with fetched B<EVP_MD>s.
 
 =item EVP_MD_provider()
 
index c5c2c5ab392e58c63c0c8c3ffefff706df2d9248..0b6d4eba440223c5396a85096d973499b2f99f88 100644 (file)
@@ -31,6 +31,7 @@ EVP_get_cipherbynid,
 EVP_get_cipherbyobj,
 EVP_CIPHER_is_a,
 EVP_CIPHER_name,
+EVP_CIPHER_names_do_all,
 EVP_CIPHER_provider,
 EVP_CIPHER_nid,
 EVP_CIPHER_get_params,
@@ -122,6 +123,9 @@ EVP_CIPHER_do_all_provided
 
  int EVP_CIPHER_nid(const EVP_CIPHER *e);
  int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name);
+ void EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher,
+                              void (*fn)(const char *name, void *data),
+                              void *data);
  const char *EVP_CIPHER_name(const EVP_CIPHER *cipher);
  const OSSL_PROVIDER *EVP_CIPHER_provider(const EVP_CIPHER *cipher);
  int EVP_CIPHER_block_size(const EVP_CIPHER *e);
@@ -335,7 +339,12 @@ algorithm that's identifiable with I<name>, otherwise 0.
 
 EVP_CIPHER_name() and EVP_CIPHER_CTX_name() return the name of the passed
 cipher or context.  For fetched ciphers with multiple names, only one
-of them is returned.
+of them is returned; it's recommended to use EVP_CIPHER_names_do_all()
+instead.
+
+EVP_CIPHER_names_do_all() traverses all names for the I<cipher>, and
+calls I<fn> with each name and I<data>.  This is only useful with
+fetched B<EVP_CIPHER>s.
 
 EVP_CIPHER_provider() returns an B<OSSL_PROVIDER> pointer to the provider
 that implements the given B<EVP_CIPHER>.
index 306961f3f155cfbc1220512dff00593d60ede808..61c7a562e56e76dd4f69127d4e933789545d38ad 100644 (file)
@@ -6,6 +6,7 @@ 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_names_do_all,
 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
@@ -24,7 +25,6 @@ EVP_KDF_gettable_params - EVP KDF routines
  void EVP_KDF_reset(EVP_KDF_CTX *ctx);
  size_t EVP_KDF_size(EVP_KDF_CTX *ctx);
  int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen);
- const char *EVP_KDF_name(const EVP_KDF *kdf);
  int EVP_KDF_up_ref(EVP_KDF *kdf);
  void EVP_KDF_free(EVP_KDF *kdf);
  EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm,
@@ -34,6 +34,9 @@ EVP_KDF_gettable_params - EVP KDF routines
  void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx,
                               void (*fn)(EVP_KDF *kdf, void *arg),
                               void *arg);
+ void EVP_KDF_names_do_all(const EVP_KDF *kdf,
+                           void (*fn)(const char *name, void *data),
+                           void *data);
  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,8 +133,6 @@ of output and B<SIZE_MAX> otherwise.  If an error occurs then 0 is returned.
 For some algorithms an error may result if input parameters necessary to
 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<kdf> is an implementation of an
 algorithm that's identifiable with I<name>, otherwise 0.
 
@@ -143,6 +144,9 @@ providers in the given library context I<libctx>, and for each of the
 implementations, calls the given function I<fn> with the implementation method
 and the given I<arg> as argument.
 
+EVP_KDF_names_do_all() traverses all names for I<kdf>, and calls
+I<fn> with each name and I<data>.
+
 =head1 PARAMETERS
 
 The standard parameter names are:
@@ -219,9 +223,6 @@ The memory size must never exceed what can be given with a B<size_t>.
 EVP_KDF_fetch() returns a pointer to a newly fetched B<EVP_KDF>, or
 NULL if allocation failed.
 
-EVP_KDF_name() returns the name for the given I<kdf>, if it has been
-added to the object database.
-
 EVP_KDF_provider() returns a pointer to the provider for the KDF, or
 NULL on error.
 
index 5e81d249e25dc4e9a24cd2720decb152711b4223..d9b36a495ae22d697ce8e3b0ce5cce44d2c3ba56 100644 (file)
@@ -3,7 +3,7 @@
 =head1 NAME
 
 EVP_KEYEXCH_fetch, EVP_KEYEXCH_free, EVP_KEYEXCH_up_ref, EVP_KEYEXCH_provider,
-EVP_KEYEXCH_is_a, EVP_KEYEXCH_do_all_provided,
+EVP_KEYEXCH_is_a, EVP_KEYEXCH_do_all_provided, EVP_KEYEXCH_names_do_all
 - Functions to manage EVP_KEYEXCH algorithm objects
 
 =head1 SYNOPSIS
@@ -19,6 +19,9 @@ EVP_KEYEXCH_is_a, EVP_KEYEXCH_do_all_provided,
  void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx,
                                   void (*fn)(EVP_KEYEXCH *exchange, void *arg),
                                   void *arg);
+ void EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *exchange,
+                               void (*fn)(const char *name, void *data),
+                               void *data);
 
 =head1 DESCRIPTION
 
@@ -42,6 +45,9 @@ EVP_KEYEXCH_provider() returns the provider that I<exchange> was fetched from.
 EVP_KEYEXCH_is_a() checks if I<exchange> is an implementation of an
 algorithm that's identifiable with I<name>.
 
+EVP_KEYEXCH_names_do_all() traverses all names for the I<exchange>, and
+calls I<fn> with each name and I<data>.
+
 EVP_KEYEXCH_do_all_provided() traverses all key exchange implementations by
 all activated providers in the library context I<libctx>, and for each
 of the implementations, calls I<fn> with the implementation method and
index 3b5a1c5763ecc570f2e3159635731c0328dff84e..2115d29e5e1e3c0d0dafeec270752f4c1ec1d770 100644 (file)
@@ -9,6 +9,7 @@ EVP_KEYMGMT_free,
 EVP_KEYMGMT_provider,
 EVP_KEYMGMT_is_a,
 EVP_KEYMGMT_do_all_provided,
+EVP_KEYMGMT_names_do_all
 - EVP key management routines
 
 =head1 SYNOPSIS
@@ -26,6 +27,9 @@ EVP_KEYMGMT_do_all_provided,
  void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx,
                                   void (*fn)(EVP_KEYMGMT *keymgmt, void *arg),
                                   void *arg);
+ void EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt,
+                               void (*fn)(const char *name, void *data),
+                               void *data);
 
 =head1 DESCRIPTION
 
@@ -54,6 +58,9 @@ implementation.
 EVP_KEYMGMT_is_a() checks if I<keymgmt> is an implementation of an
 algorithm that's identifiable with I<name>.
 
+EVP_KEYMGMT_names_do_all() traverses all names for the I<keymgmt>, and
+calls I<fn> with each name and I<data>.
+
 EVP_KEYMGMT_do_all_provided() traverses all key keymgmt implementations by
 all activated providers in the library context I<libctx>, and for each
 of the implementations, calls I<fn> with the implementation method and
index ab2e1e73342d6dbb08de8350291f95376e978e90..cd3755d8ef3a9b5cac65e55b888202b145a99d7b 100644 (file)
@@ -3,7 +3,7 @@
 =head1 NAME
 
 EVP_MAC, EVP_MAC_fetch, EVP_MAC_up_ref, EVP_MAC_free,
-EVP_MAC_is_a, EVP_MAC_name,
+EVP_MAC_is_a, EVP_MAC_names_do_all,
 EVP_MAC_provider, EVP_MAC_get_params, EVP_MAC_gettable_params,
 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,
@@ -23,7 +23,9 @@ EVP_MAC_do_all_provided - EVP MAC routines
  int EVP_MAC_up_ref(EVP_MAC *mac);
  void EVP_MAC_free(EVP_MAC *mac);
  int EVP_MAC_is_a(const EVP_MAC *mac, const char *name);
- const char *EVP_MAC_name(const EVP_MAC *mac);
+ void EVP_MAC_names_do_all(const EVP_MAC *mac,
+                           void (*fn)(const char *name, void *data),
+                           void *data);
  const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac);
  int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]);
 
@@ -157,8 +159,6 @@ See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
 
 EVP_MAC_size() returns the MAC output size for the given context.
 
-EVP_MAC_name() returns the name of the given MAC implementation.
-
 EVP_MAC_is_a() checks if the given I<mac> is an implementation of an
 algorithm that's identifiable with I<name>.
 
@@ -170,6 +170,9 @@ providers in the given library context I<libctx>, and for each of the
 implementations, calls the given function I<fn> with the implementation method
 and the given I<arg> as argument.
 
+EVP_MAC_names_do_all() traverses all names for I<mac>, and calls
+I<fn> with each name and I<data>.
+
 =head1 PARAMETERS
 
 Parameters are identified by name as strings, and have an expected
@@ -254,9 +257,6 @@ EVP_MAC_up_ref() returns 1 on success, 0 on error.
 
 EVP_MAC_free() returns nothing at all.
 
-EVP_MAC_name() returns the name of the MAC, or NULL if NULL was
-passed.
-
 EVP_MAC_is_a() returns 1 if the given method can be identified with
 the given name, otherwise 0.
 
index 3fb741622d1d62f5e0f1f6e57c84385bf94306aa..fa2106aeb8e6a75696468b14347f03dc0fed25d2 100644 (file)
@@ -3,7 +3,8 @@
 =head1 NAME
 
 EVP_SIGNATURE_fetch, EVP_SIGNATURE_free, EVP_SIGNATURE_up_ref,
-EVP_SIGNATURE_is_a, EVP_SIGNATURE_provider, EVP_SIGNATURE_do_all_provided
+EVP_SIGNATURE_is_a, EVP_SIGNATURE_provider, EVP_SIGNATURE_do_all_provided,
+EVP_SIGNATURE_names_do_all
 - Functions to manage EVP_SIGNATURE algorithm objects
 
 =head1 SYNOPSIS
@@ -20,6 +21,9 @@ EVP_SIGNATURE_is_a, EVP_SIGNATURE_provider, EVP_SIGNATURE_do_all_provided
                                     void (*fn)(EVP_SIGNATURE *signature,
                                                void *arg),
                                     void *arg);
+ void EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
+                                 void (*fn)(const char *name, void *data),
+                                 void *data);
 
 =head1 DESCRIPTION
 
@@ -50,6 +54,9 @@ activated roviders in the given library context I<libctx>, and for each of the
 implementations, calls the given function I<fn> with the implementation method
 and the given I<arg> as argument.
 
+EVP_SIGNATURE_names_do_all() traverses all names for I<signature>, and calls
+I<fn> with each name and I<data>.
+
 =head1 RETURN VALUES
 
 EVP_SIGNATURE_fetch() returns a pointer to an B<EVP_SIGNATURE> for success
index 8e452443ff2aa45750ff0f41ff710480e9424921..0ff5b6536fc0740e1963e179f1f5e3afa93e6219 100644 (file)
@@ -463,6 +463,9 @@ 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);
+void EVP_MD_names_do_all(const EVP_MD *md,
+                         void (*fn)(const char *name, void *data),
+                         void *data);
 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);
@@ -486,6 +489,9 @@ void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);
 int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
 const char *EVP_CIPHER_name(const EVP_CIPHER *cipher);
 int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name);
+void EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher,
+                             void (*fn)(const char *name, void *data),
+                             void *data);
 const OSSL_PROVIDER *EVP_CIPHER_provider(const EVP_CIPHER *cipher);
 int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
 int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);
@@ -1052,7 +1058,6 @@ EVP_MAC *EVP_MAC_fetch(OPENSSL_CTX *libctx, const char *algorithm,
                        const char *properties);
 int EVP_MAC_up_ref(EVP_MAC *mac);
 void EVP_MAC_free(EVP_MAC *mac);
-const char *EVP_MAC_name(const EVP_MAC *mac);
 int EVP_MAC_is_a(const EVP_MAC *mac, const char *name);
 const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac);
 int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]);
@@ -1076,6 +1081,9 @@ const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac);
 void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx,
                              void (*fn)(EVP_MAC *mac, void *arg),
                              void *arg);
+void EVP_MAC_names_do_all(const EVP_MAC *mac,
+                          void (*fn)(const char *name, void *data),
+                          void *data);
 
 /* PKEY stuff */
 int EVP_PKEY_decrypt_old(unsigned char *dec_key,
@@ -1443,6 +1451,9 @@ 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);
+void EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt,
+                              void (*fn)(const char *name, void *data),
+                              void *data);
 
 EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
 EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
@@ -1505,6 +1516,9 @@ void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx,
                                    void (*fn)(EVP_SIGNATURE *signature,
                                               void *data),
                                    void *data);
+void EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
+                                void (*fn)(const char *name, 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);
@@ -1769,6 +1783,9 @@ 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_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch,
+                              void (*fn)(const char *name, void *data),
+                              void *data);
 
 void EVP_add_alg_module(void);
 
index 4a53b4c30ed93dbf59dc1207b7fffc7c7bd2238b..1b9cada649290660eb2976eda3c96fafc1eb6335 100644 (file)
@@ -33,7 +33,6 @@ EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm,
 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);
@@ -51,6 +50,9 @@ const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
 void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx,
                              void (*fn)(EVP_KDF *kdf, void *arg),
                              void *arg);
+void EVP_KDF_names_do_all(const EVP_KDF *kdf,
+                          void (*fn)(const char *name, void *data),
+                          void *data);
 
 # define EVP_KDF_CTRL_SET_PASS               0x01 /* unsigned char *, size_t */
 # define EVP_KDF_CTRL_SET_SALT               0x02 /* unsigned char *, size_t */
index d6f852913c47cfff1ba360805906c9e348c3a365..b68ad3b9c46c26931d8e9f293dbb4a6379aca6c7 100644 (file)
@@ -938,6 +938,7 @@ static const EVP_TEST_METHOD cipher_test_method = {
 
 typedef struct mac_data_st {
     /* MAC type in one form or another */
+    char *mac_name;
     EVP_MAC *mac;                /* for mac_test_run_mac */
     int type;                    /* for mac_test_run_pkey */
     /* Algorithm string for this MAC */
@@ -1021,6 +1022,7 @@ static int mac_test_init(EVP_TEST *t, const char *alg)
 
     mdat = OPENSSL_zalloc(sizeof(*mdat));
     mdat->type = type;
+    mdat->mac_name = OPENSSL_strdup(alg);
     mdat->mac = mac;
     mdat->controls = sk_OPENSSL_STRING_new_null();
     t->data = mdat;
@@ -1038,6 +1040,7 @@ static void mac_test_cleanup(EVP_TEST *t)
     MAC_DATA *mdat = t->data;
 
     EVP_MAC_free(mdat->mac);
+    OPENSSL_free(mdat->mac_name);
     sk_OPENSSL_STRING_pop_free(mdat->controls, openssl_free);
     OPENSSL_free(mdat->alg);
     OPENSSL_free(mdat->key);
@@ -1198,10 +1201,10 @@ static int mac_test_run_mac(EVP_TEST *t)
         EVP_MAC_settable_ctx_params(expected->mac);
 
     if (expected->alg == NULL)
-        TEST_info("Trying the EVP_MAC %s test", EVP_MAC_name(expected->mac));
+        TEST_info("Trying the EVP_MAC %s test", expected->mac_name);
     else
         TEST_info("Trying the EVP_MAC %s test with %s",
-                  EVP_MAC_name(expected->mac), expected->alg);
+                  expected->mac_name, expected->alg);
 
 #ifdef OPENSSL_NO_DES
     if (expected->alg != NULL && strstr(expected->alg, "DES") != NULL) {
index 7b04958baaac658f6822c3093ee384e83e221556..1fd7de9b09aa6bcaddbae65ce52e832238a197a3 100644 (file)
@@ -4718,7 +4718,7 @@ EVP_MAC_CTX_get_params                  4834      3_0_0   EXIST::FUNCTION:
 EVP_MAC_gettable_ctx_params             4835   3_0_0   EXIST::FUNCTION:
 EVP_MAC_free                            4836   3_0_0   EXIST::FUNCTION:
 EVP_MAC_up_ref                          4837   3_0_0   EXIST::FUNCTION:
-EVP_MAC_name                            4838   3_0_0   EXIST::FUNCTION:
+EVP_MAC_name                            4838   3_0_0   NOEXIST::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:
@@ -4729,7 +4729,7 @@ EVP_KDF_up_ref                          4845      3_0_0   EXIST::FUNCTION:
 EVP_KDF_free                            4846   3_0_0   EXIST::FUNCTION:
 EVP_KDF_fetch                           4847   3_0_0   EXIST::FUNCTION:
 EVP_KDF_CTX_dup                         4848   3_0_0   EXIST::FUNCTION:
-EVP_KDF_name                            4849   3_0_0   EXIST::FUNCTION:
+EVP_KDF_name                            4849   3_0_0   NOEXIST::FUNCTION:
 EVP_KDF_provider                        4850   3_0_0   EXIST::FUNCTION:
 EVP_KDF_get_params                      4851   3_0_0   EXIST::FUNCTION:
 EVP_KDF_CTX_get_params                  4852   3_0_0   EXIST::FUNCTION:
@@ -4836,3 +4836,10 @@ 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:
+EVP_MD_names_do_all                     4956   3_0_0   EXIST::FUNCTION:
+EVP_CIPHER_names_do_all                 4957   3_0_0   EXIST::FUNCTION:
+EVP_MAC_names_do_all                    4958   3_0_0   EXIST::FUNCTION:
+EVP_KEYMGMT_names_do_all                4959   3_0_0   EXIST::FUNCTION:
+EVP_KEYEXCH_names_do_all                4960   3_0_0   EXIST::FUNCTION:
+EVP_KDF_names_do_all                    4961   3_0_0   EXIST::FUNCTION:
+EVP_SIGNATURE_names_do_all              4962   3_0_0   EXIST::FUNCTION: