diff options
author | Richard Levitte <levitte@openssl.org> | 2019-09-14 16:22:19 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-09-19 14:58:17 +0200 |
commit | f7c16d48a945e80f22f6f02550ee3fe14edb52fa (patch) | |
tree | b6ec900293f5a14213aa1836c916ea4e11f7c260 /crypto/evp/mac_meth.c | |
parent | f8c0218f09e190a2efb28302f6c9737efe151d27 (diff) |
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
Diffstat (limited to 'crypto/evp/mac_meth.c')
-rw-r--r-- | crypto/evp/mac_meth.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/evp/mac_meth.c b/crypto/evp/mac_meth.c index a317127e15..3dc58c1f3b 100644 --- a/crypto/evp/mac_meth.c +++ b/crypto/evp/mac_meth.c @@ -27,7 +27,6 @@ static void evp_mac_free(void *vmac) if (ref > 0) return; ossl_provider_free(mac->prov); - OPENSSL_free(mac->name); CRYPTO_THREAD_lock_free(mac->lock); OPENSSL_free(mac); } @@ -47,18 +46,19 @@ static void *evp_mac_new(void) return mac; } -static void *evp_mac_from_dispatch(const char *name, const OSSL_DISPATCH *fns, - OSSL_PROVIDER *prov, void *unused) +static void *evp_mac_from_dispatch(int name_id, + const OSSL_DISPATCH *fns, + OSSL_PROVIDER *prov, + void *unused) { EVP_MAC *mac = NULL; int fnmaccnt = 0, fnctxcnt = 0; - if ((mac = evp_mac_new()) == NULL - || (mac->name = OPENSSL_strdup(name)) == NULL) { - EVP_MAC_free(mac); + if ((mac = evp_mac_new()) == NULL) { EVPerr(0, ERR_R_MALLOC_FAILURE); return NULL; } + mac->name_id = name_id; for (; fns->function_id != 0; fns++) { switch (fns->function_id) { @@ -170,7 +170,7 @@ void EVP_MAC_free(EVP_MAC *mac) const char *EVP_MAC_name(const EVP_MAC *mac) { - return mac->name; + return evp_first_name(mac->prov, mac->name_id); } const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac) |