Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New wolfcrypt Hardware Acceleration SHA Copy Tests #6134

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2907,9 +2907,10 @@ WOLFSSL_TEST_SUBROUTINE int sha512_test(void)
/*
** See https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA512.pdf
*/
wc_Sha512 sha, shaCopy;
wc_Sha512 sha, shaCopy, shaRawCopy;
byte hash[WC_SHA512_DIGEST_SIZE];
byte hashcopy[WC_SHA512_DIGEST_SIZE];
byte hashRawCopy[WC_SHA512_DIGEST_SIZE];
int ret = 0;

testVector a, b, c;
Expand Down Expand Up @@ -2968,13 +2969,22 @@ WOLFSSL_TEST_SUBROUTINE int sha512_test(void)
ret = wc_Sha512Copy(&sha, &shaCopy);
if (ret != 0)
ERROR_OUT(-2404 - i, exit);
XMEMCPY(&shaRawCopy, &sha, sizeof(wc_Sha512));
ret = wc_Sha512Final(&shaRawCopy, hashRawCopy);
if (ret != 0)
ERROR_OUT(-2414 - i, exit);
ret = wc_Sha512Final(&sha, hash);
if (ret != 0)
ERROR_OUT(-2405 - i, exit);
wc_Sha512Free(&shaCopy);
wc_Sha512Free(&shaRawCopy); /* this is a local variable, surely does
** not actually need to be free'd? */
/* see https://cloud.wolfssl-test.com/jenkins/job/PRB-valgrind-check-v2/4286/console */

if (XMEMCMP(hash, test_sha[i].output, WC_SHA512_DIGEST_SIZE) != 0)
ERROR_OUT(-2406 - i, exit);
if (XMEMCMP(hash, hashRawCopy, WC_SHA512_DIGEST_SIZE) != 0)
ERROR_OUT(-2417 - i, exit);
if (XMEMCMP(hash, hashcopy, WC_SHA512_DIGEST_SIZE) != 0)
ERROR_OUT(-2407 - i, exit);
}
Expand Down Expand Up @@ -3009,6 +3019,13 @@ WOLFSSL_TEST_SUBROUTINE int sha512_test(void)
(word32)sizeof(large_input));
if (ret != 0)
ERROR_OUT(-2408, exit);
/* This next test is only interesting when hardware acceleration used.
** We'll check how well single-use HW handles a second call from a copy
** of the sha struct. In software, this should do nothing. With HW, it
** should *not* interfere with the original sha hash calc. */
ret = wc_Sha512Final(&shaRawCopy, hashRawCopy);
if (ret != 0)
ERROR_OUT(-2418, exit);
}
ret = wc_Sha512Final(&sha, hash);
if (ret != 0)
Expand Down