summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2021-01-20 09:43:28 +0100
committerNiels Möller <nisse@lysator.liu.se>2021-01-20 09:43:28 +0100
commitddf99ac4c5de3710c7bfac81eac60d55e59a35c2 (patch)
tree0d93adebea581cfa0164594f49bc133e09628252 /testsuite
parentb3d0bcf5a185842d2c717927eef03577fd61a912 (diff)
downloadnettle-ddf99ac4c5de3710c7bfac81eac60d55e59a35c2.tar.gz
Add testcase for ecc_ecdsa_verify with zero hash.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/ecdsa-verify-test.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/testsuite/ecdsa-verify-test.c b/testsuite/ecdsa-verify-test.c
index 6a593d6f..3ceac0eb 100644
--- a/testsuite/ecdsa-verify-test.c
+++ b/testsuite/ecdsa-verify-test.c
@@ -46,7 +46,7 @@ test_ecdsa (const struct ecc_curve *ecc,
mpz_combit (signature.r, ecc->p.bit_size / 3);
if (ecdsa_verify (&pub, h->length, h->data, &signature))
{
- fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature.\n");
+ fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature (r modified).\n");
goto fail;
}
mpz_combit (signature.r, ecc->p.bit_size / 3);
@@ -54,7 +54,7 @@ test_ecdsa (const struct ecc_curve *ecc,
mpz_combit (signature.s, 4*ecc->p.bit_size / 5);
if (ecdsa_verify (&pub, h->length, h->data, &signature))
{
- fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature.\n");
+ fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature (s modified).\n");
goto fail;
}
mpz_combit (signature.s, 4*ecc->p.bit_size / 5);
@@ -62,7 +62,7 @@ test_ecdsa (const struct ecc_curve *ecc,
h->data[2*h->length / 3] ^= 0x40;
if (ecdsa_verify (&pub, h->length, h->data, &signature))
{
- fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature.\n");
+ fprintf (stderr, "ecdsa_verify unexpectedly succeeded with invalid signature (h modified).\n");
goto fail;
}
h->data[2*h->length / 3] ^= 0x40;
@@ -81,6 +81,14 @@ test_ecdsa (const struct ecc_curve *ecc,
void
test_main (void)
{
+ /* Test case provided by Guido Vranken, from oss-fuzz */
+ test_ecdsa (&_nettle_secp_192r1,
+ "14683086 f1734c6d e68743a6 48181b54 a74d4c5b 383eb6a8", /* x */
+ " 1e2584 2ab8b2b0 4017f655 1b5e4058 a2aa0612 2dae9344", /* y */
+ SHEX("00"), /* h == 0 corner case*/
+ "952800792ed19341fdeeec047f2514f3b0f150d6066151fb", /* r */
+ "ec5971222014878b50d7a19d8954bc871e7e65b00b860ffb"); /* s */
+
/* From RFC 4754 */
test_ecdsa (&_nettle_secp_256r1,
"2442A5CC 0ECD015F A3CA31DC 8E2BBC70"