From 3da81770b841f841c5145f91a9ccedc296e13f4b Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sun, 13 Sep 2020 11:45:54 +0100 Subject: [PATCH] Fix compilation with later versions of Nettle Need to actually check for the appropriate symbols existing; the header file alone is not enough to have them defined. --- CMakeLists.txt | 8 ++++++++ build-config.h.in | 3 +++ sigcheck.c | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87f34a5..3acea5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(onak VERSION 0.6.0 LANGUAGES C) +include(CheckSymbolExists) include(FindPkgConfig) include(GNUInstallDirs) include(TestBigEndian) @@ -60,6 +61,13 @@ if (GMP_FOUND) target_include_directories(libonak SYSTEM PUBLIC ${GMP_INCLUDE_DIRS} ${HOGWEED_INCLUDE_DIRS}) LIST(APPEND LIBONAK_LIBRARIES ${GMP_LIBRARY} ${HOGWEED_LIBRARIES}) + + set(CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${NETTLE_LIBRARIES} ${HOGWEED_LIBRARIES}) + # API change in later version of Nettle + CHECK_SYMBOL_EXISTS(nettle_get_secp_256r1 "nettle/ecc-curve.h" HAVE_NETTLE_GET_SECP_256R1) + CHECK_SYMBOL_EXISTS(nettle_get_secp_384r1 "nettle/ecc-curve.h" HAVE_NETTLE_GET_SECP_384R1) + CHECK_SYMBOL_EXISTS(nettle_get_secp_521r1 "nettle/ecc-curve.h" HAVE_NETTLE_GET_SECP_521R1) endif() # Build files that have substitutions in them diff --git a/build-config.h.in b/build-config.h.in index 48e4c87..7da2d83 100644 --- a/build-config.h.in +++ b/build-config.h.in @@ -5,6 +5,9 @@ #cmakedefine HAVE_CRYPTO 1 #cmakedefine HAVE_NETTLE 1 +#cmakedefine HAVE_NETTLE_GET_SECP_256R1 1 +#cmakedefine HAVE_NETTLE_GET_SECP_384R1 1 +#cmakedefine HAVE_NETTLE_GET_SECP_521R1 1 #cmakedefine HAVE_SYSTEMD 1 #cmakedefine WORDS_BIGENDIAN 1 diff --git a/sigcheck.c b/sigcheck.c index ff80604..9a29dfc 100644 --- a/sigcheck.c +++ b/sigcheck.c @@ -49,13 +49,13 @@ #include #include "rsa.h" -#ifndef nettle_get_secp_256r1 +#ifndef HAVE_NETTLE_GET_SECP_256R1 #define nettle_get_secp_256r1() &nettle_secp_256r1 #endif -#ifndef nettle_get_secp_384r1 +#ifndef HAVE_NETTLE_GET_SECP_384R1 #define nettle_get_secp_384r1() &nettle_secp_384r1 #endif -#ifndef nettle_get_secp_521r1 +#ifndef HAVE_NETTLE_GET_SECP_521R1 #define nettle_get_secp_521r1() &nettle_secp_521r1 #endif -- 2.39.2