extern "C" {
# endif
-# define EVP_KDF_PBKDF2 NID_id_pbkdf2
-# define EVP_KDF_SCRYPT NID_id_scrypt
-# define EVP_KDF_TLS1_PRF NID_tls1_prf
-# define EVP_KDF_HKDF NID_hkdf
-# define EVP_KDF_SSHKDF NID_sshkdf
-# define EVP_KDF_SS NID_sskdf
-# define EVP_KDF_X963 NID_x963kdf
-# define EVP_KDF_X942 NID_x942kdf
-
int EVP_KDF_up_ref(EVP_KDF *kdf);
void EVP_KDF_free(EVP_KDF *kdf);
EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm,
const char *properties);
-#define EVP_get_kdfbyname(name) EVP_KDF_fetch(NULL, (name), NULL)
EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
static int test_kdf_get_kdf(void)
{
- const EVP_KDF *kdf1, *kdf2;
+ EVP_KDF *kdf1 = NULL, *kdf2 = NULL;
ASN1_OBJECT *obj;
-
- return
- TEST_ptr(obj = OBJ_nid2obj(NID_id_pbkdf2))
- && TEST_ptr(kdf1 = EVP_get_kdfbyname(LN_id_pbkdf2))
- && TEST_ptr(kdf2 = EVP_get_kdfbyname(OBJ_nid2sn(OBJ_obj2nid(obj))))
- && TEST_ptr_eq(kdf1, kdf2)
- && TEST_ptr(kdf1 = EVP_get_kdfbyname(SN_tls1_prf))
- && TEST_ptr(kdf2 = EVP_get_kdfbyname(LN_tls1_prf))
- && TEST_ptr_eq(kdf1, kdf2)
- && TEST_ptr(kdf2 = EVP_get_kdfbyname(OBJ_nid2sn(NID_tls1_prf)))
- && TEST_ptr_eq(kdf1, kdf2);
+ int ok = 1;
+
+ if (!TEST_ptr(obj = OBJ_nid2obj(NID_id_pbkdf2))
+ || !TEST_ptr(kdf1 = EVP_KDF_fetch(NULL, LN_id_pbkdf2, NULL))
+ || !TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, OBJ_nid2sn(OBJ_obj2nid(obj)),
+ NULL))
+ || !TEST_ptr_eq(kdf1, kdf2))
+ ok = 0;
+ EVP_KDF_free(kdf1);
+ kdf1 = NULL;
+ EVP_KDF_free(kdf2);
+ kdf2 = NULL;
+
+ if (!TEST_ptr(kdf1 = EVP_KDF_fetch(NULL, SN_tls1_prf, NULL))
+ || !TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, LN_tls1_prf, NULL))
+ || !TEST_ptr_eq(kdf1, kdf2))
+ ok = 0;
+ /* kdf1 is re-used below, so don't free it here */
+ EVP_KDF_free(kdf2);
+ kdf2 = NULL;
+
+ if (!TEST_ptr(kdf2 = EVP_KDF_fetch(NULL, OBJ_nid2sn(NID_tls1_prf), NULL))
+ || !TEST_ptr_eq(kdf1, kdf2))
+ ok = 0;
+ EVP_KDF_free(kdf1);
+ kdf1 = NULL;
+ EVP_KDF_free(kdf2);
+ kdf2 = NULL;
+
+ return ok;
}
#ifndef OPENSSL_NO_CMS