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,
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);
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;
ASSERT (dsa_sha1_sign(pub, key,
&lfib, (nettle_random_func *) knuth_lfib_random,
&sha1, &signature));
-
+
if (verbose)
{
fprintf(stderr, "dsa160 signature: ");
mpz_out_str(stderr, 16, signature.s);
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,
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;
fprintf(stderr, "\n");
}
-#if 0
- if (mpz_cmp(signature, expected))
- FAIL();
-#endif
+ if (expected)
+ if (mpz_cmp (signature.r, expected->r)
+ || mpz_cmp (signature.s, expected->s))
+ FAIL();
/* Try bad data */
if (DSA_VERIFY(pub, sha256,
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,