Commit 05d62ef8 authored by Niels Möller's avatar Niels Möller

(test_dsa160): Added argument for expected signature.

(test_dsa256): Likewise.

Rev: nettle/testsuite/dsa-keygen-test.c:1.5
Rev: nettle/testsuite/testutils.c:1.8
Rev: nettle/testsuite/testutils.h:1.5
parent b910a8b8
......@@ -28,7 +28,7 @@ test_main(void)
FAIL();
test_dsa_key(&pub, &key, 160);
test_dsa160(&pub, &key);
test_dsa160(&pub, &key, NULL);
if (!dsa_generate_keypair(&pub, &key,
&lfib, (nettle_random_func *) knuth_lfib_random,
......@@ -37,7 +37,7 @@ test_main(void)
FAIL();
test_dsa_key(&pub, &key, 256);
test_dsa256(&pub, &key);
test_dsa256(&pub, &key, NULL);
dsa_public_key_clear(&pub);
dsa_private_key_clear(&key);
......
......@@ -826,7 +826,8 @@ test_rsa_key(struct rsa_public_key *pub,
void
test_dsa160(const struct dsa_public_key *pub,
const struct dsa_private_key *key)
const struct dsa_private_key *key,
const struct dsa_signature *expected)
{
struct sha1_ctx sha1;
struct dsa_signature signature;
......@@ -850,6 +851,11 @@ test_dsa160(const struct dsa_public_key *pub,
fprintf(stderr, "\n");
}
if (expected)
if (mpz_cmp (signature.r, expected->r)
|| mpz_cmp (signature.s, expected->s))
FAIL();
/* Try bad data */
if (DSA_VERIFY(pub, sha1,
"The magick words are squeamish ossifrage", &signature))
......@@ -872,7 +878,8 @@ test_dsa160(const struct dsa_public_key *pub,
void
test_dsa256(const struct dsa_public_key *pub,
const struct dsa_private_key *key)
const struct dsa_private_key *key,
const struct dsa_signature *expected)
{
struct sha256_ctx sha256;
struct dsa_signature signature;
......@@ -896,10 +903,10 @@ test_dsa256(const struct dsa_public_key *pub,
fprintf(stderr, "\n");
}
#if 0
if (mpz_cmp(signature, expected))
if (expected)
if (mpz_cmp (signature.r, expected->r)
|| mpz_cmp (signature.s, expected->s))
FAIL();
#endif
/* Try bad data */
if (DSA_VERIFY(pub, sha256,
......
......@@ -168,11 +168,13 @@ test_rsa_key(struct rsa_public_key *pub,
void
test_dsa160(const struct dsa_public_key *pub,
const struct dsa_private_key *key);
const struct dsa_private_key *key,
const struct dsa_signature *expected);
void
test_dsa256(const struct dsa_public_key *pub,
const struct dsa_private_key *key);
const struct dsa_private_key *key,
const struct dsa_signature *expected);
void
test_dsa_key(struct dsa_public_key *pub,
......
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