]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Move assert_maybe macro to nettle-internal.h.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 4 Jun 2026 17:15:40 +0000 (19:15 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 4 Jun 2026 18:25:18 +0000 (20:25 +0200)
16 files changed:
ChangeLog
ecc-curve25519.c
ecc-curve448.c
ecc-internal.h
ecc-mod-arith.c
ecc-mod-inv.c
ecc-mod.c
ecc-pm1-redc.c
ecc-pp1-redc.c
ecc-secp192r1.c
ecc-secp384r1.c
eddsa-sign.c
nettle-internal.h
sntrup-internal.h
sntrup761-keygen.c
sntrup761.c

index 0d0ef01754bcbd6fa40e40d617058b7f8c268f11..854d14169ce2b4057bae1ec6a07186c202b7b174 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2026-06-04  Niels Möller  <nisse@lysator.liu.se>
 
+       * nettle-internal.h (assert_maybe): Move macro here, replacing old
+       copies. Update all users.
+       * ecc-internal.h (assert_maybe): Deleted.
+       * sntrup-internal.h (assert_maybe): Deleted.
+
        * ecc-secp256r1.c (ecc_secp256r1_modq): Rewrite adjustment step,
        to work around gcc on riscv64 generating an unwanted branch
        instruction. Suggested by Felix Yan.
index db301252ec5f3f089a1ba7a2237c4ae16d0f5dc6..0d2dabd86431cac5f49caa089ea65b58d61647dd 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 #define USE_REDC 0
 
index 1bffeeb7cb323795c83c0f9d31ebe14020917821..0e0ccc34c5cd5e6969247cbdabe38165955c82a5 100644 (file)
@@ -39,6 +39,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 #define USE_REDC 0
 
index 0e03215c2d71d781fae810597b3e715caf124aab..29f41a45a0d80a4bf5853a0b6e8cf5c0cb182cfc 100644 (file)
 #define curve25519_eh_to_x _nettle_curve25519_eh_to_x
 #define curve448_eh_to_x _nettle_curve448_eh_to_x
 
-/* For asserts that are incompatible with sc tests. Currently used
-   only by ECC code. */
-#if WITH_EXTRA_ASSERTS
-# define assert_maybe(x) assert(x)
-#else
-# define assert_maybe(x) ((void)(x))
-#endif
-
 extern const struct ecc_curve _nettle_secp_192r1;
 extern const struct ecc_curve _nettle_secp_224r1;
 extern const struct ecc_curve _nettle_secp_256r1;
index 1650f0b43b62c70b9472a0b551d475c6fce27223..a3d28b02affab37dcf21fc5ede9bbf1a468e8b4b 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 /* Routines for modp arithmetic. All values are ecc->size limbs, but
    not necessarily < p. */
index 8da08c09799d41b31279b08085b7cabf8e9e7507..d27ca1212b5c0a1f49367c4da2a4e72a04fddc37 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 static void
 cnd_neg (int cnd, mp_limb_t *rp, const mp_limb_t *ap, mp_size_t n)
index 74314b8dbca2506a2bcac1f6fccb1189e39b4e7f..1e03af11e686fb719b7958554c370add91b35ed5 100644 (file)
--- a/ecc-mod.c
+++ b/ecc-mod.c
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 /* Computes r <-- x mod m, input 2*m->size, output m->size. It's
  * allowed to have rp == xp or rp == xp + m->size, but no other kind
index 0f728a37ed70390457988a88ce2884d1f3e0f283..8cc012048d62920d7024c7b975bd20e10a2b6d8e 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 /* Use that 1 = - (p - 1) (mod p), and that at least one low limb of p
    - 1 is zero. */
index c472204196af4f60c63158d26e301aeb763688d1..eb0cadfb9330f1a1e7725c5f1e7c98a2fbdc1e0c 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 /* Use that 1 = p + 1 (mod p), and that at least one low limb of p + 1
    is zero. */
index 9cb29cef53d0751f14e022f1bed8046b26bcb071..a1f08f7ac119b03c3aeb2a4b2bf9a02eefda5e02 100644 (file)
@@ -41,6 +41,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 #define USE_REDC 0
 
index a0960d9ba1104722c72511f54a5a4f9bc5204be0..e46c7bc08e5df5f61411736e66857666f35e6096 100644 (file)
@@ -40,6 +40,7 @@
 #include <assert.h>
 
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 
 #define USE_REDC 0
 
index b471fd5f0c397afd1ee479df0437018b12f339a9..8c2dc3836492ec84d6ce6fb94fc49b79c7989c80 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "ecc.h"
 #include "ecc-internal.h"
+#include "nettle-internal.h"
 #include "nettle-meta.h"
 
 mp_size_t
index 1aed1007f2a7dff1ab05bbb36525a4aff87ddc06..803fa8d93781c232ed7db4f4d79bd2ad18c8e2c0 100644 (file)
   do { assert((size_t)(size) <= (sizeof(name))); } while (0)
 #endif 
 
+/* For asserts that are incompatible with sc tests. */
+#if WITH_EXTRA_ASSERTS
+# define assert_maybe(x) assert(x)
+#else
+# define assert_maybe(x) ((void)(x))
+#endif
+
 /* 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
index f44e075338878be8f92efb714acae00c58c6723d..968df2ac340865844747ea0c059c9747134f5798 100644 (file)
 /* Octet size of an encoded rounded polynomial, 1007. */
 #define SNTRUP761_ROUNDED_SIZE (SNTRUP761_CIPHER_SIZE - SNTRUP_HASH_SIZE)
 
-#if WITH_EXTRA_ASSERTS
-# define assert_maybe(x) assert(x)
-#else
-# define assert_maybe(x) ((void)(x))
-#endif
-
 /* Return -1 if high bit set, otherwise zero. */
 static inline int
 uint16_highbit_mask (uint16_t x)
index 00e09907eae4b5418d6f7b5fcd9a121b7374c0c6..48074525e545f0c3c532c994616c7c8081884f2e 100644 (file)
@@ -48,6 +48,8 @@
 #include "sntrup.h"
 #include "sntrup-internal.h"
 
+#include "nettle-internal.h"
+
 static void
 R3_random (sntrup761_R3_t out, void *random_ctx, nettle_random_func * random)
 {
index 389ff479eb2626934a68f94c62fa40d34c3b87db..6fdc70f0de6334886cadfa371da29dcc8a300d2a 100644 (file)
@@ -50,6 +50,7 @@
 #include "sntrup761-encoding.h"
 
 #include "bswap-internal.h"
+#include "nettle-internal.h"
 #include "sha2.h"
 
 #define uint32_MINMAX(a,b) \