public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Yaakov Selkowitz <yselkowi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/gnutls] rawhide: Bundle nettle on RHEL
Date: Tue, 15 Sep 2026 13:30:06 GMT	[thread overview]
Message-ID: <178947900690.1.4640827640269939991.rpms-gnutls-b9f4117f005d@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/gnutls
            Branch : rawhide
            Commit : b9f4117f005d12b9b4beb2d4716fe11cf66871bb
            Author : Yaakov Selkowitz <yselkowi@redhat.com>
            Date   : 2026-08-17T23:06:35-04:00
            Stats  : +1119/-2 in 5 file(s)
            URL    : https://src.fedoraproject.org/rpms/gnutls/c/b9f4117f005d12b9b4beb2d4716fe11cf66871bb?branch=rawhide

            Log:
            Bundle nettle on RHEL

https://gitlab.com/redhat/centos-stream/rpms/gnutls/-/commit/112336b5f6c8cadfb0f3e82dea8daa7b44811f7d
https://gitlab.com/redhat/centos-stream/rpms/gnutls/-/commit/a317e16f725bd59472a3317bed4e35b4f3701251
https://gitlab.com/redhat/centos-stream/rpms/gnutls/-/commit/893a2b5110dc8b0b55ede800e94874d98c094848

---
diff --git a/.gitignore b/.gitignore
index 3161056..750874d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -178,3 +178,6 @@ gnutls-2.10.1-nosrp.tar.bz2
 /gnutls-3.8.13.tar.xz
 /gnutls-3.8.13.tar.xz.sig
 /gmp-6.3.0.tar.xz
+/nettle-4.0.tar.gz
+/nettle-4.0.tar.gz.sig
+/nettle-release-keyring.gpg

diff --git a/gnutls.spec b/gnutls.spec
index c536d5c..6eaf19c 100644
--- a/gnutls.spec
+++ b/gnutls.spec
@@ -52,6 +52,12 @@ Patch: gnutls-3.8.8-tests-ktls-skip-tls12-chachapoly.patch
 %bcond_with bundled_gmp
 %endif
 
+%if 0%{?rhel} >= 10 && %{with fips}
+%bcond_without bundled_nettle
+%else
+%bcond_with bundled_nettle
+%endif
+
 
 %define fips_requires() %{lua:
 local f = assert(io.popen("rpm -q --queryformat '%{EVR}' --whatprovides "..rpm.expand("'%1%{?_isa}'")))
@@ -72,7 +78,9 @@ BuildRequires: zlib-devel, brotli-devel, libzstd-devel
 %if %{with bootstrap}
 BuildRequires: automake, autoconf, gperf, libtool, texinfo
 %endif
+%if !%{with bundled_nettle}
 BuildRequires: nettle-devel >= 3.10.1
+%endif
 %if %{with leancrypto}
 BuildRequires: meson
 %endif
@@ -96,8 +104,10 @@ BuildRequires: p11-kit-trust, ca-certificates
 Requires: crypto-policies
 Requires: p11-kit-trust
 Requires: libtasn1 >= 4.3
+%if !%{with bundled_nettle}
 # always bump when a nettle release is packaged
 Requires: nettle >= 3.10.1
+%endif
 %if %{with tpm12}
 Recommends: trousers >= 0.3.11.2
 %endif
@@ -141,6 +151,16 @@ Source102:	gmp-6.3.0-c23.patch
 Source103:      gmp-6.3.0-s390x-popcount.patch
 %endif
 
+%if %{with bundled_nettle}
+Provides:	bundled(nettle) = 4.0
+Source200:	nettle-4.0.tar.gz
+# Taken from the main nettle package
+Source201:	nettle-4.0.tar.gz.sig
+Source202:	nettle-release-keyring.gpg
+Source203:	nettle-4.0-zeroize-stack.patch
+Source204:	nettle-4.0-hobble-to-configure.patch
+%endif
+
 %if %{with leancrypto}
 Provides:	bundled(leancrypto) = 1.6.0
 Source300:	leancrypto-1.6.0.tar.gz
@@ -180,7 +200,9 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
 %package fips
 Summary: Virtual package to install packages required to use %{name} under FIPS mode
 Requires: %{name}%{?_isa} = %{version}-%{release}
+%if !%{with bundled_nettle}
 %{fips_requires nettle}
+%endif
 %if !%{with bundled_gmp}
 %{fips_requires gmp}
 %endif
@@ -279,6 +301,17 @@ patch -p1 < %{SOURCE103}
 popd
 %endif
 
+%if %{with bundled_nettle}
+%{gpgverify} --keyring='%{SOURCE202}' --signature='%{SOURCE201}' --data='%{SOURCE200}'
+
+mkdir -p bundled_nettle
+pushd bundled_nettle
+tar --strip-components=1 -xf %{SOURCE200}
+patch -p1 < %{SOURCE203}
+patch -p1 < %{SOURCE204}
+popd
+%endif
+
 %build
 %define _lto_cflags %{nil}
 
@@ -296,8 +329,39 @@ autoreconf -ifv
 %make_build
 popd
 
-export GMP_CFLAGS="-I$PWD/bundled_gmp"
-export GMP_LIBS="$PWD/bundled_gmp/.libs/libgmp.a"
+export GMP_DIR="$PWD/bundled_gmp"
+export GMP_CFLAGS="-I$GMP_DIR"
+export GMP_LIBS="$GMP_DIR/.libs/libgmp.a"
+%endif
+
+%if %{with bundled_nettle}
+pushd bundled_nettle
+./.bootstrap
+
+# Disable -ggdb3 which makes debugedit unhappy
+sed s/ggdb3/g/ -i configure
+
+autoreconf -ifv
+# For annocheck
+export ASM_FLAGS="-Wa,--generate-missing-build-notes=yes"
+CFLAGS="$CFLAGS -I$GMP_DIR" \
+LDFLAGS="$LDFLAGS -L$GMP_DIR/.libs" \
+%configure --disable-shared --enable-fat \
+	   --disable-sm3 --disable-sm4 \
+	   --disable-ecc-secp192r1 --disable-ecc-secp224r1 \
+	   --disable-documentation \
+	   %{nil}
+%make_build
+ln -s . nettle
+popd
+
+export NETTLE_DIR="$PWD/bundled_nettle"
+
+export NETTLE_CFLAGS="-I$NETTLE_DIR"
+export NETTLE_LIBS="$NETTLE_DIR/libnettle.a"
+
+export HOGWEED_CFLAGS="-I$NETTLE_DIR"
+export HOGWEED_LIBS="$NETTLE_DIR/libhogweed.a $NETTLE_LIBS $GMP_LIBS"
 %endif
 
 %if %{with leancrypto}
@@ -418,6 +482,11 @@ pushd native_build
            --with-default-priority-string="@SYSTEM"
 
 %make_build
+
+%if %{with bundled_nettle}
+sed -i '/^Requires.private:/s/\(nettle\|hogweed\)[ ,]*//g' lib/gnutls.pc
+%endif
+
 %if %{with leancrypto}
 sed -i '/^Requires.private:/s/leancrypto[ ,]*//g' lib/gnutls.pc
 %endif

diff --git a/nettle-4.0-hobble-to-configure.patch b/nettle-4.0-hobble-to-configure.patch
new file mode 100644
index 0000000..6f7bea0
--- /dev/null
+++ b/nettle-4.0-hobble-to-configure.patch
@@ -0,0 +1,749 @@
+From 6678d620a1d04b1e2661f124a72d02ed529c03ec Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <dueno@redhat.com>
+Date: Wed, 24 Jul 2024 15:19:01 +0900
+Subject: [PATCH 1/3] Add --disable-sm3 configure option
+
+Signed-off-by: Daiki Ueno <dueno@redhat.com>
+---
+ Makefile.in                 |  8 +++++---
+ configure.ac                | 14 ++++++++++++++
+ examples/nettle-benchmark.c |  8 +++++++-
+ nettle-meta-hashes.c        |  2 ++
+ nettle-meta-macs.c          |  2 ++
+ testsuite/Makefile.in       |  4 +++-
+ testsuite/hmac-test.c       |  2 ++
+ testsuite/meta-hash-test.c  |  2 ++
+ testsuite/meta-mac-test.c   |  2 ++
+ 9 files changed, 39 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 93999850..d66183ba 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -134,11 +134,11 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
+ 		 gost28147.c gosthash94.c gosthash94-meta.c \
+ 		 hmac-internal.c hmac-gosthash94.c hmac-md5.c hmac-ripemd160.c \
+ 		 hmac-sha1.c hmac-sha224.c hmac-sha256.c hmac-sha384.c \
+-		 hmac-sha512.c hmac-streebog.c hmac-sm3.c \
++		 hmac-sha512.c hmac-streebog.c \
+ 		 hmac-md5-meta.c hmac-ripemd160-meta.c hmac-sha1-meta.c \
+ 		 hmac-sha224-meta.c hmac-sha256-meta.c hmac-sha384-meta.c \
+ 		 hmac-sha512-meta.c hmac-gosthash94-meta.c \
+-		 hmac-streebog-meta.c hmac-sm3-meta.c \
++		 hmac-streebog-meta.c \
+ 		 knuth-lfib.c hkdf.c \
+ 		 md2.c md2-meta.c md4.c md4-meta.c \
+ 		 md5.c md5-meta.c \
+@@ -164,7 +164,6 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
+ 		 sha3-224.c sha3-224-meta.c sha3-256.c sha3-256-meta.c \
+ 		 sha3-384.c sha3-384-meta.c sha3-512.c sha3-512-meta.c \
+ 		 sha3-shake.c shake128.c shake256.c \
+-		 sm3.c sm3-meta.c \
+ 		 serpent-set-key.c serpent-encrypt.c serpent-decrypt.c \
+ 		 serpent-meta.c \
+ 		 streebog.c streebog-meta.c \
+@@ -240,6 +239,9 @@ hogweed_SOURCES = sexp.c sexp-format.c \
+ 		  ed448-shake256.c ed448-shake256-pubkey.c \
+ 		  ed448-shake256-sign.c ed448-shake256-verify.c
+ 
++
++nettle_SOURCES += @IF_SM3@ hmac-sm3.c hmac-sm3-meta.c sm3.c sm3-meta.c
++
+ OPT_SOURCES = fat-arm.c fat-arm64.c fat-ppc.c fat-s390x.c fat-x86_64.c mini-gmp.c
+ 
+ HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h balloon.h \
+diff --git a/configure.ac b/configure.ac
+index af017d81..1bbf449f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -108,6 +108,10 @@ AC_ARG_ENABLE(mini-gmp,
+   AS_HELP_STRING([--enable-mini-gmp], [Enable mini-gmp, used instead of libgmp.]),,
+   [enable_mini_gmp=no])
+ 
++AC_ARG_ENABLE(sm3,
++  AS_HELP_STRING([--disable-sm3], [Disable SM3 hash algorithm]),,
++  [enable_sm3=yes])
++
+ AC_ARG_VAR(ASM_FLAGS, [Extra flags for processing assembly source files])
+ 
+ if test "x$enable_mini_gmp" = xyes ; then
+@@ -1097,6 +1101,15 @@ else
+   IF_MINI_GMP='#'
+ fi
+   
++AH_TEMPLATE([WITH_SM3], [Defined if SM3 hash algorithm is enabled])
++
++if test "x$enable_sm3" = xyes ; then
++  AC_DEFINE(WITH_SM3)
++  IF_SM3=''
++else
++  IF_SM3='#'
++fi
++
+ AC_SUBST(IF_HOGWEED)
+ AC_SUBST(IF_STATIC)
+ AC_SUBST(IF_SHARED)
+@@ -1105,6 +1118,7 @@ AC_SUBST(IF_DLOPEN_TEST)
+ AC_SUBST(IF_DOCUMENTATION)
+ AC_SUBST(IF_DLL)
+ AC_SUBST(IF_MINI_GMP)
++AC_SUBST(IF_SM3)
+ 
+ OPENSSL_LIBFLAGS=''
+ 
+diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c
+index 70c4513e..1f176cae 100644
+--- a/examples/nettle-benchmark.c
++++ b/examples/nettle-benchmark.c
+@@ -896,6 +896,12 @@ bench_ghash_update(void)
+ # define OPENSSL(x)
+ #endif
+ 
++#if WITH_SM3
++# define SM3(x) x,
++#else
++# define SM3(x)
++#endif
++
+ int
+ main(int argc, char **argv)
+ {
+@@ -915,7 +921,7 @@ main(int argc, char **argv)
+       &nettle_sha3_384, &nettle_sha3_512,
+       &nettle_ripemd160, &nettle_gosthash94,
+       &nettle_gosthash94cp, &nettle_streebog256,
+-      &nettle_streebog512, &nettle_sm3,
++      &nettle_streebog512, SM3(&nettle_sm3)
+       NULL
+     };
+ 
+diff --git a/nettle-meta-hashes.c b/nettle-meta-hashes.c
+index 2245dfb7..6d4563d9 100644
+--- a/nettle-meta-hashes.c
++++ b/nettle-meta-hashes.c
+@@ -57,7 +57,9 @@ const struct nettle_hash * const _nettle_hashes[] = {
+   &nettle_sha3_512,
+   &nettle_streebog256,
+   &nettle_streebog512,
++#if WITH_SM3
+   &nettle_sm3,
++#endif
+   NULL
+ };
+ 
+diff --git a/nettle-meta-macs.c b/nettle-meta-macs.c
+index 48b2176e..866f0766 100644
+--- a/nettle-meta-macs.c
++++ b/nettle-meta-macs.c
+@@ -52,7 +52,9 @@ const struct nettle_mac * const _nettle_macs[] = {
+   &nettle_hmac_sha512,
+   &nettle_hmac_streebog256,
+   &nettle_hmac_streebog512,
++#if WITH_SM3
+   &nettle_hmac_sm3,
++#endif
+   NULL
+ };
+ 
+diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
+index b2f0518c..01f52ccd 100644
+--- a/testsuite/Makefile.in
++++ b/testsuite/Makefile.in
+@@ -25,7 +25,7 @@ TS_NETTLE_SOURCES = aes-test.c aes-keywrap-test.c arcfour-test.c arctwo-test.c \
+ 		    sha3-permute-test.c sha3-224-test.c sha3-256-test.c \
+ 		    sha3-384-test.c sha3-512-test.c \
+ 		    shake128-test.c shake256-test.c \
+-		    streebog-test.c sm3-test.c sm4-test.c \
++		    streebog-test.c sm4-test.c \
+ 		    serpent-test.c twofish-test.c version-test.c \
+ 		    knuth-lfib-test.c \
+ 		    cbc-test.c cfb-test.c ctr-test.c gcm-test.c eax-test.c ccm-test.c \
+@@ -61,6 +61,8 @@ TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
+ 		     gostdsa-sign-test.c gostdsa-verify-test.c \
+ 		     gostdsa-keygen-test.c gostdsa-vko-test.c
+ 
++TS_NETTLE_SOURCES += @IF_SM3@ sm3-test.c
++
+ TS_SOURCES = $(TS_NETTLE_SOURCES) $(TS_HOGWEED_SOURCES)
+ CXX_SOURCES = cxx-test.cxx
+ 
+diff --git a/testsuite/hmac-test.c b/testsuite/hmac-test.c
+index d7af2475..d34127bf 100644
+--- a/testsuite/hmac-test.c
++++ b/testsuite/hmac-test.c
+@@ -949,9 +949,11 @@ test_main (void)
+ 	    SHEX("a1aa5f7de402d7b3d323f2991c8d4534"
+ 		 "013137010a83754fd0af6d7cd4922ed9"));
+ 
++#if WITH_SM3
+   test_mac (&nettle_hmac_sm3, (nettle_hash_update_func*) hmac_sm3_set_key,
+ 	    SDATA("monkey monkey monkey monkey"),
+ 	    SDATA("abc"),
+ 	    SHEX("7a9388e2ca5343b5d76e7c2c3d84f239"
+ 		 "f306c0b60d5e0dc4d2771e42860a6a2b"));
++#endif
+ }
+diff --git a/testsuite/meta-hash-test.c b/testsuite/meta-hash-test.c
+index ec4e0d1e..8427e0a1 100644
+--- a/testsuite/meta-hash-test.c
++++ b/testsuite/meta-hash-test.c
+@@ -24,7 +24,9 @@ const char* hashes[] = {
+   "sha3_512",
+   "streebog256",
+   "streebog512",
++#if WITH_SM3
+   "sm3",
++#endif
+ };
+ 
+ void
+diff --git a/testsuite/meta-mac-test.c b/testsuite/meta-mac-test.c
+index 6c848a88..c00efd3c 100644
+--- a/testsuite/meta-mac-test.c
++++ b/testsuite/meta-mac-test.c
+@@ -16,7 +16,9 @@ const char* macs[] = {
+   "hmac_sha512",
+   "hmac_streebog256",
+   "hmac_streebog512",
++#if WITH_SM3
+   "hmac_sm3",
++#endif
+ };
+ 
+ void
+-- 
+2.53.0
+
+
+From 2346de14d0fcf5db78458406ac0f533dfc062694 Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <dueno@redhat.com>
+Date: Wed, 24 Jul 2024 15:28:13 +0900
+Subject: [PATCH 2/3] Add --disable-sm4 configure option
+
+Signed-off-by: Daiki Ueno <dueno@redhat.com>
+---
+ Makefile.in                  |  3 +--
+ configure.ac                 | 14 ++++++++++++++
+ examples/nettle-benchmark.c  |  8 +++++++-
+ nettle-meta-aeads.c          |  2 ++
+ nettle-meta-ciphers.c        |  2 ++
+ testsuite/Makefile.in        |  3 ++-
+ testsuite/gcm-test.c         |  2 ++
+ testsuite/meta-aead-test.c   |  2 ++
+ testsuite/meta-cipher-test.c |  4 +++-
+ 9 files changed, 35 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index d66183ba..c74e2b7d 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -128,7 +128,6 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
+ 		 gcm-aes256.c gcm-aes256-meta.c \
+ 		 gcm-camellia128.c gcm-camellia128-meta.c \
+ 		 gcm-camellia256.c gcm-camellia256-meta.c \
+-		 gcm-sm4.c gcm-sm4-meta.c \
+ 		 cmac.c cmac64.c cmac-aes128.c cmac-aes256.c cmac-des3.c \
+ 		 cmac-aes128-meta.c cmac-aes256-meta.c cmac-des3-meta.c \
+ 		 gost28147.c gosthash94.c gosthash94-meta.c \
+@@ -168,7 +167,6 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt-table.c \
+ 		 serpent-meta.c \
+ 		 streebog.c streebog-meta.c \
+ 		 twofish.c twofish-meta.c \
+-		 sm4.c sm4-meta.c \
+ 		 umac-nh.c umac-nh-n.c umac-l2.c umac-l3.c \
+ 		 umac-poly64.c umac-poly128.c umac-set-key.c \
+ 		 umac32.c umac64.c umac96.c umac128.c \
+@@ -241,6 +239,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
+ 
+ 
+ nettle_SOURCES += @IF_SM3@ hmac-sm3.c hmac-sm3-meta.c sm3.c sm3-meta.c
++nettle_SOURCES += @IF_SM4@ gcm-sm4.c gcm-sm4-meta.c sm4.c sm4-meta.c
+ 
+ OPT_SOURCES = fat-arm.c fat-arm64.c fat-ppc.c fat-s390x.c fat-x86_64.c mini-gmp.c
+ 
+diff --git a/configure.ac b/configure.ac
+index 1bbf449f..61470275 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -112,6 +112,10 @@ AC_ARG_ENABLE(sm3,
+   AS_HELP_STRING([--disable-sm3], [Disable SM3 hash algorithm]),,
+   [enable_sm3=yes])
+ 
++AC_ARG_ENABLE(sm4,
++  AS_HELP_STRING([--disable-sm4], [Disable SM4 symmetric cipher algorithm]),,
++  [enable_sm4=yes])
++
+ AC_ARG_VAR(ASM_FLAGS, [Extra flags for processing assembly source files])
+ 
+ if test "x$enable_mini_gmp" = xyes ; then
+@@ -1110,6 +1114,15 @@ else
+   IF_SM3='#'
+ fi
+ 
++AH_TEMPLATE([WITH_SM4], [Defined if SM4 symmetric cipher is enabled])
++
++if test "x$enable_sm4" = xyes ; then
++  AC_DEFINE(WITH_SM4)
++  IF_SM4=''
++else
++  IF_SM4='#'
++fi
++
+ AC_SUBST(IF_HOGWEED)
+ AC_SUBST(IF_STATIC)
+ AC_SUBST(IF_SHARED)
+@@ -1119,6 +1132,7 @@ AC_SUBST(IF_DOCUMENTATION)
+ AC_SUBST(IF_DLL)
+ AC_SUBST(IF_MINI_GMP)
+ AC_SUBST(IF_SM3)
++AC_SUBST(IF_SM4)
+ 
+ OPENSSL_LIBFLAGS=''
+ 
+diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c
+index 1f176cae..f938ac20 100644
+--- a/examples/nettle-benchmark.c
++++ b/examples/nettle-benchmark.c
+@@ -902,6 +902,12 @@ bench_ghash_update(void)
+ # define SM3(x)
+ #endif
+ 
++#if WITH_SM4
++# define SM4(x) x,
++#else
++# define SM4(x)
++#endif
++
+ int
+ main(int argc, char **argv)
+ {
+@@ -938,7 +944,7 @@ main(int argc, char **argv)
+       &nettle_des3,
+       &nettle_serpent256,
+       &nettle_twofish128, &nettle_twofish192, &nettle_twofish256,
+-      &nettle_sm4,
++      SM4(&nettle_sm4)
+       NULL
+     };
+ 
+diff --git a/nettle-meta-aeads.c b/nettle-meta-aeads.c
+index 78f38a3c..c94fecd5 100644
+--- a/nettle-meta-aeads.c
++++ b/nettle-meta-aeads.c
+@@ -43,7 +43,9 @@ const struct nettle_aead * const _nettle_aeads[] = {
+   &nettle_gcm_aes256,
+   &nettle_gcm_camellia128,
+   &nettle_gcm_camellia256,
++#if WITH_SM4
+   &nettle_gcm_sm4,
++#endif
+   &nettle_eax_aes128,
+   &nettle_chacha_poly1305,
+   NULL
+diff --git a/nettle-meta-ciphers.c b/nettle-meta-ciphers.c
+index f8d691cf..6a84a43a 100644
+--- a/nettle-meta-ciphers.c
++++ b/nettle-meta-ciphers.c
+@@ -54,7 +54,9 @@ const struct nettle_cipher * const _nettle_ciphers[] = {
+   &nettle_arctwo64,
+   &nettle_arctwo128,
+   &nettle_arctwo_gutmann128,
++#if WITH_SM4
+   &nettle_sm4,
++#endif
+   NULL
+ };
+ 
+diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
+index 01f52ccd..f24fdc3f 100644
+--- a/testsuite/Makefile.in
++++ b/testsuite/Makefile.in
+@@ -25,7 +25,7 @@ TS_NETTLE_SOURCES = aes-test.c aes-keywrap-test.c arcfour-test.c arctwo-test.c \
+ 		    sha3-permute-test.c sha3-224-test.c sha3-256-test.c \
+ 		    sha3-384-test.c sha3-512-test.c \
+ 		    shake128-test.c shake256-test.c \
+-		    streebog-test.c sm4-test.c \
++		    streebog-test.c \
+ 		    serpent-test.c twofish-test.c version-test.c \
+ 		    knuth-lfib-test.c \
+ 		    cbc-test.c cfb-test.c ctr-test.c gcm-test.c eax-test.c ccm-test.c \
+@@ -62,6 +62,7 @@ TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
+ 		     gostdsa-keygen-test.c gostdsa-vko-test.c
+ 
+ TS_NETTLE_SOURCES += @IF_SM3@ sm3-test.c
++TS_NETTLE_SOURCES += @IF_SM4@ sm4-test.c
+ 
+ TS_SOURCES = $(TS_NETTLE_SOURCES) $(TS_HOGWEED_SOURCES)
+ CXX_SOURCES = cxx-test.cxx
+diff --git a/testsuite/gcm-test.c b/testsuite/gcm-test.c
+index db3b8090..3227d88f 100644
+--- a/testsuite/gcm-test.c
++++ b/testsuite/gcm-test.c
+@@ -775,6 +775,7 @@ test_main(void)
+ 		 "16aedbf5a0de6a57 a637b39b"),	/* iv */
+ 	    SHEX("5791883f822013f8bd136fc36fb9946b"));	/* tag */
+ 
++#if WITH_SM4
+   /*
+    * GCM-SM4 Test Vectors from
+    * https://datatracker.ietf.org/doc/html/rfc8998
+@@ -792,6 +793,7 @@ test_main(void)
+ 	         "A56834CBCF98C397B4024A2691233B8D"),
+ 	    SHEX("00001234567800000000ABCD"),
+ 	    SHEX("83DE3541E4C2B58177E065A9BF7B62EC"));
++#endif
+ 
+   /* Test gcm_hash, with varying message size, keys and iv all zero.
+      Not compared to any other implementation. */
+diff --git a/testsuite/meta-aead-test.c b/testsuite/meta-aead-test.c
+index ceeca227..d1a3193f 100644
+--- a/testsuite/meta-aead-test.c
++++ b/testsuite/meta-aead-test.c
+@@ -8,7 +8,9 @@ const char* aeads[] = {
+   "gcm_aes256",
+   "gcm_camellia128",
+   "gcm_camellia256",
++#if WITH_SM4
+   "gcm_sm4",
++#endif
+   "eax_aes128",
+   "chacha_poly1305",
+ };
+diff --git a/testsuite/meta-cipher-test.c b/testsuite/meta-cipher-test.c
+index 912fac5a..b57fcbe1 100644
+--- a/testsuite/meta-cipher-test.c
++++ b/testsuite/meta-cipher-test.c
+@@ -20,7 +20,9 @@ const char* ciphers[] = {
+   "twofish128",
+   "twofish192",
+   "twofish256",
+-  "sm4"
++#if WITH_SM4
++  "sm4",
++#endif
+ };
+ 
+ void
+-- 
+2.53.0
+
+
+From 63499dc186c2c0379d0ca4c4591be0b85023cd74 Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <dueno@redhat.com>
+Date: Thu, 22 Aug 2024 10:49:46 +0900
+Subject: [PATCH 3/3] Add --disable-ecc-{secp192r1,secp224r1} configure option
+
+Signed-off-by: Daiki Ueno <dueno@redhat.com>
+---
+ Makefile.in                   |  5 ++++-
+ configure.ac                  | 36 ++++++++++++++++++++++++++++++++++-
+ examples/ecc-benchmark.c      |  4 ++++
+ examples/hogweed-benchmark.c  |  6 ++++++
+ testsuite/ecdh-test.c         |  4 ++++
+ testsuite/ecdsa-sign-test.c   |  6 ++++++
+ testsuite/ecdsa-verify-test.c |  4 ++++
+ testsuite/testutils.c         | 10 +++++++++-
+ 8 files changed, 72 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index c74e2b7d..775df3ca 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -214,7 +214,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
+ 		  ecc-mod-arith.c ecc-pp1-redc.c ecc-pm1-redc.c \
+ 		  ecc-curve25519.c ecc-curve448.c \
+ 		  ecc-gost-gc256b.c ecc-gost-gc512a.c \
+-		  ecc-secp192r1.c ecc-secp224r1.c ecc-secp256r1.c \
++		  ecc-secp256r1.c \
+ 		  ecc-secp384r1.c ecc-secp521r1.c \
+ 		  ecc-size.c ecc-j-to-a.c ecc-a-to-j.c \
+ 		  ecc-dup-jj.c ecc-add-jja.c ecc-add-jjj.c ecc-nonsec-add-jjj.c \
+@@ -241,6 +241,9 @@ hogweed_SOURCES = sexp.c sexp-format.c \
+ nettle_SOURCES += @IF_SM3@ hmac-sm3.c hmac-sm3-meta.c sm3.c sm3-meta.c
+ nettle_SOURCES += @IF_SM4@ gcm-sm4.c gcm-sm4-meta.c sm4.c sm4-meta.c
+ 
++hogweed_SOURCES += @IF_ECC_SECP192R1@ ecc-secp192r1.c
++hogweed_SOURCES += @IF_ECC_SECP224R1@ ecc-secp224r1.c
++
+ OPT_SOURCES = fat-arm.c fat-arm64.c fat-ppc.c fat-s390x.c fat-x86_64.c mini-gmp.c
+ 
+ HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h balloon.h \
+diff --git a/configure.ac b/configure.ac
+index 61470275..1e57707a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -116,6 +116,14 @@ AC_ARG_ENABLE(sm4,
+   AS_HELP_STRING([--disable-sm4], [Disable SM4 symmetric cipher algorithm]),,
+   [enable_sm4=yes])
+ 
++AC_ARG_ENABLE(ecc-secp192r1,
++  AS_HELP_STRING([--disable-ecc-secp192r1], [Disable NIST secp192r1 curve]),,
++  [enable_ecc_secp192r1=yes])
++
++AC_ARG_ENABLE(ecc-secp224r1,
++  AS_HELP_STRING([--disable-ecc-secp224r1], [Disable NIST secp224r1 curve]),,
++  [enable_ecc_secp224r1=yes])
++
+ AC_ARG_VAR(ASM_FLAGS, [Extra flags for processing assembly source files])
+ 
+ if test "x$enable_mini_gmp" = xyes ; then
+@@ -563,9 +571,15 @@ asm_nettle_optional_list="cpuid.asm cpu-facility.asm \
+ 
+ asm_hogweed_optional_list=""
+ if test "x$enable_public_key" = "xyes" ; then
+-  asm_hogweed_optional_list="ecc-secp192r1-modp.asm ecc-secp224r1-modp.asm \
++  asm_hogweed_optional_list="\
+     ecc-secp256r1-redc.asm ecc-secp384r1-modp.asm ecc-secp521r1-modp.asm \
+     ecc-curve25519-modp.asm ecc-curve448-modp.asm"
++  if test "x$enable_ecc_secp192r1" = "xyes" ; then
++    asm_hogweed_optional_list="ecc-secp192r1-modp.asm $asm_hogweed_optional_list"
++  fi
++  if test "x$enable_ecc_secp224r1" = "xyes" ; then
++    asm_hogweed_optional_list="ecc-secp224r1-modp.asm $asm_hogweed_optional_list"
++  fi
+ fi
+ 
+ OPT_NETTLE_OBJS=""
+@@ -1123,6 +1137,24 @@ else
+   IF_SM4='#'
+ fi
+ 
++AH_TEMPLATE([WITH_ECC_SECP192R1], [Defined if NIST secp192r1 curve is enabled])
++
++if test "x$enable_ecc_secp192r1" = xyes ; then
++  AC_DEFINE(WITH_ECC_SECP192R1)
++  IF_ECC_SECP192R1=''
++else
++  IF_ECC_SECP192R1='#'
++fi
++
++AH_TEMPLATE([WITH_ECC_SECP224R1], [Defined if NIST secp224r1 curve is enabled])
++
++if test "x$enable_ecc_secp224r1" = xyes ; then
++  AC_DEFINE(WITH_ECC_SECP224R1)
++  IF_ECC_SECP224R1=''
++else
++  IF_ECC_SECP224R1='#'
++fi
++
+ AC_SUBST(IF_HOGWEED)
+ AC_SUBST(IF_STATIC)
+ AC_SUBST(IF_SHARED)
+@@ -1133,6 +1165,8 @@ AC_SUBST(IF_DLL)
+ AC_SUBST(IF_MINI_GMP)
+ AC_SUBST(IF_SM3)
+ AC_SUBST(IF_SM4)
++AC_SUBST(IF_ECC_SECP192R1)
++AC_SUBST(IF_ECC_SECP224R1)
+ 
+ OPENSSL_LIBFLAGS=''
+ 
+diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c
+index 7e857f80..ebcced65 100644
+--- a/examples/ecc-benchmark.c
++++ b/examples/ecc-benchmark.c
+@@ -314,8 +314,12 @@ bench_curve (const struct ecc_curve *ecc)
+ }
+ 
+ const struct ecc_curve * const curves[] = {
++#if WITH_ECC_SECP192R1
+   &_nettle_secp_192r1,
++#endif
++#if WITH_ECC_SECP224R1
+   &_nettle_secp_224r1,
++#endif
+   &_nettle_curve25519,
+   &_nettle_secp_256r1,
+   &_nettle_secp_384r1,
+diff --git a/examples/hogweed-benchmark.c b/examples/hogweed-benchmark.c
+index 467631cd..22f8f0b9 100644
+--- a/examples/hogweed-benchmark.c
++++ b/examples/hogweed-benchmark.c
+@@ -414,6 +414,7 @@ bench_ecdsa_init (unsigned size)
+ 
+   switch (size)
+     {
++#if WITH_ECC_SECP192R1
+     case 192:
+       ecc = &_nettle_secp_192r1;
+       xs = "8e8e07360350fb6b7ad8370cfd32fa8c6bba785e6e200599";
+@@ -422,6 +423,8 @@ bench_ecdsa_init (unsigned size)
+       ctx->digest = hash_string (&nettle_sha1, "abc");
+       ctx->digest_size = 20;
+       break;
++#endif
++#if WITH_ECC_SECP224R1
+     case 224:
+       ecc = &_nettle_secp_224r1;
+       xs = "993bf363f4f2bc0f255f22563980449164e9c894d9efd088d7b77334";
+@@ -430,6 +433,7 @@ bench_ecdsa_init (unsigned size)
+       ctx->digest = hash_string (&nettle_sha224, "abc");
+       ctx->digest_size = 28;
+       break;
++#endif
+ 
+       /* From RFC 4754 */
+     case 256:
+@@ -977,7 +981,9 @@ struct alg alg_list[] = {
+ #if 0
+   { "dsa",2048, bench_dsa_init, bench_dsa_sign,   bench_dsa_verify, bench_dsa_clear },
+ #endif
++#if WITH_ECC_SECP192R1
+   { "ecdsa",  192, bench_ecdsa_init, bench_ecdsa_sign, bench_ecdsa_verify, bench_ecdsa_clear },
++#endif
+   { "ecdsa",  224, bench_ecdsa_init, bench_ecdsa_sign, bench_ecdsa_verify, bench_ecdsa_clear },
+   { "ecdsa",  256, bench_ecdsa_init, bench_ecdsa_sign, bench_ecdsa_verify, bench_ecdsa_clear },
+   { "ecdsa",  384, bench_ecdsa_init, bench_ecdsa_sign, bench_ecdsa_verify, bench_ecdsa_clear },
+diff --git a/testsuite/ecdh-test.c b/testsuite/ecdh-test.c
+index ff4f7233..f852d813 100644
+--- a/testsuite/ecdh-test.c
++++ b/testsuite/ecdh-test.c
+@@ -159,6 +159,7 @@ test_public_key (const char *label, const struct ecc_curve *ecc,
+ void
+ test_main(void)
+ {
++#if WITH_ECC_SECP192R1
+   test_public_key ("(0,0) with secp-192r1", &_nettle_secp_192r1, "0", "0", 0);
+   test_public_key (
+     "(P,0) with secp-192r1", &_nettle_secp_192r1,
+@@ -188,7 +189,9 @@ test_main(void)
+ 	   "293088185788565313717816218507714888251468410990708684573",
+ 	   "149293809021051532782730990145509724807636529827149481690",
+ 	   "2891131861147398318714693938158856874319184314120776776192");
++#endif
+ 
++#if WITH_ECC_SECP224R1
+   test_dh ("secp-224r1", &_nettle_secp_224r1,
+ 	   "1321072106881784386340709783538698930880431939595776773514895067682",
+ 	   "6768311794185371282972144247871764855860666277647541840973645586477",
+@@ -198,6 +201,7 @@ test_main(void)
+ 	   "24223309755162432227459925493224336241652868856405241018762887667883",
+ 	   "8330362698029245839097779050425944245826040430538860338085968752913",
+ 	   "24167244512472228715617822000878192535267113543393576038737592837010");	   
++#endif
+ 
+   test_dh ("secp-256r1", &_nettle_secp_256r1,
+ 	   "94731533361265297353914491124013058635674217345912524033267198103710636378786",
+diff --git a/testsuite/ecdsa-sign-test.c b/testsuite/ecdsa-sign-test.c
+index 46fc2738..aa44adb5 100644
+--- a/testsuite/ecdsa-sign-test.c
++++ b/testsuite/ecdsa-sign-test.c
+@@ -74,6 +74,7 @@ test_main (void)
+   if (test_side_channel)
+     SKIP();
+ #endif
++#if WITH_ECC_SECP224R1
+   /* Producing the signature for corresponding test in
+      ecdsa-verify-test.c, with special u1 and u2. */
+   test_ecdsa (&_nettle_secp_224r1,
+@@ -86,6 +87,7 @@ test_main (void)
+ 	      "d16dc18032d268fd1a704fa6", /* r */
+ 	      "3a41e1423b1853e8aa89747b1f987364"
+ 	      "44705d6d6d8371ea1f578f2e"); /* s */
++#endif
+ 
+   /* Produce a signature where verify operation results in a point duplication. */
+   test_ecdsa (&_nettle_secp_256r1,
+@@ -99,6 +101,7 @@ test_main (void)
+ 	      "53f097727a0e0dc284a0daa0da0ab77d"
+ 	      "5792ae67ed075d1f8d5bda0f853fa093"); /* s */
+ 
++#if WITH_ECC_SECP192R1
+   /* Test cases for the smaller groups, verified with a
+      proof-of-concept implementation done for Yubico AB. */
+   test_ecdsa (&_nettle_secp_192r1,
+@@ -116,7 +119,9 @@ test_main (void)
+ 
+ 	      "a91fb738f9f175d72f9c98527e881c36"
+ 	      "8de68cb55ffe589"); /* s */
++#endif
+ 
++#if WITH_ECC_SECP224R1
+   test_ecdsa (&_nettle_secp_224r1,
+ 	      "446df0a771ed58403ca9cb316e617f6b"
+ 	      "158420465d00a69601e22858",  /* z */
+@@ -132,6 +137,7 @@ test_main (void)
+ 
+ 	      "d0f069fd0f108eb07b7bbc54c8d6c88d"
+ 	      "f2715c38a95c31a2b486995f"); /* s */
++#endif
+ 
+   /* From RFC 4754 */
+   test_ecdsa (&_nettle_secp_256r1,
+diff --git a/testsuite/ecdsa-verify-test.c b/testsuite/ecdsa-verify-test.c
+index 8d527000..1fa69f09 100644
+--- a/testsuite/ecdsa-verify-test.c
++++ b/testsuite/ecdsa-verify-test.c
+@@ -81,6 +81,7 @@ test_ecdsa (const struct ecc_curve *ecc,
+ void
+ test_main (void)
+ {
++#if WITH_ECC_SECP224R1
+   /* Corresponds to nonce k = 2 and private key z =
+      0x99b5b787484def12894ca507058b3bf543d72d82fa7721d2e805e5e6. z and
+      hash are chosen so that intermediate scalars in the verify
+@@ -100,7 +101,9 @@ test_main (void)
+ 	      "d16dc18032d268fd1a704fa6", /* r */
+ 	      "3a41e1423b1853e8aa89747b1f987364"
+ 	      "44705d6d6d8371ea1f578f2e"); /* s */
++#endif
+ 
++#if WITH_ECC_SECP192R1
+   /* Test case provided by Guido Vranken, from oss-fuzz */
+   test_ecdsa (&_nettle_secp_192r1,
+ 	      "14683086 f1734c6d e68743a6 48181b54 a74d4c5b 383eb6a8", /* x */
+@@ -108,6 +111,7 @@ test_main (void)
+ 	      SHEX("00"), /* h == 0 corner case*/
+ 	      "952800792ed19341fdeeec047f2514f3b0f150d6066151fb", /* r */
+ 	      "ec5971222014878b50d7a19d8954bc871e7e65b00b860ffb"); /* s */
++#endif
+ 
+   /* Test case provided by Guido Vranken, from oss-fuzz. Triggers
+      point duplication in the verify operation by using private key =
+diff --git a/testsuite/testutils.c b/testsuite/testutils.c
+index 7b0c9020..5b5ba179 100644
+--- a/testsuite/testutils.c
++++ b/testsuite/testutils.c
+@@ -2213,8 +2213,12 @@ test_dsa_key(const struct dsa_params *params,
+ }
+ 
+ const struct ecc_curve * const ecc_curves[] = {
++#if WITH_ECC_SECP192R1
+   &_nettle_secp_192r1,
++#endif
++#if WITH_ECC_SECP224R1
+   &_nettle_secp_224r1,
++#endif
+   &_nettle_secp_256r1,
+   &_nettle_secp_384r1,
+   &_nettle_secp_521r1,
+@@ -2338,7 +2342,8 @@ test_ecc_point (const struct ecc_curve *ecc,
+ }
+ 
+ /* For each curve, the points g, 2 g, 3 g and 4 g */
+-static const struct ecc_ref_point ecc_ref[9][4] = {
++static const struct ecc_ref_point ecc_ref[][4] = {
++#if WITH_ECC_SECP192R1
+   { { "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
+       "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" },
+     { "dafebf5828783f2ad35534631588a3f629a70fb16982a888",
+@@ -2348,6 +2353,8 @@ static const struct ecc_ref_point ecc_ref[9][4] = {
+     { "35433907297cc378b0015703374729d7a4fe46647084e4ba",
+ 	"a2649984f2135c301ea3acb0776cd4f125389b311db3be32" }
+   },
++#endif
++#if WITH_ECC_SECP224R1
+   { { "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
+ 	"bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34" },
+     { "706a46dc76dcb76798e60e6d89474788d16dc18032d268fd1a704fa6",
+@@ -2357,6 +2364,7 @@ static const struct ecc_ref_point ecc_ref[9][4] = {
+     { "ae99feebb5d26945b54892092a8aee02912930fa41cd114e40447301",
+ 	"482580a0ec5bc47e88bc8c378632cd196cb3fa058a7114eb03054c9" },
+   },
++#endif
+   { { "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
+ 	"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" },
+     { "7cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc47669978",
+-- 
+2.53.0
+

diff --git a/nettle-4.0-zeroize-stack.patch b/nettle-4.0-zeroize-stack.patch
new file mode 100644
index 0000000..d9ad7d6
--- /dev/null
+++ b/nettle-4.0-zeroize-stack.patch
@@ -0,0 +1,293 @@
+From b075d64f83702b2ff3e745a6e842ae01a02ea6c0 Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <dueno@redhat.com>
+Date: Wed, 24 Aug 2022 17:19:57 +0900
+Subject: [PATCH] Clear any intermediate data allocate on stack
+
+Signed-off-by: Daiki Ueno <dueno@redhat.com>
+---
+ cbc.c                 |  3 +++
+ cfb.c                 | 13 +++++++++++++
+ ctr.c                 |  4 ++++
+ ctr16.c               |  2 ++
+ ecc-random.c          |  3 +++
+ ecdsa-keygen.c        |  2 ++
+ ecdsa-sign.c          |  2 ++
+ ed25519-sha512-sign.c |  2 ++
+ ed448-shake256-sign.c |  2 ++
+ gostdsa-sign.c        |  2 ++
+ nettle-internal.h     |  5 +++++
+ pbkdf2.c              |  5 ++++-
+ pss-mgf1.c            |  5 ++++-
+ pss.c                 |  4 ++++
+ 14 files changed, 52 insertions(+), 2 deletions(-)
+
+diff --git a/cbc.c b/cbc.c
+index 76b6492d..b9da3aa0 100644
+--- a/cbc.c
++++ b/cbc.c
+@@ -128,6 +128,9 @@ cbc_decrypt(const void *ctx, nettle_cipher_func *f,
+ 	      length - block_size);
+       /* Writes first block. */
+       memxor3(dst, buffer, initial_iv, block_size);
++
++      TMP_CLEAR(buffer, buffer_size);
++      TMP_CLEAR(initial_iv, block_size);
+     }
+ }
+ 
+diff --git a/cfb.c b/cfb.c
+index b9da3159..b1b01b9e 100644
+--- a/cfb.c
++++ b/cfb.c
+@@ -83,6 +83,8 @@ cfb_encrypt(const void *ctx, nettle_cipher_func *f,
+       /* We do not care about updating IV here. This is the last call in
+        * message sequence and one has to set IV afterwards anyway */
+     }
++
++  TMP_CLEAR(buffer, block_size);
+ }
+ 
+ /* Don't allocate any more space than this on the stack */
+@@ -115,6 +117,8 @@ cfb_decrypt(const void *ctx, nettle_cipher_func *f,
+ 
+ 	  f(ctx, block_size, buffer, iv);
+ 	  memxor3(dst + length, src + length, buffer, left);
++
++	  TMP_CLEAR(buffer, block_size);
+ 	}
+     }
+   else
+@@ -160,6 +164,9 @@ cfb_decrypt(const void *ctx, nettle_cipher_func *f,
+ 	  f(ctx, block_size, buffer, iv);
+ 	  memxor(dst, buffer, left);
+ 	}
++
++      TMP_CLEAR(buffer, buffer_size);
++      TMP_CLEAR(initial_iv, block_size);
+     }
+ }
+ 
+@@ -196,6 +203,9 @@ cfb8_encrypt(const void *ctx, nettle_cipher_func *f,
+       pos ++;
+     }
+   memcpy(iv, buffer + pos, block_size);
++
++  TMP_CLEAR(buffer, block_size * 2);
++  TMP_CLEAR(outbuf, block_size);
+ }
+ 
+ void
+@@ -235,4 +245,7 @@ cfb8_decrypt(const void *ctx, nettle_cipher_func *f,
+     }
+ 
+   memcpy(iv, buffer + i, block_size);
++
++  TMP_CLEAR(buffer, block_size * 2);
++  TMP_CLEAR(outbuf, block_size * 2);
+ }
+diff --git a/ctr.c b/ctr.c
+index 21316ecd..fc093bbd 100644
+--- a/ctr.c
++++ b/ctr.c
+@@ -130,6 +130,8 @@ ctr_crypt(const void *ctx, nettle_cipher_func *f,
+ 	  f(ctx, block_size, block, ctr);
+ 	  INCREMENT(block_size, ctr);
+ 	  memxor3(dst + filled, src + filled, block, length - filled);
++
++	  TMP_CLEAR(block, block_size);
+ 	}
+     }
+   else
+@@ -166,5 +168,7 @@ ctr_crypt(const void *ctx, nettle_cipher_func *f,
+ 	  INCREMENT(block_size, ctr);
+ 	  memxor(dst, buffer, length);
+ 	}
++
++      TMP_CLEAR(buffer, buffer_size);
+     }
+ }
+diff --git a/ctr16.c b/ctr16.c
+index 341fac99..10204f3c 100644
+--- a/ctr16.c
++++ b/ctr16.c
+@@ -102,5 +102,7 @@ _nettle_ctr_crypt16(const void *ctx, nettle_cipher_func *f,
+ 	done:
+ 	  memxor3 (dst + i, src + i, buffer->b, length - i);
+ 	}
++
++      TMP_CLEAR(buffer, MIN(blocks, CTR_BUFFER_LIMIT / 16));
+     }
+ }
+diff --git a/ecc-random.c b/ecc-random.c
+index a7b48d6a..676f5933 100644
+--- a/ecc-random.c
++++ b/ecc-random.c
+@@ -36,6 +36,7 @@
+ #endif
+ 
+ #include <assert.h>
++#include <string.h>
+ 
+ #include "ecc.h"
+ #include "ecc-internal.h"
+@@ -79,4 +80,6 @@ ecc_scalar_random (struct ecc_scalar *x,
+   TMP_ALLOC (scratch, ECC_MOD_RANDOM_ITCH (x->ecc->q.size));
+ 
+   ecc_mod_random (&x->ecc->q, x->p, random_ctx, random, scratch);
++
++  TMP_CLEAR (scratch, ECC_MOD_RANDOM_ITCH (x->ecc->q.size));
+ }
+diff --git a/ecdsa-keygen.c b/ecdsa-keygen.c
+index 870282b0..05dd827a 100644
+--- a/ecdsa-keygen.c
++++ b/ecdsa-keygen.c
+@@ -59,4 +59,6 @@ ecdsa_generate_keypair (struct ecc_point *pub,
+   ecc_mod_random (&ecc->q, key->p, random_ctx, random, p);
+   ecc->mul_g (ecc, p, key->p, p + 3*ecc->p.size);
+   ecc->h_to_a (ecc, 0, pub->p, p, p + 3*ecc->p.size);
++
++  TMP_CLEAR (p, itch);
+ }
+diff --git a/ecdsa-sign.c b/ecdsa-sign.c
+index e6fb3287..e6b960bf 100644
+--- a/ecdsa-sign.c
++++ b/ecdsa-sign.c
+@@ -68,4 +68,6 @@ ecdsa_sign (const struct ecc_scalar *key,
+       mpz_limbs_finish (signature->s, size);
+     }
+   while (mpz_sgn (signature->r) == 0 || mpz_sgn (signature->s) == 0);
++
++  TMP_CLEAR (k, size + ECC_ECDSA_SIGN_ITCH (size));
+ }
+diff --git a/ed25519-sha512-sign.c b/ed25519-sha512-sign.c
+index 389a157e..52a46ea5 100644
+--- a/ed25519-sha512-sign.c
++++ b/ed25519-sha512-sign.c
+@@ -38,6 +38,7 @@
+ 
+ #include "ecc-internal.h"
+ #include "sha2.h"
++#include <string.h>
+ 
+ void
+ ed25519_sha512_sign (const uint8_t *pub,
+@@ -61,6 +62,7 @@ ed25519_sha512_sign (const uint8_t *pub,
+ 	       length, msg, signature, scratch_out);
+ 
+   gmp_free_limbs (scratch, itch);
++  explicit_bzero (digest, sizeof(digest));
+ #undef k1
+ #undef k2
+ #undef scratch_out
+diff --git a/ed448-shake256-sign.c b/ed448-shake256-sign.c
+index 5d3cdbd5..b7def5ec 100644
+--- a/ed448-shake256-sign.c
++++ b/ed448-shake256-sign.c
+@@ -39,6 +39,7 @@
+ #include "ecc-internal.h"
+ #include "eddsa-internal.h"
+ #include "sha3.h"
++#include <string.h>
+ 
+ void
+ ed448_shake256_sign (const uint8_t *pub,
+@@ -63,6 +64,7 @@ ed448_shake256_sign (const uint8_t *pub,
+ 	       length, msg, signature, scratch_out);
+ 
+   gmp_free_limbs (scratch, itch);
++  explicit_bzero (digest, sizeof(digest));
+ #undef k1
+ #undef k2
+ #undef scratch_out
+diff --git a/gostdsa-sign.c b/gostdsa-sign.c
+index 892c0742..a7e0c21d 100644
+--- a/gostdsa-sign.c
++++ b/gostdsa-sign.c
+@@ -71,4 +71,6 @@ gostdsa_sign (const struct ecc_scalar *key,
+       mpz_limbs_finish (signature->s, size);
+     }
+   while (mpz_sgn (signature->r) == 0 || mpz_sgn (signature->s) == 0);
++
++  TMP_CLEAR (k, size + ECC_GOSTDSA_SIGN_ITCH (size));
+ }
+diff --git a/nettle-internal.h b/nettle-internal.h
+index 1aed1007..9a5758f2 100644
+--- a/nettle-internal.h
++++ b/nettle-internal.h
+@@ -71,6 +71,11 @@
+   do { assert((size_t)(size) <= (sizeof(name))); } while (0)
+ #endif 
+ 
++#include <string.h>		/* explicit_bzero */
++
++#define TMP_CLEAR(name, size) (explicit_bzero (name, sizeof (*name) * (size)))
++#define TMP_CLEAR_ALIGN(name, size) (explicit_bzero (name, size))
++
+ /* Limits that apply to systems that don't have alloca */
+ #define NETTLE_MAX_HASH_BLOCK_SIZE 144  /* For sha3_224*/
+ #define NETTLE_MAX_HASH_DIGEST_SIZE 64
+diff --git a/pbkdf2.c b/pbkdf2.c
+index 737b847e..c891d95d 100644
+--- a/pbkdf2.c
++++ b/pbkdf2.c
+@@ -92,8 +92,11 @@ pbkdf2 (void *mac_ctx,
+       if (length <= digest_size)
+ 	{
+ 	  memcpy (dst, T, length);
+-	  return;
++	  break;
+ 	}
+       memcpy (dst, T, digest_size);
+     }
++
++  TMP_CLEAR (U, digest_size);
++  TMP_CLEAR (T, digest_size);
+ }
+diff --git a/pss-mgf1.c b/pss-mgf1.c
+index e6395736..5415f417 100644
+--- a/pss-mgf1.c
++++ b/pss-mgf1.c
+@@ -67,8 +67,11 @@ pss_mgf1(const void *seed, const struct nettle_hash *hash,
+ 	{
+ 	  hash->digest(state, h);
+ 	  memcpy(mask, h, length);
+-	  return;
++	  break;
+ 	}
+       hash->digest(state, mask);
+     }
++
++  TMP_CLEAR(h, hash->digest_size);
++  TMP_CLEAR_ALIGN(state, hash->context_size);
+ }
+diff --git a/pss.c b/pss.c
+index 404ab6f0..a08bab8b 100644
+--- a/pss.c
++++ b/pss.c
+@@ -77,6 +77,7 @@ pss_encode_mgf1(mpz_t m, size_t bits,
+   if (key_size < hash->digest_size + salt_length + 2)
+     {
+       TMP_GMP_FREE(em);
++      TMP_CLEAR_ALIGN(state, hash->context_size);
+       return 0;
+     }
+ 
+@@ -111,6 +112,7 @@ pss_encode_mgf1(mpz_t m, size_t bits,
+ 
+   nettle_mpz_set_str_256_u(m, key_size, em);
+   TMP_GMP_FREE(em);
++  TMP_CLEAR_ALIGN(state, hash->context_size);
+   return 1;
+ }
+ 
+@@ -194,5 +196,7 @@ pss_verify_mgf1(const mpz_t m, size_t bits,
+   ret = 1;
+  cleanup:
+   TMP_GMP_FREE(em);
++  TMP_CLEAR(h2, hash->digest_size);
++  TMP_CLEAR_ALIGN(state, hash->context_size);
+   return ret;
+ }
+-- 
+2.53.0
+

diff --git a/sources b/sources
index f5595f5..9a206c3 100644
--- a/sources
+++ b/sources
@@ -3,3 +3,6 @@ SHA512 (gnutls-3.8.13.tar.xz.sig) = 190a219f7c452049c668b1f8b2d4ed5fb932625a257e
 SHA512 (gnutls-release-keyring.gpg) = 8c2b39239d1d8c5319757fcf669f28a11de7f8ec4a726f9904c57ba8105bea80240083c0de71b747115907bab46569f10cf58004137cc7884ac5c20f8319ae0a
 SHA512 (gmp-6.3.0.tar.xz) = e85a0dab5195889948a3462189f0e0598d331d3457612e2d3350799dba2e244316d256f8161df5219538eb003e4b5343f989aaa00f96321559063ed8c8f29fd2
 SHA512 (leancrypto-1.6.0.tar.gz) = cb6ace4a1642208dd7656b62a48e99d6261f471aa7967b738057745a4534abfa11d380dd5de98a737c0c13b1e1cb37ce780e02297eefc1cf839581629d34e100
+SHA512 (nettle-4.0.tar.gz) = 833303d94f5a67094011ad4dd931fffdb9adf679b4df241a544a08194a66e6e449398b704ba5b29d52c1c3b5ada6f6dc18b24d1adb3382a68470a11645bf13cd
+SHA512 (nettle-4.0.tar.gz.sig) = 5f66a4f32b35473d54a1f9e1473e56530c9d22182169449568ae1a27c76a380c2a1d400b4e94c89f1b12bf22b21cf7021a3622da09b6c95f1e8d38929ae89f48
+SHA512 (nettle-release-keyring.gpg) = 0e59447eb74017439c8b5b5b05173c0ffd710705d2a9c1f74833b7034fad1608fa1bdd2c308e6c42214553cd648606b6a07044ea39677b1b3452cb4d07bf889b

                 reply	other threads:[~2026-09-15 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178947900690.1.4640827640269939991.rpms-gnutls-b9f4117f005d@fedoraproject.org \
    --to=yselkowi@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox