Commit 615bdd0c authored by Niels Möller's avatar Niels Möller

Move mpn_zero_p to testutils.c.

parent 2b372dfd
2014-09-17 Niels Möller <nisse@lysator.liu.se> 2014-09-17 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecc-modinv-test.c (mpn_zero_p): Moved function, to...
* testsuite/testutils.c (mpn_zero_p): New location. Also make
non-static.
* testsuite/testutils.c (ecc_curves): Include curve25519 in list. * testsuite/testutils.c (ecc_curves): Include curve25519 in list.
(test_ecc_mul_a): Include reference points for curve25519 (with (test_ecc_mul_a): Include reference points for curve25519 (with
Edwards coordinates). Allow n == 1, and compare to the generator. Edwards coordinates). Allow n == 1, and compare to the generator.
......
...@@ -37,17 +37,6 @@ ref_modinv (mp_limb_t *rp, const mp_limb_t *ap, const mp_limb_t *mp, mp_size_t m ...@@ -37,17 +37,6 @@ ref_modinv (mp_limb_t *rp, const mp_limb_t *ap, const mp_limb_t *mp, mp_size_t m
#define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS) #define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS)
#define COUNT 500 #define COUNT 500
static int
mpn_zero_p (mp_srcptr ap, mp_size_t n)
{
while (--n >= 0)
{
if (ap[n] != 0)
return 0;
}
return 1;
}
void void
test_main (void) test_main (void)
{ {
......
...@@ -686,6 +686,19 @@ mpz_combit (mpz_t x, unsigned long int bit) ...@@ -686,6 +686,19 @@ mpz_combit (mpz_t x, unsigned long int bit)
} }
#endif #endif
#ifndef mpn_zero_p
int
mpn_zero_p (mp_srcptr ap, mp_size_t n)
{
while (--n >= 0)
{
if (ap[n] != 0)
return 0;
}
return 1;
}
#endif
mp_limb_t * mp_limb_t *
xalloc_limbs (mp_size_t n) xalloc_limbs (mp_size_t n)
{ {
......
...@@ -157,6 +157,11 @@ test_armor(const struct nettle_armor *armor, ...@@ -157,6 +157,11 @@ test_armor(const struct nettle_armor *armor,
const uint8_t *ascii); const uint8_t *ascii);
#if WITH_HOGWEED #if WITH_HOGWEED
#ifndef mpn_zero_p
int
mpn_zero_p (mp_srcptr ap, mp_size_t n);
#endif
mp_limb_t * mp_limb_t *
xalloc_limbs (mp_size_t n); xalloc_limbs (mp_size_t n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment