mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Digest tests: add more tests
Add testing of MD2 and Md4. Add more tests of functions in hash.c. Reformat data to match what is output by PRINT_DATA macro.
This commit is contained in:
@ -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
|
||||
|
27
tests/api.c
27
tests/api.c
@ -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>
|
||||
@ -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),
|
||||
@ -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),
|
||||
@ -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),
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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);
|
||||
@ -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();
|
||||
}
|
||||
|
@ -68,6 +68,17 @@ do { \
|
||||
\
|
||||
wc_##name##Free(NULL)
|
||||
|
||||
#define DIGEST_INIT_ONLY_TEST(type, name) \
|
||||
do { \
|
||||
type dgst; \
|
||||
\
|
||||
/* Test bad arg. */ \
|
||||
wc_Init##name(NULL); \
|
||||
\
|
||||
/* Test good arg. */ \
|
||||
wc_Init##name(&dgst); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_UPDATE_TEST(type, name) \
|
||||
type dgst; \
|
||||
\
|
||||
@ -79,6 +90,8 @@ do { \
|
||||
ExpectIntEQ(wc_##name##Update(&dgst, NULL, 1), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Update(NULL, NULL, 0), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Update(NULL, (byte*)"a", 1), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ExpectIntEQ(wc_##name##Update(&dgst, NULL, 0), 0); \
|
||||
@ -98,6 +111,8 @@ do { \
|
||||
ExpectIntEQ(wc_##name##_Update(&dgst, NULL, 1), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##_Update(NULL, NULL, 0), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##_Update(NULL, (byte*)"a", 1), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ExpectIntEQ(wc_##name##_Update(&dgst, NULL, 0), 0); \
|
||||
@ -106,6 +121,20 @@ do { \
|
||||
wc_##name##_Free(&dgst); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_UPDATE_ONLY_TEST(type, name) \
|
||||
type dgst; \
|
||||
\
|
||||
wc_Init##name(&dgst); \
|
||||
\
|
||||
/* Pass in bad values. */ \
|
||||
wc_##name##Update(NULL, NULL, 1); \
|
||||
wc_##name##Update(&dgst, NULL, 1); \
|
||||
wc_##name##Update(NULL, NULL, 0); \
|
||||
wc_##name##Update(NULL, (byte*)"a", 1); \
|
||||
\
|
||||
wc_##name##Update(&dgst, NULL, 0); \
|
||||
wc_##name##Update(&dgst, (byte*)"a", 1)
|
||||
|
||||
#define DIGEST_FINAL_TEST(type, name, upper) \
|
||||
type dgst; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE]; \
|
||||
@ -165,6 +194,21 @@ do { \
|
||||
wc_##name##_Free(&dgst); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_FINAL_ONLY_TEST(type, name, upper) \
|
||||
type dgst; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE]; \
|
||||
\
|
||||
/* Initialize */ \
|
||||
wc_Init##name(&dgst); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
wc_##name##Final(NULL, NULL); \
|
||||
wc_##name##Final(&dgst, NULL); \
|
||||
wc_##name##Final(NULL, hash); \
|
||||
\
|
||||
/* Test good args. */ \
|
||||
wc_##name##Final(&dgst, hash); \
|
||||
|
||||
#define DIGEST_FINAL_RAW_TEST(type, name, upper, hashStr) \
|
||||
type dgst; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE]; \
|
||||
@ -241,6 +285,23 @@ do { \
|
||||
\
|
||||
wc_##name##_Free(&dgst)
|
||||
|
||||
#define DIGEST_KATS_ONLY_TEST(name, upper) \
|
||||
do { \
|
||||
(void)i; \
|
||||
\
|
||||
/* Initialize */ \
|
||||
wc_Init##name(&dgst); \
|
||||
\
|
||||
for (i = 0; i < upper##_KAT_CNT; i++) { \
|
||||
/* Do KAT. */ \
|
||||
wc_##name##Update(&dgst, (byte*)dgst_kat[i].input, \
|
||||
(word32)dgst_kat[i].inLen); \
|
||||
wc_##name##Final(&dgst, hash); \
|
||||
ExpectBufEQ(hash, (byte*)dgst_kat[i].output, \
|
||||
WC_##upper##_DIGEST_SIZE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_OTHER_TEST(type, name, upper, hashStr) \
|
||||
type dgst; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE + 1]; \
|
||||
@ -367,6 +428,46 @@ do { \
|
||||
wc_##name##_Free(&dgst); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_OTHER_ONLY_TEST(type, name, upper, hashStr) \
|
||||
do { \
|
||||
type dgst; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE + 1]; \
|
||||
byte data[WC_##upper##_DIGEST_SIZE * 8 + 1]; \
|
||||
int dataLen = WC_##upper##_DIGEST_SIZE * 8; \
|
||||
const char* expHash = hashStr; \
|
||||
int i; \
|
||||
int j; \
|
||||
\
|
||||
XMEMSET(data, 0xa5, sizeof(data)); \
|
||||
\
|
||||
/* Initialize */ \
|
||||
wc_Init##name(&dgst); \
|
||||
\
|
||||
/* Unaligned input and output buffer. */ \
|
||||
wc_##name##Update(&dgst, data + 1, dataLen); \
|
||||
wc_##name##Final(&dgst, hash + 1); \
|
||||
ExpectBufEQ(hash + 1, (byte*)expHash, WC_##upper##_DIGEST_SIZE); \
|
||||
\
|
||||
/* Test that empty updates work. */ \
|
||||
wc_##name##Update(&dgst, NULL, 0); \
|
||||
wc_##name##Update(&dgst, (byte*)"", 0); \
|
||||
wc_##name##Update(&dgst, data, dataLen); \
|
||||
wc_##name##Final(&dgst, hash); \
|
||||
ExpectBufEQ(hash, (byte*)expHash, WC_##upper##_DIGEST_SIZE); \
|
||||
\
|
||||
/* Ensure chunking works. */ \
|
||||
for (i = 1; i < dataLen; i++) { \
|
||||
for (j = 0; j < dataLen; j += i) { \
|
||||
int len = dataLen - j; \
|
||||
if (i < len) \
|
||||
len = i; \
|
||||
wc_##name##Update(&dgst, data + j, len); \
|
||||
} \
|
||||
wc_##name##Final(&dgst, hash); \
|
||||
ExpectBufEQ(hash, (byte*)expHash, WC_##upper##_DIGEST_SIZE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_COPY_TEST(type, name, upper, emptyHashStr, abcHashStr) \
|
||||
type src; \
|
||||
type dst; \
|
||||
@ -541,10 +642,12 @@ do { \
|
||||
ExpectIntEQ(wc_Init##name(&dgst), 0); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
|
||||
BAD_FUNC_ARG); \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, (byte*)abc##name##Data), 0); \
|
||||
ExpectBufEQ((byte*)dgst.digest, (byte*)abcHash, WC_##upper##_DIGEST_SIZE); \
|
||||
@ -564,10 +667,12 @@ do { \
|
||||
ExpectIntEQ(wc_Init##name(&dgst), 0); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
|
||||
BAD_FUNC_ARG); \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, (byte*)abcData), 0); \
|
||||
ExpectIntEQ(wc_##name##FinalRaw(&dgst, hash), 0); \
|
||||
@ -587,10 +692,12 @@ do { \
|
||||
ExpectIntEQ(wc_Init##name(&dgst), 0); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
|
||||
BAD_FUNC_ARG); \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ByteReverseWords((word32*)abc##name##DataBE, (word32*)abc##name##Data, \
|
||||
WC_##upper##_BLOCK_SIZE); \
|
||||
@ -613,10 +720,12 @@ do { \
|
||||
ExpectIntEQ(wc_Init##name(&dgst), 0); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
|
||||
BAD_FUNC_ARG); \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ByteReverseWords((word32*)abc##name##DataBE, (word32*)abc##name##Data, \
|
||||
WC_##upper##_BLOCK_SIZE); \
|
||||
@ -641,10 +750,12 @@ do { \
|
||||
ExpectIntEQ(wc_Init##name(&dgst), 0); \
|
||||
\
|
||||
/* Test bad args. */ \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), BAD_FUNC_ARG); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Transform(NULL, (byte*)abc##name##Data), \
|
||||
BAD_FUNC_ARG); \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
ExpectIntEQ(wc_##name##Transform(&dgst, (byte*)abcData), 0); \
|
||||
ExpectIntEQ(wc_##name##FinalRaw(&dgst, hash), 0); \
|
||||
@ -714,3 +825,62 @@ do { \
|
||||
wc_##inst##_Free(&dgst_copy); \
|
||||
wc_##inst##_Free(&dgst)
|
||||
|
||||
#define DIGEST_HASH_TEST(name, upper) \
|
||||
do { \
|
||||
byte data[WC_##upper##_BLOCK_SIZE]; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE]; \
|
||||
\
|
||||
XMEMSET(data, 0xa5, sizeof(data)); \
|
||||
\
|
||||
/* Invalid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(NULL, sizeof(data), hash), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(NULL, sizeof(data), hash, HEAP_HINT, \
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(data, sizeof(data), NULL, HEAP_HINT, \
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
/* Valid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), hash), 0); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(data, sizeof(data), hash, HEAP_HINT, \
|
||||
INVALID_DEVID), 0); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_COUNT_HASH_TEST(name, upper) \
|
||||
do { \
|
||||
byte data[WC_##upper##_COUNT * 8]; \
|
||||
byte hash[WC_##upper##_COUNT * 8]; \
|
||||
\
|
||||
XMEMSET(data, 0xa5, sizeof(data)); \
|
||||
\
|
||||
/* Invalid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(NULL, sizeof(data), hash), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), NULL), \
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(NULL, sizeof(data), hash, HEAP_HINT, \
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(data, sizeof(data), NULL, HEAP_HINT, \
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); \
|
||||
\
|
||||
/* Valid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), hash), 0); \
|
||||
ExpectIntEQ(wc_##name##Hash_ex(data, sizeof(data), hash, HEAP_HINT, \
|
||||
INVALID_DEVID), 0); \
|
||||
} while (0)
|
||||
|
||||
#define DIGEST_HASH_ONLY_TEST(name, upper) \
|
||||
byte data[WC_##upper##_BLOCK_SIZE]; \
|
||||
byte hash[WC_##upper##_DIGEST_SIZE]; \
|
||||
\
|
||||
XMEMSET(data, 0xa5, sizeof(data)); \
|
||||
\
|
||||
/* Invalid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(NULL, sizeof(data), hash), 0); \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), NULL), 0); \
|
||||
\
|
||||
/* Valid parameters. */ \
|
||||
ExpectIntEQ(wc_##name##Hash(data, sizeof(data), hash), 0)
|
||||
|
||||
|
@ -40,119 +40,549 @@
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_hash.h>
|
||||
#include <tests/api/test_digest.h>
|
||||
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
static const enum wc_HashType supportedHash[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
#ifndef WOLFSSL_NOSHA512_224
|
||||
WC_HASH_TYPE_SHA512_224,
|
||||
#endif
|
||||
#ifndef WOLFSSL_NOSHA512_256
|
||||
WC_HASH_TYPE_SHA512_256,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
WC_HASH_TYPE_SHA3_256,
|
||||
WC_HASH_TYPE_SHA3_384,
|
||||
WC_HASH_TYPE_SHA3_512,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SM3
|
||||
WC_HASH_TYPE_SM3,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int supportedHashLen = (sizeof(supportedHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
|
||||
static const enum wc_HashType notCompiledHash[] = {
|
||||
#ifdef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifdef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifdef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
WC_HASH_TYPE_SHA3_256,
|
||||
WC_HASH_TYPE_SHA3_384,
|
||||
WC_HASH_TYPE_SHA3_512,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int notCompiledHashLen = (sizeof(notCompiledHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
|
||||
static const enum wc_HashType notSupportedHash[] = {
|
||||
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
|
||||
WC_HASH_TYPE_SHAKE128,
|
||||
#endif
|
||||
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
|
||||
WC_HASH_TYPE_SHAKE256,
|
||||
#endif
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
WC_HASH_TYPE_MD2,
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE
|
||||
};
|
||||
static const int notSupportedHashLen = (sizeof(notSupportedHash) /
|
||||
sizeof(enum wc_HashType));
|
||||
|
||||
static const enum wc_HashType sizeSupportedHash[] = {
|
||||
#if !defined(NO_MD5) && !defined(NO_SHA)
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_MD2
|
||||
WC_HASH_TYPE_MD2,
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
WC_HASH_TYPE_MD4,
|
||||
#endif
|
||||
#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int sizeSupportedHashLen = (sizeof(sizeSupportedHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
static const enum wc_HashType sizeNotCompiledHash[] = {
|
||||
#if defined(NO_MD5) || defined(NO_SHA)
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
#endif
|
||||
#ifndef WOLFSSL_MD2
|
||||
WC_HASH_TYPE_MD2,
|
||||
#endif
|
||||
#ifdef NO_MD4
|
||||
WC_HASH_TYPE_MD4,
|
||||
#endif
|
||||
#if !defined(HAVE_BLAKE2) && !defined(HAVE_BLAKE2S)
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int sizeNotCompiledHashLen = (sizeof(sizeNotCompiledHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
static const enum wc_HashType sizeNotSupportedHash[] = {
|
||||
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
|
||||
WC_HASH_TYPE_SHAKE128,
|
||||
#endif
|
||||
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
|
||||
WC_HASH_TYPE_SHAKE256,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE
|
||||
};
|
||||
static const int sizeNotSupportedHashLen = (sizeof(sizeNotSupportedHash) /
|
||||
sizeof(enum wc_HashType));
|
||||
#endif /* NO_HASH_WRAPPER */
|
||||
|
||||
int test_wc_HashInit(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
wc_HashAlg hash;
|
||||
int i; /* 0 indicates tests passed, 1 indicates failure */
|
||||
|
||||
wc_HashAlg hash;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
};
|
||||
/* dynamically finds the length */
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
/* check for bad args */
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
/* check for null ptr */
|
||||
ExpectIntEQ(wc_HashInit(NULL, enumArray[i]),
|
||||
ExpectIntEQ(wc_HashInit(NULL, supportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashInit_ex(NULL, supportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashInit(&hash, supportedHash[i]), 0);
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
ExpectIntEQ(wc_HashInit_ex(&hash, supportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), 0);
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
|
||||
wc_HashFree(NULL, supportedHash[i]);
|
||||
} /* end of for loop */
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
/* check for null ptr */
|
||||
ExpectIntEQ(wc_HashInit(NULL, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashInit_ex(NULL, notCompiledHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashInit(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashInit_ex(&hash, notCompiledHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
|
||||
wc_HashFree(NULL, notCompiledHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
/* check for null ptr */
|
||||
ExpectIntEQ(wc_HashInit(NULL, supportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashInit_ex(NULL, supportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, notSupportedHash[i]);
|
||||
ExpectIntEQ(wc_HashInit_ex(&hash, notSupportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, notSupportedHash[i]);
|
||||
|
||||
wc_HashFree(NULL, notSupportedHash[i]);
|
||||
} /* end of for loop */
|
||||
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* end of test_wc_HashInit */
|
||||
|
||||
int test_wc_HashUpdate(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
wc_HashAlg hash;
|
||||
int i; /* 0 indicates tests passed, 1 indicates failure */
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, supportedHash[i]), 0);
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, supportedHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, supportedHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, supportedHash[i], NULL, 0),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, supportedHash[i], (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, supportedHash[i], NULL, 0), 0);
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, supportedHash[i], (byte*)"a", 1), 0);
|
||||
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notCompiledHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notCompiledHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notCompiledHash[i], NULL, 0),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notCompiledHash[i], (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notCompiledHash[i], NULL, 0),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notCompiledHash[i], (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
|
||||
wc_HashFree(&hash, notCompiledHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notSupportedHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notSupportedHash[i], NULL, 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notSupportedHash[i], NULL, 0),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(NULL, notSupportedHash[i], (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notSupportedHash[i], NULL, 0),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, notSupportedHash[i], (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_HashFree(&hash, notSupportedHash[i]);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WOLFSSL) && !defined(NO_SHA256) && defined(WOLFSSL_SHA512)
|
||||
ExpectIntEQ(wc_HashInit(&hash, WC_HASH_TYPE_SHA256), 0);
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, WC_HASH_TYPE_SHA512, NULL, 0),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashUpdate(&hash, WC_HASH_TYPE_SHA512, (byte*)"a", 1),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_HashFinal(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
wc_HashAlg hash;
|
||||
byte digest[WC_MAX_DIGEST_SIZE];
|
||||
int i; /* 0 indicates tests passed, 1 indicates failure */
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, supportedHash[i]), 0);
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashFinal(NULL, supportedHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(&hash, supportedHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(NULL, supportedHash[i], digest),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashFinal(&hash, supportedHash[i], digest), 0);
|
||||
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashFinal(NULL, notCompiledHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(&hash, notCompiledHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(NULL, notCompiledHash[i], digest),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashFinal(&hash, notCompiledHash[i], digest),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
|
||||
wc_HashFree(&hash, notCompiledHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
/* Invalid parameters */
|
||||
ExpectIntEQ(wc_HashFinal(NULL, notSupportedHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(&hash, notSupportedHash[i], NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFinal(NULL, notSupportedHash[i], digest),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
ExpectIntEQ(wc_HashFinal(&hash, notSupportedHash[i], digest),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_HashFree(&hash, notSupportedHash[i]);
|
||||
}
|
||||
#if defined(DEBUG_WOLFSSL) && !defined(NO_SHA256) && defined(WOLFSSL_SHA512)
|
||||
ExpectIntEQ(wc_HashInit(&hash, WC_HASH_TYPE_SHA256), 0);
|
||||
ExpectIntEQ(wc_HashFinal(&hash, WC_HASH_TYPE_SHA512, digest),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_HashNewDelete(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_HASH_WRAPPER) && !defined(WC_NO_CONSTRUCTORS)
|
||||
wc_HashAlg* hash;
|
||||
byte digest[WC_MAX_DIGEST_SIZE];
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectNotNull(hash = wc_HashNew(supportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID, &ret));
|
||||
ExpectIntEQ(ret, 0);
|
||||
|
||||
ExpectIntEQ(wc_HashUpdate(hash, supportedHash[i], (byte*)"a", 1), 0);
|
||||
ExpectIntEQ(wc_HashFinal(hash, supportedHash[i], digest), 0);
|
||||
|
||||
ExpectIntEQ(wc_HashDelete(hash, &hash), 0);
|
||||
ExpectNull(hash);
|
||||
|
||||
ExpectNotNull(hash = wc_HashNew(supportedHash[i], HEAP_HINT,
|
||||
INVALID_DEVID, &ret));
|
||||
ExpectIntEQ(ret, 0);
|
||||
ExpectIntEQ(wc_HashDelete(hash, NULL), 0);
|
||||
|
||||
ExpectIntEQ(wc_HashDelete(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectNull(wc_HashNew(notCompiledHash[i], HEAP_HINT, INVALID_DEVID,
|
||||
&ret));
|
||||
ExpectIntEQ(ret, WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
ExpectNull(wc_HashNew(notSupportedHash[i], HEAP_HINT, INVALID_DEVID,
|
||||
&ret));
|
||||
ExpectIntEQ(ret, WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_HashGetDigestSize(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
int i;
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetDigestSize(supportedHash[i]), 0);
|
||||
}
|
||||
for (i = 0; i < sizeSupportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetDigestSize(sizeSupportedHash[i]), 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetDigestSize(notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
for (i = 0; i < sizeNotCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetDigestSize(sizeNotCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeNotSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetDigestSize(sizeNotSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_HashGetBlockSize(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
int i;
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetBlockSize(supportedHash[i]), 0);
|
||||
}
|
||||
for (i = 0; i < sizeSupportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetBlockSize(sizeSupportedHash[i]), 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetBlockSize(notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
for (i = 0; i < sizeNotCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetBlockSize(sizeNotCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeNotSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetBlockSize(sizeNotSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_Hash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_HASH_WRAPPER) && !defined(WC_NO_CONSTRUCTORS)
|
||||
byte digest[WC_MAX_DIGEST_SIZE];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_Hash(supportedHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest)), 0);
|
||||
ExpectIntEQ(wc_Hash_ex(supportedHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest), HEAP_HINT, INVALID_DEVID), 0);
|
||||
}
|
||||
#if !defined(NO_MD5) && !defined(NO_SHA)
|
||||
ExpectIntEQ(wc_Hash(WC_HASH_TYPE_MD5_SHA, (byte*)"a", 1,
|
||||
digest, sizeof(digest)), 0);
|
||||
ExpectIntEQ(wc_Hash_ex(WC_HASH_TYPE_MD5_SHA, (byte*)"a", 1,
|
||||
digest, sizeof(digest), HEAP_HINT, INVALID_DEVID), 0);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_Hash(notCompiledHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest)), WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_Hash_ex(notCompiledHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest), HEAP_HINT, INVALID_DEVID),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
for (i = 0; i < sizeNotCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_Hash(sizeNotCompiledHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest)), WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_Hash_ex(sizeNotCompiledHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest), HEAP_HINT, INVALID_DEVID),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeNotSupportedHashLen; i++) {
|
||||
if (notSupportedHash[i] == WC_HASH_TYPE_MD5_SHA) {
|
||||
/* Algorithm only supported with wc_Hash() and wc_Hash_ex(). */
|
||||
continue;
|
||||
}
|
||||
ExpectIntEQ(wc_Hash(sizeNotSupportedHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest)), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Hash_ex(sizeNotSupportedHash[i], (byte*)"a", 1,
|
||||
digest, sizeof(digest), HEAP_HINT, INVALID_DEVID),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unit test function for wc_HashSetFlags()
|
||||
*/
|
||||
int test_wc_HashSetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_HASH_FLAGS
|
||||
#if !defined(NO_HASH_WRAPPER) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_HashAlg hash;
|
||||
word32 flags = 0;
|
||||
int i, j;
|
||||
int notSupportedLen;
|
||||
int i;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
#endif
|
||||
};
|
||||
enum wc_HashType notSupported[] = {
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
WC_HASH_TYPE_MD2,
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE,
|
||||
};
|
||||
|
||||
/* dynamically finds the length */
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, enumArray[i], flags), 0);
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, supportedHash[i]), 0);
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, supportedHash[i], flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
ExpectIntEQ(wc_HashSetFlags(NULL, enumArray[i], flags),
|
||||
ExpectIntEQ(wc_HashSetFlags(NULL, supportedHash[i], flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, notCompiledHash[i], flags),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
/* For loop to test not supported cases */
|
||||
notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
|
||||
for (j = 0; j < notSupportedLen; j++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupported[j]),
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, notSupported[j], flags),
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, notSupportedHash[i], flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupported[j]),
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
@ -165,66 +595,230 @@ int test_wc_HashSetFlags(void)
|
||||
int test_wc_HashGetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_HASH_FLAGS
|
||||
#if !defined(NO_HASH_WRAPPER) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_HashAlg hash;
|
||||
word32 flags = 0;
|
||||
int i, j;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
#endif
|
||||
};
|
||||
enum wc_HashType notSupported[] = {
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
WC_HASH_TYPE_MD2,
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE,
|
||||
};
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
int notSupportedLen;
|
||||
int i;
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, enumArray[i], &flags), 0);
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, supportedHash[i]), 0);
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, supportedHash[i], &flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
ExpectIntEQ(wc_HashGetFlags(NULL, enumArray[i], &flags),
|
||||
ExpectIntEQ(wc_HashGetFlags(NULL, supportedHash[i], &flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
wc_HashFree(&hash, supportedHash[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, notCompiledHash[i], &flags),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
/* For loop to test not supported cases */
|
||||
notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
|
||||
for (j = 0; j < notSupportedLen; j++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupported[j]),
|
||||
for (i = 0; i < notSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, notSupported[j], &flags),
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, notSupportedHash[i], &flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupported[j]),
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_HashGetFlags */
|
||||
|
||||
int test_wc_Hash_Algs(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_HASH_WRAPPER
|
||||
#ifndef NO_MD5
|
||||
DIGEST_HASH_TEST(Md5, MD5);
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
DIGEST_HASH_TEST(Sha, SHA);
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
DIGEST_HASH_TEST(Sha224, SHA224);
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
DIGEST_HASH_TEST(Sha256, SHA256);
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
DIGEST_HASH_TEST(Sha384, SHA384);
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
DIGEST_HASH_TEST(Sha512, SHA512);
|
||||
#ifndef WOLFSSL_NOSHA512_224
|
||||
DIGEST_HASH_TEST(Sha512_224, SHA512_224);
|
||||
#endif
|
||||
#ifndef WOLFSSL_NOSHA512_256
|
||||
DIGEST_HASH_TEST(Sha512_256, SHA512_256);
|
||||
#endif
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
#ifdef WOLFSSL_SHA3
|
||||
DIGEST_COUNT_HASH_TEST(Sha3_224, SHA3_224);
|
||||
DIGEST_COUNT_HASH_TEST(Sha3_256, SHA3_256);
|
||||
DIGEST_COUNT_HASH_TEST(Sha3_384, SHA3_384);
|
||||
DIGEST_COUNT_HASH_TEST(Sha3_512, SHA3_512);
|
||||
#endif
|
||||
#ifdef WOLFSSL_SM3
|
||||
DIGEST_HASH_TEST(Sm3, SM3);
|
||||
#endif
|
||||
#endif /* !NO_HASH_WRAPPER */
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_HashGetOID(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_HASH_WRAPPER) && (!defined(NO_ASN) || !defined(NO_DH) || \
|
||||
defined(HAVE_ECC))
|
||||
static const enum wc_HashType oidOnlySupportedHash[] = {
|
||||
#ifdef WOLFSSL_MD2
|
||||
WC_HASH_TYPE_MD2,
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int oidOnlySupportedHashLen = (sizeof(oidOnlySupportedHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
static const enum wc_HashType oidOnlyNotCompiledHash[] = {
|
||||
#ifndef WOLFSSL_MD2
|
||||
WC_HASH_TYPE_MD2,
|
||||
#endif
|
||||
#ifdef NO_MD5
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
#endif
|
||||
WC_HASH_TYPE_NONE /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int oidOnlyNotCompiledHashLen =
|
||||
(sizeof(oidOnlyNotCompiledHash) / sizeof(enum wc_HashType)) - 1;
|
||||
static const enum wc_HashType oidNotSupportedHash[] = {
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE
|
||||
};
|
||||
static const int oidNotSupportedHashLen = (sizeof(oidNotSupportedHash) /
|
||||
sizeof(enum wc_HashType));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < supportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetOID(supportedHash[i]), 0);
|
||||
}
|
||||
for (i = 0; i < oidOnlySupportedHashLen; i++) {
|
||||
ExpectIntGT(wc_HashGetOID(oidOnlySupportedHash[i]), 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < notCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetOID(notCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
for (i = 0; i < oidOnlyNotCompiledHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetOID(oidOnlyNotCompiledHash[i]),
|
||||
WC_NO_ERR_TRACE(HASH_TYPE_E));
|
||||
}
|
||||
|
||||
for (i = 0; i < oidNotSupportedHashLen; i++) {
|
||||
ExpectIntEQ(wc_HashGetOID(oidNotSupportedHash[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_OidGetHash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_HASH_WRAPPER) && !defined(NO_ASN)
|
||||
static const int sumSupportedHash[] = {
|
||||
#ifdef WOLFSSL_MD2
|
||||
MD2h,
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
MD5h,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
SHAh,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
SHA224h,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
SHA256h,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
SHA384h,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
SHA512h,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
SHA3_224h,
|
||||
SHA3_256h,
|
||||
SHA3_384h,
|
||||
SHA3_512h,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SM3
|
||||
SM3h,
|
||||
#endif
|
||||
0 /* Dummy value to ensure list is non-zero. */
|
||||
};
|
||||
static const int sumSupportedHashLen = (sizeof(sumSupportedHash) /
|
||||
sizeof(enum wc_HashType)) - 1;
|
||||
static const int sumNotSupportedHash[] = {
|
||||
MD4h,
|
||||
#ifdef NO_MD5
|
||||
MD5h,
|
||||
#endif
|
||||
#ifdef NO_SHA
|
||||
SHAh,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA224
|
||||
SHA224h,
|
||||
#endif
|
||||
#ifdef NO_SHA256
|
||||
SHA256h,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA384
|
||||
SHA384h,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA512
|
||||
SHA512h,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA3
|
||||
SHA3_224h,
|
||||
SHA3_256h,
|
||||
SHA3_384h,
|
||||
SHA3_512h,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SM3
|
||||
SM3h,
|
||||
#endif
|
||||
0
|
||||
};
|
||||
static const int sumNotSupportedHashLen = (sizeof(sumNotSupportedHash) /
|
||||
sizeof(enum wc_HashType));
|
||||
int i;
|
||||
enum wc_HashType hash;
|
||||
|
||||
for (i = 0; i < sumSupportedHashLen; i++) {
|
||||
hash = wc_OidGetHash(sumSupportedHash[i]);
|
||||
ExpectTrue(hash != WC_HASH_TYPE_NONE);
|
||||
}
|
||||
|
||||
for (i = 0; i < sumNotSupportedHashLen; i++) {
|
||||
hash = wc_OidGetHash(sumNotSupportedHash[i]);
|
||||
ExpectTrue(hash == WC_HASH_TYPE_NONE);
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,16 @@
|
||||
#define WOLFCRYPT_TEST_HASH_H
|
||||
|
||||
int test_wc_HashInit(void);
|
||||
int test_wc_HashUpdate(void);
|
||||
int test_wc_HashFinal(void);
|
||||
int test_wc_HashNewDelete(void);
|
||||
int test_wc_HashGetDigestSize(void);
|
||||
int test_wc_HashGetBlockSize(void);
|
||||
int test_wc_Hash(void);
|
||||
int test_wc_HashSetFlags(void);
|
||||
int test_wc_HashGetFlags(void);
|
||||
int test_wc_Hash_Algs(void);
|
||||
int test_wc_HashGetOID(void);
|
||||
int test_wc_OidGetHash(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_HASH_H */
|
||||
|
135
tests/api/test_md2.c
Normal file
135
tests/api/test_md2.c
Normal file
@ -0,0 +1,135 @@
|
||||
/* test_md2.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/md2.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_md2.h>
|
||||
#include <tests/api/test_digest.h>
|
||||
|
||||
/* Unit test for wc_InitMd2() and wc_InitMd2_ex() */
|
||||
int test_wc_InitMd2(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifdef WOLFSSL_MD2
|
||||
DIGEST_INIT_ONLY_TEST(wc_Md2, Md2);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/* Unit test for wc_UpdateMd2() */
|
||||
int test_wc_Md2Update(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifdef WOLFSSL_MD2
|
||||
DIGEST_UPDATE_ONLY_TEST(wc_Md2, Md2);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/* Unit test for wc_Md2Final() */
|
||||
int test_wc_Md2Final(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifdef WOLFSSL_MD2
|
||||
DIGEST_FINAL_ONLY_TEST(wc_Md2, Md2, MD2);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
#define MD2_KAT_CNT 7
|
||||
|
||||
int test_wc_Md2_KATs(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_MD2
|
||||
DIGEST_KATS_TEST_VARS(wc_Md2, MD2);
|
||||
|
||||
/* From RFC 1321. */
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\x83\x50\xe5\xa3\xe2\x4c\x15\x3d"
|
||||
"\xf2\x27\x5c\x9f\x80\x69\x27\x73" );
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x32\xec\x01\xec\x4a\x6d\xac\x72"
|
||||
"\xc0\xab\x96\xfb\x34\xc0\xb5\xd1");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xda\x85\x3b\x0d\x3f\x88\xd9\x9b"
|
||||
"\x30\x28\x3a\x69\xe6\xde\xd6\xbb");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xab\x4f\x49\x6b\xfb\x2a\x53\x0b"
|
||||
"\x21\x9f\xf3\x30\x31\xfe\x06\xb0");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\x4e\x8d\xdf\xf3\x65\x02\x92\xab"
|
||||
"\x5a\x41\x08\xc3\xaa\x47\x94\x0b");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xda\x33\xde\xf2\xa4\x2d\xf1\x39"
|
||||
"\x75\x35\x28\x46\xc3\x03\x38\xcd");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xd5\x97\x6f\x79\xd8\x3d\x3a\x0d"
|
||||
"\xc9\x80\x6c\x3c\x66\xf3\xef\xd8");
|
||||
|
||||
DIGEST_KATS_ONLY_TEST(Md2, MD2);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_Md2_other(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_MD2
|
||||
DIGEST_OTHER_ONLY_TEST(wc_Md2, Md2, MD2,
|
||||
"\xa3\x0c\xa1\xdd\xfa\xd0\x7c\x97"
|
||||
"\x58\xfd\xe2\x53\xf0\xa1\xb0\x6d");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing wc_Md2Hash()
|
||||
*/
|
||||
int test_wc_Md2Hash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_MD2)
|
||||
DIGEST_HASH_ONLY_TEST(Md2, MD2);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sm3Hash */
|
||||
|
32
tests/api/test_md2.h
Normal file
32
tests/api/test_md2.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* test_md2.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_MD2_H
|
||||
#define WOLFCRYPT_TEST_MD2_H
|
||||
|
||||
int test_wc_InitMd2(void);
|
||||
int test_wc_Md2Update(void);
|
||||
int test_wc_Md2Final(void);
|
||||
int test_wc_Md2_KATs(void);
|
||||
int test_wc_Md2_other(void);
|
||||
int test_wc_Md2Hash(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_MD2_H */
|
123
tests/api/test_md4.c
Normal file
123
tests/api/test_md4.c
Normal file
@ -0,0 +1,123 @@
|
||||
/* test_md4.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/md4.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_md4.h>
|
||||
#include <tests/api/test_digest.h>
|
||||
|
||||
/* Unit test for wc_InitMd4() and wc_InitMd4_ex() */
|
||||
int test_wc_InitMd4(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifndef NO_MD4
|
||||
DIGEST_INIT_ONLY_TEST(wc_Md4, Md4);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/* Unit test for wc_UpdateMd4() */
|
||||
int test_wc_Md4Update(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifndef NO_MD4
|
||||
DIGEST_UPDATE_ONLY_TEST(wc_Md4, Md4);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/* Unit test for wc_Md4Final() */
|
||||
int test_wc_Md4Final(void)
|
||||
{
|
||||
EXPECT_SUCCESS_DECLS;
|
||||
#ifndef NO_MD4
|
||||
DIGEST_FINAL_ONLY_TEST(wc_Md4, Md4, MD4);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
#define MD4_KAT_CNT 7
|
||||
|
||||
int test_wc_Md4_KATs(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD4
|
||||
DIGEST_KATS_TEST_VARS(wc_Md4, MD4);
|
||||
|
||||
/* From RFC 1321. */
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31"
|
||||
"\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46"
|
||||
"\x24\x5e\x05\xfb\xdb\xd6\xfb\x24");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xa4\x48\x01\x7a\xaf\x21\xd8\x52"
|
||||
"\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xd9\x13\x0a\x81\x64\x54\x9f\xe8"
|
||||
"\x18\x87\x48\x06\xe1\xc7\x01\x4b");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd"
|
||||
"\xee\xa8\xed\x63\xdf\x41\x2d\xa9");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\x04\x3f\x85\x82\xf2\x41\xdb\x35"
|
||||
"\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19"
|
||||
"\x9c\x3e\x7b\x16\x4f\xcc\x05\x36");
|
||||
|
||||
DIGEST_KATS_ONLY_TEST(Md4, MD4);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_Md4_other(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD4
|
||||
DIGEST_OTHER_ONLY_TEST(wc_Md4, Md4, MD4,
|
||||
"\x1b\x60\x7d\x08\x57\x0c\xf1\x52"
|
||||
"\xbb\x44\x55\x97\x73\x26\x95\x6d");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
31
tests/api/test_md4.h
Normal file
31
tests/api/test_md4.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* test_md2.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_MD4_H
|
||||
#define WOLFCRYPT_TEST_MD4_H
|
||||
|
||||
int test_wc_InitMd4(void);
|
||||
int test_wc_Md4Update(void);
|
||||
int test_wc_Md4Final(void);
|
||||
int test_wc_Md4_KATs(void);
|
||||
int test_wc_Md4_other(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_MD4_H */
|
@ -82,28 +82,28 @@ int test_wc_Md5_KATs(void)
|
||||
|
||||
/* From RFC 1321. */
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e");
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
|
||||
"\x31\xc3\x99\xe2\x69\x77\x26\x61");
|
||||
"\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
|
||||
"\x31\xc3\x99\xe2\x69\x77\x26\x61");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
|
||||
"\x52\x5a\x2f\x31\xaa\xf1\x61\xd0");
|
||||
"\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
|
||||
"\x52\x5a\x2f\x31\xaa\xf1\x61\xd0");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
|
||||
"\x7d\xfb\x49\x6c\xca\x67\xe1\x3b");
|
||||
"\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
|
||||
"\x7d\xfb\x49\x6c\xca\x67\xe1\x3b");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
|
||||
"\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f");
|
||||
"\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
|
||||
"\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
|
||||
"\xac\x49\xda\x2e\x21\x07\xb6\x7a");
|
||||
"\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
|
||||
"\xac\x49\xda\x2e\x21\x07\xb6\x7a");
|
||||
|
||||
DIGEST_KATS_TEST(Md5, MD5);
|
||||
#endif
|
||||
@ -115,8 +115,8 @@ int test_wc_Md5_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
DIGEST_OTHER_TEST(wc_Md5, Md5, MD5,
|
||||
"\xd9\xa6\xc2\x1f\xf4\x05\xab\x62"
|
||||
"\xd6\xad\xa8\xcd\x0c\xb9\x49\x14");
|
||||
"\xd9\xa6\xc2\x1f\xf4\x05\xab\x62"
|
||||
"\xd6\xad\xa8\xcd\x0c\xb9\x49\x14");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -126,10 +126,10 @@ int test_wc_Md5Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
DIGEST_COPY_TEST(wc_Md5, Md5, MD5,
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -139,10 +139,10 @@ int test_wc_Md5GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
DIGEST_GET_HASH_TEST(wc_Md5, Md5, MD5,
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
|
||||
"\xe9\x80\x09\x98\xec\xf8\x42\x7e",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -153,16 +153,16 @@ int test_wc_Md5Transform(void)
|
||||
#if !defined(NO_MD5) && (defined(OPENSSL_EXTRA) || defined(HAVE_CURL)) && \
|
||||
!defined(HAVE_MD5_CUST_API)
|
||||
DIGEST_TRANSFORM_TEST(wc_Md5, Md5, MD5,
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x18\x00\x00\x00\x00\x00\x00\x00",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x18\x00\x00\x00\x00\x00\x00\x00",
|
||||
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
|
||||
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ int test_wc_ShaFinalRaw(void)
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \
|
||||
!defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha, Sha, SHA,
|
||||
"\x67\x45\x23\x01\xef\xcd\xab\x89"
|
||||
"\x98\xba\xdc\xfe\x10\x32\x54\x76"
|
||||
"\xc3\xd2\xe1\xf0");
|
||||
"\x67\x45\x23\x01\xef\xcd\xab\x89"
|
||||
"\x98\xba\xdc\xfe\x10\x32\x54\x76"
|
||||
"\xc3\xd2\xe1\xf0");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_ShaFinal */
|
||||
@ -104,35 +104,35 @@ int test_wc_Sha_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha, SHA);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09");
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x86\xf7\xe4\x37\xfa\xa5\xa7\xfc"
|
||||
"\xe1\x5d\x1d\xdc\xb9\xea\xea\xea"
|
||||
"\x37\x76\x67\xb8");
|
||||
"\x86\xf7\xe4\x37\xfa\xa5\xa7\xfc"
|
||||
"\xe1\x5d\x1d\xdc\xb9\xea\xea\xea"
|
||||
"\x37\x76\x67\xb8");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xc1\x22\x52\xce\xda\x8b\xe8\x99"
|
||||
"\x4d\x5f\xa0\x29\x0a\x47\x23\x1c"
|
||||
"\x1d\x16\xaa\xe3");
|
||||
"\xc1\x22\x52\xce\xda\x8b\xe8\x99"
|
||||
"\x4d\x5f\xa0\x29\x0a\x47\x23\x1c"
|
||||
"\x1d\x16\xaa\xe3");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\x32\xd1\x0c\x7b\x8c\xf9\x65\x70"
|
||||
"\xca\x04\xce\x37\xf2\xa1\x9d\x84"
|
||||
"\x24\x0d\x3a\x89");
|
||||
"\x32\xd1\x0c\x7b\x8c\xf9\x65\x70"
|
||||
"\xca\x04\xce\x37\xf2\xa1\x9d\x84"
|
||||
"\x24\x0d\x3a\x89");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\x76\x1c\x45\x7b\xf7\x3b\x14\xd2"
|
||||
"\x7e\x9e\x92\x65\xc4\x6f\x4b\x4d"
|
||||
"\xda\x11\xf9\x40");
|
||||
"\x76\x1c\x45\x7b\xf7\x3b\x14\xd2"
|
||||
"\x7e\x9e\x92\x65\xc4\x6f\x4b\x4d"
|
||||
"\xda\x11\xf9\x40");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\x50\xab\xf5\x70\x6a\x15\x09\x90"
|
||||
"\xa0\x8b\x2c\x5e\xa4\x0f\xa0\xe5"
|
||||
"\x85\x55\x47\x32");
|
||||
"\x50\xab\xf5\x70\x6a\x15\x09\x90"
|
||||
"\xa0\x8b\x2c\x5e\xa4\x0f\xa0\xe5"
|
||||
"\x85\x55\x47\x32");
|
||||
|
||||
DIGEST_KATS_TEST(Sha, SHA);
|
||||
#endif
|
||||
@ -144,9 +144,9 @@ int test_wc_Sha_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
DIGEST_OTHER_TEST(wc_Sha, Sha, SHA,
|
||||
"\xf0\xc2\x3f\xeb\xe0\xb0\xd9\x8c"
|
||||
"\x01\x23\x6c\x4c\x3b\x72\x7b\x01"
|
||||
"\xc7\x0d\x2b\x60");
|
||||
"\xf0\xc2\x3f\xeb\xe0\xb0\xd9\x8c"
|
||||
"\x01\x23\x6c\x4c\x3b\x72\x7b\x01"
|
||||
"\xc7\x0d\x2b\x60");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_ShaFinal */
|
||||
@ -156,12 +156,12 @@ int test_wc_ShaCopy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
DIGEST_COPY_TEST(wc_Sha, Sha, SHA,
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -171,12 +171,12 @@ int test_wc_ShaGetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
DIGEST_GET_HASH_TEST(wc_Sha, Sha, SHA,
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
"\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
|
||||
"\x32\x55\xbf\xef\x95\x60\x18\x90"
|
||||
"\xaf\xd8\x07\x09",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -188,17 +188,17 @@ int test_wc_ShaTransform(void)
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
|
||||
DIGEST_TRANSFORM_FINAL_RAW_TEST(wc_Sha, Sha, SHA,
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\xa9\x99\x3e\x36\x47\x06\x81\x6a"
|
||||
"\xba\x3e\x25\x71\x78\x50\xc2\x6c"
|
||||
"\x9c\xd0\xd8\x9d");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ int test_wc_Sha256FinalRaw(void)
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \
|
||||
!defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha256, Sha256, SHA256,
|
||||
"\x6a\x09\xe6\x67\xbb\x67\xae\x85"
|
||||
"\x3c\x6e\xf3\x72\xa5\x4f\xf5\x3a"
|
||||
"\x51\x0e\x52\x7f\x9b\x05\x68\x8c"
|
||||
"\x1f\x83\xd9\xab\x5b\xe0\xcd\x19");
|
||||
"\x6a\x09\xe6\x67\xbb\x67\xae\x85"
|
||||
"\x3c\x6e\xf3\x72\xa5\x4f\xf5\x3a"
|
||||
"\x51\x0e\x52\x7f\x9b\x05\x68\x8c"
|
||||
"\x1f\x83\xd9\xab\x5b\xe0\xcd\x19");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Final */
|
||||
@ -109,42 +109,42 @@ int test_wc_Sha256_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha256, SHA256);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55");
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\xca\x97\x81\x12\xca\x1b\xbd\xca"
|
||||
"\xfa\xc2\x31\xb3\x9a\x23\xdc\x4d"
|
||||
"\xa7\x86\xef\xf8\x14\x7c\x4e\x72"
|
||||
"\xb9\x80\x77\x85\xaf\xee\x48\xbb");
|
||||
"\xca\x97\x81\x12\xca\x1b\xbd\xca"
|
||||
"\xfa\xc2\x31\xb3\x9a\x23\xdc\x4d"
|
||||
"\xa7\x86\xef\xf8\x14\x7c\x4e\x72"
|
||||
"\xb9\x80\x77\x85\xaf\xee\x48\xbb");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xf7\x84\x6f\x55\xcf\x23\xe1\x4e"
|
||||
"\xeb\xea\xb5\xb4\xe1\x55\x0c\xad"
|
||||
"\x5b\x50\x9e\x33\x48\xfb\xc4\xef"
|
||||
"\xa3\xa1\x41\x3d\x39\x3c\xb6\x50");
|
||||
"\xf7\x84\x6f\x55\xcf\x23\xe1\x4e"
|
||||
"\xeb\xea\xb5\xb4\xe1\x55\x0c\xad"
|
||||
"\x5b\x50\x9e\x33\x48\xfb\xc4\xef"
|
||||
"\xa3\xa1\x41\x3d\x39\x3c\xb6\x50");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\x71\xc4\x80\xdf\x93\xd6\xae\x2f"
|
||||
"\x1e\xfa\xd1\x44\x7c\x66\xc9\x52"
|
||||
"\x5e\x31\x62\x18\xcf\x51\xfc\x8d"
|
||||
"\x9e\xd8\x32\xf2\xda\xf1\x8b\x73");
|
||||
"\x71\xc4\x80\xdf\x93\xd6\xae\x2f"
|
||||
"\x1e\xfa\xd1\x44\x7c\x66\xc9\x52"
|
||||
"\x5e\x31\x62\x18\xcf\x51\xfc\x8d"
|
||||
"\x9e\xd8\x32\xf2\xda\xf1\x8b\x73");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xdb\x4b\xfc\xbd\x4d\xa0\xcd\x85"
|
||||
"\xa6\x0c\x3c\x37\xd3\xfb\xd8\x80"
|
||||
"\x5c\x77\xf1\x5f\xc6\xb1\xfd\xfe"
|
||||
"\x61\x4e\xe0\xa7\xc8\xfd\xb4\xc0");
|
||||
"\xdb\x4b\xfc\xbd\x4d\xa0\xcd\x85"
|
||||
"\xa6\x0c\x3c\x37\xd3\xfb\xd8\x80"
|
||||
"\x5c\x77\xf1\x5f\xc6\xb1\xfd\xfe"
|
||||
"\x61\x4e\xe0\xa7\xc8\xfd\xb4\xc0");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xf3\x71\xbc\x4a\x31\x1f\x2b\x00"
|
||||
"\x9e\xef\x95\x2d\xd8\x3c\xa8\x0e"
|
||||
"\x2b\x60\x02\x6c\x8e\x93\x55\x92"
|
||||
"\xd0\xf9\xc3\x08\x45\x3c\x81\x3e");
|
||||
"\xf3\x71\xbc\x4a\x31\x1f\x2b\x00"
|
||||
"\x9e\xef\x95\x2d\xd8\x3c\xa8\x0e"
|
||||
"\x2b\x60\x02\x6c\x8e\x93\x55\x92"
|
||||
"\xd0\xf9\xc3\x08\x45\x3c\x81\x3e");
|
||||
|
||||
DIGEST_KATS_TEST(Sha256, SHA256);
|
||||
#endif
|
||||
@ -156,10 +156,10 @@ int test_wc_Sha256_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
DIGEST_OTHER_TEST(wc_Sha256, Sha256, SHA256,
|
||||
"\x2c\x41\xa1\xdd\x58\x4e\x37\x73"
|
||||
"\xb9\x56\x74\x84\x1b\x68\x5f\x36"
|
||||
"\xc7\x6b\x48\xec\x4d\xb7\x58\x63"
|
||||
"\x37\x2c\x2f\xd6\xe1\x9a\x61\xce");
|
||||
"\x2c\x41\xa1\xdd\x58\x4e\x37\x73"
|
||||
"\xb9\x56\x74\x84\x1b\x68\x5f\x36"
|
||||
"\xc7\x6b\x48\xec\x4d\xb7\x58\x63"
|
||||
"\x37\x2c\x2f\xd6\xe1\x9a\x61\xce");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Final */
|
||||
@ -169,14 +169,14 @@ int test_wc_Sha256Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
DIGEST_COPY_TEST(wc_Sha256, Sha256, SHA256,
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -186,14 +186,14 @@ int test_wc_Sha256GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
DIGEST_GET_HASH_TEST(wc_Sha256, Sha256, SHA256,
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14"
|
||||
"\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
|
||||
"\x27\xae\x41\xe4\x64\x9b\x93\x4c"
|
||||
"\xa4\x95\x99\x1b\x78\x52\xb8\x55",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -206,18 +206,18 @@ int test_wc_Sha256Transform(void)
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
|
||||
DIGEST_TRANSFORM_FINAL_RAW_TEST(wc_Sha256, Sha256, SHA256,
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\xba\x78\x16\xbf\x8f\x01\xcf\xea"
|
||||
"\x41\x41\x40\xde\x5d\xae\x22\x23"
|
||||
"\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
|
||||
"\xb4\x10\xff\x61\xf2\x00\x15\xad");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -279,42 +279,42 @@ int test_wc_Sha224_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha224, SHA224);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f");
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\xab\xd3\x75\x34\xc7\xd9\xa2\xef"
|
||||
"\xb9\x46\x5d\xe9\x31\xcd\x70\x55"
|
||||
"\xff\xdb\x88\x79\x56\x3a\xe9\x80"
|
||||
"\x78\xd6\xd6\xd5");
|
||||
"\xab\xd3\x75\x34\xc7\xd9\xa2\xef"
|
||||
"\xb9\x46\x5d\xe9\x31\xcd\x70\x55"
|
||||
"\xff\xdb\x88\x79\x56\x3a\xe9\x80"
|
||||
"\x78\xd6\xd6\xd5");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\x2c\xb2\x1c\x83\xae\x2f\x00\x4d"
|
||||
"\xe7\xe8\x1c\x3c\x70\x19\xcb\xcb"
|
||||
"\x65\xb7\x1a\xb6\x56\xb2\x2d\x6d"
|
||||
"\x0c\x39\xb8\xeb");
|
||||
"\x2c\xb2\x1c\x83\xae\x2f\x00\x4d"
|
||||
"\xe7\xe8\x1c\x3c\x70\x19\xcb\xcb"
|
||||
"\x65\xb7\x1a\xb6\x56\xb2\x2d\x6d"
|
||||
"\x0c\x39\xb8\xeb");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\x45\xa5\xf7\x2c\x39\xc5\xcf\xf2"
|
||||
"\x52\x2e\xb3\x42\x97\x99\xe4\x9e"
|
||||
"\x5f\x44\xb3\x56\xef\x92\x6b\xcf"
|
||||
"\x39\x0d\xcc\xc2");
|
||||
"\x45\xa5\xf7\x2c\x39\xc5\xcf\xf2"
|
||||
"\x52\x2e\xb3\x42\x97\x99\xe4\x9e"
|
||||
"\x5f\x44\xb3\x56\xef\x92\x6b\xcf"
|
||||
"\x39\x0d\xcc\xc2");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xbf\xf7\x2b\x4f\xcb\x7d\x75\xe5"
|
||||
"\x63\x29\x00\xac\x5f\x90\xd2\x19"
|
||||
"\xe0\x5e\x97\xa7\xbd\xe7\x2e\x74"
|
||||
"\x0d\xb3\x93\xd9");
|
||||
"\xbf\xf7\x2b\x4f\xcb\x7d\x75\xe5"
|
||||
"\x63\x29\x00\xac\x5f\x90\xd2\x19"
|
||||
"\xe0\x5e\x97\xa7\xbd\xe7\x2e\x74"
|
||||
"\x0d\xb3\x93\xd9");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xb5\x0a\xec\xbe\x4e\x9b\xb0\xb5"
|
||||
"\x7b\xc5\xf3\xae\x76\x0a\x8e\x01"
|
||||
"\xdb\x24\xf2\x03\xfb\x3c\xdc\xd1"
|
||||
"\x31\x48\x04\x6e");
|
||||
"\xb5\x0a\xec\xbe\x4e\x9b\xb0\xb5"
|
||||
"\x7b\xc5\xf3\xae\x76\x0a\x8e\x01"
|
||||
"\xdb\x24\xf2\x03\xfb\x3c\xdc\xd1"
|
||||
"\x31\x48\x04\x6e");
|
||||
|
||||
DIGEST_KATS_TEST(Sha224, SHA224);
|
||||
#endif
|
||||
@ -326,10 +326,10 @@ int test_wc_Sha224_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
DIGEST_OTHER_TEST(wc_Sha224, Sha224, SHA224,
|
||||
"\x60\x81\xdf\x2f\xae\xe2\x25\xe9"
|
||||
"\x87\x61\x2a\x8e\x25\x19\x16\x39"
|
||||
"\x80\xfb\x77\xfa\x28\x74\x17\x4d"
|
||||
"\xf3\x15\x52\x2b");
|
||||
"\x60\x81\xdf\x2f\xae\xe2\x25\xe9"
|
||||
"\x87\x61\x2a\x8e\x25\x19\x16\x39"
|
||||
"\x80\xfb\x77\xfa\x28\x74\x17\x4d"
|
||||
"\xf3\x15\x52\x2b");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224Final */
|
||||
@ -339,14 +339,14 @@ int test_wc_Sha224Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
DIGEST_COPY_TEST(wc_Sha224, Sha224, SHA224,
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f",
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f",
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -356,14 +356,14 @@ int test_wc_Sha224GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
DIGEST_GET_HASH_TEST(wc_Sha224, Sha224, SHA224,
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f",
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
"\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9"
|
||||
"\x47\x61\x02\xbb\x28\x82\x34\xc4"
|
||||
"\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a"
|
||||
"\xc5\xb3\xe4\x2f",
|
||||
"\x23\x09\x7d\x22\x34\x05\xd8\x22"
|
||||
"\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
|
||||
"\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7"
|
||||
"\xe3\x6c\x9d\xa7");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
@ -93,14 +93,14 @@ int test_wc_Sha512FinalRaw(void)
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \
|
||||
!defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha512, Sha512, SHA512,
|
||||
"\x6a\x09\xe6\x67\xf3\xbc\xc9\x08"
|
||||
"\xbb\x67\xae\x85\x84\xca\xa7\x3b"
|
||||
"\x3c\x6e\xf3\x72\xfe\x94\xf8\x2b"
|
||||
"\xa5\x4f\xf5\x3a\x5f\x1d\x36\xf1"
|
||||
"\x51\x0e\x52\x7f\xad\xe6\x82\xd1"
|
||||
"\x9b\x05\x68\x8c\x2b\x3e\x6c\x1f"
|
||||
"\x1f\x83\xd9\xab\xfb\x41\xbd\x6b"
|
||||
"\x5b\xe0\xcd\x19\x13\x7e\x21\x79");
|
||||
"\x6a\x09\xe6\x67\xf3\xbc\xc9\x08"
|
||||
"\xbb\x67\xae\x85\x84\xca\xa7\x3b"
|
||||
"\x3c\x6e\xf3\x72\xfe\x94\xf8\x2b"
|
||||
"\xa5\x4f\xf5\x3a\x5f\x1d\x36\xf1"
|
||||
"\x51\x0e\x52\x7f\xad\xe6\x82\xd1"
|
||||
"\x9b\x05\x68\x8c\x2b\x3e\x6c\x1f"
|
||||
"\x1f\x83\xd9\xab\xfb\x41\xbd\x6b"
|
||||
"\x5b\xe0\xcd\x19\x13\x7e\x21\x79");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512Final */
|
||||
@ -113,70 +113,70 @@ int test_wc_Sha512_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha512, SHA512);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e");
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x1f\x40\xfc\x92\xda\x24\x16\x94"
|
||||
"\x75\x09\x79\xee\x6c\xf5\x82\xf2"
|
||||
"\xd5\xd7\xd2\x8e\x18\x33\x5d\xe0"
|
||||
"\x5a\xbc\x54\xd0\x56\x0e\x0f\x53"
|
||||
"\x02\x86\x0c\x65\x2b\xf0\x8d\x56"
|
||||
"\x02\x52\xaa\x5e\x74\x21\x05\x46"
|
||||
"\xf3\x69\xfb\xbb\xce\x8c\x12\xcf"
|
||||
"\xc7\x95\x7b\x26\x52\xfe\x9a\x75");
|
||||
"\x1f\x40\xfc\x92\xda\x24\x16\x94"
|
||||
"\x75\x09\x79\xee\x6c\xf5\x82\xf2"
|
||||
"\xd5\xd7\xd2\x8e\x18\x33\x5d\xe0"
|
||||
"\x5a\xbc\x54\xd0\x56\x0e\x0f\x53"
|
||||
"\x02\x86\x0c\x65\x2b\xf0\x8d\x56"
|
||||
"\x02\x52\xaa\x5e\x74\x21\x05\x46"
|
||||
"\xf3\x69\xfb\xbb\xce\x8c\x12\xcf"
|
||||
"\xc7\x95\x7b\x26\x52\xfe\x9a\x75");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\x10\x7d\xbf\x38\x9d\x9e\x9f\x71"
|
||||
"\xa3\xa9\x5f\x6c\x05\x5b\x92\x51"
|
||||
"\xbc\x52\x68\xc2\xbe\x16\xd6\xc1"
|
||||
"\x34\x92\xea\x45\xb0\x19\x9f\x33"
|
||||
"\x09\xe1\x64\x55\xab\x1e\x96\x11"
|
||||
"\x8e\x8a\x90\x5d\x55\x97\xb7\x20"
|
||||
"\x38\xdd\xb3\x72\xa8\x98\x26\x04"
|
||||
"\x6d\xe6\x66\x87\xbb\x42\x0e\x7c");
|
||||
"\x10\x7d\xbf\x38\x9d\x9e\x9f\x71"
|
||||
"\xa3\xa9\x5f\x6c\x05\x5b\x92\x51"
|
||||
"\xbc\x52\x68\xc2\xbe\x16\xd6\xc1"
|
||||
"\x34\x92\xea\x45\xb0\x19\x9f\x33"
|
||||
"\x09\xe1\x64\x55\xab\x1e\x96\x11"
|
||||
"\x8e\x8a\x90\x5d\x55\x97\xb7\x20"
|
||||
"\x38\xdd\xb3\x72\xa8\x98\x26\x04"
|
||||
"\x6d\xe6\x66\x87\xbb\x42\x0e\x7c");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\x4d\xbf\xf8\x6c\xc2\xca\x1b\xae"
|
||||
"\x1e\x16\x46\x8a\x05\xcb\x98\x81"
|
||||
"\xc9\x7f\x17\x53\xbc\xe3\x61\x90"
|
||||
"\x34\x89\x8f\xaa\x1a\xab\xe4\x29"
|
||||
"\x95\x5a\x1b\xf8\xec\x48\x3d\x74"
|
||||
"\x21\xfe\x3c\x16\x46\x61\x3a\x59"
|
||||
"\xed\x54\x41\xfb\x0f\x32\x13\x89"
|
||||
"\xf7\x7f\x48\xa8\x79\xc7\xb1\xf1");
|
||||
"\x4d\xbf\xf8\x6c\xc2\xca\x1b\xae"
|
||||
"\x1e\x16\x46\x8a\x05\xcb\x98\x81"
|
||||
"\xc9\x7f\x17\x53\xbc\xe3\x61\x90"
|
||||
"\x34\x89\x8f\xaa\x1a\xab\xe4\x29"
|
||||
"\x95\x5a\x1b\xf8\xec\x48\x3d\x74"
|
||||
"\x21\xfe\x3c\x16\x46\x61\x3a\x59"
|
||||
"\xed\x54\x41\xfb\x0f\x32\x13\x89"
|
||||
"\xf7\x7f\x48\xa8\x79\xc7\xb1\xf1");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\x1e\x07\xbe\x23\xc2\x6a\x86\xea"
|
||||
"\x37\xea\x81\x0c\x8e\xc7\x80\x93"
|
||||
"\x52\x51\x5a\x97\x0e\x92\x53\xc2"
|
||||
"\x6f\x53\x6c\xfc\x7a\x99\x96\xc4"
|
||||
"\x5c\x83\x70\x58\x3e\x0a\x78\xfa"
|
||||
"\x4a\x90\x04\x1d\x71\xa4\xce\xab"
|
||||
"\x74\x23\xf1\x9c\x71\xb9\xd5\xa3"
|
||||
"\xe0\x12\x49\xf0\xbe\xbd\x58\x94");
|
||||
"\x1e\x07\xbe\x23\xc2\x6a\x86\xea"
|
||||
"\x37\xea\x81\x0c\x8e\xc7\x80\x93"
|
||||
"\x52\x51\x5a\x97\x0e\x92\x53\xc2"
|
||||
"\x6f\x53\x6c\xfc\x7a\x99\x96\xc4"
|
||||
"\x5c\x83\x70\x58\x3e\x0a\x78\xfa"
|
||||
"\x4a\x90\x04\x1d\x71\xa4\xce\xab"
|
||||
"\x74\x23\xf1\x9c\x71\xb9\xd5\xa3"
|
||||
"\xe0\x12\x49\xf0\xbe\xbd\x58\x94");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\x72\xec\x1e\xf1\x12\x4a\x45\xb0"
|
||||
"\x47\xe8\xb7\xc7\x5a\x93\x21\x95"
|
||||
"\x13\x5b\xb6\x1d\xe2\x4e\xc0\xd1"
|
||||
"\x91\x40\x42\x24\x6e\x0a\xec\x3a"
|
||||
"\x23\x54\xe0\x93\xd7\x6f\x30\x48"
|
||||
"\xb4\x56\x76\x43\x46\x90\x0c\xb1"
|
||||
"\x30\xd2\xa4\xfd\x5d\xd1\x6a\xbb"
|
||||
"\x5e\x30\xbc\xb8\x50\xde\xe8\x43");
|
||||
"\x72\xec\x1e\xf1\x12\x4a\x45\xb0"
|
||||
"\x47\xe8\xb7\xc7\x5a\x93\x21\x95"
|
||||
"\x13\x5b\xb6\x1d\xe2\x4e\xc0\xd1"
|
||||
"\x91\x40\x42\x24\x6e\x0a\xec\x3a"
|
||||
"\x23\x54\xe0\x93\xd7\x6f\x30\x48"
|
||||
"\xb4\x56\x76\x43\x46\x90\x0c\xb1"
|
||||
"\x30\xd2\xa4\xfd\x5d\xd1\x6a\xbb"
|
||||
"\x5e\x30\xbc\xb8\x50\xde\xe8\x43");
|
||||
|
||||
DIGEST_KATS_TEST(Sha512, SHA512);
|
||||
#endif
|
||||
@ -188,14 +188,14 @@ int test_wc_Sha512_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA512
|
||||
DIGEST_OTHER_TEST(wc_Sha512, Sha512, SHA512,
|
||||
"\xf2\x7d\xa3\xe0\x25\x71\x51\x3f"
|
||||
"\x75\xf4\xdc\xea\xdc\xf7\x7f\xf1"
|
||||
"\xad\x5a\x51\x32\x07\x73\x1d\xf8"
|
||||
"\xdd\xaa\xf1\x15\x3e\xa3\x3c\xc5"
|
||||
"\x00\x76\x6e\x1d\xa5\xa2\x4a\x44"
|
||||
"\x99\x3e\x2d\xaa\xa8\x05\xc8\x49"
|
||||
"\xf0\x83\x34\x02\x07\x43\x8b\xac"
|
||||
"\xfb\xe6\x02\x40\x6b\x48\x54\x8e");
|
||||
"\xf2\x7d\xa3\xe0\x25\x71\x51\x3f"
|
||||
"\x75\xf4\xdc\xea\xdc\xf7\x7f\xf1"
|
||||
"\xad\x5a\x51\x32\x07\x73\x1d\xf8"
|
||||
"\xdd\xaa\xf1\x15\x3e\xa3\x3c\xc5"
|
||||
"\x00\x76\x6e\x1d\xa5\xa2\x4a\x44"
|
||||
"\x99\x3e\x2d\xaa\xa8\x05\xc8\x49"
|
||||
"\xf0\x83\x34\x02\x07\x43\x8b\xac"
|
||||
"\xfb\xe6\x02\x40\x6b\x48\x54\x8e");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512Final */
|
||||
@ -205,22 +205,22 @@ int test_wc_Sha512Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA512
|
||||
DIGEST_COPY_TEST(wc_Sha512, Sha512, SHA512,
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e",
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e",
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -230,22 +230,22 @@ int test_wc_Sha512GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA512
|
||||
DIGEST_GET_HASH_TEST(wc_Sha512, Sha512, SHA512,
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e",
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
"\xcf\x83\xe1\x35\x7e\xef\xb8\xbd"
|
||||
"\xf1\x54\x28\x50\xd6\x6d\x80\x07"
|
||||
"\xd6\x20\xe4\x05\x0b\x57\x15\xdc"
|
||||
"\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
|
||||
"\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0"
|
||||
"\xff\x83\x18\xd2\x87\x7e\xec\x2f"
|
||||
"\x63\xb9\x31\xbd\x47\x41\x7a\x81"
|
||||
"\xa5\x38\x32\x7a\xf9\x27\xda\x3e",
|
||||
"\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
|
||||
"\xcc\x41\x73\x49\xae\x20\x41\x31"
|
||||
"\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
|
||||
"\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
|
||||
"\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
|
||||
"\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
|
||||
"\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
|
||||
"\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -258,30 +258,30 @@ int test_wc_Sha512Transform(void)
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
|
||||
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512, SHA512,
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\x54\x52\xb6\x73\x58\x3e\x6f\x12"
|
||||
"\xcb\x0b\xf3\x61\x38\xb9\x76\xe8"
|
||||
"\x2e\x46\x13\xd9\x4a\x67\xe3\x7c"
|
||||
"\x5c\xd7\xa5\xe6\x43\x55\x16\xa2"
|
||||
"\x83\x06\x9a\x32\x69\x55\x63\x95"
|
||||
"\x68\x75\xde\x70\x09\x4d\xcd\xfe"
|
||||
"\xbe\x11\x20\xd6\xe7\x7c\x49\xd3"
|
||||
"\x5b\xd7\x07\x75\x19\xc9\x8a\xfa");
|
||||
"\x80\x63\x62\x61\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x18\x00\x00\x00",
|
||||
"\x54\x52\xb6\x73\x58\x3e\x6f\x12"
|
||||
"\xcb\x0b\xf3\x61\x38\xb9\x76\xe8"
|
||||
"\x2e\x46\x13\xd9\x4a\x67\xe3\x7c"
|
||||
"\x5c\xd7\xa5\xe6\x43\x55\x16\xa2"
|
||||
"\x83\x06\x9a\x32\x69\x55\x63\x95"
|
||||
"\x68\x75\xde\x70\x09\x4d\xcd\xfe"
|
||||
"\xbe\x11\x20\xd6\xe7\x7c\x49\xd3"
|
||||
"\x5b\xd7\x07\x75\x19\xc9\x8a\xfa");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -346,10 +346,10 @@ int test_wc_Sha512_224FinalRaw(void)
|
||||
(!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && \
|
||||
(HAVE_FIPS_VERSION >= 3))) && !defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha512, Sha512_224, SHA512_224,
|
||||
"\x8c\x3d\x37\xc8\x19\x54\x4d\xa2"
|
||||
"\x73\xe1\x99\x66\x89\xdc\xd4\xd6"
|
||||
"\x1d\xfa\xb7\xae\x32\xff\x9c\x82"
|
||||
"\x67\x9d\xd5\x14");
|
||||
"\x8c\x3d\x37\xc8\x19\x54\x4d\xa2"
|
||||
"\x73\xe1\x99\x66\x89\xdc\xd4\xd6"
|
||||
"\x1d\xfa\xb7\xae\x32\xff\x9c\x82"
|
||||
"\x67\x9d\xd5\x14");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512_224Final */
|
||||
@ -362,42 +362,42 @@ int test_wc_Sha512_224_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha512, SHA512_224);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4");
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\xd5\xcd\xb9\xcc\xc7\x69\xa5\x12"
|
||||
"\x1d\x41\x75\xf2\xbf\xdd\x13\xd6"
|
||||
"\x31\x0e\x0d\x3d\x36\x1e\xa7\x5d"
|
||||
"\x82\x10\x83\x27");
|
||||
"\xd5\xcd\xb9\xcc\xc7\x69\xa5\x12"
|
||||
"\x1d\x41\x75\xf2\xbf\xdd\x13\xd6"
|
||||
"\x31\x0e\x0d\x3d\x36\x1e\xa7\x5d"
|
||||
"\x82\x10\x83\x27");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\xad\x1a\x4d\xb1\x88\xfe\x57\x06"
|
||||
"\x4f\x4f\x24\x60\x9d\x2a\x83\xcd"
|
||||
"\x0a\xfb\x9b\x39\x8e\xb2\xfc\xae"
|
||||
"\xaa\xe2\xc5\x64");
|
||||
"\xad\x1a\x4d\xb1\x88\xfe\x57\x06"
|
||||
"\x4f\x4f\x24\x60\x9d\x2a\x83\xcd"
|
||||
"\x0a\xfb\x9b\x39\x8e\xb2\xfc\xae"
|
||||
"\xaa\xe2\xc5\x64");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\xff\x83\x14\x8a\xa0\x7e\xc3\x06"
|
||||
"\x55\xc1\xb4\x0a\xff\x86\x14\x1c"
|
||||
"\x02\x15\xfe\x2a\x54\xf7\x67\xd3"
|
||||
"\xf3\x87\x43\xd8");
|
||||
"\xff\x83\x14\x8a\xa0\x7e\xc3\x06"
|
||||
"\x55\xc1\xb4\x0a\xff\x86\x14\x1c"
|
||||
"\x02\x15\xfe\x2a\x54\xf7\x67\xd3"
|
||||
"\xf3\x87\x43\xd8");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xa8\xb4\xb9\x17\x4b\x99\xff\xc6"
|
||||
"\x7d\x6f\x49\xbe\x99\x81\x58\x7b"
|
||||
"\x96\x44\x10\x51\xe1\x6e\x6d\xd0"
|
||||
"\x36\xb1\x40\xd3");
|
||||
"\xa8\xb4\xb9\x17\x4b\x99\xff\xc6"
|
||||
"\x7d\x6f\x49\xbe\x99\x81\x58\x7b"
|
||||
"\x96\x44\x10\x51\xe1\x6e\x6d\xd0"
|
||||
"\x36\xb1\x40\xd3");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xae\x98\x8f\xaa\xa4\x7e\x40\x1a"
|
||||
"\x45\xf7\x04\xd1\x27\x2d\x99\x70"
|
||||
"\x24\x58\xfe\xa2\xdd\xc6\x58\x28"
|
||||
"\x27\x55\x6d\xd2");
|
||||
"\xae\x98\x8f\xaa\xa4\x7e\x40\x1a"
|
||||
"\x45\xf7\x04\xd1\x27\x2d\x99\x70"
|
||||
"\x24\x58\xfe\xa2\xdd\xc6\x58\x28"
|
||||
"\x27\x55\x6d\xd2");
|
||||
|
||||
DIGEST_KATS_TEST(Sha512_224, SHA512_224);
|
||||
#endif
|
||||
@ -409,10 +409,10 @@ int test_wc_Sha512_224_other(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224)
|
||||
DIGEST_OTHER_TEST(wc_Sha512, Sha512_224, SHA512_224,
|
||||
"\xbe\xbb\x85\xa0\x14\x9f\xd7\xae"
|
||||
"\xc4\xbe\xa4\x8f\xa3\xeb\xac\xc0"
|
||||
"\x88\x02\x6b\xa0\xe8\x22\x5c\xb3"
|
||||
"\x12\x11\xa0\x48");
|
||||
"\xbe\xbb\x85\xa0\x14\x9f\xd7\xae"
|
||||
"\xc4\xbe\xa4\x8f\xa3\xeb\xac\xc0"
|
||||
"\x88\x02\x6b\xa0\xe8\x22\x5c\xb3"
|
||||
"\x12\x11\xa0\x48");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512_224Final */
|
||||
@ -422,14 +422,14 @@ int test_wc_Sha512_224Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224)
|
||||
DIGEST_COPY_TEST(wc_Sha512, Sha512_224, SHA512_224,
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -439,14 +439,14 @@ int test_wc_Sha512_224GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224)
|
||||
DIGEST_GET_HASH_TEST(wc_Sha512, Sha512_224, SHA512_224,
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
"\x6e\xd0\xdd\x02\x80\x6f\xa8\x9e"
|
||||
"\x25\xde\x06\x0c\x19\xd3\xac\x86"
|
||||
"\xca\xbb\x87\xd6\xa0\xdd\xd0\x5c"
|
||||
"\x33\x3b\x84\xf4",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -459,26 +459,26 @@ int test_wc_Sha512_224Transform(void)
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
|
||||
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512_224, SHA512_224,
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x18",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x18",
|
||||
"\x46\x34\x27\x0f\x70\x7b\x6a\x54"
|
||||
"\xda\xae\x75\x30\x46\x08\x42\xe2"
|
||||
"\x0e\x37\xed\x26\x5c\xee\xe9\xa4"
|
||||
"\x3e\x89\x24\xaa");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -544,10 +544,10 @@ int test_wc_Sha512_256FinalRaw(void)
|
||||
(!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && \
|
||||
(HAVE_FIPS_VERSION >= 3))) && !defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha512, Sha512_256, SHA512_256,
|
||||
"\x22\x31\x21\x94\xfc\x2b\xf7\x2c"
|
||||
"\x9f\x55\x5f\xa3\xc8\x4c\x64\xc2"
|
||||
"\x23\x93\xb8\x6b\x6f\x53\xb1\x51"
|
||||
"\x96\x38\x77\x19\x59\x40\xea\xbd");
|
||||
"\x22\x31\x21\x94\xfc\x2b\xf7\x2c"
|
||||
"\x9f\x55\x5f\xa3\xc8\x4c\x64\xc2"
|
||||
"\x23\x93\xb8\x6b\x6f\x53\xb1\x51"
|
||||
"\x96\x38\x77\x19\x59\x40\xea\xbd");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512_256Final */
|
||||
@ -560,42 +560,42 @@ int test_wc_Sha512_256_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha512, SHA512_256);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a");
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x45\x5e\x51\x88\x24\xbc\x06\x01"
|
||||
"\xf9\xfb\x85\x8f\xf5\xc3\x7d\x41"
|
||||
"\x7d\x67\xc2\xf8\xe0\xdf\x2b\xab"
|
||||
"\xe4\x80\x88\x58\xae\xa8\x30\xf8");
|
||||
"\x45\x5e\x51\x88\x24\xbc\x06\x01"
|
||||
"\xf9\xfb\x85\x8f\xf5\xc3\x7d\x41"
|
||||
"\x7d\x67\xc2\xf8\xe0\xdf\x2b\xab"
|
||||
"\xe4\x80\x88\x58\xae\xa8\x30\xf8");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\x0c\xf4\x71\xfd\x17\xed\x69\xd9"
|
||||
"\x90\xda\xf3\x43\x3c\x89\xb1\x6d"
|
||||
"\x63\xde\xc1\xbb\x9c\xb4\x2a\x60"
|
||||
"\x94\x60\x4e\xe5\xd7\xb4\xe9\xfb");
|
||||
"\x0c\xf4\x71\xfd\x17\xed\x69\xd9"
|
||||
"\x90\xda\xf3\x43\x3c\x89\xb1\x6d"
|
||||
"\x63\xde\xc1\xbb\x9c\xb4\x2a\x60"
|
||||
"\x94\x60\x4e\xe5\xd7\xb4\xe9\xfb");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\xfc\x31\x89\x44\x3f\x9c\x26\x8f"
|
||||
"\x62\x6a\xea\x08\xa7\x56\xab\xe7"
|
||||
"\xb7\x26\xb0\x5f\x70\x1c\xb0\x82"
|
||||
"\x22\x31\x2c\xcf\xd6\x71\x0a\x26");
|
||||
"\xfc\x31\x89\x44\x3f\x9c\x26\x8f"
|
||||
"\x62\x6a\xea\x08\xa7\x56\xab\xe7"
|
||||
"\xb7\x26\xb0\x5f\x70\x1c\xb0\x82"
|
||||
"\x22\x31\x2c\xcf\xd6\x71\x0a\x26");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\xcd\xf1\xcc\x0e\xff\xe2\x6e\xcc"
|
||||
"\x0c\x13\x75\x8f\x7b\x4a\x48\xe0"
|
||||
"\x00\x61\x5d\xf2\x41\x28\x41\x85"
|
||||
"\xc3\x9e\xb0\x5d\x35\x5b\xb9\xc8");
|
||||
"\xcd\xf1\xcc\x0e\xff\xe2\x6e\xcc"
|
||||
"\x0c\x13\x75\x8f\x7b\x4a\x48\xe0"
|
||||
"\x00\x61\x5d\xf2\x41\x28\x41\x85"
|
||||
"\xc3\x9e\xb0\x5d\x35\x5b\xb9\xc8");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\x2c\x9f\xdb\xc0\xc9\x0b\xdd\x87"
|
||||
"\x61\x2e\xe8\x45\x54\x74\xf9\x04"
|
||||
"\x48\x50\x24\x1d\xc1\x05\xb1\xe8"
|
||||
"\xb9\x4b\x8d\xdf\x5f\xac\x91\x48");
|
||||
"\x2c\x9f\xdb\xc0\xc9\x0b\xdd\x87"
|
||||
"\x61\x2e\xe8\x45\x54\x74\xf9\x04"
|
||||
"\x48\x50\x24\x1d\xc1\x05\xb1\xe8"
|
||||
"\xb9\x4b\x8d\xdf\x5f\xac\x91\x48");
|
||||
|
||||
DIGEST_KATS_TEST(Sha512_256, SHA512_256);
|
||||
#endif
|
||||
@ -607,10 +607,10 @@ int test_wc_Sha512_256_other(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256)
|
||||
DIGEST_OTHER_TEST(wc_Sha512, Sha512_256, SHA512_256,
|
||||
"\x0c\x80\x73\xf5\xf4\xc8\xc7\x13"
|
||||
"\x4a\xc4\x8a\xda\x04\xfc\x77\x74"
|
||||
"\xea\xa0\x85\xa9\x29\xb3\x54\xa4"
|
||||
"\x08\xef\x2a\x87\x61\x1f\x8c\xb8");
|
||||
"\x0c\x80\x73\xf5\xf4\xc8\xc7\x13"
|
||||
"\x4a\xc4\x8a\xda\x04\xfc\x77\x74"
|
||||
"\xea\xa0\x85\xa9\x29\xb3\x54\xa4"
|
||||
"\x08\xef\x2a\x87\x61\x1f\x8c\xb8");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha512_256Final */
|
||||
@ -620,14 +620,14 @@ int test_wc_Sha512_256Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256)
|
||||
DIGEST_COPY_TEST(wc_Sha512, Sha512_256, SHA512_256,
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -637,14 +637,14 @@ int test_wc_Sha512_256GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256)
|
||||
DIGEST_GET_HASH_TEST(wc_Sha512, Sha512_256, SHA512_256,
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
"\xc6\x72\xb8\xd1\xef\x56\xed\x28"
|
||||
"\xab\x87\xc3\x62\x2c\x51\x14\x06"
|
||||
"\x9b\xdd\x3a\xd7\xb8\xf9\x73\x74"
|
||||
"\x98\xd0\xc0\x1e\xce\xf0\x96\x7a",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -657,26 +657,26 @@ int test_wc_Sha512_256Transform(void)
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))
|
||||
DIGEST_TRANSFORM_FINAL_RAW_ALL_TEST(wc_Sha512, Sha512_256, SHA512_256,
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x18",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
"\x61\x62\x63\x80\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x18",
|
||||
"\x53\x04\x8e\x26\x81\x94\x1e\xf9"
|
||||
"\x9b\x2e\x29\xb7\x6b\x4c\x7d\xab"
|
||||
"\xe4\xc2\xd0\xc6\x34\xfc\x6d\x46"
|
||||
"\xe0\xe2\xf1\x31\x07\xe7\xaf\x23");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -742,12 +742,12 @@ int test_wc_Sha384FinalRaw(void)
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \
|
||||
!defined(WOLFSSL_NO_HASH_RAW)
|
||||
DIGEST_FINAL_RAW_TEST(wc_Sha384, Sha384, SHA384,
|
||||
"\xcb\xbb\x9d\x5d\xc1\x05\x9e\xd8"
|
||||
"\x62\x9a\x29\x2a\x36\x7c\xd5\x07"
|
||||
"\x91\x59\x01\x5a\x30\x70\xdd\x17"
|
||||
"\x15\x2f\xec\xd8\xf7\x0e\x59\x39"
|
||||
"\x67\x33\x26\x67\xff\xc0\x0b\x31"
|
||||
"\x8e\xb4\x4a\x87\x68\x58\x15\x11");
|
||||
"\xcb\xbb\x9d\x5d\xc1\x05\x9e\xd8"
|
||||
"\x62\x9a\x29\x2a\x36\x7c\xd5\x07"
|
||||
"\x91\x59\x01\x5a\x30\x70\xdd\x17"
|
||||
"\x15\x2f\xec\xd8\xf7\x0e\x59\x39"
|
||||
"\x67\x33\x26\x67\xff\xc0\x0b\x31"
|
||||
"\x8e\xb4\x4a\x87\x68\x58\x15\x11");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha384 */
|
||||
@ -760,56 +760,56 @@ int test_wc_Sha384_KATs(void)
|
||||
DIGEST_KATS_TEST_VARS(wc_Sha384, SHA384);
|
||||
|
||||
DIGEST_KATS_ADD("", 0,
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b");
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b");
|
||||
DIGEST_KATS_ADD("a", 1,
|
||||
"\x54\xa5\x9b\x9f\x22\xb0\xb8\x08"
|
||||
"\x80\xd8\x42\x7e\x54\x8b\x7c\x23"
|
||||
"\xab\xd8\x73\x48\x6e\x1f\x03\x5d"
|
||||
"\xce\x9c\xd6\x97\xe8\x51\x75\x03"
|
||||
"\x3c\xaa\x88\xe6\xd5\x7b\xc3\x5e"
|
||||
"\xfa\xe0\xb5\xaf\xd3\x14\x5f\x31");
|
||||
"\x54\xa5\x9b\x9f\x22\xb0\xb8\x08"
|
||||
"\x80\xd8\x42\x7e\x54\x8b\x7c\x23"
|
||||
"\xab\xd8\x73\x48\x6e\x1f\x03\x5d"
|
||||
"\xce\x9c\xd6\x97\xe8\x51\x75\x03"
|
||||
"\x3c\xaa\x88\xe6\xd5\x7b\xc3\x5e"
|
||||
"\xfa\xe0\xb5\xaf\xd3\x14\x5f\x31");
|
||||
DIGEST_KATS_ADD("abc", 3,
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
DIGEST_KATS_ADD("message digest", 14,
|
||||
"\x47\x3e\xd3\x51\x67\xec\x1f\x5d"
|
||||
"\x8e\x55\x03\x68\xa3\xdb\x39\xbe"
|
||||
"\x54\x63\x9f\x82\x88\x68\xe9\x45"
|
||||
"\x4c\x23\x9f\xc8\xb5\x2e\x3c\x61"
|
||||
"\xdb\xd0\xd8\xb4\xde\x13\x90\xc2"
|
||||
"\x56\xdc\xbb\x5d\x5f\xd9\x9c\xd5");
|
||||
"\x47\x3e\xd3\x51\x67\xec\x1f\x5d"
|
||||
"\x8e\x55\x03\x68\xa3\xdb\x39\xbe"
|
||||
"\x54\x63\x9f\x82\x88\x68\xe9\x45"
|
||||
"\x4c\x23\x9f\xc8\xb5\x2e\x3c\x61"
|
||||
"\xdb\xd0\xd8\xb4\xde\x13\x90\xc2"
|
||||
"\x56\xdc\xbb\x5d\x5f\xd9\x9c\xd5");
|
||||
DIGEST_KATS_ADD("abcdefghijklmnopqrstuvwxyz", 26,
|
||||
"\xfe\xb6\x73\x49\xdf\x3d\xb6\xf5"
|
||||
"\x92\x48\x15\xd6\xc3\xdc\x13\x3f"
|
||||
"\x09\x18\x09\x21\x37\x31\xfe\x5c"
|
||||
"\x7b\x5f\x49\x99\xe4\x63\x47\x9f"
|
||||
"\xf2\x87\x7f\x5f\x29\x36\xfa\x63"
|
||||
"\xbb\x43\x78\x4b\x12\xf3\xeb\xb4");
|
||||
"\xfe\xb6\x73\x49\xdf\x3d\xb6\xf5"
|
||||
"\x92\x48\x15\xd6\xc3\xdc\x13\x3f"
|
||||
"\x09\x18\x09\x21\x37\x31\xfe\x5c"
|
||||
"\x7b\x5f\x49\x99\xe4\x63\x47\x9f"
|
||||
"\xf2\x87\x7f\x5f\x29\x36\xfa\x63"
|
||||
"\xbb\x43\x78\x4b\x12\xf3\xeb\xb4");
|
||||
DIGEST_KATS_ADD("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789", 62,
|
||||
"\x17\x61\x33\x6e\x3f\x7c\xbf\xe5"
|
||||
"\x1d\xeb\x13\x7f\x02\x6f\x89\xe0"
|
||||
"\x1a\x44\x8e\x3b\x1f\xaf\xa6\x40"
|
||||
"\x39\xc1\x46\x4e\xe8\x73\x2f\x11"
|
||||
"\xa5\x34\x1a\x6f\x41\xe0\xc2\x02"
|
||||
"\x29\x47\x36\xed\x64\xdb\x1a\x84");
|
||||
"\x17\x61\x33\x6e\x3f\x7c\xbf\xe5"
|
||||
"\x1d\xeb\x13\x7f\x02\x6f\x89\xe0"
|
||||
"\x1a\x44\x8e\x3b\x1f\xaf\xa6\x40"
|
||||
"\x39\xc1\x46\x4e\xe8\x73\x2f\x11"
|
||||
"\xa5\x34\x1a\x6f\x41\xe0\xc2\x02"
|
||||
"\x29\x47\x36\xed\x64\xdb\x1a\x84");
|
||||
DIGEST_KATS_ADD("1234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890", 80,
|
||||
"\xb1\x29\x32\xb0\x62\x7d\x1c\x06"
|
||||
"\x09\x42\xf5\x44\x77\x64\x15\x56"
|
||||
"\x55\xbd\x4d\xa0\xc9\xaf\xa6\xdd"
|
||||
"\x9b\x9e\xf5\x31\x29\xaf\x1b\x8f"
|
||||
"\xb0\x19\x59\x96\xd2\xde\x9c\xa0"
|
||||
"\xdf\x9d\x82\x1f\xfe\xe6\x70\x26");
|
||||
"\xb1\x29\x32\xb0\x62\x7d\x1c\x06"
|
||||
"\x09\x42\xf5\x44\x77\x64\x15\x56"
|
||||
"\x55\xbd\x4d\xa0\xc9\xaf\xa6\xdd"
|
||||
"\x9b\x9e\xf5\x31\x29\xaf\x1b\x8f"
|
||||
"\xb0\x19\x59\x96\xd2\xde\x9c\xa0"
|
||||
"\xdf\x9d\x82\x1f\xfe\xe6\x70\x26");
|
||||
|
||||
DIGEST_KATS_TEST(Sha384, SHA384);
|
||||
#endif
|
||||
@ -821,12 +821,12 @@ int test_wc_Sha384_other(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA384
|
||||
DIGEST_OTHER_TEST(wc_Sha384, Sha384, SHA384,
|
||||
"\xbe\x28\x56\x36\xd3\xae\x1c\x63"
|
||||
"\x94\x7a\xc0\x7f\xb1\x71\x5c\x19"
|
||||
"\x45\xfd\x81\x7b\x46\xfb\x03\xc2"
|
||||
"\x46\x2c\x80\x8d\xd2\xc0\x16\x91"
|
||||
"\x23\x51\x6b\xa5\x0d\x71\x6f\x8b"
|
||||
"\x2f\x52\x74\x86\x0d\x05\xa5\x95");
|
||||
"\xbe\x28\x56\x36\xd3\xae\x1c\x63"
|
||||
"\x94\x7a\xc0\x7f\xb1\x71\x5c\x19"
|
||||
"\x45\xfd\x81\x7b\x46\xfb\x03\xc2"
|
||||
"\x46\x2c\x80\x8d\xd2\xc0\x16\x91"
|
||||
"\x23\x51\x6b\xa5\x0d\x71\x6f\x8b"
|
||||
"\x2f\x52\x74\x86\x0d\x05\xa5\x95");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha384Final */
|
||||
@ -836,18 +836,18 @@ int test_wc_Sha384Copy(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA384
|
||||
DIGEST_COPY_TEST(wc_Sha384, Sha384, SHA384,
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b",
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b",
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
@ -857,18 +857,18 @@ int test_wc_Sha384GetHash(void)
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA384
|
||||
DIGEST_GET_HASH_TEST(wc_Sha384, Sha384, SHA384,
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b",
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
"\x38\xb0\x60\xa7\x51\xac\x96\x38"
|
||||
"\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
|
||||
"\x21\xfd\xb7\x11\x14\xbe\x07\x43"
|
||||
"\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
|
||||
"\x27\x4e\xde\xbf\xe7\x6f\x65\xfb"
|
||||
"\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b",
|
||||
"\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
|
||||
"\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
|
||||
"\x27\x2c\x32\xab\x0e\xde\xd1\x63"
|
||||
"\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
|
||||
"\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
|
||||
"\x58\xba\xec\xa1\x34\xc8\x25\xa7");
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
@ -423,25 +423,3 @@ int test_wc_Sm3_Flags(void)
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing wc_Sm3Hash()
|
||||
*/
|
||||
int test_wc_Sm3Hash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SM3) && defined(WOLFSSL_HASH_FLAGS)
|
||||
byte data[WC_SM3_BLOCK_SIZE];
|
||||
byte hash[WC_SM3_DIGEST_SIZE];
|
||||
|
||||
/* Invalid parameters. */
|
||||
ExpectIntEQ(wc_Sm3Hash(NULL, sizeof(data), hash),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sm3Hash(data, sizeof(data), NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
/* Valid parameters. */
|
||||
ExpectIntEQ(wc_Sm3Hash(data, sizeof(data), hash), 0);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sm3Hash */
|
||||
|
||||
|
@ -31,6 +31,5 @@ int test_wc_Sm3_other(void);
|
||||
int test_wc_Sm3Copy(void);
|
||||
int test_wc_Sm3GetHash(void);
|
||||
int test_wc_Sm3_Flags(void);
|
||||
int test_wc_Sm3Hash(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_SM3_H */
|
||||
|
@ -141,6 +141,8 @@
|
||||
|
||||
#define EXPECT_DECLS \
|
||||
int _ret = TEST_SKIPPED, _fail_codepoint_id = TEST_FAIL
|
||||
#define EXPECT_SUCCESS_DECLS \
|
||||
int _ret = TEST_SUCCESS, _fail_codepoint_id = TEST_SUCCESS
|
||||
#define EXPECT_DECLS_NO_MSGS(fail_codepoint_offset) \
|
||||
int _ret = TEST_SKIPPED_NO_MSGS, \
|
||||
_fail_codepoint_id = (fail_codepoint_offset)
|
||||
|
@ -42,6 +42,9 @@
|
||||
|
||||
void wc_InitMd2(wc_Md2* md2)
|
||||
{
|
||||
if (md2 == NULL)
|
||||
return;
|
||||
|
||||
XMEMSET(md2->X, 0, WC_MD2_X_SIZE);
|
||||
XMEMSET(md2->C, 0, WC_MD2_BLOCK_SIZE);
|
||||
XMEMSET(md2->buffer, 0, WC_MD2_BLOCK_SIZE);
|
||||
@ -73,6 +76,9 @@ void wc_Md2Update(wc_Md2* md2, const byte* data, word32 len)
|
||||
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
|
||||
};
|
||||
|
||||
if (md2 == NULL || (data == NULL && len != 0))
|
||||
return;
|
||||
|
||||
while (len) {
|
||||
word32 L = (WC_MD2_PAD_SIZE - md2->count) < len ?
|
||||
(WC_MD2_PAD_SIZE - md2->count) : len;
|
||||
@ -117,9 +123,13 @@ void wc_Md2Update(wc_Md2* md2, const byte* data, word32 len)
|
||||
void wc_Md2Final(wc_Md2* md2, byte* hash)
|
||||
{
|
||||
byte padding[WC_MD2_BLOCK_SIZE];
|
||||
word32 padLen = WC_MD2_PAD_SIZE - md2->count;
|
||||
word32 padLen;
|
||||
word32 i;
|
||||
|
||||
if (md2 == NULL || hash == NULL)
|
||||
return;
|
||||
|
||||
padLen = WC_MD2_PAD_SIZE - md2->count;
|
||||
for (i = 0; i < padLen; i++)
|
||||
padding[i] = (byte)padLen;
|
||||
|
||||
|
@ -39,6 +39,9 @@
|
||||
|
||||
void wc_InitMd4(wc_Md4* md4)
|
||||
{
|
||||
if (md4 == NULL)
|
||||
return;
|
||||
|
||||
md4->digest[0] = 0x67452301L;
|
||||
md4->digest[1] = 0xefcdab89L;
|
||||
md4->digest[2] = 0x98badcfeL;
|
||||
@ -141,8 +144,12 @@ static WC_INLINE void AddLength(wc_Md4* md4, word32 len)
|
||||
void wc_Md4Update(wc_Md4* md4, const byte* data, word32 len)
|
||||
{
|
||||
/* do block size increments */
|
||||
byte* local = (byte*)md4->buffer;
|
||||
byte* local;
|
||||
|
||||
if (md4 == NULL || (data == NULL && len != 0))
|
||||
return;
|
||||
|
||||
local = (byte*)md4->buffer;
|
||||
while (len) {
|
||||
word32 add = min(len, WC_MD4_BLOCK_SIZE - md4->buffLen);
|
||||
XMEMCPY(&local[md4->buffLen], data, add);
|
||||
@ -165,8 +172,12 @@ void wc_Md4Update(wc_Md4* md4, const byte* data, word32 len)
|
||||
|
||||
void wc_Md4Final(wc_Md4* md4, byte* hash)
|
||||
{
|
||||
byte* local = (byte*)md4->buffer;
|
||||
byte* local;
|
||||
|
||||
if (md4 == NULL || hash == NULL)
|
||||
return;
|
||||
|
||||
local = (byte*)md4->buffer;
|
||||
AddLength(md4, md4->buffLen); /* before adding pads */
|
||||
|
||||
local[md4->buffLen++] = 0x80; /* add 1 */
|
||||
|
Reference in New Issue
Block a user