mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #3498 from ethanlooney/30th_branch
Added unit tests for blake2b
This commit is contained in:
45
tests/api.c
45
tests/api.c
@@ -5877,6 +5877,50 @@ static int test_wc_InitBlake2b (void)
|
||||
return ret;
|
||||
} /*END test_wc_InitBlake2b*/
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitBlake2b_WithKey()
|
||||
*/
|
||||
static int test_wc_InitBlake2b_WithKey (void)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef HAVE_BLAKE2
|
||||
Blake2b blake2;
|
||||
word32 digestSz = BLAKE2B_KEYBYTES;
|
||||
byte key[BLAKE2B_KEYBYTES];
|
||||
word32 keylen = BLAKE2B_KEYBYTES;
|
||||
|
||||
|
||||
|
||||
printf(testingFmt, "wc_InitBlake2b_WithKey()");
|
||||
|
||||
/* Test good arg. */
|
||||
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, key, keylen);
|
||||
if (ret != 0) {
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
/* Test bad args. */
|
||||
if (ret == 0) {
|
||||
ret = wc_InitBlake2b_WithKey(NULL, digestSz, key, keylen);
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, key, 256);
|
||||
if (ret == BAD_FUNC_ARG) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, NULL, keylen);
|
||||
}
|
||||
|
||||
printf(resultFmt, ret == 0 ? passed : failed);
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
} /*END wc_InitBlake2b_WithKey*/
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitBlake2s_WithKey()
|
||||
*/
|
||||
@@ -39024,6 +39068,7 @@ void ApiTest(void)
|
||||
AssertFalse(test_wc_Sha224GetHash());
|
||||
AssertFalse(test_wc_Sha224Copy());
|
||||
AssertFalse(test_wc_InitBlake2b());
|
||||
AssertFalse(test_wc_InitBlake2b_WithKey());
|
||||
AssertFalse(test_wc_InitBlake2s_WithKey());
|
||||
AssertFalse(test_wc_InitRipeMd());
|
||||
AssertFalse(test_wc_RipeMdUpdate());
|
||||
|
Reference in New Issue
Block a user