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

* testsuite/testutils.c (test_dsa_key): New function to sanity

check a dsa keypair.

Rev: src/nettle/testsuite/testutils.c:1.16
Rev: src/nettle/testsuite/testutils.h:1.14
parent d30ef637
......@@ -507,5 +507,33 @@ test_dsa(const struct dsa_public_key *pub,
dsa_signature_clear(&signature);
}
void
test_dsa_key(struct dsa_public_key *pub,
struct dsa_private_key *key)
{
mpz_t t;
mpz_init(t);
ASSERT(mpz_sizeinbase(pub->q, 2) == 160);
ASSERT(mpz_sizeinbase(pub->p, 2) >= DSA_MINIMUM_BITS);
ASSERT(mpz_probab_prime_p(pub->p, 10));
ASSERT(mpz_probab_prime_p(pub->q, 10));
mpz_fdiv_r(t, pub->p, pub->q);
ASSERT(0 == mpz_cmp_ui(t, 1));
ASSERT(mpz_cmp_ui(pub->g, 1) > 0);
mpz_powm(t, pub->g, pub->q, pub->p);
ASSERT(0 == mpz_cmp_ui(t, 1));
mpz_powm(t, pub->g, key->x, pub->p);
ASSERT(0 == mpz_cmp(t, pub->y));
};
#endif /* WITH_PUBLIC_KEY */
......@@ -91,6 +91,10 @@ void
test_dsa(const struct dsa_public_key *pub,
const struct dsa_private_key *key);
void
test_dsa_key(struct dsa_public_key *pub,
struct dsa_private_key *key);
#endif /* WITH_PUBLIC_KEY */
#define H2(d, s) decode_hex((d), (s))
......
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