Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitry Baryshkov
nettle
Commits
c716de8f
Commit
c716de8f
authored
Mar 22, 2010
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(test_main): Added test cases for hmac-sha512.
Rev: nettle/testsuite/hmac-test.c:1.2
parent
181d6f2b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
testsuite/hmac-test.c
+59
-6
59 additions, 6 deletions
testsuite/hmac-test.c
with
59 additions
and
6 deletions
testsuite/hmac-test.c
+
59
−
6
View file @
c716de8f
...
...
@@ -7,9 +7,10 @@ test_main(void)
struct
hmac_md5_ctx
md5
;
struct
hmac_sha1_ctx
sha1
;
struct
hmac_sha256_ctx
sha256
;
struct
hmac_sha512_ctx
sha512
;
/* sha
256
's digests are longest */
uint8_t
digest
[
SHA
256
_DIGEST_SIZE
];
/* sha
512
's digests are longest */
uint8_t
digest
[
SHA
512
_DIGEST_SIZE
];
memset
(
digest
,
0
,
sizeof
(
digest
));
...
...
@@ -316,5 +317,57 @@ test_main(void)
"84d3e7a1ff98a2fc 2ac7d8e064c3b2e6"
)))
FAIL
();
/* Test vectors for sha512, from draft-kelly-ipsec-ciph-sha2-01.txt */
/* Test case AUTH512-1: */
hmac_sha512_set_key
(
&
sha512
,
HL
(
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
));
hmac_sha512_update
(
&
sha512
,
LDATA
(
"Hi There"
));
hmac_sha512_digest
(
&
sha512
,
SHA512_DIGEST_SIZE
,
digest
);
if
(
!
MEMEQ
(
SHA512_DIGEST_SIZE
,
digest
,
H
(
"637edc6e01dce7e6742a99451aae82df"
"23da3e92439e590e43e761b33e910fb8"
"ac2878ebd5803f6f0b61dbce5e251ff8"
"789a4722c1be65aea45fd464e89f8f5b"
)))
FAIL
();
/* Test case AUTH512-2: */
hmac_sha512_set_key
(
&
sha512
,
LDATA
(
"JefeJefeJefeJefe"
"JefeJefeJefeJefe"
"JefeJefeJefeJefe"
"JefeJefeJefeJefe"
));
hmac_sha512_update
(
&
sha512
,
LDATA
(
"what do ya want for nothing?"
));
hmac_sha512_digest
(
&
sha512
,
SHA512_DIGEST_SIZE
,
digest
);
if
(
!
MEMEQ
(
SHA512_DIGEST_SIZE
,
digest
,
H
(
"cb370917ae8a7ce28cfd1d8f4705d614"
"1c173b2a9362c15df235dfb251b15454"
"6aa334ae9fb9afc2184932d8695e397b"
"fa0ffb93466cfcceaae38c833b7dba38"
)))
FAIL
();
/* Test case AUTH512-3: */
hmac_sha512_set_key
(
&
sha512
,
HL
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
));
hmac_sha512_update
(
&
sha512
,
HL
(
"dddddddddddddddddddddddddddddddd"
"dddddddddddddddddddddddddddddddd"
"dddddddddddddddddddddddddddddddd"
"dddd"
));
hmac_sha512_digest
(
&
sha512
,
SHA512_DIGEST_SIZE
,
digest
);
if
(
!
MEMEQ
(
SHA512_DIGEST_SIZE
,
digest
,
H
(
"2ee7acd783624ca9398710f3ee05ae41"
"b9f9b0510c87e49e586cc9bf961733d8"
"623c7b55cebefccf02d5581acc1c9d5f"
"b1ff68a1de45509fbe4da9a433922655"
)))
FAIL
();
/* Test case AUTH512-3 from same document seems broken. */
SUCCESS
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment