Blame SOURCES/dovecot-2.3.6-opensslhmac.patch

8f30fd
diff -up dovecot-2.3.8/src/auth/auth-token.c.opensslhmac dovecot-2.3.8/src/auth/auth-token.c
8f30fd
--- dovecot-2.3.8/src/auth/auth-token.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/auth/auth-token.c	2019-11-19 16:34:11.338037002 +0100
8f30fd
@@ -161,17 +161,17 @@ void auth_token_deinit(void)
8f30fd
 const char *auth_token_get(const char *service, const char *session_pid,
8f30fd
 			   const char *username, const char *session_id)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	unsigned char result[SHA1_RESULTLEN];
8f30fd
 
8f30fd
-	hmac_init(&ctx, (const unsigned char*)username, strlen(username),
8f30fd
+	openssl_hmac_init(&ctx, (const unsigned char*)username, strlen(username),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, session_pid, strlen(session_pid));
8f30fd
+	openssl_hmac_update(&ctx, session_pid, strlen(session_pid));
8f30fd
 	if (session_id != NULL && *session_id != '\0')
8f30fd
-		hmac_update(&ctx, session_id, strlen(session_id));
8f30fd
-	hmac_update(&ctx, service, strlen(service));
8f30fd
-	hmac_update(&ctx, auth_token_secret, sizeof(auth_token_secret));
8f30fd
-	hmac_final(&ctx, result);
8f30fd
+		openssl_hmac_update(&ctx, session_id, strlen(session_id));
8f30fd
+	openssl_hmac_update(&ctx, service, strlen(service));
8f30fd
+	openssl_hmac_update(&ctx, auth_token_secret, sizeof(auth_token_secret));
8f30fd
+	openssl_hmac_final(&ctx, result);
8f30fd
 
8f30fd
 	return binary_to_hex(result, sizeof(result));
8f30fd
 }
8f30fd
diff -up dovecot-2.3.8/src/auth/mech-cram-md5.c.opensslhmac dovecot-2.3.8/src/auth/mech-cram-md5.c
8f30fd
--- dovecot-2.3.8/src/auth/mech-cram-md5.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/auth/mech-cram-md5.c	2019-11-19 16:34:11.338037002 +0100
8f30fd
@@ -51,7 +51,7 @@ static bool verify_credentials(struct cr
8f30fd
 {
8f30fd
 	
8f30fd
 	unsigned char digest[MD5_RESULTLEN];
8f30fd
-        struct hmac_context ctx;
8f30fd
+        struct orig_hmac_context ctx;
8f30fd
 	const char *response_hex;
8f30fd
 
8f30fd
 	if (size != CRAM_MD5_CONTEXTLEN) {
8f30fd
@@ -60,10 +60,10 @@ static bool verify_credentials(struct cr
8f30fd
 		return FALSE;
8f30fd
 	}
8f30fd
 
8f30fd
-	hmac_init(&ctx, NULL, 0, &hash_method_md5);
8f30fd
+	orig_hmac_init(&ctx, NULL, 0, &hash_method_md5);
8f30fd
 	hmac_md5_set_cram_context(&ctx, credentials);
8f30fd
-	hmac_update(&ctx, request->challenge, strlen(request->challenge));
8f30fd
-	hmac_final(&ctx, digest);
8f30fd
+	orig_hmac_update(&ctx, request->challenge, strlen(request->challenge));
8f30fd
+	orig_hmac_final(&ctx, digest);
8f30fd
 
8f30fd
 	response_hex = binary_to_hex(digest, sizeof(digest));
8f30fd
 
8f30fd
diff -up dovecot-2.3.8/src/auth/mech-scram-sha1.c.opensslhmac dovecot-2.3.8/src/auth/mech-scram-sha1.c
8f30fd
--- dovecot-2.3.8/src/auth/mech-scram-sha1.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/auth/mech-scram-sha1.c	2019-11-19 16:34:11.338037002 +0100
8f30fd
@@ -71,7 +71,7 @@ static const char *get_scram_server_firs
8f30fd
 
8f30fd
 static const char *get_scram_server_final(struct scram_auth_request *request)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	const char *auth_message;
8f30fd
 	unsigned char server_signature[SHA1_RESULTLEN];
8f30fd
 	string_t *str;
8f30fd
@@ -80,10 +80,10 @@ static const char *get_scram_server_fina
8f30fd
 			request->server_first_message, ",",
8f30fd
 			request->client_final_message_without_proof, NULL);
8f30fd
 
8f30fd
-	hmac_init(&ctx, request->server_key, sizeof(request->server_key),
8f30fd
+	openssl_hmac_init(&ctx, request->server_key, sizeof(request->server_key),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, auth_message, strlen(auth_message));
8f30fd
-	hmac_final(&ctx, server_signature);
8f30fd
+	openssl_hmac_update(&ctx, auth_message, strlen(auth_message));
8f30fd
+	openssl_hmac_final(&ctx, server_signature);
8f30fd
 
8f30fd
 	str = t_str_new(MAX_BASE64_ENCODED_SIZE(sizeof(server_signature)));
8f30fd
 	str_append(str, "v=");
8f30fd
@@ -221,7 +221,7 @@ static bool parse_scram_client_first(str
8f30fd
 
8f30fd
 static bool verify_credentials(struct scram_auth_request *request)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	const char *auth_message;
8f30fd
 	unsigned char client_key[SHA1_RESULTLEN];
8f30fd
 	unsigned char client_signature[SHA1_RESULTLEN];
8f30fd
@@ -232,10 +232,10 @@ static bool verify_credentials(struct sc
8f30fd
 			request->server_first_message, ",",
8f30fd
 			request->client_final_message_without_proof, NULL);
8f30fd
 
8f30fd
-	hmac_init(&ctx, request->stored_key, sizeof(request->stored_key),
8f30fd
+	openssl_hmac_init(&ctx, request->stored_key, sizeof(request->stored_key),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, auth_message, strlen(auth_message));
8f30fd
-	hmac_final(&ctx, client_signature);
8f30fd
+	openssl_hmac_update(&ctx, auth_message, strlen(auth_message));
8f30fd
+	openssl_hmac_final(&ctx, client_signature);
8f30fd
 
8f30fd
 	for (i = 0; i < sizeof(client_signature); i++)
8f30fd
 		client_key[i] =
8f30fd
diff -up dovecot-2.3.8/src/auth/password-scheme.c.opensslhmac dovecot-2.3.8/src/auth/password-scheme.c
8f30fd
--- dovecot-2.3.8/src/auth/password-scheme.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/auth/password-scheme.c	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -647,11 +647,11 @@ static void
8f30fd
 cram_md5_generate(const char *plaintext, const struct password_generate_params *params ATTR_UNUSED,
8f30fd
 		  const unsigned char **raw_password_r, size_t *size_r)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct orig_hmac_context ctx;
8f30fd
 	unsigned char *context_digest;
8f30fd
 
8f30fd
 	context_digest = t_malloc_no0(CRAM_MD5_CONTEXTLEN);
8f30fd
-	hmac_init(&ctx, (const unsigned char *)plaintext,
8f30fd
+	orig_hmac_init(&ctx, (const unsigned char *)plaintext,
8f30fd
 		  strlen(plaintext), &hash_method_md5);
8f30fd
 	hmac_md5_get_cram_context(&ctx, context_digest);
8f30fd
 
8f30fd
diff -up dovecot-2.3.8/src/auth/password-scheme-scram.c.opensslhmac dovecot-2.3.8/src/auth/password-scheme-scram.c
8f30fd
--- dovecot-2.3.8/src/auth/password-scheme-scram.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/auth/password-scheme-scram.c	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -27,23 +27,23 @@ static void Hi(const unsigned char *str,
8f30fd
 	       const unsigned char *salt, size_t salt_size, unsigned int i,
8f30fd
 	       unsigned char result[SHA1_RESULTLEN])
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	unsigned char U[SHA1_RESULTLEN];
8f30fd
 	unsigned int j, k;
8f30fd
 
8f30fd
 	/* Calculate U1 */
8f30fd
-	hmac_init(&ctx, str, str_size, &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, salt, salt_size);
8f30fd
-	hmac_update(&ctx, "\0\0\0\1", 4);
8f30fd
-	hmac_final(&ctx, U);
8f30fd
+	openssl_hmac_init(&ctx, str, str_size, &hash_method_sha1);
8f30fd
+	openssl_hmac_update(&ctx, salt, salt_size);
8f30fd
+	openssl_hmac_update(&ctx, "\0\0\0\1", 4);
8f30fd
+	openssl_hmac_final(&ctx, U);
8f30fd
 
8f30fd
 	memcpy(result, U, SHA1_RESULTLEN);
8f30fd
 
8f30fd
 	/* Calculate U2 to Ui and Hi */
8f30fd
 	for (j = 2; j <= i; j++) {
8f30fd
-		hmac_init(&ctx, str, str_size, &hash_method_sha1);
8f30fd
-		hmac_update(&ctx, U, sizeof(U));
8f30fd
-		hmac_final(&ctx, U);
8f30fd
+		openssl_hmac_init(&ctx, str, str_size, &hash_method_sha1);
8f30fd
+		openssl_hmac_update(&ctx, U, sizeof(U));
8f30fd
+		openssl_hmac_final(&ctx, U);
8f30fd
 		for (k = 0; k < SHA1_RESULTLEN; k++)
8f30fd
 			result[k] ^= U[k];
8f30fd
 	}
8f30fd
@@ -94,7 +94,7 @@ int scram_sha1_verify(const char *plaint
8f30fd
 		      const unsigned char *raw_password, size_t size,
8f30fd
 		      const char **error_r)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	const char *salt_base64;
8f30fd
 	unsigned int iter_count;
8f30fd
 	const unsigned char *salt;
8f30fd
@@ -118,10 +118,10 @@ int scram_sha1_verify(const char *plaint
8f30fd
 	   iter_count, salted_password);
8f30fd
 
8f30fd
 	/* Calculate ClientKey */
8f30fd
-	hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
+	openssl_hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, "Client Key", 10);
8f30fd
-	hmac_final(&ctx, client_key);
8f30fd
+	openssl_hmac_update(&ctx, "Client Key", 10);
8f30fd
+	openssl_hmac_final(&ctx, client_key);
8f30fd
 
8f30fd
 	/* Calculate StoredKey */
8f30fd
 	sha1_get_digest(client_key, sizeof(client_key), calculated_stored_key);
8f30fd
@@ -139,7 +139,7 @@ void scram_sha1_generate(const char *pla
8f30fd
 			 const unsigned char **raw_password_r, size_t *size_r)
8f30fd
 {
8f30fd
 	string_t *str;
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	unsigned char salt[16];
8f30fd
 	unsigned char salted_password[SHA1_RESULTLEN];
8f30fd
 	unsigned char client_key[SHA1_RESULTLEN];
8f30fd
@@ -157,10 +157,10 @@ void scram_sha1_generate(const char *pla
8f30fd
 	   sizeof(salt), SCRAM_DEFAULT_ITERATE_COUNT, salted_password);
8f30fd
 
8f30fd
 	/* Calculate ClientKey */
8f30fd
-	hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
+	openssl_hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, "Client Key", 10);
8f30fd
-	hmac_final(&ctx, client_key);
8f30fd
+	openssl_hmac_update(&ctx, "Client Key", 10);
8f30fd
+	openssl_hmac_final(&ctx, client_key);
8f30fd
 
8f30fd
 	/* Calculate StoredKey */
8f30fd
 	sha1_get_digest(client_key, sizeof(client_key), stored_key);
8f30fd
@@ -168,10 +168,10 @@ void scram_sha1_generate(const char *pla
8f30fd
 	base64_encode(stored_key, sizeof(stored_key), str);
8f30fd
 
8f30fd
 	/* Calculate ServerKey */
8f30fd
-	hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
+	openssl_hmac_init(&ctx, salted_password, sizeof(salted_password),
8f30fd
 		  &hash_method_sha1);
8f30fd
-	hmac_update(&ctx, "Server Key", 10);
8f30fd
-	hmac_final(&ctx, server_key);
8f30fd
+	openssl_hmac_update(&ctx, "Server Key", 10);
8f30fd
+	openssl_hmac_final(&ctx, server_key);
8f30fd
 	str_append_c(str, ',');
8f30fd
 	base64_encode(server_key, sizeof(server_key), str);
8f30fd
 
8f30fd
diff -up dovecot-2.3.8/src/lib/hmac.c.opensslhmac dovecot-2.3.8/src/lib/hmac.c
8f30fd
--- dovecot-2.3.8/src/lib/hmac.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/hmac.c	2019-11-19 17:25:28.045716181 +0100
8f30fd
@@ -7,6 +7,10 @@
8f30fd
  * This software is released under the MIT license.
8f30fd
  */
8f30fd
 
8f30fd
+#include <sys/types.h>
8f30fd
+#include <sys/stat.h>
8f30fd
+#include <fcntl.h>
8f30fd
+#include <unistd.h>
8f30fd
 #include "lib.h"
8f30fd
 #include "hmac.h"
8f30fd
 #include "safe-memset.h"
8f30fd
@@ -14,10 +18,65 @@
8f30fd
 
8f30fd
 #include "hex-binary.h"
8f30fd
 
8f30fd
-void hmac_init(struct hmac_context *_ctx, const unsigned char *key,
8f30fd
+#ifndef HAVE_HMAC_CTX_NEW
8f30fd
+#  define HMAC_Init_ex(ctx, key, key_len, md, impl) \
8f30fd
+	HMAC_Init_ex(&(ctx), key, key_len, md, impl)
8f30fd
+#  define HMAC_Update(ctx, data, len) HMAC_Update(&(ctx), data, len)
8f30fd
+#  define HMAC_Final(ctx, md, len) HMAC_Final(&(ctx), md, len)
8f30fd
+#  define HMAC_CTX_free(ctx) HMAC_cleanup(&(ctx))
8f30fd
+#else
8f30fd
+#  define HMAC_CTX_free(ctx) \
8f30fd
+	STMT_START { HMAC_CTX_free(ctx); (ctx) = NULL; } STMT_END
8f30fd
+#endif
8f30fd
+
8f30fd
+
8f30fd
+void openssl_hmac_init(struct openssl_hmac_context *_ctx, const unsigned char *key,
8f30fd
 		size_t key_len, const struct hash_method *meth)
8f30fd
 {
8f30fd
-	struct hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+ 	struct openssl_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+
8f30fd
+	const EVP_MD *md;
8f30fd
+	const char *ebuf = NULL;
8f30fd
+	const char **error_r = &ebuf;
8f30fd
+
8f30fd
+	md = EVP_get_digestbyname(meth->name);
8f30fd
+	if(md == NULL) {
8f30fd
+		if (error_r != NULL) {
8f30fd
+			*error_r = t_strdup_printf("Invalid digest %s",
8f30fd
+						   meth->name);
8f30fd
+		}
8f30fd
+		//return FALSE;
8f30fd
+	}
8f30fd
+
8f30fd
+// 	int ec;
8f30fd
+
8f30fd
+	i_assert(md != NULL);
8f30fd
+#ifdef HAVE_HMAC_CTX_NEW
8f30fd
+	ctx->ctx = HMAC_CTX_new();
8f30fd
+/*	if (ctx->ctx == NULL)
8f30fd
+		dcrypt_openssl_error(error_r);*/
8f30fd
+#endif
8f30fd
+	/*ec = */HMAC_Init_ex(ctx->ctx, key, key_len, md, NULL);
8f30fd
+}
8f30fd
+
8f30fd
+void orig_hmac_init(struct orig_hmac_context *_ctx, const unsigned char *key,
8f30fd
+		size_t key_len, const struct hash_method *meth)
8f30fd
+{
8f30fd
+    static int no_fips = -1;
8f30fd
+    if (no_fips == -1) {
8f30fd
+        int fd = open("/proc/sys/crypto/fips_enabled", O_RDONLY);
8f30fd
+        if (fd != -1)
8f30fd
+        {
8f30fd
+            char buf[4];
8f30fd
+            if (read(fd, buf, 4) > 0)
8f30fd
+            {
8f30fd
+                no_fips = buf[0] == '0';   
8f30fd
+            }
8f30fd
+            close(fd);   
8f30fd
+        }
8f30fd
+    }
8f30fd
+    i_assert(no_fips);
8f30fd
+	struct orig_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
 	int i;
8f30fd
 	unsigned char k_ipad[64];
8f30fd
 	unsigned char k_opad[64];
8f30fd
@@ -53,9 +112,27 @@ void hmac_init(struct hmac_context *_ctx
8f30fd
 	safe_memset(k_opad, 0, 64);
8f30fd
 }
8f30fd
 
8f30fd
-void hmac_final(struct hmac_context *_ctx, unsigned char *digest)
8f30fd
+void openssl_hmac_final(struct openssl_hmac_context *_ctx, unsigned char *digest)
8f30fd
+{
8f30fd
+	int ec;
8f30fd
+	unsigned char buf[HMAC_MAX_MD_CBLOCK];
8f30fd
+	unsigned int outl;
8f30fd
+//     const char *ebuf = NULL;
8f30fd
+//     const char **error_r = &ebuf;
8f30fd
+
8f30fd
+    struct openssl_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+	ec = HMAC_Final(ctx->ctx, buf, &outl);
8f30fd
+	HMAC_CTX_free(ctx->ctx);
8f30fd
+	if (ec == 1)
8f30fd
+		memcpy(digest, buf, outl);
8f30fd
+//	else
8f30fd
+//		dcrypt_openssl_error(error_r);
8f30fd
+
8f30fd
+}
8f30fd
+
8f30fd
+void orig_hmac_final(struct orig_hmac_context *_ctx, unsigned char *digest)
8f30fd
 {
8f30fd
-	struct hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+	struct orig_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
 
8f30fd
 	ctx->hash->result(ctx->ctx, digest);
8f30fd
 
8f30fd
@@ -63,53 +140,50 @@ void hmac_final(struct hmac_context *_ct
8f30fd
 	ctx->hash->result(ctx->ctxo, digest);
8f30fd
 }
8f30fd
 
8f30fd
-buffer_t *t_hmac_data(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_data(const struct hash_method *meth,
8f30fd
 		      const unsigned char *key, size_t key_len,
8f30fd
 		      const void *data, size_t data_len)
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	i_assert(meth != NULL);
8f30fd
 	i_assert(key != NULL && key_len > 0);
8f30fd
 	i_assert(data != NULL || data_len == 0);
8f30fd
 
8f30fd
 	buffer_t *res = t_buffer_create(meth->digest_size);
8f30fd
-	hmac_init(&ctx, key, key_len, meth);
8f30fd
+	openssl_hmac_init(&ctx, key, key_len, meth);
8f30fd
 	if (data_len > 0)
8f30fd
-		hmac_update(&ctx, data, data_len);
8f30fd
+		openssl_hmac_update(&ctx, data, data_len);
8f30fd
 	unsigned char *buf = buffer_get_space_unsafe(res, 0, meth->digest_size);
8f30fd
-	hmac_final(&ctx, buf);
8f30fd
+	openssl_hmac_final(&ctx, buf);
8f30fd
 	return res;
8f30fd
 }
8f30fd
 
8f30fd
-buffer_t *t_hmac_buffer(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_buffer(const struct hash_method *meth,
8f30fd
 			const unsigned char *key, size_t key_len,
8f30fd
 			const buffer_t *data)
8f30fd
 {
8f30fd
-	return t_hmac_data(meth, key, key_len, data->data, data->used);
8f30fd
+	return openssl_t_hmac_data(meth, key, key_len, data->data, data->used);
8f30fd
 }
8f30fd
 
8f30fd
-buffer_t *t_hmac_str(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_str(const struct hash_method *meth,
8f30fd
 		     const unsigned char *key, size_t key_len,
8f30fd
 		     const char *data)
8f30fd
 {
8f30fd
-	return t_hmac_data(meth, key, key_len, data, strlen(data));
8f30fd
+	return openssl_t_hmac_data(meth, key, key_len, data, strlen(data));
8f30fd
 }
8f30fd
 
8f30fd
-void hmac_hkdf(const struct hash_method *method,
8f30fd
+void openssl_hmac_hkdf(const struct hash_method *method,
8f30fd
 	       const unsigned char *salt, size_t salt_len,
8f30fd
 	       const unsigned char *ikm, size_t ikm_len,
8f30fd
 	       const unsigned char *info, size_t info_len,
8f30fd
 	       buffer_t *okm_r, size_t okm_len)
8f30fd
 {
8f30fd
+	const EVP_MD *md;
8f30fd
+	EVP_PKEY_CTX *pctx;
8f30fd
+	int r = 1;
8f30fd
+
8f30fd
 	i_assert(method != NULL);
8f30fd
 	i_assert(okm_len < 255*method->digest_size);
8f30fd
-	struct hmac_context key_mac;
8f30fd
-	struct hmac_context info_mac;
8f30fd
-	size_t remain = okm_len;
8f30fd
-	unsigned char prk[method->digest_size];
8f30fd
-	unsigned char okm[method->digest_size];
8f30fd
-	/* N = ceil(L/HashLen) */
8f30fd
-	unsigned int rounds = (okm_len + method->digest_size - 1)/method->digest_size;
8f30fd
 
8f30fd
 	/* salt and info can be NULL */
8f30fd
 	i_assert(salt != NULL || salt_len == 0);
8f30fd
@@ -118,35 +192,30 @@ void hmac_hkdf(const struct hash_method
8f30fd
 	i_assert(ikm != NULL && ikm_len > 0);
8f30fd
 	i_assert(okm_r != NULL && okm_len > 0);
8f30fd
 
8f30fd
-	/* but they still need valid pointer, reduces
8f30fd
-	   complains from static analysers */
8f30fd
-	if (salt == NULL)
8f30fd
-		salt = &uchar_nul;
8f30fd
-	if (info == NULL)
8f30fd
-		info = &uchar_nul;
8f30fd
-
8f30fd
-	/* extract */
8f30fd
-	hmac_init(&key_mac, salt, salt_len, method);
8f30fd
-	hmac_update(&key_mac, ikm, ikm_len);
8f30fd
-	hmac_final(&key_mac, prk);
8f30fd
-
8f30fd
-	/* expand */
8f30fd
-	for (unsigned int i = 0; remain > 0 && i < rounds; i++) {
8f30fd
-		unsigned char round = (i+1);
8f30fd
-		size_t amt = remain;
8f30fd
-		if (amt > method->digest_size)
8f30fd
-			amt = method->digest_size;
8f30fd
-		hmac_init(&info_mac, prk, method->digest_size, method);
8f30fd
-		if (i > 0)
8f30fd
-			hmac_update(&info_mac, okm, method->digest_size);
8f30fd
-		hmac_update(&info_mac, info, info_len);
8f30fd
-		hmac_update(&info_mac, &round, 1);
8f30fd
-		memset(okm, 0, method->digest_size);
8f30fd
-		hmac_final(&info_mac, okm);
8f30fd
-		buffer_append(okm_r, okm, amt);
8f30fd
-		remain -= amt;
8f30fd
+
8f30fd
+	md = EVP_get_digestbyname(method->name);
8f30fd
+	pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
8f30fd
+	unsigned char *okm_buf = buffer_get_space_unsafe(okm_r, 0, okm_len);
8f30fd
+
8f30fd
+	if ((r=EVP_PKEY_derive_init(pctx)) <= 0)
8f30fd
+		goto out;
8f30fd
+	if ((r=EVP_PKEY_CTX_set_hkdf_md(pctx, md)) <= 0)
8f30fd
+		goto out;
8f30fd
+	if ((r=EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, salt_len)) <= 0)
8f30fd
+		goto out;
8f30fd
+	if ((r=EVP_PKEY_CTX_set1_hkdf_key(pctx, ikm, ikm_len)) <= 0)
8f30fd
+		goto out;
8f30fd
+	if ((r=EVP_PKEY_CTX_add1_hkdf_info(pctx, info, info_len)) <= 0)
8f30fd
+		goto out;
8f30fd
+	if ((r=EVP_PKEY_derive(pctx, okm_buf, &okm_len)) <= 0)
8f30fd
+		goto out;
8f30fd
+
8f30fd
+     out:
8f30fd
+	EVP_PKEY_CTX_free(pctx);
8f30fd
+	if (r <= 0) {
8f30fd
+		unsigned long ec = ERR_get_error();
8f30fd
+		unsigned char *error = t_strdup_printf("%s", ERR_error_string(ec, NULL));
8f30fd
+		i_error("%s", error);
8f30fd
 	}
8f30fd
 
8f30fd
-	safe_memset(prk, 0, sizeof(prk));
8f30fd
-	safe_memset(okm, 0, sizeof(okm));
8f30fd
 }
8f30fd
diff -up dovecot-2.3.8/src/lib/hmac-cram-md5.c.opensslhmac dovecot-2.3.8/src/lib/hmac-cram-md5.c
8f30fd
--- dovecot-2.3.8/src/lib/hmac-cram-md5.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/hmac-cram-md5.c	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -9,10 +9,10 @@
8f30fd
 #include "md5.h"
8f30fd
 #include "hmac-cram-md5.h"
8f30fd
 
8f30fd
-void hmac_md5_get_cram_context(struct hmac_context *_hmac_ctx,
8f30fd
+void hmac_md5_get_cram_context(struct orig_hmac_context *_hmac_ctx,
8f30fd
 			unsigned char context_digest[CRAM_MD5_CONTEXTLEN])
8f30fd
 {
8f30fd
-	struct hmac_context_priv *hmac_ctx = &_hmac_ctx->u.priv;
8f30fd
+	struct orig_hmac_context_priv *hmac_ctx = &_hmac_ctx->u.priv;
8f30fd
 	unsigned char *cdp;
8f30fd
 
8f30fd
 	struct md5_context *ctx = (void*)hmac_ctx->ctx;
8f30fd
@@ -35,10 +35,10 @@ void hmac_md5_get_cram_context(struct hm
8f30fd
 	CDPUT(cdp, ctx->d);
8f30fd
 }
8f30fd
 
8f30fd
-void hmac_md5_set_cram_context(struct hmac_context *_hmac_ctx,
8f30fd
+void hmac_md5_set_cram_context(struct orig_hmac_context *_hmac_ctx,
8f30fd
 			const unsigned char context_digest[CRAM_MD5_CONTEXTLEN])
8f30fd
 {
8f30fd
-	struct hmac_context_priv *hmac_ctx = &_hmac_ctx->u.priv;
8f30fd
+	struct orig_hmac_context_priv *hmac_ctx = &_hmac_ctx->u.priv;
8f30fd
 	const unsigned char *cdp;
8f30fd
 
8f30fd
 	struct md5_context *ctx = (void*)hmac_ctx->ctx;
8f30fd
diff -up dovecot-2.3.8/src/lib/hmac-cram-md5.h.opensslhmac dovecot-2.3.8/src/lib/hmac-cram-md5.h
8f30fd
--- dovecot-2.3.8/src/lib/hmac-cram-md5.h.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/hmac-cram-md5.h	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -5,9 +5,9 @@
8f30fd
 
8f30fd
 #define CRAM_MD5_CONTEXTLEN 32
8f30fd
 
8f30fd
-void hmac_md5_get_cram_context(struct hmac_context *ctx,
8f30fd
+void hmac_md5_get_cram_context(struct orig_hmac_context *ctx,
8f30fd
 		unsigned char context_digest[CRAM_MD5_CONTEXTLEN]);
8f30fd
-void hmac_md5_set_cram_context(struct hmac_context *ctx,
8f30fd
+void hmac_md5_set_cram_context(struct orig_hmac_context *ctx,
8f30fd
 		const unsigned char context_digest[CRAM_MD5_CONTEXTLEN]);
8f30fd
 
8f30fd
 
8f30fd
diff -up dovecot-2.3.8/src/lib/hmac.h.opensslhmac dovecot-2.3.8/src/lib/hmac.h
8f30fd
--- dovecot-2.3.8/src/lib/hmac.h.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/hmac.h	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -3,60 +3,97 @@
8f30fd
 
8f30fd
 #include "hash-method.h"
8f30fd
 #include "sha1.h"
8f30fd
+#include <openssl/objects.h>
8f30fd
+#include <openssl/hmac.h>
8f30fd
+#include <openssl/kdf.h>
8f30fd
+#include <openssl/err.h>
8f30fd
 
8f30fd
 #define HMAC_MAX_CONTEXT_SIZE 256
8f30fd
 
8f30fd
-struct hmac_context_priv {
8f30fd
+struct openssl_hmac_context_priv {
8f30fd
+#ifdef HAVE_HMAC_CTX_NEW
8f30fd
+	HMAC_CTX *ctx;
8f30fd
+#else
8f30fd
+	HMAC_CTX ctx;
8f30fd
+#endif
8f30fd
+	const struct hash_method *hash;
8f30fd
+};
8f30fd
+
8f30fd
+struct orig_hmac_context_priv {
8f30fd
 	char ctx[HMAC_MAX_CONTEXT_SIZE];
8f30fd
 	char ctxo[HMAC_MAX_CONTEXT_SIZE];
8f30fd
 	const struct hash_method *hash;
8f30fd
 };
8f30fd
 
8f30fd
-struct hmac_context {
8f30fd
+struct openssl_hmac_context {
8f30fd
+	union {
8f30fd
+		struct openssl_hmac_context_priv priv;
8f30fd
+		uint64_t padding_requirement;
8f30fd
+	} u;
8f30fd
+};
8f30fd
+
8f30fd
+struct orig_hmac_context {
8f30fd
 	union {
8f30fd
-		struct hmac_context_priv priv;
8f30fd
+		struct orig_hmac_context_priv priv;
8f30fd
 		uint64_t padding_requirement;
8f30fd
 	} u;
8f30fd
 };
8f30fd
 
8f30fd
-void hmac_init(struct hmac_context *ctx, const unsigned char *key,
8f30fd
+void openssl_hmac_init(struct openssl_hmac_context *ctx, const unsigned char *key,
8f30fd
+		size_t key_len, const struct hash_method *meth);
8f30fd
+void openssl_hmac_final(struct openssl_hmac_context *ctx, unsigned char *digest);
8f30fd
+
8f30fd
+static inline void
8f30fd
+openssl_hmac_update(struct openssl_hmac_context *_ctx, const void *data, size_t size)
8f30fd
+{
8f30fd
+	struct openssl_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+	HMAC_Update(ctx->ctx, data, size);
8f30fd
+/*	if (ec != 1)
8f30fd
+    {
8f30fd
+        const char *ebuf = NULL;
8f30fd
+        const char **error_r = &ebuf;
8f30fd
+		dcrypt_openssl_error(error_r);
8f30fd
+    }*/
8f30fd
+}
8f30fd
+
8f30fd
+void orig_hmac_init(struct orig_hmac_context *ctx, const unsigned char *key,
8f30fd
 		size_t key_len, const struct hash_method *meth);
8f30fd
-void hmac_final(struct hmac_context *ctx, unsigned char *digest);
8f30fd
+void orig_hmac_final(struct orig_hmac_context *ctx, unsigned char *digest);
8f30fd
 
8f30fd
 
8f30fd
 static inline void
8f30fd
-hmac_update(struct hmac_context *_ctx, const void *data, size_t size)
8f30fd
+orig_hmac_update(struct orig_hmac_context *_ctx, const void *data, size_t size)
8f30fd
 {
8f30fd
-	struct hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
+	struct orig_hmac_context_priv *ctx = &_ctx->u.priv;
8f30fd
 
8f30fd
 	ctx->hash->loop(ctx->ctx, data, size);
8f30fd
 }
8f30fd
 
8f30fd
-buffer_t *t_hmac_data(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_data(const struct hash_method *meth,
8f30fd
 		      const unsigned char *key, size_t key_len,
8f30fd
 		      const void *data, size_t data_len);
8f30fd
-buffer_t *t_hmac_buffer(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_buffer(const struct hash_method *meth,
8f30fd
 			const unsigned char *key, size_t key_len,
8f30fd
 			const buffer_t *data);
8f30fd
-buffer_t *t_hmac_str(const struct hash_method *meth,
8f30fd
+buffer_t *openssl_t_hmac_str(const struct hash_method *meth,
8f30fd
 		     const unsigned char *key, size_t key_len,
8f30fd
 		     const char *data);
8f30fd
 
8f30fd
-void hmac_hkdf(const struct hash_method *method,
8f30fd
+void openssl_hmac_hkdf(const struct hash_method *method,
8f30fd
 	       const unsigned char *salt, size_t salt_len,
8f30fd
 	       const unsigned char *ikm, size_t ikm_len,
8f30fd
 	       const unsigned char *info, size_t info_len,
8f30fd
 	       buffer_t *okm_r, size_t okm_len);
8f30fd
 
8f30fd
 static inline buffer_t *
8f30fd
-t_hmac_hkdf(const struct hash_method *method,
8f30fd
+openssl_t_hmac_hkdf(const struct hash_method *method,
8f30fd
 	    const unsigned char *salt, size_t salt_len,
8f30fd
 	    const unsigned char *ikm, size_t ikm_len,
8f30fd
 	    const unsigned char *info, size_t info_len,
8f30fd
 	    size_t okm_len)
8f30fd
 {
8f30fd
 	buffer_t *okm_buffer = t_buffer_create(okm_len);
8f30fd
-	hmac_hkdf(method, salt, salt_len, ikm, ikm_len, info, info_len,
8f30fd
+	openssl_hmac_hkdf(method, salt, salt_len, ikm, ikm_len, info, info_len,
8f30fd
 		  okm_buffer, okm_len);
8f30fd
 	return okm_buffer;
8f30fd
 }
8f30fd
diff -up dovecot-2.3.8/src/lib-imap-urlauth/imap-urlauth.c.opensslhmac dovecot-2.3.8/src/lib-imap-urlauth/imap-urlauth.c
8f30fd
--- dovecot-2.3.8/src/lib-imap-urlauth/imap-urlauth.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib-imap-urlauth/imap-urlauth.c	2019-11-19 16:34:11.339036998 +0100
8f30fd
@@ -85,15 +85,15 @@ imap_urlauth_internal_generate(const cha
8f30fd
 			       const unsigned char mailbox_key[IMAP_URLAUTH_KEY_LEN],
8f30fd
 			       size_t *token_len_r)
8f30fd
 {
8f30fd
-	struct hmac_context hmac;
8f30fd
+	struct openssl_hmac_context hmac;
8f30fd
 	unsigned char *token;
8f30fd
 
8f30fd
 	token = t_new(unsigned char, SHA1_RESULTLEN + 1);
8f30fd
 	token[0] = IMAP_URLAUTH_MECH_INTERNAL_VERSION;
8f30fd
 
8f30fd
-	hmac_init(&hmac, mailbox_key, IMAP_URLAUTH_KEY_LEN, &hash_method_sha1);
8f30fd
-	hmac_update(&hmac, rumpurl, strlen(rumpurl));
8f30fd
-	hmac_final(&hmac, token+1);
8f30fd
+	openssl_hmac_init(&hmac, mailbox_key, IMAP_URLAUTH_KEY_LEN, &hash_method_sha1);
8f30fd
+	openssl_hmac_update(&hmac, rumpurl, strlen(rumpurl));
8f30fd
+	openssl_hmac_final(&hmac, token+1);
8f30fd
 
8f30fd
 	*token_len_r = SHA1_RESULTLEN + 1;
8f30fd
 	return token;
8f30fd
diff -up dovecot-2.3.8/src/lib/Makefile.am.opensslhmac dovecot-2.3.8/src/lib/Makefile.am
8f30fd
--- dovecot-2.3.8/src/lib/Makefile.am.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/Makefile.am	2019-11-19 16:34:11.340036994 +0100
8f30fd
@@ -323,6 +323,9 @@ headers = \
8f30fd
 	wildcard-match.h \
8f30fd
 	write-full.h
8f30fd
 
8f30fd
+liblib_la_LIBADD = $(SSL_LIBS)
8f30fd
+liblib_la_CFLAGS = $(SSL_CFLAGS)
8f30fd
+
8f30fd
 test_programs = test-lib
8f30fd
 noinst_PROGRAMS = $(test_programs)
8f30fd
 
8f30fd
diff -up dovecot-2.3.8/src/lib-ntlm/ntlm-encrypt.c.opensslhmac dovecot-2.3.8/src/lib-ntlm/ntlm-encrypt.c
8f30fd
--- dovecot-2.3.8/src/lib-ntlm/ntlm-encrypt.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib-ntlm/ntlm-encrypt.c	2019-11-19 16:34:11.340036994 +0100
8f30fd
@@ -61,12 +61,12 @@ void ntlm_v1_hash(const char *passwd, un
8f30fd
 }
8f30fd
 
8f30fd
 static void
8f30fd
-hmac_md5_ucs2le_string_ucase(struct hmac_context *ctx, const char *str)
8f30fd
-{
8f30fd
-	size_t len;
8f30fd
-	unsigned char *wstr = t_unicode_str(str, TRUE, &len;;
8f30fd
-
8f30fd
-	hmac_update(ctx, wstr, len);
8f30fd
+hmac_md5_ucs2le_string_ucase(struct openssl_hmac_context *ctx, const char *str)
8f30fd
+ {
8f30fd
+ 	size_t len;
8f30fd
+ 	unsigned char *wstr = t_unicode_str(str, TRUE, &len;;
8f30fd
+ 
8f30fd
+	openssl_hmac_update(ctx, wstr, len);
8f30fd
 }
8f30fd
 
8f30fd
 static void ATTR_NULL(2)
8f30fd
@@ -74,13 +74,13 @@ ntlm_v2_hash(const char *user, const cha
8f30fd
 	     const unsigned char *hash_v1,
8f30fd
 	     unsigned char hash[NTLMSSP_V2_HASH_SIZE])
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 
8f30fd
-	hmac_init(&ctx, hash_v1, NTLMSSP_HASH_SIZE, &hash_method_md5);
8f30fd
+	openssl_hmac_init(&ctx, hash_v1, NTLMSSP_HASH_SIZE, &hash_method_md5);
8f30fd
 	hmac_md5_ucs2le_string_ucase(&ctx, user);
8f30fd
 	if (target != NULL)
8f30fd
 		hmac_md5_ucs2le_string_ucase(&ctx, target);
8f30fd
-	hmac_final(&ctx, hash);
8f30fd
+	openssl_hmac_final(&ctx, hash);
8f30fd
 }
8f30fd
 
8f30fd
 void
8f30fd
@@ -125,15 +125,15 @@ ntlmssp_v2_response(const char *user, co
8f30fd
 		    const unsigned char *blob, size_t blob_size,
8f30fd
 		    unsigned char response[NTLMSSP_V2_RESPONSE_SIZE])
8f30fd
 {
8f30fd
-	struct hmac_context ctx;
8f30fd
+	struct openssl_hmac_context ctx;
8f30fd
 	unsigned char hash[NTLMSSP_V2_HASH_SIZE];
8f30fd
 
8f30fd
 	ntlm_v2_hash(user, target, hash_v1, hash);
8f30fd
 
8f30fd
-	hmac_init(&ctx, hash, NTLMSSP_V2_HASH_SIZE, &hash_method_md5);
8f30fd
-	hmac_update(&ctx, challenge, NTLMSSP_CHALLENGE_SIZE);
8f30fd
-	hmac_update(&ctx, blob, blob_size);
8f30fd
-	hmac_final(&ctx, response);
8f30fd
+	openssl_hmac_init(&ctx, hash, NTLMSSP_V2_HASH_SIZE, &hash_method_md5);
8f30fd
+	openssl_hmac_update(&ctx, challenge, NTLMSSP_CHALLENGE_SIZE);
8f30fd
+	openssl_hmac_update(&ctx, blob, blob_size);
8f30fd
+	openssl_hmac_final(&ctx, response);
8f30fd
 
8f30fd
 	safe_memset(hash, 0, sizeof(hash));
8f30fd
 }
8f30fd
diff -up dovecot-2.3.8/src/lib/pkcs5.c.opensslhmac dovecot-2.3.8/src/lib/pkcs5.c
8f30fd
--- dovecot-2.3.8/src/lib/pkcs5.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/pkcs5.c	2019-11-19 16:34:11.340036994 +0100
8f30fd
@@ -52,7 +52,7 @@ int pkcs5_pbkdf2(const struct hash_metho
8f30fd
 	size_t l = (length + hash->digest_size - 1)/hash->digest_size; /* same as ceil(length/hash->digest_size) */
8f30fd
 	unsigned char dk[l * hash->digest_size];
8f30fd
 	unsigned char *block;
8f30fd
-	struct hmac_context hctx;
8f30fd
+	struct openssl_hmac_context hctx;
8f30fd
 	unsigned int c,i,t;
8f30fd
 	unsigned char U_c[hash->digest_size];
8f30fd
 
8f30fd
@@ -60,17 +60,17 @@ int pkcs5_pbkdf2(const struct hash_metho
8f30fd
 		block = &(dk[t*hash->digest_size]);
8f30fd
 		/* U_1 = PRF(Password, Salt|| INT_BE32(Block_Number)) */
8f30fd
 		c = htonl(t+1);
8f30fd
-		hmac_init(&hctx, password, password_len, hash);
8f30fd
-		hmac_update(&hctx, salt, salt_len);
8f30fd
-		hmac_update(&hctx, &c, sizeof(c));
8f30fd
-		hmac_final(&hctx, U_c);
8f30fd
+		openssl_hmac_init(&hctx, password, password_len, hash);
8f30fd
+		openssl_hmac_update(&hctx, salt, salt_len);
8f30fd
+		openssl_hmac_update(&hctx, &c, sizeof(c));
8f30fd
+		openssl_hmac_final(&hctx, U_c);
8f30fd
 		/* block = U_1 ^ .. ^ U_iter */
8f30fd
 		memcpy(block, U_c, hash->digest_size);
8f30fd
 		/* U_c = PRF(Password, U_c-1) */
8f30fd
 		for(c = 1; c < iter; c++) {
8f30fd
-			hmac_init(&hctx, password, password_len, hash);
8f30fd
-			hmac_update(&hctx, U_c, hash->digest_size);
8f30fd
-			hmac_final(&hctx, U_c);
8f30fd
+			openssl_hmac_init(&hctx, password, password_len, hash);
8f30fd
+			openssl_hmac_update(&hctx, U_c, hash->digest_size);
8f30fd
+			openssl_hmac_final(&hctx, U_c);
8f30fd
 			for(i = 0; i < hash->digest_size; i++)
8f30fd
 				block[i] ^= U_c[i];
8f30fd
 		}
8f30fd
diff -up dovecot-2.3.8/src/lib/test-hmac.c.opensslhmac dovecot-2.3.8/src/lib/test-hmac.c
8f30fd
--- dovecot-2.3.8/src/lib/test-hmac.c.opensslhmac	2019-10-08 10:46:18.000000000 +0200
8f30fd
+++ dovecot-2.3.8/src/lib/test-hmac.c	2019-11-19 16:34:11.340036994 +0100
8f30fd
@@ -112,11 +112,11 @@ static void test_hmac_rfc(void)
8f30fd
 	test_begin("hmac sha256 rfc4231 vectors");
8f30fd
 	for(size_t i = 0; i < N_ELEMENTS(test_vectors); i++) {
8f30fd
 		const struct test_vector *vec = &(test_vectors[i]);
8f30fd
-		struct hmac_context ctx;
8f30fd
-		hmac_init(&ctx, vec->key, vec->key_len, hash_method_lookup(vec->prf));
8f30fd
-		hmac_update(&ctx, vec->data, vec->data_len);
8f30fd
+		struct openssl_hmac_context ctx;
8f30fd
+		openssl_hmac_init(&ctx, vec->key, vec->key_len, hash_method_lookup(vec->prf));
8f30fd
+		openssl_hmac_update(&ctx, vec->data, vec->data_len);
8f30fd
 		unsigned char res[SHA256_RESULTLEN];
8f30fd
-		hmac_final(&ctx, res);
8f30fd
+		openssl_hmac_final(&ctx, res);
8f30fd
 		test_assert_idx(memcmp(res, vec->res, vec->res_len) == 0, i);
8f30fd
 	}
8f30fd
 	test_end();
8f30fd
@@ -129,7 +129,7 @@ static void test_hmac_buffer(void)
8f30fd
 
8f30fd
 	buffer_t *tmp;
8f30fd
 
8f30fd
-	tmp = t_hmac_data(hash_method_lookup(vec->prf), vec->key, vec->key_len,
8f30fd
+	tmp = openssl_t_hmac_data(hash_method_lookup(vec->prf), vec->key, vec->key_len,
8f30fd
 			  vec->data, vec->data_len);
8f30fd
 
8f30fd
 	test_assert(tmp->used == vec->res_len &&
8f30fd
@@ -146,7 +146,7 @@ static void test_hkdf_rfc(void)
8f30fd
 		buffer_set_used_size(res, 0);
8f30fd
 		const struct test_vector_5869 *vec = &(test_vectors_5869[i]);
8f30fd
 		const struct hash_method *m = hash_method_lookup(vec->prf);
8f30fd
-		hmac_hkdf(m, vec->salt, vec->salt_len, vec->ikm, vec->ikm_len,
8f30fd
+		openssl_hmac_hkdf(m, vec->salt, vec->salt_len, vec->ikm, vec->ikm_len,
8f30fd
 			  vec->info, vec->info_len, res, vec->okm_len);
8f30fd
 		test_assert_idx(memcmp(res->data, vec->okm, vec->okm_len) == 0, i);
8f30fd
 	}
8f30fd
@@ -159,7 +159,7 @@ static void test_hkdf_buffer(void)
8f30fd
 	test_begin("hkdf temporary buffer");
8f30fd
 	const struct test_vector_5869 *vec = &(test_vectors_5869[0]);
8f30fd
 	const struct hash_method *m = hash_method_lookup(vec->prf);
8f30fd
-	buffer_t *tmp = t_hmac_hkdf(m, vec->salt, vec->salt_len, vec->ikm,
8f30fd
+	buffer_t *tmp = openssl_t_hmac_hkdf(m, vec->salt, vec->salt_len, vec->ikm,
8f30fd
 				    vec->ikm_len, vec->info, vec->info_len,
8f30fd
 				    vec->okm_len);
8f30fd
 	test_assert(tmp->used == vec->okm_len &&