+2022-08-17 Niels Möller <nisse@lysator.liu.se>
+
+ * testsuite/testutils.c (mpz_urandomm) [NETTLE_USE_MINI_GMP]: New
+ fallback definition when building with mini-gmp.
+
2022-08-16 Niels Möller <nisse@lysator.liu.se>
* ecc-mod-arith.c (ecc_mod_sub): Ensure that if inputs are in the
nettle_mpz_set_str_256_u (r, bytes, buf);
free (buf);
}
+void
+mpz_urandomm (mpz_t r, struct knuth_lfib_ctx *ctx, const mpz_t n)
+{
+ /* Add some extra bits, to make result almost unbiased. */
+ mpz_urandomb(r, ctx, mpz_sizeinbase(n, 2) + 30);
+ mpz_mod(r, r, n);
+}
#else /* !NETTLE_USE_MINI_GMP */
static void
get_random_seed(mpz_t seed)
void gmp_randinit_default (struct knuth_lfib_ctx *ctx);
#define gmp_randclear(state)
void mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits);
+void mpz_urandomm (mpz_t r, struct knuth_lfib_ctx *ctx, const mpz_t n);
/* This is cheating */
#define mpz_rrandomb mpz_urandomb
+#define mpz_rrandomm mpz_urandomm
static inline int
test_randomize (gmp_randstate_t rands UNUSED) { return 0; }
#else /* !NETTLE_USE_MINI_GMP */