diff options
author | Richard Levitte <levitte@openssl.org> | 2021-03-16 14:23:54 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-04-02 08:57:47 +0200 |
commit | 03888233290bf3b8410e8dc2acbef8950fffef60 (patch) | |
tree | cffa3d7c31504acbc2b80d7fe7d826381acc76fe /crypto/evp | |
parent | b638dad970c65e311e9a724b89972441268adc9f (diff) |
EVP: Add EVP_<TYPE>_description()
The following operation types are covered:
EVP_MD, EVP_CIPHER, EVP_MAC, EVP_RAND, EVP_KEYMGMT, EVP_SIGNATURE,
EVP_ASYM_CIPHER, EVP_KEM, EVP_KEYEXCH, EVP_KDF. Also EVP_PKEY.
For EVP_MD and EVP_CIPHER, OBJ_nid2ln() is used as a fallback for
legacy implementations.
For EVP_PKEY, the info field of the EVP_PKEY_ASN1_METHOD is used as a
fallback for legacy implementations.
Fixes #14514
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14656)
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/asymcipher.c | 5 | ||||
-rw-r--r-- | crypto/evp/evp_lib.c | 22 | ||||
-rw-r--r-- | crypto/evp/evp_rand.c | 5 | ||||
-rw-r--r-- | crypto/evp/exchange.c | 5 | ||||
-rw-r--r-- | crypto/evp/kdf_lib.c | 5 | ||||
-rw-r--r-- | crypto/evp/kem.c | 5 | ||||
-rw-r--r-- | crypto/evp/keymgmt_meth.c | 5 | ||||
-rw-r--r-- | crypto/evp/mac_lib.c | 5 | ||||
-rw-r--r-- | crypto/evp/p_lib.c | 14 | ||||
-rw-r--r-- | crypto/evp/signature.c | 5 |
10 files changed, 76 insertions, 0 deletions
diff --git a/crypto/evp/asymcipher.c b/crypto/evp/asymcipher.c index 60f3ce67cf..08c8fb0088 100644 --- a/crypto/evp/asymcipher.c +++ b/crypto/evp/asymcipher.c @@ -435,6 +435,11 @@ int EVP_ASYM_CIPHER_number(const EVP_ASYM_CIPHER *cipher) return cipher->name_id; } +const char *EVP_ASYM_CIPHER_description(const EVP_ASYM_CIPHER *cipher) +{ + return cipher->description; +} + void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_ASYM_CIPHER *cipher, void *arg), diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 31d2a7392b..a707285c91 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -645,6 +645,17 @@ const char *EVP_CIPHER_name(const EVP_CIPHER *cipher) #endif } +const char *EVP_CIPHER_description(const EVP_CIPHER *cipher) +{ + if (cipher->description != NULL) + return cipher->description; +#ifndef FIPS_MODULE + return OBJ_nid2ln(EVP_CIPHER_nid(cipher)); +#else + return NULL; +#endif +} + int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher, void (*fn)(const char *name, void *data), void *data) @@ -677,6 +688,17 @@ int EVP_MD_number(const EVP_MD *md) return md->name_id; } +const char *EVP_MD_description(const EVP_MD *md) +{ + if (md->description != NULL) + return md->description; +#ifndef FIPS_MODULE + return OBJ_nid2ln(EVP_MD_nid(md)); +#else + return NULL; +#endif +} + const char *EVP_MD_name(const EVP_MD *md) { if (md->prov != NULL) diff --git a/crypto/evp/evp_rand.c b/crypto/evp/evp_rand.c index 131550b4f3..cae21891ee 100644 --- a/crypto/evp/evp_rand.c +++ b/crypto/evp/evp_rand.c @@ -295,6 +295,11 @@ const char *EVP_RAND_name(const EVP_RAND *rand) return evp_first_name(rand->prov, rand->name_id); } +const char *EVP_RAND_description(const EVP_RAND *rand) +{ + return rand->description; +} + int EVP_RAND_is_a(const EVP_RAND *rand, const char *name) { return evp_is_a(rand->prov, rand->name_id, NULL, name); diff --git a/crypto/evp/exchange.c b/crypto/evp/exchange.c index fd8e9210a1..07d5e4ab9b 100644 --- a/crypto/evp/exchange.c +++ b/crypto/evp/exchange.c @@ -465,6 +465,11 @@ int EVP_KEYEXCH_number(const EVP_KEYEXCH *keyexch) return keyexch->name_id; } +const char *EVP_KEYEXCH_description(const EVP_KEYEXCH *keyexch) +{ + return keyexch->description; +} + int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name) { return evp_is_a(keyexch->prov, keyexch->name_id, NULL, name); diff --git a/crypto/evp/kdf_lib.c b/crypto/evp/kdf_lib.c index f5ff00d7e7..1a1074b21b 100644 --- a/crypto/evp/kdf_lib.c +++ b/crypto/evp/kdf_lib.c @@ -95,6 +95,11 @@ const char *EVP_KDF_name(const EVP_KDF *kdf) return NULL; } +const char *EVP_KDF_description(const EVP_KDF *kdf) +{ + return kdf->description; +} + int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name) { return evp_is_a(kdf->prov, kdf->name_id, NULL, name); diff --git a/crypto/evp/kem.c b/crypto/evp/kem.c index d57290643b..cd8924ef39 100644 --- a/crypto/evp/kem.c +++ b/crypto/evp/kem.c @@ -343,6 +343,11 @@ int EVP_KEM_number(const EVP_KEM *kem) return kem->name_id; } +const char *EVP_KEM_description(const EVP_KEM *kem) +{ + return kem->description; +} + void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KEM *kem, void *arg), void *arg) diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c index f7603f3fa2..cdd7c70ed9 100644 --- a/crypto/evp/keymgmt_meth.c +++ b/crypto/evp/keymgmt_meth.c @@ -251,6 +251,11 @@ int EVP_KEYMGMT_number(const EVP_KEYMGMT *keymgmt) return keymgmt->name_id; } +const char *EVP_KEYMGMT_description(const EVP_KEYMGMT *keymgmt) +{ + return keymgmt->description; +} + const char *EVP_KEYMGMT_get0_first_name(const EVP_KEYMGMT *keymgmt) { return evp_first_name(keymgmt->prov, keymgmt->name_id); diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index 746abf53c1..e7eea3294b 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -170,6 +170,11 @@ const char *EVP_MAC_name(const EVP_MAC *mac) return NULL; } +const char *EVP_MAC_description(const EVP_MAC *mac) +{ + return mac->description; +} + int EVP_MAC_is_a(const EVP_MAC *mac, const char *name) { return evp_is_a(mac->prov, mac->name_id, NULL, name); diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index d424106360..f1ffb80e90 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1723,6 +1723,20 @@ int EVP_PKEY_size(const EVP_PKEY *pkey) return size < 0 ? 0 : size; } +const char *EVP_PKEY_description(const EVP_PKEY *pkey) +{ + if (!evp_pkey_is_assigned(pkey)) + return NULL; + + if (evp_pkey_is_provided(pkey) && pkey->keymgmt->description != NULL) + return pkey->keymgmt->description; +#ifndef FIPS_MODULE + if (pkey->ameth != NULL) + return pkey->ameth->info; +#endif + return NULL; +} + void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx, EVP_KEYMGMT **keymgmt, const char *propquery) diff --git a/crypto/evp/signature.c b/crypto/evp/signature.c index 1a1235821e..7df984e1bf 100644 --- a/crypto/evp/signature.c +++ b/crypto/evp/signature.c @@ -319,6 +319,11 @@ int EVP_SIGNATURE_number(const EVP_SIGNATURE *signature) return signature->name_id; } +const char *EVP_SIGNATURE_description(const EVP_SIGNATURE *signature) +{ + return signature->description; +} + void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_SIGNATURE *signature, void *arg), |