From: Richard Levitte Date: Wed, 10 Jul 2019 20:59:07 +0000 (+0200) Subject: Add EVP_MD_provider() and EVP_CIPHER_provider() X-Git-Tag: openssl-3.0.0-alpha1~1736 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1d2622d4f357a7994cf6fdc3fdba27317a6a6597;p=oweals%2Fopenssl.git Add EVP_MD_provider() and EVP_CIPHER_provider() Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/9356) --- diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 36a6aee690..0825c102b5 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -426,6 +426,11 @@ const char *EVP_CIPHER_name(const EVP_CIPHER *cipher) #endif } +const OSSL_PROVIDER *EVP_CIPHER_provider(const EVP_CIPHER *cipher) +{ + return cipher->prov; +} + int EVP_CIPHER_mode(const EVP_CIPHER *cipher) { int ok, v = EVP_CIPHER_flags(cipher) & EVP_CIPH_MODE; @@ -448,6 +453,11 @@ const char *EVP_MD_name(const EVP_MD *md) #endif } +const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md) +{ + return md->prov; +} + int EVP_MD_block_size(const EVP_MD *md) { if (md == NULL) { diff --git a/doc/man3/EVP_DigestInit.pod b/doc/man3/EVP_DigestInit.pod index 6c125d2a32..a44266208c 100644 --- a/doc/man3/EVP_DigestInit.pod +++ b/doc/man3/EVP_DigestInit.pod @@ -8,7 +8,7 @@ EVP_MD_CTX_copy_ex, EVP_MD_CTX_ctrl, EVP_MD_CTX_set_params, EVP_MD_CTX_get_param 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_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, @@ -48,6 +48,7 @@ EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx - EVP digest routines int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in); const char *EVP_MD_name(const EVP_MD *md); + 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); int EVP_MD_size(const EVP_MD *md); @@ -193,6 +194,11 @@ EVP_MD_CTX_name() Return the name of the given message digest. +=item EVP_MD_provider() + +Returns an B pointer to the provider that implements the given +B. + =item EVP_MD_size(), EVP_MD_CTX_size() diff --git a/doc/man3/EVP_EncryptInit.pod b/doc/man3/EVP_EncryptInit.pod index 1bf25ac985..b1d18450d2 100644 --- a/doc/man3/EVP_EncryptInit.pod +++ b/doc/man3/EVP_EncryptInit.pod @@ -27,6 +27,7 @@ EVP_get_cipherbyname, EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_name, +EVP_CIPHER_provider, EVP_CIPHER_nid, EVP_CIPHER_block_size, EVP_CIPHER_key_length, @@ -104,6 +105,7 @@ EVP_enc_null int EVP_CIPHER_nid(const EVP_CIPHER *e); 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); int EVP_CIPHER_key_length(const EVP_CIPHER *e); int EVP_CIPHER_iv_length(const EVP_CIPHER *e); @@ -262,6 +264,9 @@ B. EVP_CIPHER_name() and EVP_CIPHER_CTX_name() return the name of the passed cipher or context. +EVP_CIPHER_provider() returns an B pointer to the provider +that implements the given B. + EVP_CIPHER_CTX_cipher() returns the B structure when passed an B structure. diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 74dcb1af9d..dac1f3ac09 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -450,6 +450,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); +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); int EVP_MD_block_size(const EVP_MD *md); @@ -471,6 +472,7 @@ 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); +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); int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); diff --git a/util/libcrypto.num b/util/libcrypto.num index e9e5cfdca1..1a8d91b2d6 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4693,3 +4693,5 @@ X509_PUBKEY_dup 4798 3_0_0 EXIST::FUNCTION: ERR_put_func_error 4799 3_0_0 EXIST::FUNCTION: EVP_MD_name 4800 3_0_0 EXIST::FUNCTION: 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: