else
algorithm_do_this(provider, &cbdata);
}
+
+char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo)
+{
+ const char *first_name_end = NULL;
+ size_t first_name_len = 0;
+ char *ret;
+
+ if (algo->algorithm_names == NULL)
+ return NULL;
+
+ first_name_end = strchr(algo->algorithm_names, ':');
+ if (first_name_end == NULL)
+ first_name_len = strlen(algo->algorithm_names);
+ else
+ first_name_len = first_name_end - algo->algorithm_names;
+
+ ret = OPENSSL_strndup(algo->algorithm_names, first_name_len);
+ if (ret == NULL)
+ ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
+ return ret;
+}
#include <openssl/objects.h>
#include <openssl/evp.h>
#include "internal/cryptlib.h"
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
}
cipher->name_id = name_id;
+ if ((cipher->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
+ goto err;
cipher->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
CRYPTO_DOWN_REF(&cipher->refcnt, &i, cipher->lock);
if (i > 0)
return;
+ OPENSSL_free(cipher->type_name);
ossl_provider_free(cipher->prov);
CRYPTO_THREAD_lock_free(cipher->lock);
OPENSSL_free(cipher);
return cipher->name_id;
}
+const char *EVP_ASYM_CIPHER_name(const EVP_ASYM_CIPHER *cipher)
+{
+ return cipher->type_name;
+}
+
const char *EVP_ASYM_CIPHER_description(const EVP_ASYM_CIPHER *cipher)
{
return cipher->description;
#include <openssl/params.h>
#include <openssl/core_names.h>
#include "internal/cryptlib.h"
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
#endif
md->name_id = name_id;
+ if ((md->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
+ EVP_MD_free(md);
+ return NULL;
+ }
md->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
#include <stdio.h>
#include <limits.h>
#include <assert.h>
-#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/engine.h>
#include <openssl/params.h>
#include <openssl/core_names.h>
-#include "crypto/evp.h"
+#include "internal/cryptlib.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
#endif
cipher->name_id = name_id;
+ if ((cipher->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
+ EVP_CIPHER_free(cipher);
+ return NULL;
+ }
cipher->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
void evp_cipher_free_int(EVP_CIPHER *cipher)
{
+ OPENSSL_free(cipher->type_name);
ossl_provider_free(cipher->prov);
CRYPTO_THREAD_lock_free(cipher->lock);
OPENSSL_free(cipher);
&data);
}
-const char *evp_first_name(const OSSL_PROVIDER *prov, int name_id)
-{
- OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
- OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
-
- return ossl_namemap_num2name(namemap, name_id, 0);
-}
-
int evp_is_a(OSSL_PROVIDER *prov, int number,
const char *legacy_name, const char *name)
{
const char *EVP_CIPHER_name(const EVP_CIPHER *cipher)
{
- if (cipher->prov != NULL)
- return evp_first_name(cipher->prov, cipher->name_id);
+ if (cipher->type_name != NULL)
+ return cipher->type_name;
#ifndef FIPS_MODULE
return OBJ_nid2sn(EVP_CIPHER_nid(cipher));
#else
{
if (md == NULL)
return NULL;
- if (md->prov != NULL)
- return evp_first_name(md->prov, md->name_id);
+ if (md->type_name != NULL)
+ return md->type_name;
#ifndef FIPS_MODULE
return OBJ_nid2sn(EVP_MD_nid(md));
#else
void evp_md_free_int(EVP_MD *md)
{
+ OPENSSL_free(md->type_name);
ossl_provider_free(md->prov);
CRYPTO_THREAD_lock_free(md->lock);
OPENSSL_free(md);
int id; /* libcrypto internal */
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
struct evp_keyexch_st {
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
struct evp_signature_st {
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
struct evp_asym_cipher_st {
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
struct evp_kem_st {
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
void evp_md_free_int(EVP_MD *md);
/* OSSL_PROVIDER * is only used to get the library context */
-const char *evp_first_name(const OSSL_PROVIDER *prov, int name_id);
int evp_is_a(OSSL_PROVIDER *prov, int number,
const char *legacy_name, const char *name);
int evp_names_do_all(OSSL_PROVIDER *prov, int number,
const char *name = NULL;
if (key->keymgmt != NULL)
- return EVP_KEYMGMT_get0_first_name(key->keymgmt);
+ return EVP_KEYMGMT_name(key->keymgmt);
/* Otherwise fallback to legacy */
ameth = EVP_PKEY_get0_asn1(key);
#include <openssl/core.h>
#include <openssl/core_names.h>
#include <openssl/crypto.h>
-#include "crypto/asn1.h"
-#include "crypto/evp.h"
#include "internal/cryptlib.h"
#include "internal/numbers.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/asn1.h"
+#include "crypto/evp.h"
#include "evp_local.h"
struct evp_rand_st {
OSSL_PROVIDER *prov;
int name_id;
+ char *type_name;
const char *description;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *refcnt_lock;
CRYPTO_DOWN_REF(&rand->refcnt, &ref, rand->refcnt_lock);
if (ref > 0)
return;
+ OPENSSL_free(rand->type_name);
ossl_provider_free(rand->prov);
CRYPTO_THREAD_lock_free(rand->refcnt_lock);
OPENSSL_free(rand);
return NULL;
}
rand->name_id = name_id;
+ if ((rand->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
+ evp_rand_free(rand);
+ return NULL;
+ }
rand->description = algodef->algorithm_description;
rand->dispatch = fns;
for (; fns->function_id != 0; fns++) {
const char *EVP_RAND_name(const EVP_RAND *rand)
{
- return evp_first_name(rand->prov, rand->name_id);
+ return rand->type_name;
}
const char *EVP_RAND_description(const EVP_RAND *rand)
#include <openssl/evp.h>
#include <openssl/err.h>
#include "internal/refcount.h"
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
#include "internal/numbers.h" /* includes SIZE_MAX */
+#include "crypto/evp.h"
#include "evp_local.h"
static EVP_KEYEXCH *evp_keyexch_new(OSSL_PROVIDER *prov)
}
exchange->name_id = name_id;
+ if ((exchange->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
+ goto err;
exchange->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
CRYPTO_DOWN_REF(&exchange->refcnt, &i, exchange->lock);
if (i > 0)
return;
+ OPENSSL_free(exchange->type_name);
ossl_provider_free(exchange->prov);
CRYPTO_THREAD_lock_free(exchange->lock);
OPENSSL_free(exchange);
return keyexch->name_id;
}
+const char *EVP_KEYEXCH_name(const EVP_KEYEXCH *keyexch)
+{
+ return keyexch->type_name;
+}
+
const char *EVP_KEYEXCH_description(const EVP_KEYEXCH *keyexch)
{
return keyexch->description;
const char *EVP_KDF_name(const EVP_KDF *kdf)
{
- if (kdf->prov != NULL)
- return evp_first_name(kdf->prov, kdf->name_id);
- return NULL;
+ return kdf->type_name;
}
const char *EVP_KDF_description(const EVP_KDF *kdf)
#include <openssl/core.h>
#include <openssl/core_dispatch.h>
#include <openssl/kdf.h>
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
static int evp_kdf_up_ref(void *vkdf)
CRYPTO_DOWN_REF(&kdf->refcnt, &ref, kdf->lock);
if (ref > 0)
return;
+ OPENSSL_free(kdf->type_name);
ossl_provider_free(kdf->prov);
CRYPTO_THREAD_lock_free(kdf->lock);
OPENSSL_free(kdf);
return NULL;
}
kdf->name_id = name_id;
+ if ((kdf->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
+ evp_kdf_free(kdf);
+ return NULL;
+ }
kdf->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
#include <openssl/objects.h>
#include <openssl/evp.h>
#include "internal/cryptlib.h"
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
}
kem->name_id = name_id;
+ if ((kem->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
+ goto err;
kem->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
CRYPTO_DOWN_REF(&kem->refcnt, &i, kem->lock);
if (i > 0)
return;
+ OPENSSL_free(kem->type_name);
ossl_provider_free(kem->prov);
CRYPTO_THREAD_lock_free(kem->lock);
OPENSSL_free(kem);
return kem->name_id;
}
+const char *EVP_KEM_name(const EVP_KEM *kem)
+{
+ return kem->type_name;
+}
+
const char *EVP_KEM_description(const EVP_KEM *kem)
{
return kem->description;
*/
static int match_type(const EVP_KEYMGMT *keymgmt1, const EVP_KEYMGMT *keymgmt2)
{
- const OSSL_PROVIDER *prov2 = EVP_KEYMGMT_provider(keymgmt2);
- const char *name2 = evp_first_name(prov2, EVP_KEYMGMT_number(keymgmt2));
+ const char *name2 = EVP_KEYMGMT_name(keymgmt2);
return EVP_KEYMGMT_is_a(keymgmt1, name2);
}
#include <openssl/err.h>
#include "internal/provider.h"
#include "internal/refcount.h"
+#include "internal/core.h"
#include "crypto/evp.h"
#include "evp_local.h"
int setgenparamfncnt = 0;
int importfncnt = 0, exportfncnt = 0;
- if ((keymgmt = keymgmt_new()) == NULL) {
+ if ((keymgmt = keymgmt_new()) == NULL)
+ return NULL;
+
+ keymgmt->name_id = name_id;
+ if ((keymgmt->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
EVP_KEYMGMT_free(keymgmt);
return NULL;
}
- keymgmt->name_id = name_id;
keymgmt->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
CRYPTO_DOWN_REF(&keymgmt->refcnt, &ref, keymgmt->lock);
if (ref > 0)
return;
+ OPENSSL_free(keymgmt->type_name);
ossl_provider_free(keymgmt->prov);
CRYPTO_THREAD_lock_free(keymgmt->lock);
OPENSSL_free(keymgmt);
return keymgmt->description;
}
-const char *EVP_KEYMGMT_get0_first_name(const EVP_KEYMGMT *keymgmt)
+const char *EVP_KEYMGMT_name(const EVP_KEYMGMT *keymgmt)
{
- return evp_first_name(keymgmt->prov, keymgmt->name_id);
+ return keymgmt->type_name;
}
int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name)
const char *EVP_MAC_name(const EVP_MAC *mac)
{
- if (mac->prov != NULL)
- return evp_first_name(mac->prov, mac->name_id);
- return NULL;
+ return mac->type_name;
}
const char *EVP_MAC_description(const EVP_MAC *mac)
#include <openssl/err.h>
#include <openssl/core.h>
#include <openssl/core_dispatch.h>
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
static int evp_mac_up_ref(void *vmac)
CRYPTO_DOWN_REF(&mac->refcnt, &ref, mac->lock);
if (ref > 0)
return;
+ OPENSSL_free(mac->type_name);
ossl_provider_free(mac->prov);
CRYPTO_THREAD_lock_free(mac->lock);
OPENSSL_free(mac);
return NULL;
}
mac->name_id = name_id;
+ if ((mac->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) {
+ evp_mac_free(mac);
+ return NULL;
+ }
mac->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
const char *supported_sig =
pkey->keymgmt->query_operation_name != NULL
? pkey->keymgmt->query_operation_name(OSSL_OP_SIGNATURE)
- : evp_first_name(prov, pkey->keymgmt->name_id);
+ : EVP_KEYMGMT_name(pkey->keymgmt);
EVP_SIGNATURE *signature = NULL;
signature = EVP_SIGNATURE_fetch(libctx, supported_sig, NULL);
int type = src->type;
const char *keytype = NULL;
- keytype = evp_first_name(EVP_KEYMGMT_provider(keymgmt),
- keymgmt->name_id);
+ keytype = EVP_KEYMGMT_name(keymgmt);
/*
* If the type is EVP_PKEY_NONE, then we have a problem somewhere
/* If we have an engine, something went wrong somewhere... */
if (!ossl_assert(e == NULL))
return NULL;
- keytype = evp_first_name(pkey->keymgmt->prov, pkey->keymgmt->name_id);
+ keytype = EVP_KEYMGMT_name(pkey->keymgmt);
goto common;
}
#include <openssl/objects.h>
#include <openssl/evp.h>
#include "internal/cryptlib.h"
-#include "crypto/evp.h"
#include "internal/provider.h"
+#include "internal/core.h"
+#include "crypto/evp.h"
#include "evp_local.h"
static EVP_SIGNATURE *evp_signature_new(OSSL_PROVIDER *prov)
}
signature->name_id = name_id;
+ if ((signature->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
+ goto err;
signature->description = algodef->algorithm_description;
for (; fns->function_id != 0; fns++) {
CRYPTO_DOWN_REF(&signature->refcnt, &i, signature->lock);
if (i > 0)
return;
+ OPENSSL_free(signature->type_name);
ossl_provider_free(signature->prov);
CRYPTO_THREAD_lock_free(signature->lock);
OPENSSL_free(signature);
return signature->name_id;
}
+const char *EVP_SIGNATURE_name(const EVP_SIGNATURE *signature)
+{
+ return signature->type_name;
+}
+
const char *EVP_SIGNATURE_description(const EVP_SIGNATURE *signature)
{
return signature->description;
EVP_ASYM_CIPHER_fetch, EVP_ASYM_CIPHER_free, EVP_ASYM_CIPHER_up_ref,
EVP_ASYM_CIPHER_number, EVP_ASYM_CIPHER_is_a, EVP_ASYM_CIPHER_provider,
EVP_ASYM_CIPHER_do_all_provided, EVP_ASYM_CIPHER_names_do_all,
-EVP_ASYM_CIPHER_description,
+EVP_ASYM_CIPHER_name, EVP_ASYM_CIPHER_description,
EVP_ASYM_CIPHER_gettable_ctx_params, EVP_ASYM_CIPHER_settable_ctx_params
- Functions to manage EVP_ASYM_CIPHER algorithm objects
void EVP_ASYM_CIPHER_free(EVP_ASYM_CIPHER *cipher);
int EVP_ASYM_CIPHER_up_ref(EVP_ASYM_CIPHER *cipher);
int EVP_ASYM_CIPHER_number(const EVP_ASYM_CIPHER *cipher);
+ const char *EVP_ASYM_CIPHER_name(const EVP_ASYM_CIPHER *cipher);
int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name);
OSSL_PROVIDER *EVP_ASYM_CIPHER_provider(const EVP_ASYM_CIPHER *cipher);
void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
EVP_ASYM_CIPHER_number() returns the internal dynamic number assigned to
I<cipher>.
+EVP_ASYM_CIPHER_name() returns the algorithm name from the provided
+implementation for the given I<cipher>. Note that the I<cipher> may have
+multiple synonyms associated with it. In this case the first name from the
+algorithm definition is returned. Ownership of the returned string is retained
+by the I<cipher> object and should not be freed by the caller.
+
EVP_ASYM_CIPHER_names_do_all() traverses all names for I<cipher>, and calls
I<fn> with each name and I<data>.
=head1 NAME
EVP_KEM_fetch, EVP_KEM_free, EVP_KEM_up_ref,
-EVP_KEM_number, EVP_KEM_is_a, EVP_KEM_provider,
+EVP_KEM_number, EVP_KEM_name, EVP_KEM_is_a, EVP_KEM_provider,
EVP_KEM_do_all_provided, EVP_KEM_names_do_all, EVP_KEM_description,
EVP_KEM_gettable_ctx_params, EVP_KEM_settable_ctx_params
- Functions to manage EVP_KEM algorithm objects
void EVP_KEM_free(EVP_KEM *kem);
int EVP_KEM_up_ref(EVP_KEM *kem);
int EVP_KEM_number(const EVP_KEM *kem);
+ const char *EVP_KEM_name(const EVP_KEM *kem);
int EVP_KEM_is_a(const EVP_KEM *kem, const char *name);
OSSL_PROVIDER *EVP_KEM_provider(const EVP_KEM *kem);
void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
EVP_KEM_number() returns the internal dynamic number assigned to I<kem>.
+EVP_KEM_name() returns the algorithm name from the provided
+implementation for the given I<kem>. Note that the I<kem> may have
+multiple synonyms associated with it. In this case the first name from the
+algorithm definition is returned. Ownership of the returned string is retained
+by the I<kem> object and should not be freed by the caller.
+
EVP_KEM_names_do_all() traverses all names for I<kem>, and calls I<fn> with
each name and I<data>.
EVP_KEYEXCH_fetch, EVP_KEYEXCH_free, EVP_KEYEXCH_up_ref, EVP_KEYEXCH_provider,
EVP_KEYEXCH_is_a, EVP_KEYEXCH_do_all_provided,
EVP_KEYEXCH_number, EVP_KEYEXCH_names_do_all,
-EVP_KEYEXCH_description,
+EVP_KEYEXCH_name, EVP_KEYEXCH_description,
EVP_KEYEXCH_gettable_ctx_params, EVP_KEYEXCH_settable_ctx_params
- Functions to manage EVP_KEYEXCH algorithm objects
OSSL_PROVIDER *EVP_KEYEXCH_provider(const EVP_KEYEXCH *exchange);
int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *exchange, const char *name);
int EVP_KEYEXCH_number(const EVP_KEYEXCH *exchange);
+ const char *EVP_KEYEXCH_name(const EVP_KEYEXCH *exchange);
void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_KEYEXCH *exchange, void *arg),
void *arg);
EVP_KEYEXCH_number() returns the internal dynamic number assigned to
the I<exchange>.
+EVP_KEYEXCH_name() returns the algorithm name from the provided
+implementation for the given I<exchange>. Note that the I<exchange> may have
+multiple synonyms associated with it. In this case the first name from the
+algorithm definition is returned. Ownership of the returned string is retained
+by the I<exchange> object and should not be freed by the caller.
+
EVP_KEYEXCH_names_do_all() traverses all names for the I<exchange>, and
calls I<fn> with each name and I<data>.
EVP_KEYMGMT_is_a,
EVP_KEYMGMT_number,
EVP_KEYMGMT_description,
-EVP_KEYMGMT_get0_first_name,
+EVP_KEYMGMT_name,
EVP_KEYMGMT_do_all_provided,
EVP_KEYMGMT_names_do_all,
EVP_KEYMGMT_gettable_params,
const OSSL_PROVIDER *EVP_KEYMGMT_provider(const EVP_KEYMGMT *keymgmt);
int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name);
int EVP_KEYMGMT_number(const EVP_KEYMGMT *keymgmt);
- const char *EVP_KEYMGMT_get0_first_name(const EVP_KEYMGMT *keymgmt);
+ const char *EVP_KEYMGMT_name(const EVP_KEYMGMT *keymgmt);
const char *EVP_KEYMGMT_description(const EVP_KEYMGMT *keymgmt);
void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx,
EVP_KEYMGMT_number() returns the internal dynamic number assigned to
the I<keymgmt>.
-EVP_KEYMGMT_get0_first_name() returns the first algorithm name that is found for
-the given I<keymgmt>. Note that the I<keymgmt> may have multiple synonyms
-associated with it. In this case it is undefined which one will be returned.
-Ownership of the returned string is retained by the I<keymgmt> object and should
-not be freed by the caller.
+EVP_KEYMGMT_name() returns the algorithm name from the provided implementation
+for the given I<keymgmt>. Note that the I<keymgmt> may have multiple synonyms
+associated with it. In this case the first name from the algorithm
+definition is returned. Ownership of the returned string is retained by the
+I<keymgmt> object and should not be freed by the caller.
EVP_KEYMGMT_names_do_all() traverses all names for the I<keymgmt>, and
calls I<fn> with each name and I<data>.
EVP_KEYMGMT_number() returns an integer.
-EVP_KEYMGMT_get0_first_name() returns the name that is found or NULL on error.
+EVP_KEYMGMT_name() returns the algorithm name, or NULL on error.
EVP_KEYMGMT_description() returns a pointer to a decription, or NULL if
there isn't one.
EVP_SIGNATURE_fetch, EVP_SIGNATURE_free, EVP_SIGNATURE_up_ref,
EVP_SIGNATURE_number, EVP_SIGNATURE_is_a, EVP_SIGNATURE_provider,
EVP_SIGNATURE_do_all_provided, EVP_SIGNATURE_names_do_all,
-EVP_SIGNATURE_description,
+EVP_SIGNATURE_name, EVP_SIGNATURE_description,
EVP_SIGNATURE_gettable_ctx_params, EVP_SIGNATURE_settable_ctx_params
- Functions to manage EVP_SIGNATURE algorithm objects
void EVP_SIGNATURE_free(EVP_SIGNATURE *signature);
int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature);
int EVP_SIGNATURE_number(const EVP_SIGNATURE *signature);
+ const char *EVP_SIGNATURE_name(const 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(OSSL_LIB_CTX *libctx,
int EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
void (*fn)(const char *name, void *data),
void *data);
+ const char *EVP_SIGNATURE_name(const EVP_SIGNATURE *signature);
const char *EVP_SIGNATURE_description(const EVP_SIGNATURE *signature);
const OSSL_PARAM *EVP_SIGNATURE_gettable_ctx_params(const EVP_SIGNATURE *sig);
const OSSL_PARAM *EVP_SIGNATURE_settable_ctx_params(const EVP_SIGNATURE *sig);
EVP_SIGNATURE_number() returns the internal dynamic number assigned to
I<signature>.
+EVP_SIGNATURE_name() returns the algorithm name from the provided
+implementation for the given I<signature>. Note that the I<signature> may have
+multiple synonyms associated with it. In this case the first name from the
+algorithm definition is returned. Ownership of the returned string is retained
+by the I<signature> object and should not be freed by the caller.
+
EVP_SIGNATURE_names_do_all() traverses all names for I<signature>, and calls
I<fn> with each name and I<data>.
The algorithm names and property definitions are defined by the
providers.
+The OpenSSL libraries use the first of the algorithm names as the main
+or canonical name, on a per algorithm implementation basis.
+
=item B<OSSL_PARAM>
This type is a structure that allows passing arbitrary object data
struct evp_mac_st {
OSSL_PROVIDER *prov;
int name_id;
+ char *type_name;
const char *description;
CRYPTO_REF_COUNT refcnt;
struct evp_kdf_st {
OSSL_PROVIDER *prov;
int name_id;
+ char *type_name;
const char *description;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
/* New structure members */
/* Above comment to be removed when legacy has gone */
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
/* New structure members */
/* Above comment to be removed when legacy has gone */
int name_id;
+ char *type_name;
const char *description;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
int (*post)(OSSL_PROVIDER *, int operation_id,
int no_store, void *data, int *result),
void *data);
+char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo);
__owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx);
__owur int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx);
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);
-const char *EVP_KEYMGMT_get0_first_name(const EVP_KEYMGMT *keymgmt);
+const char *EVP_KEYMGMT_name(const EVP_KEYMGMT *keymgmt);
const char *EVP_KEYMGMT_description(const EVP_KEYMGMT *keymgmt);
int EVP_KEYMGMT_number(const EVP_KEYMGMT *keymgmt);
int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name);
const char *properties);
int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name);
int EVP_SIGNATURE_number(const EVP_SIGNATURE *signature);
+const char *EVP_SIGNATURE_name(const EVP_SIGNATURE *signature);
const char *EVP_SIGNATURE_description(const EVP_SIGNATURE *signature);
void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_SIGNATURE *signature,
const char *properties);
int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name);
int EVP_ASYM_CIPHER_number(const EVP_ASYM_CIPHER *cipher);
+const char *EVP_ASYM_CIPHER_name(const EVP_ASYM_CIPHER *cipher);
const char *EVP_ASYM_CIPHER_description(const EVP_ASYM_CIPHER *cipher);
void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_ASYM_CIPHER *cipher,
const char *properties);
int EVP_KEM_is_a(const EVP_KEM *wrap, const char *name);
int EVP_KEM_number(const EVP_KEM *wrap);
+const char *EVP_KEM_name(const EVP_KEM *wrap);
const char *EVP_KEM_description(const EVP_KEM *wrap);
void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_KEM *wrap, void *arg), void *arg);
OSSL_PROVIDER *EVP_KEYEXCH_provider(const EVP_KEYEXCH *exchange);
int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name);
int EVP_KEYEXCH_number(const EVP_KEYEXCH *keyexch);
+const char *EVP_KEYEXCH_name(const EVP_KEYEXCH *keyexch);
const char *EVP_KEYEXCH_description(const EVP_KEYEXCH *keyexch);
void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(EVP_KEYEXCH *keyexch, void *data),
* internal use.
*/
#include "internal/deprecated.h"
+#include <assert.h>
#include <openssl/evp.h>
#include <openssl/provider.h>
#include <openssl/dsa.h>
static OSSL_LIB_CTX *libctx = NULL;
static OSSL_PROVIDER *nullprov = NULL;
static OSSL_PROVIDER *libprov = NULL;
-static STACK_OF(OPENSSL_CSTRING) *cipher_names = NULL;
+static STACK_OF(OPENSSL_STRING) *cipher_names = NULL;
typedef enum OPTION_choice {
OPT_ERR = -1,
0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
};
- const char *name = sk_OPENSSL_CSTRING_value(cipher_names, test_id);
+ const char *name = sk_OPENSSL_STRING_value(cipher_names, test_id);
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
};
- const char *name = sk_OPENSSL_CSTRING_value(cipher_names, test_id);
+ const char *name = sk_OPENSSL_STRING_value(cipher_names, test_id);
if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
goto err;
static void collect_cipher_names(EVP_CIPHER *cipher, void *cipher_names_list)
{
- STACK_OF(OPENSSL_CSTRING) *names = cipher_names_list;
-
- sk_OPENSSL_CSTRING_push(names, EVP_CIPHER_name(cipher));
+ STACK_OF(OPENSSL_STRING) *names = cipher_names_list;
+ const char *name = EVP_CIPHER_name(cipher);
+ char *namedup = NULL;
+
+ assert(name != NULL);
+ /* the cipher will be freed after returning, strdup is needed */
+ if ((namedup = OPENSSL_strdup(name)) != NULL
+ && !sk_OPENSSL_STRING_push(names, namedup))
+ OPENSSL_free(namedup);
}
static int rsa_keygen(int bits, EVP_PKEY **pub, EVP_PKEY **priv)
ADD_TEST(dhx_cert_load);
#endif
- if (!TEST_ptr(cipher_names = sk_OPENSSL_CSTRING_new(name_cmp)))
+ if (!TEST_ptr(cipher_names = sk_OPENSSL_STRING_new(name_cmp)))
return 0;
EVP_CIPHER_do_all_provided(libctx, collect_cipher_names, cipher_names);
- ADD_ALL_TESTS(test_cipher_reinit, sk_OPENSSL_CSTRING_num(cipher_names));
+ ADD_ALL_TESTS(test_cipher_reinit, sk_OPENSSL_STRING_num(cipher_names));
ADD_ALL_TESTS(test_cipher_reinit_partialupdate,
- sk_OPENSSL_CSTRING_num(cipher_names));
+ sk_OPENSSL_STRING_num(cipher_names));
ADD_TEST(kem_rsa_gen_recover);
ADD_TEST(kem_rsa_params);
#ifndef OPENSSL_NO_DH
return 1;
}
+/* Because OPENSSL_free is a macro, it can't be passed as a function pointer */
+static void string_free(char *m)
+{
+ OPENSSL_free(m);
+}
+
void cleanup_tests(void)
{
- sk_OPENSSL_CSTRING_free(cipher_names);
+ sk_OPENSSL_STRING_pop_free(cipher_names, string_free);
OSSL_PROVIDER_unload(libprov);
OSSL_LIB_CTX_free(libctx);
OSSL_PROVIDER_unload(nullprov);
CMS_AuthEnvelopedData_create_ex ? 3_0_0 EXIST::FUNCTION:CMS
EVP_PKEY_CTX_set_ec_param_enc ? 3_0_0 EXIST::FUNCTION:
EVP_PKEY_get0_type_name ? 3_0_0 EXIST::FUNCTION:
-EVP_KEYMGMT_get0_first_name ? 3_0_0 EXIST::FUNCTION:
+EVP_KEYMGMT_name ? 3_0_0 EXIST::FUNCTION:
EC_KEY_decoded_from_explicit_params ? 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
EVP_KEM_free ? 3_0_0 EXIST::FUNCTION:
EVP_KEM_up_ref ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get0_cipher ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get1_cipher ? 3_0_0 EXIST::FUNCTION:
OSSL_LIB_CTX_get0_global_default ? 3_0_0 EXIST::FUNCTION:
+EVP_SIGNATURE_name ? 3_0_0 EXIST::FUNCTION:
+EVP_ASYM_CIPHER_name ? 3_0_0 EXIST::FUNCTION:
+EVP_KEM_name ? 3_0_0 EXIST::FUNCTION:
+EVP_KEYEXCH_name ? 3_0_0 EXIST::FUNCTION: