diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2019-04-22 17:18:56 +1000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-05-03 17:52:50 +0200 |
commit | d2ba812343a62b1f86a15ae09bdeafec6d82f43a (patch) | |
tree | e37b3953dae069a3ea00ebdd321f68a29761d627 /crypto/evp/names.c | |
parent | e616c11e170ef524b12e218537f4bf290057f8b7 (diff) |
Added EVP_KDF (similiar to the EVP_MAC)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8808)
Diffstat (limited to 'crypto/evp/names.c')
-rw-r--r-- | crypto/evp/names.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crypto/evp/names.c b/crypto/evp/names.c index 4e17926165..5237bcaf24 100644 --- a/crypto/evp/names.c +++ b/crypto/evp/names.c @@ -10,6 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> +#include <openssl/kdf.h> #include "internal/objects.h" #include <openssl/x509.h> #include "internal/evp_int.h" @@ -71,6 +72,23 @@ int EVP_add_mac(const EVP_MAC *m) return r; } +/* TODO(3.0) Is this needed after changing to providers? */ +int EVP_add_kdf(const EVP_KDF *k) +{ + int r; + + if (k == NULL) + return 0; + + r = OBJ_NAME_add(OBJ_nid2sn(k->type), OBJ_NAME_TYPE_KDF_METH, + (const char *)k); + if (r == 0) + return 0; + r = OBJ_NAME_add(OBJ_nid2ln(k->type), OBJ_NAME_TYPE_KDF_METH, + (const char *)k); + return r; +} + const EVP_CIPHER *EVP_get_cipherbyname(const char *name) { const EVP_CIPHER *cp; @@ -104,9 +122,22 @@ const EVP_MAC *EVP_get_macbyname(const char *name) return mp; } +/* TODO(3.0) Is this API needed after implementing providers? */ +const EVP_KDF *EVP_get_kdfbyname(const char *name) +{ + const EVP_KDF *kdf; + + if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_KDFS, NULL)) + return NULL; + + kdf = (const EVP_KDF *)OBJ_NAME_get(name, OBJ_NAME_TYPE_KDF_METH); + return kdf; +} + void evp_cleanup_int(void) { OBJ_NAME_cleanup(OBJ_NAME_TYPE_MAC_METH); + OBJ_NAME_cleanup(OBJ_NAME_TYPE_KDF_METH); OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH); OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH); /* @@ -207,6 +238,7 @@ void EVP_MD_do_all_sorted(void (*fn) (const EVP_MD *md, OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc); } +/* TODO(3.0) Are these do_all API's needed for MAC? */ struct doall_mac { void *arg; void (*fn) (const EVP_MAC *ciph, @@ -250,4 +282,3 @@ void EVP_MAC_do_all_sorted(void (*fn) dc.arg = arg; OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MAC_METH, do_all_mac_fn, &dc); } - |