Commit 99e8976d authored by Niels Möller's avatar Niels Möller

(test_rsa_sha512): New function.

Rev: nettle/testsuite/testutils.c:1.4
Rev: nettle/testsuite/testutils.h:1.3
parent 3eebb3fd
......@@ -600,8 +600,8 @@ test_rsa_md5(struct rsa_public_key *pub,
void
test_rsa_sha1(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected)
struct rsa_private_key *key,
mpz_t expected)
{
struct sha1_ctx sha1;
mpz_t signature;
......@@ -643,8 +643,8 @@ test_rsa_sha1(struct rsa_public_key *pub,
void
test_rsa_sha256(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected)
struct rsa_private_key *key,
mpz_t expected)
{
struct sha256_ctx sha256;
mpz_t signature;
......@@ -684,6 +684,49 @@ test_rsa_sha256(struct rsa_public_key *pub,
mpz_clear(signature);
}
void
test_rsa_sha512(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected)
{
struct sha512_ctx sha512;
mpz_t signature;
sha512_init(&sha512);
mpz_init(signature);
SIGN(key, sha512, "The magic words are squeamish ossifrage", signature);
if (verbose)
{
fprintf(stderr, "rsa-sha512 signature: ");
mpz_out_str(stderr, 16, signature);
fprintf(stderr, "\n");
}
if (mpz_cmp(signature, expected))
FAIL();
/* Try bad data */
if (VERIFY(pub, sha512,
"The magick words are squeamish ossifrage", signature))
FAIL();
/* Try correct data */
if (!VERIFY(pub, sha512,
"The magic words are squeamish ossifrage", signature))
FAIL();
/* Try bad signature */
mpz_togglebit(signature, 17);
if (VERIFY(pub, sha512,
"The magic words are squeamish ossifrage", signature))
FAIL();
mpz_clear(signature);
}
#undef SIGN
#undef VERIFY
......
......@@ -122,6 +122,11 @@ test_rsa_sha256(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected);
void
test_rsa_sha512(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected);
void
test_rsa_key(struct rsa_public_key *pub,
struct rsa_private_key *key);
......
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