Blame SOURCES/gnutls-3.7.8-revert-hmac-name.patch

a74aed
diff --color -ruNp a/configure.ac b/configure.ac
a74aed
--- a/configure.ac	2022-05-27 09:17:26.000000000 +0200
a74aed
+++ b/configure.ac	2022-12-15 11:00:18.830698584 +0100
a74aed
@@ -619,6 +619,8 @@ if [ test "$enable_fips" = "yes" ];then
a74aed
     if test "x$fips_module_version" != xnone; then
a74aed
        AC_DEFINE_UNQUOTED([FIPS_MODULE_VERSION], ["$fips_module_version"], [The FIPS140 module version])
a74aed
     fi
a74aed
+
a74aed
+    AC_CHECK_FUNCS(dl_iterate_phdr)
a74aed
   else
a74aed
     enable_fips=no
a74aed
     AC_MSG_WARN([[
a74aed
diff --color -ruNp a/lib/fips.c b/lib/fips.c
a74aed
--- a/lib/fips.c	2022-12-15 10:59:57.460279029 +0100
a74aed
+++ b/lib/fips.c	2022-12-15 11:00:18.831698604 +0100
a74aed
@@ -23,9 +23,11 @@
a74aed
 #include <gnutls/gnutls.h>
a74aed
 #include <gnutls/crypto.h>
a74aed
 #include <unistd.h>
a74aed
+#include "dirname.h"
a74aed
 #include "errors.h"
a74aed
 #include "file.h"
a74aed
 #include "inih/ini.h"
a74aed
+#include "str.h"
a74aed
 #include <fips.h>
a74aed
 #include <gnutls/self-test.h>
a74aed
 #include <stdio.h>
a74aed
@@ -34,6 +36,10 @@
a74aed
 
a74aed
 #include "gthreads.h"
a74aed
 
a74aed
+#ifdef HAVE_DL_ITERATE_PHDR
a74aed
+#include <link.h>
a74aed
+#endif
a74aed
+
a74aed
 unsigned int _gnutls_lib_state = LIB_STATE_POWERON;
a74aed
 
a74aed
 struct gnutls_fips140_context_st {
a74aed
@@ -153,7 +159,6 @@ void _gnutls_fips_mode_reset_zombie(void
a74aed
 
a74aed
 #define HMAC_SIZE 32
a74aed
 #define HMAC_ALGO GNUTLS_MAC_SHA256
a74aed
-#define HMAC_FILE_NAME ".gnutls.hmac"
a74aed
 #define HMAC_FORMAT_VERSION 1
a74aed
 
a74aed
 struct hmac_entry
a74aed
@@ -162,51 +167,32 @@ struct hmac_entry
a74aed
 	uint8_t hmac[HMAC_SIZE];
a74aed
 };
a74aed
 
a74aed
-typedef struct
a74aed
+struct hmac_file
a74aed
 {
a74aed
 	int version;
a74aed
 	struct hmac_entry gnutls;
a74aed
 	struct hmac_entry nettle;
a74aed
 	struct hmac_entry hogweed;
a74aed
 	struct hmac_entry gmp;
a74aed
-} hmac_file;
a74aed
+};
a74aed
 
a74aed
-static int get_library_path(const char* lib, const char* symbol, char* path, size_t path_size)
a74aed
+struct lib_paths
a74aed
 {
a74aed
-	int ret;
a74aed
-	void *dl, *sym;
a74aed
-	Dl_info info;
a74aed
-
a74aed
-	dl = dlopen(lib, RTLD_LAZY);
a74aed
-	if (dl == NULL)
a74aed
-		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-
a74aed
-	sym = dlsym(dl, symbol);
a74aed
-	if (sym == NULL) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = dladdr(sym, &info;;
a74aed
-	if (ret == 0) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = snprintf(path, path_size, "%s", info.dli_fname);
a74aed
-	if ((size_t)ret >= path_size) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = 0;
a74aed
-cleanup:
a74aed
-	dlclose(dl);
a74aed
-	return ret;
a74aed
-}
a74aed
+	char gnutls[GNUTLS_PATH_MAX];
a74aed
+	char nettle[GNUTLS_PATH_MAX];
a74aed
+	char hogweed[GNUTLS_PATH_MAX];
a74aed
+	char gmp[GNUTLS_PATH_MAX];
a74aed
+};
a74aed
 
a74aed
-/* Parses hmac data and copies hex value into dest.
a74aed
+/*
a74aed
+ * get_hmac:
a74aed
+ * @dest: buffer for the hex value
a74aed
+ * @value: hmac value
a74aed
+ *
a74aed
+ * Parses hmac data and copies hex value into dest.
a74aed
  * dest must point to at least HMAC_SIZE amount of memory
a74aed
+ *
a74aed
+ * Returns: 0 on success, a negative error code otherwise
a74aed
  */
a74aed
 static int get_hmac(uint8_t *dest, const char *value)
a74aed
 {
a74aed
@@ -245,7 +231,7 @@ lib_handler(struct hmac_entry *entry,
a74aed
 
a74aed
 static int handler(void *user, const char *section, const char *name, const char *value)
a74aed
 {
a74aed
-	hmac_file *p = (hmac_file *)user;
a74aed
+	struct hmac_file *p = (struct hmac_file *)user;
a74aed
 
a74aed
 	if (!strcmp(section, "global")) {
a74aed
 		if (!strcmp(name, "format-version")) {
a74aed
@@ -267,24 +253,29 @@ static int handler(void *user, const cha
a74aed
 	return 1;
a74aed
 }
a74aed
 
a74aed
-static int get_hmac_path(char *mac_file, size_t mac_file_size)
a74aed
+/*
a74aed
+ * get_hmac_path:
a74aed
+ * @mac_file: buffer where the hmac file path will be written to
a74aed
+ * @mac_file_size: size of the mac_file buffer
a74aed
+ * @gnutls_path: path to the gnutls library, used to deduce hmac file path
a74aed
+ * 
a74aed
+ * Deduces hmac file path from the gnutls library path.
a74aed
+ *
a74aed
+ * Returns: 0 on success, a negative error code otherwise
a74aed
+ */
a74aed
+static int get_hmac_path(char *mac_file, size_t mac_file_size, const char *gnutls_path)
a74aed
 {
a74aed
 	int ret;
a74aed
 	char *p;
a74aed
-	char file[GNUTLS_PATH_MAX];
a74aed
 
a74aed
-	ret = get_library_path(GNUTLS_LIBRARY_NAME, "gnutls_global_init",
a74aed
-			       file, sizeof(file));
a74aed
-	if (ret < 0)
a74aed
-		return ret;
a74aed
-
a74aed
-	p = strrchr(file, '/');
a74aed
+	p = strrchr(gnutls_path, '/');
a74aed
 
a74aed
 	if (p == NULL)
a74aed
-		ret = snprintf(mac_file, mac_file_size, HMAC_FILE_NAME);
a74aed
+		ret = snprintf(mac_file, mac_file_size, ".%s.hmac", gnutls_path);
a74aed
 	else
a74aed
-		ret = snprintf(mac_file, mac_file_size,
a74aed
-			       "%.*s/"HMAC_FILE_NAME, (int)(p - file), file);
a74aed
+		ret = snprintf(mac_file, mac_file_size, "%.*s/.%s.hmac",
a74aed
+			       (int)(p - gnutls_path), gnutls_path, p + 1);
a74aed
+
a74aed
 	if ((size_t)ret >= mac_file_size)
a74aed
 		return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
a74aed
 
a74aed
@@ -293,10 +284,11 @@ static int get_hmac_path(char *mac_file,
a74aed
 		return GNUTLS_E_SUCCESS;
a74aed
 
a74aed
 	if (p == NULL)
a74aed
-		ret = snprintf(mac_file, mac_file_size, "fipscheck/"HMAC_FILE_NAME);
a74aed
+		ret = snprintf(mac_file, mac_file_size, "fipscheck/.%s.hmac", gnutls_path);
a74aed
 	else
a74aed
-		ret = snprintf(mac_file, mac_file_size,
a74aed
-			       "%.*s/fipscheck/"HMAC_FILE_NAME, (int)(p - file), file);
a74aed
+		ret = snprintf(mac_file, mac_file_size, "%.*s/fipscheck/.%s.hmac",
a74aed
+			       (int)(p - gnutls_path), gnutls_path, p + 1);
a74aed
+
a74aed
 	if ((size_t)ret >= mac_file_size)
a74aed
 		return gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
a74aed
 
a74aed
@@ -307,51 +299,52 @@ static int get_hmac_path(char *mac_file,
a74aed
 	return GNUTLS_E_FILE_ERROR;
a74aed
 }
a74aed
 
a74aed
-static int load_hmac_file(hmac_file *p)
a74aed
+/*
a74aed
+ * load_hmac_file:
a74aed
+ * @hmac_file: hmac file structure
a74aed
+ * @hmac_path: path to the hmac file
a74aed
+ *
a74aed
+ * Loads the hmac file into the hmac file structure.
a74aed
+ *
a74aed
+ * Returns: 0 on success, a negative error code otherwise
a74aed
+ */
a74aed
+static int load_hmac_file(struct hmac_file *hmac_file, const char *hmac_path)
a74aed
 {
a74aed
 	int ret;
a74aed
 	FILE *stream;
a74aed
-	char hmac_path[GNUTLS_PATH_MAX];
a74aed
-
a74aed
-	ret = get_hmac_path(hmac_path, sizeof(hmac_path));
a74aed
-	if (ret < 0)
a74aed
-		return gnutls_assert_val(ret);
a74aed
 
a74aed
 	stream = fopen(hmac_path, "r");
a74aed
 	if (stream == NULL)
a74aed
 		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
 
a74aed
-	gnutls_memset(p, 0, sizeof(*p));
a74aed
-	ret = ini_parse_file(stream, handler, p);
a74aed
+	gnutls_memset(hmac_file, 0, sizeof(*hmac_file));
a74aed
+	ret = ini_parse_file(stream, handler, hmac_file);
a74aed
 	fclose(stream);
a74aed
 	if (ret < 0)
a74aed
 		return gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
a74aed
 
a74aed
-	if (p->version != HMAC_FORMAT_VERSION)
a74aed
+	if (hmac_file->version != HMAC_FORMAT_VERSION)
a74aed
 		return gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
a74aed
 
a74aed
 	return 0;
a74aed
 }
a74aed
 
a74aed
-/* Run an HMAC using the key above on the library binary data.
a74aed
- * Returns 0 on success and negative value on error.
a74aed
+/*
a74aed
+ * check_lib_hmac:
a74aed
+ * @entry: hmac file entry
a74aed
+ * @path: path to the library which hmac should be compared
a74aed
+ *
a74aed
+ * Verify that HMAC from hmac file entry matches HMAC of given library.
a74aed
+ *
a74aed
+ * Returns: 0 on successful HMAC verification, a negative error code otherwise
a74aed
  */
a74aed
-static int check_lib_hmac(struct hmac_entry *entry,
a74aed
-			  const char *lib, const char *sym)
a74aed
+static int check_lib_hmac(struct hmac_entry *entry, const char *path)
a74aed
 {
a74aed
 	int ret;
a74aed
 	unsigned prev;
a74aed
-	char path[GNUTLS_PATH_MAX];
a74aed
 	uint8_t hmac[HMAC_SIZE];
a74aed
 	gnutls_datum_t data;
a74aed
 
a74aed
-	ret = get_library_path(lib, sym, path, sizeof(path));
a74aed
-	if (ret < 0) {
a74aed
-		_gnutls_debug_log("Could not get lib path for %s: %s\n",
a74aed
-				  lib, gnutls_strerror(ret));
a74aed
-		return gnutls_assert_val(ret);
a74aed
-	}
a74aed
-
a74aed
 	_gnutls_debug_log("Loading: %s\n", path);
a74aed
 	ret = gnutls_load_file(path, &data);
a74aed
 	if (ret < 0) {
a74aed
@@ -382,28 +375,99 @@ static int check_lib_hmac(struct hmac_en
a74aed
 	return 0;
a74aed
 }
a74aed
 
a74aed
+#ifdef HAVE_DL_ITERATE_PHDR
a74aed
+
a74aed
+static int callback(struct dl_phdr_info *info, size_t size, void *data)
a74aed
+{
a74aed
+	const char *path = info->dlpi_name;
a74aed
+	const char *soname = last_component(path);
a74aed
+	struct lib_paths *paths = (struct lib_paths *)data;
a74aed
+
a74aed
+	if (!strcmp(soname, GNUTLS_LIBRARY_SONAME))
a74aed
+		_gnutls_str_cpy(paths->gnutls, GNUTLS_PATH_MAX, path);
a74aed
+	else if (!strcmp(soname, NETTLE_LIBRARY_SONAME))
a74aed
+		_gnutls_str_cpy(paths->nettle, GNUTLS_PATH_MAX, path);
a74aed
+	else if (!strcmp(soname, HOGWEED_LIBRARY_SONAME))
a74aed
+		_gnutls_str_cpy(paths->hogweed, GNUTLS_PATH_MAX, path);
a74aed
+	else if (!strcmp(soname, GMP_LIBRARY_SONAME))
a74aed
+		_gnutls_str_cpy(paths->gmp, GNUTLS_PATH_MAX, path);
a74aed
+	return 0;
a74aed
+}
a74aed
+
a74aed
+static int load_lib_paths(struct lib_paths *paths)
a74aed
+{
a74aed
+	memset(paths, 0, sizeof(*paths));
a74aed
+	dl_iterate_phdr(callback, paths);
a74aed
+	
a74aed
+	if (paths->gnutls[0] == '\0') {
a74aed
+		_gnutls_debug_log("Gnutls library path was not found\n");
a74aed
+		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
+	}
a74aed
+	if (paths->nettle[0] == '\0') {
a74aed
+		_gnutls_debug_log("Nettle library path was not found\n");
a74aed
+		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
+	}
a74aed
+	if (paths->hogweed[0] == '\0') {
a74aed
+		_gnutls_debug_log("Hogweed library path was not found\n");
a74aed
+		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
+	}
a74aed
+	if (paths->gmp[0] == '\0') {
a74aed
+		_gnutls_debug_log("Gmp library path was not found\n");
a74aed
+		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
+	}
a74aed
+
a74aed
+	return GNUTLS_E_SUCCESS;
a74aed
+}
a74aed
+
a74aed
+#else
a74aed
+
a74aed
+static int load_lib_paths(struct lib_paths *paths)
a74aed
+{
a74aed
+	(void)paths;
a74aed
+	_gnutls_debug_log("Function dl_iterate_phdr is missing\n");
a74aed
+	return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
a74aed
+}
a74aed
+
a74aed
+#endif /* HAVE_DL_ITERATE_PHDR */
a74aed
+
a74aed
 static int check_binary_integrity(void)
a74aed
 {
a74aed
 	int ret;
a74aed
-	hmac_file file;
a74aed
+	struct lib_paths paths;
a74aed
+	struct hmac_file hmac;
a74aed
+	char hmac_path[GNUTLS_PATH_MAX];
a74aed
+
a74aed
+	ret = load_lib_paths(&paths);
a74aed
+	if (ret < 0) {
a74aed
+		_gnutls_debug_log("Could not load library paths: %s\n",
a74aed
+				  gnutls_strerror(ret));
a74aed
+		return ret;
a74aed
+	}
a74aed
+
a74aed
+	ret = get_hmac_path(hmac_path, sizeof(hmac_path), paths.gnutls);
a74aed
+	if (ret < 0) {
a74aed
+		_gnutls_debug_log("Could not get hmac file path: %s\n",
a74aed
+				  gnutls_strerror(ret));
a74aed
+		return ret;
a74aed
+	}
a74aed
 
a74aed
-	ret = load_hmac_file(&file;;
a74aed
+	ret = load_hmac_file(&hmac, hmac_path);
a74aed
 	if (ret < 0) {
a74aed
 		_gnutls_debug_log("Could not load hmac file: %s\n",
a74aed
 				  gnutls_strerror(ret));
a74aed
 		return ret;
a74aed
 	}
a74aed
 
a74aed
-	ret = check_lib_hmac(&file.gnutls, GNUTLS_LIBRARY_NAME, "gnutls_global_init");
a74aed
+	ret = check_lib_hmac(&hmac.gnutls, paths.gnutls);
a74aed
 	if (ret < 0)
a74aed
 		return ret;
a74aed
-	ret = check_lib_hmac(&file.nettle, NETTLE_LIBRARY_NAME, "nettle_aes_set_encrypt_key");
a74aed
+	ret = check_lib_hmac(&hmac.nettle, paths.nettle);
a74aed
 	if (ret < 0)
a74aed
 		return ret;
a74aed
-	ret = check_lib_hmac(&file.hogweed, HOGWEED_LIBRARY_NAME, "nettle_mpz_sizeinbase_256_u");
a74aed
+	ret = check_lib_hmac(&hmac.hogweed, paths.hogweed);
a74aed
 	if (ret < 0)
a74aed
 		return ret;
a74aed
-	ret = check_lib_hmac(&file.gmp, GMP_LIBRARY_NAME, "__gmpz_init");
a74aed
+	ret = check_lib_hmac(&hmac.gmp, paths.gmp);
a74aed
 	if (ret < 0)
a74aed
 		return ret;
a74aed
 
a74aed
diff --color -ruNp a/lib/fipshmac.c b/lib/fipshmac.c
a74aed
--- a/lib/fipshmac.c	2022-12-15 10:59:57.461279049 +0100
a74aed
+++ b/lib/fipshmac.c	2022-12-15 11:00:18.832698623 +0100
a74aed
@@ -22,12 +22,14 @@
a74aed
 
a74aed
 #include "config.h"
a74aed
 
a74aed
-#include <gnutls/gnutls.h>
a74aed
-#include <gnutls/crypto.h>
a74aed
-#include <dlfcn.h>
a74aed
-#include <stdint.h>
a74aed
 #include <stdio.h>
a74aed
 #include <stdlib.h>
a74aed
+
a74aed
+#ifdef HAVE_DL_ITERATE_PHDR
a74aed
+
a74aed
+#include <gnutls/gnutls.h>
a74aed
+#include <gnutls/crypto.h>
a74aed
+#include <link.h>
a74aed
 #include "dirname.h"
a74aed
 #include "errors.h"
a74aed
 
a74aed
@@ -36,40 +38,6 @@
a74aed
 #define HMAC_ALGO GNUTLS_MAC_SHA256
a74aed
 #define HMAC_STR_SIZE (2 * HMAC_SIZE + 1)
a74aed
 
a74aed
-static int get_path(const char *lib, const char *symbol, char *path, size_t path_size)
a74aed
-{
a74aed
-	int ret;
a74aed
-	void *dl, *sym;
a74aed
-	Dl_info info;
a74aed
-
a74aed
-	dl = dlopen(lib, RTLD_LAZY);
a74aed
-	if (dl == NULL)
a74aed
-		return gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-
a74aed
-	sym = dlsym(dl, symbol);
a74aed
-	if (sym == NULL) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = dladdr(sym, &info;;
a74aed
-	if (ret == 0) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_FILE_ERROR);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = snprintf(path, path_size, "%s", info.dli_fname);
a74aed
-	if ((size_t)ret >= path_size) {
a74aed
-		ret = gnutls_assert_val(GNUTLS_E_SHORT_MEMORY_BUFFER);
a74aed
-		goto cleanup;
a74aed
-	}
a74aed
-
a74aed
-	ret = 0;
a74aed
-cleanup:
a74aed
-	dlclose(dl);
a74aed
-	return ret;
a74aed
-}
a74aed
-
a74aed
 static int get_hmac(const char *path, char *hmac, size_t hmac_size)
a74aed
 {
a74aed
 	int ret;
a74aed
@@ -99,7 +67,7 @@ static int get_hmac(const char *path, ch
a74aed
 	return 0;
a74aed
 }
a74aed
 
a74aed
-static int print_lib_path(const char *path)
a74aed
+static int print_lib(const char *path, const char *soname)
a74aed
 {
a74aed
 	int ret;
a74aed
 	char *real_path = NULL;
a74aed
@@ -119,7 +87,7 @@ static int print_lib_path(const char *pa
a74aed
 		goto cleanup;
a74aed
 	}
a74aed
 
a74aed
-	printf("[%s]\n", last_component(path));
a74aed
+	printf("[%s]\n", soname);
a74aed
 	printf("path = %s\n", real_path);
a74aed
 	printf("hmac = %s\n", hmac);
a74aed
 
a74aed
@@ -128,25 +96,24 @@ cleanup:
a74aed
 	return ret;
a74aed
 }
a74aed
 
a74aed
-static int print_lib_dl(const char *lib, const char *sym)
a74aed
+static int callback(struct dl_phdr_info *info, size_t size, void *data)
a74aed
 {
a74aed
-	int ret;
a74aed
-	char path[GNUTLS_PATH_MAX];
a74aed
-
a74aed
-	ret = get_path(lib, sym, path, sizeof(path));
a74aed
-	if (ret < 0) {
a74aed
-		fprintf(stderr, "Could not get lib path for %s: %s\n",
a74aed
-                        lib, gnutls_strerror(ret));
a74aed
-		return ret;
a74aed
-	}
a74aed
+	const char *path = info->dlpi_name;
a74aed
+	const char *soname = last_component(path);
a74aed
 
a74aed
-	return print_lib_path(path);
a74aed
+	if (!strcmp(soname, GNUTLS_LIBRARY_SONAME))
a74aed
+		return print_lib(data ? data : path, soname);
a74aed
+	if (!strcmp(soname, NETTLE_LIBRARY_SONAME))
a74aed
+		return print_lib(path, soname);
a74aed
+	if (!strcmp(soname, HOGWEED_LIBRARY_SONAME))
a74aed
+		return print_lib(path, soname);
a74aed
+	if (!strcmp(soname, GMP_LIBRARY_SONAME))
a74aed
+		return print_lib(path, soname);
a74aed
+        return 0;
a74aed
 }
a74aed
 
a74aed
 int main(int argc, char **argv)
a74aed
 {
a74aed
-	int ret;
a74aed
-
a74aed
 	if (argc != 1 && argc != 2) {
a74aed
 		fprintf(stderr, "Usage: %s [gnutls_so_path]\n", last_component(argv[0]));
a74aed
 		return EXIT_FAILURE;
a74aed
@@ -155,24 +122,15 @@ int main(int argc, char **argv)
a74aed
 	printf("[global]\n");
a74aed
 	printf("format-version = %d\n", FORMAT_VERSION);
a74aed
 
a74aed
-	if (argc == 2)
a74aed
-		ret = print_lib_path(argv[1]);
a74aed
-	else
a74aed
-		ret = print_lib_dl(GNUTLS_LIBRARY_SONAME, "gnutls_global_init");
a74aed
-	if (ret < 0)
a74aed
-		return EXIT_FAILURE;
a74aed
+	return dl_iterate_phdr(callback, argc == 2 ? argv[1] : NULL);
a74aed
+}
a74aed
 
a74aed
-	ret = print_lib_dl(NETTLE_LIBRARY_SONAME, "nettle_aes_set_encrypt_key");
a74aed
-	if (ret < 0)
a74aed
-		return EXIT_FAILURE;
a74aed
-	
a74aed
-	ret = print_lib_dl(HOGWEED_LIBRARY_SONAME, "nettle_mpz_sizeinbase_256_u");
a74aed
-	if (ret < 0)
a74aed
-		return EXIT_FAILURE;
a74aed
-	
a74aed
-	ret = print_lib_dl(GMP_LIBRARY_SONAME, "__gmpz_init");
a74aed
-	if (ret < 0)
a74aed
-		return EXIT_FAILURE;
a74aed
+#else
a74aed
 
a74aed
-	return EXIT_SUCCESS;
a74aed
+int main(void)
a74aed
+{
a74aed
+	fprintf(stderr, "Function dl_iterate_phdr is missing\n");
a74aed
+	return EXIT_FAILURE;
a74aed
 }
a74aed
+
a74aed
+#endif /* HAVE_DL_ITERATE_PHDR */
a74aed
diff --color -ruNp a/lib/Makefile.am b/lib/Makefile.am
a74aed
--- a/lib/Makefile.am	2022-05-18 16:46:00.000000000 +0200
a74aed
+++ b/lib/Makefile.am	2022-12-15 11:00:18.789697779 +0100
a74aed
@@ -202,14 +202,14 @@ noinst_PROGRAMS = fipshmac
a74aed
 fipshmac_SOURCES = fipshmac.c
a74aed
 fipshmac_LDADD = libgnutls.la ../gl/libgnu.la
a74aed
 
a74aed
-hmac_files = .libs/.gnutls.hmac
a74aed
+hmac_file = .libs/.$(gnutls_so).hmac
a74aed
 
a74aed
-all-local: $(hmac_files)
a74aed
+all-local: $(hmac_file)
a74aed
 
a74aed
-.libs/.gnutls.hmac: libgnutls.la fipshmac
a74aed
+$(hmac_file): libgnutls.la fipshmac
a74aed
 	$(AM_V_GEN) $(builddir)/fipshmac > $@-t && mv $@-t $@
a74aed
 
a74aed
-CLEANFILES = $(hmac_files)
a74aed
+CLEANFILES = $(hmac_file)
a74aed
 endif
a74aed
 
a74aed
 if NEED_LTLIBDL