← Commit list

cfadbaa133

Xi Ruoyao
Xi Ruoyao
2026-05-12
SUCCESS Duration: 219s

Subject

gnutls: allow building with nettle 4.0

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/curl_sha512_256.c+6 -1
@@ -75,7 +75,8 @@
#endif
#if !defined(HAS_SHA512_256_IMPLEMENTATION) && defined(USE_GNUTLS)
-# include <nettle/sha.h>
+# include <nettle/sha2.h>
+# include <nettle/version.h>
# ifdef SHA512_256_DIGEST_SIZE
# define USE_GNUTLS_SHA512_256 1
# endif
@@ -281,8 +282,12 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context)
{
Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context;
+#if NETTLE_VERSION_MAJOR >= 4
+ sha512_256_digest(ctx, (uint8_t *)digest);
+#else
sha512_256_digest(ctx,
(size_t)CURL_SHA512_256_DIGEST_SIZE, (uint8_t *)digest);
+#endif
return CURLE_OK;
}
lib/md5.c+5 -0
@@ -47,6 +47,7 @@
#ifdef USE_GNUTLS
#include <nettle/md5.h>
+#include <nettle/version.h>
typedef struct md5_ctx my_md5_ctx;
@@ -64,7 +65,11 @@ static void my_md5_update(void *ctx,
static void my_md5_final(unsigned char *digest, void *ctx)
{
+#if NETTLE_VERSION_MAJOR >= 4
+ md5_digest(ctx, digest);
+#else
md5_digest(ctx, 16, digest);
+#endif
}
#elif defined(USE_OPENSSL) && \
lib/sha256.c+6 -1
@@ -113,7 +113,8 @@ static void my_sha256_final(unsigned char *digest, void *in)
}
#elif defined(USE_GNUTLS)
-#include <nettle/sha.h>
+#include <nettle/sha2.h>
+#include <nettle/version.h>
typedef struct sha256_ctx my_sha256_ctx;
@@ -132,7 +133,11 @@ static void my_sha256_update(void *ctx,
static void my_sha256_final(unsigned char *digest, void *ctx)
{
+#if NETTLE_VERSION_MAJOR >= 4
+ sha256_digest(ctx, digest);
+#else
sha256_digest(ctx, SHA256_DIGEST_SIZE, digest);
+#endif
}
#elif defined(USE_MBEDTLS) && \
lib/vtls/gtls.c+5 -0
@@ -37,6 +37,7 @@
#include <gnutls/x509.h>
#include <gnutls/crypto.h>
#include <nettle/sha2.h>
+#include <nettle/version.h>
#include "urldata.h"
#include "curl_trc.h"
@@ -2268,7 +2269,11 @@ static CURLcode gtls_sha256sum(const unsigned char *tmp, /* input */
struct sha256_ctx SHA256pw;
sha256_init(&SHA256pw);
sha256_update(&SHA256pw, (unsigned int)tmplen, tmp);
+#if NETTLE_VERSION_MAJOR >= 4
+ sha256_digest(&SHA256pw, sha256sum);
+#else
sha256_digest(&SHA256pw, (unsigned int)sha256len, sha256sum);
+#endif
return CURLE_OK;
}
m4/curl-gnutls.m4+2 -2
@@ -145,7 +145,7 @@ dnl
if test "$GNUTLS_ENABLED" = "1"; then
USE_GNUTLS_NETTLE=
dnl First check if we can detect either crypto library via transitive linking
- AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
+ AC_CHECK_LIB(gnutls, nettle_md5_init, [ USE_GNUTLS_NETTLE=1 ])
dnl If not, try linking directly to both of them to see if they are available
if test -z "$USE_GNUTLS_NETTLE"; then
@@ -174,7 +174,7 @@ if test "$GNUTLS_ENABLED" = "1"; then
CPPFLAGS="$CPPFLAGS $addcflags"
fi
- AC_CHECK_LIB(nettle, nettle_MD5Init,
+ AC_CHECK_LIB(nettle, nettle_md5_init,
[
USE_GNUTLS_NETTLE=1
],