Commit b2780333 authored by Niels Möller's avatar Niels Möller
Browse files

New function write_mpn, used in the testsuite.

parent 4351c027
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
* testsuite/testutils.c (die): Use plain vfprintf, not * testsuite/testutils.c (die): Use plain vfprintf, not
gmp_vfprintf. gmp_vfprintf.
(write_mpn): New function.
(test_ecc_point): Use it, replacing gmp_fprintf.
* testsuite/testutils.h (write_mpn): Declare it.
* der-iterator.c: Deleted HAVE_LIBGMP conditionals. * der-iterator.c: Deleted HAVE_LIBGMP conditionals.
......
...@@ -1282,6 +1282,13 @@ struct ecc_ref_point ...@@ -1282,6 +1282,13 @@ struct ecc_ref_point
const char *y; const char *y;
}; };
void
write_mpn (FILE *f, int base, const mp_limb_t *xp, mp_size_t n)
{
mpz_t t;
mpz_out_str (f, base, mpz_roinit_n (t,xp, n));
}
static void static void
test_ecc_point (const struct ecc_curve *ecc, test_ecc_point (const struct ecc_curve *ecc,
const struct ecc_ref_point *ref, const struct ecc_ref_point *ref,
...@@ -1290,13 +1297,16 @@ test_ecc_point (const struct ecc_curve *ecc, ...@@ -1290,13 +1297,16 @@ test_ecc_point (const struct ecc_curve *ecc,
if (! (test_mpn (ref->x, p, ecc->size) if (! (test_mpn (ref->x, p, ecc->size)
&& test_mpn (ref->y, p + ecc->size, ecc->size) )) && test_mpn (ref->y, p + ecc->size, ecc->size) ))
{ {
gmp_fprintf (stderr, "Incorrect point!\n" fprintf (stderr, "Incorrect point!\n"
"got: x = %Nx\n" "got: x = ");
" y = %Nx\n" write_mpn (stderr, 16, p, ecc->size);
"ref: x = %s\n" fprintf (stderr, "\n"
" y = %s\n", " y = ");
p, ecc->size, p + ecc->size, ecc->size, write_mpn (stderr, 16, p + ecc->size, ecc->size);
ref->x, ref->y); fprintf (stderr, "\n"
"ref: x = %s\n"
" y = %s\n",
ref->x, ref->y);
abort(); abort();
} }
} }
......
...@@ -164,6 +164,9 @@ test_armor(const struct nettle_armor *armor, ...@@ -164,6 +164,9 @@ test_armor(const struct nettle_armor *armor,
mp_limb_t * mp_limb_t *
xalloc_limbs (mp_size_t n); xalloc_limbs (mp_size_t n);
void
write_mpn (FILE *f, int base, const mp_limb_t *xp, mp_size_t n);
void void
test_rsa_set_key_1(struct rsa_public_key *pub, test_rsa_set_key_1(struct rsa_public_key *pub,
struct rsa_private_key *key); struct rsa_private_key *key);
......
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