]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add EVP_CIPHER_do_all_ex() and EVP_MD_do_all_ex()
authorRichard Levitte <levitte@openssl.org>
Sat, 13 Jul 2019 05:02:54 +0000 (07:02 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 23 Jul 2019 04:34:09 +0000 (06:34 +0200)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9356)

crypto/evp/digest.c
crypto/evp/evp_enc.c
doc/man3/EVP_DigestInit.pod
doc/man3/EVP_EncryptInit.pod
include/openssl/evp.h
util/libcrypto.num

index 27f9d128ee92afef43cf44472642c33369a02c9e..78e8756f2ac98f54797da56478b3aa1beac32a5a 100644 (file)
@@ -701,3 +701,12 @@ EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm,
 
     return md;
 }
+
+void EVP_MD_do_all_ex(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,
+                       evp_md_from_dispatch, evp_md_free);
+}
index bfdd581e0da7f33675969d32469b12d8acd93b8e..0873bae81a61c6333aac3b4cdc21ecee7c49b34a 100644 (file)
@@ -1263,3 +1263,12 @@ EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm,
 
     return cipher;
 }
+
+void EVP_CIPHER_do_all_ex(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,
+                       evp_cipher_from_dispatch, evp_cipher_free);
+}
index a44266208c9e1af22e06da6054c02b9ff09beec9..226bc467c4ba1050f6cbc809c9380fe506bea82b 100644 (file)
@@ -15,7 +15,9 @@ EVP_MD_CTX_md, EVP_MD_CTX_type, EVP_MD_CTX_size, EVP_MD_CTX_block_size,
 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 digest routines
+EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx,
+EVP_MD_do_all_ex
+- EVP digest routines
 
 =head1 SYNOPSIS
 
@@ -76,6 +78,10 @@ EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx - EVP digest routines
  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);
+
 =head1 DESCRIPTION
 
 The EVP digest routines are a high level interface to message digests,
@@ -281,6 +287,13 @@ by the caller. A NULL B<pctx> pointer is also allowed to clear the B<EVP_PKEY_CT
 assigned to B<ctx>. In such case, freeing the cleared B<EVP_PKEY_CTX> or not
 depends on how the B<EVP_PKEY_CTX> is created.
 
+=item EVP_MD_do_all_ex()
+
+Traverses all messages digests implemented by all activated 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.
+
 =back
 
 =head1 PARAMS
index b1d18450d2a0f2aedebb25838bb239b03c7d0d35..43ed7f90c2654c4628d57da2c77c7e79f412ed3b 100644 (file)
@@ -49,7 +49,8 @@ EVP_CIPHER_CTX_mode,
 EVP_CIPHER_param_to_asn1,
 EVP_CIPHER_asn1_to_param,
 EVP_CIPHER_CTX_set_padding,
-EVP_enc_null
+EVP_enc_null,
+EVP_CIPHER_do_all_ex
 - EVP cipher routines
 
 =head1 SYNOPSIS
@@ -127,6 +128,10 @@ EVP_enc_null
  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);
+
 =head1 DESCRIPTION
 
 The EVP cipher routines are a high level interface to certain
@@ -302,6 +307,11 @@ based on the cipher context. The EVP_CIPHER can provide its own random key
 generation routine to support keys of a specific form. B<Key> 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
+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.
+
 =head1 RETURN VALUES
 
 EVP_CIPHER_fetch() returns a pointer to a B<EVP_CIPHER> for success
index dac1f3ac09d90bc86642adee5efa05856e486d50..24ad23f3eaf1c6da31062e186da27bb3682aac38 100644 (file)
@@ -995,6 +995,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_MD_do_all(void (*fn) (const EVP_MD *ciph,
                                const char *from, const char *to, void *x),
@@ -1002,6 +1005,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);
 
 /* MAC stuff */
 
index 3caf9b859cb9b28957249aa7e00e84bc4bf63bd6..b0a7f81607fed9f6a6cdc73378ffdee01a5721dc 100644 (file)
@@ -4696,3 +4696,5 @@ EVP_CIPHER_name                         4801      3_0_0   EXIST::FUNCTION:
 EVP_MD_provider                         4802   3_0_0   EXIST::FUNCTION:
 EVP_CIPHER_provider                     4803   3_0_0   EXIST::FUNCTION:
 OSSL_PROVIDER_name                      4804   3_0_0   EXIST::FUNCTION:
+EVP_CIPHER_do_all_ex                    4805   3_0_0   EXIST::FUNCTION:
+EVP_MD_do_all_ex                        4806   3_0_0   EXIST::FUNCTION: