Update dependency nettle to v4 (#2872)
* Update dependency nettle to v4 * Fix incompatibility with Nettle 4.x --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FooIbar <118464521+FooIbar@users.noreply.github.com>
This commit is contained in:
1 parent
f6b43cb7e3
commit
956a3ac1fd
3 files changed
+58
-4
No files matched your search
@@ -0,0 +1,53 @@
|
||||
From 6a3d059507dd23e981090909e6f42f79f6de2a39 Mon Sep 17 00:00:00 2001
|
||||
From: FooIbar <118464521+FooIbar@users.noreply.github.com>
|
||||
Date: Fri, 6 Feb 2026 20:52:25 +0800
|
||||
Subject: [PATCH] Fix incompatibility with Nettle 4.x
|
||||
|
||||
---
|
||||
libarchive/archive_cryptor_private.h | 4 ++++
|
||||
libarchive/archive_hmac.c | 6 ++++++
|
||||
2 files changed, 10 insertions(+)
|
||||
|
||||
diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h
|
||||
index 367d7c3b..069eccd9 100644
|
||||
--- a/libarchive/archive_cryptor_private.h
|
||||
+++ b/libarchive/archive_cryptor_private.h
|
||||
@@ -109,6 +109,10 @@ typedef struct {
|
||||
#include <nettle/version.h>
|
||||
#define ARCHIVE_CRYPTOR_USE_NETTLE 1
|
||||
|
||||
+#ifndef AES_MAX_KEY_SIZE
|
||||
+#define AES_MAX_KEY_SIZE AES256_KEY_SIZE
|
||||
+#endif
|
||||
+
|
||||
typedef struct {
|
||||
#if NETTLE_VERSION_MAJOR < 3
|
||||
struct aes_ctx ctx;
|
||||
diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c
|
||||
index edb3bf5a..e1e8f05f 100644
|
||||
--- a/libarchive/archive_hmac.c
|
||||
+++ b/libarchive/archive_hmac.c
|
||||
@@ -198,6 +198,7 @@ static void __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
|
||||
+#include <nettle/version.h>
|
||||
|
||||
static int
|
||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
@@ -216,7 +217,12 @@ __hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
||||
static void
|
||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
||||
{
|
||||
+#if NETTLE_VERSION_MAJOR < 4
|
||||
hmac_sha1_digest(ctx, (unsigned)*out_len, out);
|
||||
+#else
|
||||
+ hmac_sha1_digest(ctx, out);
|
||||
+ *out_len = SHA1_DIGEST_SIZE;
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.51.0
|
||||
|
||||
@@ -47,7 +47,7 @@ if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
else ()
|
||||
set(TOOLCHAIN "${ANDROID_TOOLCHAIN_ROOT}/bin")
|
||||
endif ()
|
||||
set(CONFIGURE_COMMAND ./.bootstrap && ./configure --disable-public-key --disable-dependency-tracking
|
||||
set(CONFIGURE_COMMAND ${WSL} ./.bootstrap && ${WSL} ./configure --disable-public-key --disable-dependency-tracking
|
||||
"--host=${CMAKE_C_COMPILER_TARGET}"
|
||||
"CFLAGS=${CMAKE_C_FLAGS} -Qunused-arguments"
|
||||
"AR=${TOOLCHAIN}/llvm-ar"
|
||||
@@ -57,10 +57,10 @@ set(CONFIGURE_COMMAND ./.bootstrap && ./configure --disable-public-key --disable
|
||||
ExternalProject_Add(
|
||||
nettle
|
||||
GIT_REPOSITORY https://gitlab.com/gnutls/nettle.git
|
||||
GIT_TAG nettle_3.10.2_release_20250626
|
||||
GIT_TAG nettle_4.0_release_20260205
|
||||
GIT_SHALLOW 1
|
||||
GIT_CONFIG core.autocrlf=input
|
||||
CONFIGURE_COMMAND ${WSL} ${CONFIGURE_COMMAND}
|
||||
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
|
||||
BUILD_COMMAND ${WSL} make -j4 libnettle.a
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
@@ -99,6 +99,7 @@ option(ENABLE_TEST OFF)
|
||||
set(LIBARCHIVE_PATCH
|
||||
${CMAKE_CURRENT_LIST_DIR}/0001-Fix-zip_time-performance.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0002-Use-UTF-8-as-default-charset-on-bionic.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0003-Fix-incompatibility-with-Nettle-4.x.patch
|
||||
)
|
||||
FetchContent_Declare(
|
||||
libarchive
|
||||
|
||||
@@ -24,7 +24,7 @@ Java_com_hippo_ehviewer_jni_HashKt_sha1(JNIEnv *env, jclass clazz, jint fd) {
|
||||
}
|
||||
|
||||
byte digest[SHA1_DIGEST_SIZE];
|
||||
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
|
||||
sha1_digest(&ctx, digest);
|
||||
|
||||
byte byte;
|
||||
char hex_digest[2 * SHA1_DIGEST_SIZE + 1];
|
||||
|
||||
Reference in new issue
Block a user