Skip to content

Commit 328903c

Browse files
authored
Merge pull request #459 from banburybill/release/1.6.0-rc.1
Tighten Nettle version checking, and fix build issue with Nettle >= 3.4.
2 parents e2cb4fc + ab49db8 commit 328903c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,19 @@ endif()
365365
# handle digital signature algorithms. GnuTLS uses Nettle internally.
366366
if (USE_GNUTLS)
367367
find_package(GnuTLS "3.5.0" REQUIRED)
368-
find_package(Nettle REQUIRED)
368+
find_package(Nettle "3.2" REQUIRED)
369369

370370
set(tlsdir "gnutls")
371371
set(HAVE_NETTLE 1)
372372

373373
set(CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR})
374+
set(CMAKE_REQUIRED_LIBRARIES ${NETTLE_LIBRARIES})
374375
check_include_file(nettle/dsa-compat.h HAVE_NETTLE_DSA_COMPAT_H)
375376
check_include_file(nettle/eddsa.h HAVE_NETTLE_EDDSA_H)
377+
378+
# API change in Nettle 3.4.
379+
check_symbol_exists(nettle_get_secp_256r1 "nettle/ecc-curve.h" HAVE_NETTLE_GET_SECP_256R1)
380+
check_symbol_exists(nettle_get_secp_384r1 "nettle/ecc-curve.h" HAVE_NETTLE_GET_SECP_384R1)
376381
endif()
377382

378383
# Sort out what signature algorithms can be used.
@@ -390,7 +395,7 @@ endif ()
390395

391396
if (USE_ED448)
392397
if (USE_GNUTLS)
393-
message(WARNING "ED448 enabled and Nettle does not support it. Disabled.")
398+
message(WARNING "ED448 enabled and Nettle support not implemented. Disabled.")
394399
unset(USE_ED448)
395400
elseif (NOT HAVE_SSL_ED448)
396401
message(WARNING "ED448 enabled and OpenSSL does not support it. Disabled.")

cmake/include/cmakeconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979

8080
#cmakedefine HAVE_HMAC_CTX_NEW 1
8181

82+
#cmakedefine HAVE_NETTLE_GET_SECP_256R1 1
83+
#cmakedefine HAVE_NETTLE_GET_SECP_384R1 1
84+
8285
#cmakedefine HAVE_TLS_CLIENT_METHOD 1
8386

8487
#cmakedefine HAVE_OPENSSL_VERSION_NUM 1

src/tls/val_secalgo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,11 @@ _verify_nettle_ecdsa(sldns_buffer* buf, unsigned int digest_size, unsigned char*
17261726
{
17271727
uint8_t digest[SHA256_DIGEST_SIZE];
17281728
mpz_t x, y;
1729+
#ifdef HAVE_NETTLE_GET_SECP_256R1
1730+
nettle_ecc_point_init(&pubkey, nettle_get_secp_256r1());
1731+
#else
17291732
nettle_ecc_point_init(&pubkey, &nettle_secp_256r1);
1733+
#endif
17301734
nettle_mpz_init_set_str_256_u(x, SHA256_DIGEST_SIZE, key);
17311735
nettle_mpz_init_set_str_256_u(y, SHA256_DIGEST_SIZE, key+SHA256_DIGEST_SIZE);
17321736
nettle_mpz_set_str_256_u(signature.r, SHA256_DIGEST_SIZE, sigblock);
@@ -1743,7 +1747,11 @@ _verify_nettle_ecdsa(sldns_buffer* buf, unsigned int digest_size, unsigned char*
17431747
{
17441748
uint8_t digest[SHA384_DIGEST_SIZE];
17451749
mpz_t x, y;
1750+
#ifdef HAVE_NETTLE_GET_SECP_384R1
1751+
nettle_ecc_point_init(&pubkey, nettle_get_secp_384r1());
1752+
#else
17461753
nettle_ecc_point_init(&pubkey, &nettle_secp_384r1);
1754+
#endif
17471755
nettle_mpz_init_set_str_256_u(x, SHA384_DIGEST_SIZE, key);
17481756
nettle_mpz_init_set_str_256_u(y, SHA384_DIGEST_SIZE, key+SHA384_DIGEST_SIZE);
17491757
nettle_mpz_set_str_256_u(signature.r, SHA384_DIGEST_SIZE, sigblock);

0 commit comments

Comments
 (0)