Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nettle
nettle
Commits
99e8976d
Commit
99e8976d
authored
Mar 23, 2010
by
Niels Möller
Browse files
(test_rsa_sha512): New function.
Rev: nettle/testsuite/testutils.c:1.4 Rev: nettle/testsuite/testutils.h:1.3
parent
3eebb3fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
testsuite/testutils.c
View file @
99e8976d
...
...
@@ -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
...
...
testsuite/testutils.h
View file @
99e8976d
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment