Commit 0f1adf55 authored by Niels Möller's avatar Niels Möller

Eliminate more uses of gmp_fprintf.

parent 51fb8e8f
2014-06-25 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecdsa-keygen-test.c (test_main): Use printf,
mpz_out_str and write_mpn instead of gmp_fprintf.
* testsuite/ecdsa-sign-test.c (test_ecdsa): Likewise.
* testsuite/ecdsa-verify-test.c (test_ecdsa): Likewise.
* dsa.h: Include bignum.h instead of gmp.h.
* ecc-internal.h: Likewise.
* ecc.h: Likewise.
......
......@@ -71,11 +71,13 @@ test_main (void)
if (verbose)
{
gmp_fprintf (stderr,
"Public key:\nx = %Nx\ny = %Nx\n",
pub.p, ecc->size, pub.p + ecc->size, ecc->size);
gmp_fprintf (stderr,
"Private key: %Nx\n", key.p, ecc->size);
fprintf (stderr, "Public key:\nx = ");
write_mpn (stderr, 16, pub.p, ecc->size);
fprintf (stderr, "\ny = ");
write_mpn (stderr, 16, pub.p + ecc->size, ecc->size);
fprintf (stderr, "\nPrivate key: ");
write_mpn (stderr, 16, key.p, ecc->size);
fprintf (stderr, "\n");
}
if (!ecc_valid_p (&pub))
die ("ecdsa_generate_keypair produced an invalid point.\n");
......
......@@ -34,10 +34,15 @@ test_ecdsa (const struct ecc_curve *ecc,
|| mpz_limbs_cmp (ref.s, sp, ecc->size) != 0)
{
fprintf (stderr, "_ecdsa_sign failed, bit_size = %u\n", ecc->bit_size);
gmp_fprintf (stderr, "r = %Nx\n", rp, ecc->size);
gmp_fprintf (stderr, "s = %Nx\n", sp, ecc->size);
gmp_fprintf (stderr, "ref.r = %Zx\n", ref.r);
gmp_fprintf (stderr, "ref.s = %Zx\n", ref.s);
fprintf (stderr, "r = ");
write_mpn (stderr, 16, rp, ecc->size);
fprintf (stderr, "\ns = ");
write_mpn (stderr, 16, sp, ecc->size);
fprintf (stderr, "\nref.r = ");
mpz_out_str (stderr, 16, ref.r);
fprintf (stderr, "\nref.s = ");
mpz_out_str (stderr, 16, ref.s);
fprintf (stderr, "\n");
abort();
}
......
......@@ -29,12 +29,17 @@ test_ecdsa (const struct ecc_curve *ecc,
{
fprintf (stderr, "ecdsa_verify failed with valid signature.\n");
fail:
fprintf (stderr, "bit_size = %u\n", ecc->bit_size);
gmp_fprintf (stderr, "x = %Zx\n", x);
gmp_fprintf (stderr, "y = %Zx\ndigest ", y);
fprintf (stderr, "bit_size = %u\nx = ", ecc->bit_size);
mpz_out_str (stderr, 16, x);
fprintf (stderr, "\ny = ");
mpz_out_str (stderr, 16, y);
fprintf (stderr, "\ndigest ");
print_hex (h->length, h->data);
gmp_fprintf (stderr, "r = %Zx\n", signature.r);
gmp_fprintf (stderr, "s = %Zx\n", signature.s);
fprintf (stderr, "r = ");
mpz_out_str (stderr, 16, signature.r);
fprintf (stderr, "\ns = ");
mpz_out_str (stderr, 16, signature.s);
fprintf (stderr, "\n");
abort();
}
......
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