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.
#include <assert.h>
#include "ecc-internal.h"
+#include "nettle-internal.h"
#define USE_REDC 0
#include <assert.h>
#include "ecc-internal.h"
+#include "nettle-internal.h"
#define USE_REDC 0
#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;
#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. */
#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)
#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
#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. */
#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. */
#include <assert.h>
#include "ecc-internal.h"
+#include "nettle-internal.h"
#define USE_REDC 0
#include <assert.h>
#include "ecc-internal.h"
+#include "nettle-internal.h"
#define USE_REDC 0
#include "ecc.h"
#include "ecc-internal.h"
+#include "nettle-internal.h"
#include "nettle-meta.h"
mp_size_t
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
/* 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)
#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)
{
#include "sntrup761-encoding.h"
#include "bswap-internal.h"
+#include "nettle-internal.h"
#include "sha2.h"
#define uint32_MINMAX(a,b) \