Commit 8bdcb98a authored by Niels Möller's avatar Niels Möller

* testsuite/rsa-test.c (test_main): Use test_rsa_sha256.

* testsuite/testutils.c (test_rsa_sha256): New function.

Rev: src/nettle/testsuite/rsa-test.c:1.8
Rev: src/nettle/testsuite/testutils.c:1.30
Rev: src/nettle/testsuite/testutils.h:1.25
parent d4f1ce9f
......@@ -39,6 +39,16 @@ test_main(void)
test_rsa_sha1(&pub, &key, expected);
mpz_set_str(expected,
"13f9e43f7a401a73" "0a74985c01520d76" "bf5f2e2dff91e93b"
"9267d8c388d6937b" "d4bc6f1fa31618a9" "b5e3a1a875af72f5"
"0e805dbfebdf4348" "7d49763f0b365e78" "d2c0ea8fb3785897"
"782289a58f998907" "248c9cdf2c643d7e" "6ba6b55026227773"
"6f19caa69c4fc6d7" "7e2e5d4cd6b7a82b" "900d201ffd000448"
"685e5a4f3e", 16);
test_rsa_sha256(&pub, &key, expected);
/* 777-bit key, generated by
*
* lsh-keygen -a rsa -l 777 -f advanced-hex
......@@ -147,6 +157,15 @@ test_main(void)
test_rsa_sha1(&pub, &key, expected);
mpz_set_str(expected,
"d759bb28b4d249a2" "f8b67bdbb1ab7f50" "c88712fbcabc2956"
"1ec6ca3f8fdafe7a" "38433d7da287b8f7" "87857274c1640b2b"
"e652cd89c501d570" "3980a0af5c6bb60c" "f84feab25b099d06"
"e2519accb73dac43" "fb8bdad28835f3bd" "84c43678fe2ef41f"
"af", 16);
test_rsa_sha256(&pub, &key, expected);
rsa_private_key_clear(&key);
rsa_public_key_clear(&pub);
mpz_clear(expected);
......
......@@ -624,6 +624,49 @@ test_rsa_sha1(struct rsa_public_key *pub,
mpz_clear(signature);
}
void
test_rsa_sha256(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected)
{
struct sha256_ctx sha256;
mpz_t signature;
sha256_init(&sha256);
mpz_init(signature);
SIGN(key, sha256, "The magic words are squeamish ossifrage", signature);
if (verbose)
{
fprintf(stderr, "rsa-sha256 signature: ");
mpz_out_str(stderr, 16, signature);
fprintf(stderr, "\n");
}
if (mpz_cmp(signature, expected))
FAIL();
/* Try bad data */
if (VERIFY(pub, sha256,
"The magick words are squeamish ossifrage", signature))
FAIL();
/* Try correct data */
if (!VERIFY(pub, sha256,
"The magic words are squeamish ossifrage", signature))
FAIL();
/* Try bad signature */
mpz_togglebit(signature, 17);
if (VERIFY(pub, sha256,
"The magic words are squeamish ossifrage", signature))
FAIL();
mpz_clear(signature);
}
#undef SIGN
#undef VERIFY
......
......@@ -117,6 +117,11 @@ test_rsa_sha1(struct rsa_public_key *pub,
struct rsa_private_key *key,
mpz_t expected);
void
test_rsa_sha256(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