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

Digest tests: add more tests #8528

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,8 @@ if(WOLFSSL_EXAMPLES)
# Build unit tests
add_executable(unit_test
tests/api.c
tests/api/test_md2.c
tests/api/test_md4.c
tests/api/test_md5.c
tests/api/test_sha.c
tests/api/test_sha256.c
Expand Down
27 changes: 26 additions & 1 deletion tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@
#include <tests/api/api.h>

/* Gather test declarations to include them in the testCases array */
#include <tests/api/test_md2.h>
#include <tests/api/test_md4.h>
#include <tests/api/test_md5.h>
#include <tests/api/test_sha.h>
#include <tests/api/test_sha256.h>
Expand Down Expand Up @@ -88997,6 +88999,21 @@ TEST_CASE testCases[] = {
TEST_DECL(test_wc_LockMutex_ex),

/* Digests */
/* test_md2.c */
TEST_DECL(test_wc_InitMd2),
TEST_DECL(test_wc_Md2Update),
TEST_DECL(test_wc_Md2Final),
TEST_DECL(test_wc_Md2_KATs),
TEST_DECL(test_wc_Md2_other),
TEST_DECL(test_wc_Md2Hash),

/* test_md4.c */
TEST_DECL(test_wc_InitMd4),
TEST_DECL(test_wc_Md4Update),
TEST_DECL(test_wc_Md4Final),
TEST_DECL(test_wc_Md4_KATs),
TEST_DECL(test_wc_Md4_other),

/* test_md5.c */
TEST_DECL(test_wc_InitMd5),
TEST_DECL(test_wc_Md5Update),
Expand Down Expand Up @@ -89145,7 +89162,6 @@ TEST_CASE testCases[] = {
TEST_DECL(test_wc_Sm3Copy),
TEST_DECL(test_wc_Sm3GetHash),
TEST_DECL(test_wc_Sm3_Flags),
TEST_DECL(test_wc_Sm3Hash),

/* test_ripemd.c */
TEST_DECL(test_wc_InitRipeMd),
Expand All @@ -89156,8 +89172,17 @@ TEST_CASE testCases[] = {

/* test_hash.c */
TEST_DECL(test_wc_HashInit),
TEST_DECL(test_wc_HashUpdate),
TEST_DECL(test_wc_HashFinal),
TEST_DECL(test_wc_HashNewDelete),
TEST_DECL(test_wc_HashGetDigestSize),
TEST_DECL(test_wc_HashGetBlockSize),
TEST_DECL(test_wc_Hash),
TEST_DECL(test_wc_HashSetFlags),
TEST_DECL(test_wc_HashGetFlags),
TEST_DECL(test_wc_Hash_Algs),
TEST_DECL(test_wc_HashGetOID),
TEST_DECL(test_wc_OidGetHash),

/* HMAC */
TEST_DECL(test_wc_Md5HmacSetKey),
Expand Down
4 changes: 4 additions & 0 deletions tests/api/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

if BUILD_TESTS
# Digests
tests_unit_test_SOURCES += tests/api/test_md2.c
tests_unit_test_SOURCES += tests/api/test_md4.c
tests_unit_test_SOURCES += tests/api/test_md5.c
tests_unit_test_SOURCES += tests/api/test_sha.c
tests_unit_test_SOURCES += tests/api/test_sha256.c
Expand Down Expand Up @@ -37,6 +39,8 @@ tests_unit_test_SOURCES += tests/api/test_ocsp.c
endif

EXTRA_DIST += tests/api/api.h
EXTRA_DIST += tests/api/test_md2.h
EXTRA_DIST += tests/api/test_md4.h
EXTRA_DIST += tests/api/test_md5.h
EXTRA_DIST += tests/api/test_sha.h
EXTRA_DIST += tests/api/test_sha256.h
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_blake2.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ int test_wc_Blake2sFinal(void)
EXPECT_DECLS;
#ifdef HAVE_BLAKE2S
Blake2s blake;
byte hash[WC_BLAKE2B_DIGEST_SIZE];
byte hash[WC_BLAKE2S_DIGEST_SIZE];

/* Initialize */
ExpectIntEQ(wc_InitBlake2s(&blake, WC_BLAKE2S_DIGEST_SIZE), 0);
Expand All @@ -407,7 +407,7 @@ int test_wc_Blake2sFinal(void)
ExpectIntEQ(wc_Blake2sFinal(NULL, hash, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG));

/* Test good args. */
ExpectIntEQ(wc_Blake2sFinal(&blake, hash, WC_BLAKE2B_DIGEST_SIZE), 0);
ExpectIntEQ(wc_Blake2sFinal(&blake, hash, WC_BLAKE2S_DIGEST_SIZE), 0);
#endif
return EXPECT_RESULT();
}
Expand Down
200 changes: 185 additions & 15 deletions tests/api/test_digest.h

Large diffs are not rendered by default.

Loading
Loading