]> the.earth.li Git - onak.git/commitdiff
Fix compilation with later versions of Nettle
authorJonathan McDowell <noodles@earth.li>
Sun, 13 Sep 2020 10:45:54 +0000 (11:45 +0100)
committerJonathan McDowell <noodles@earth.li>
Sun, 13 Sep 2020 10:45:54 +0000 (11:45 +0100)
Need to actually check for the appropriate symbols existing; the header
file alone is not enough to have them defined.

CMakeLists.txt
build-config.h.in
sigcheck.c

index 87f34a57c8f3fe911e0b2aa6a41165a79e7bde87..3acea5cc27cdb34205cf2b1498079a8bfcc912dd 100644 (file)
@@ -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
index 48e4c87776714cb4e4a369f3fd86c8fdba98c4d2..7da2d83b9c67fb2cea180ab4974f3ee9c01d3543 100644 (file)
@@ -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
 
index ff806046b3d9866b657bb8afc3fd39cb6e54ee36..9a29dfc4b5451b439b82f0c56e9e08437b458b26 100644 (file)
 #include <nettle/rsa.h>
 #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