mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Added unit tests for blake2b
This commit is contained in:
46
tests/api.c
46
tests/api.c
@@ -5877,6 +5877,48 @@ 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 = (byte*)"01234567890123456789012345678901";
|
||||
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()
|
||||
*/
|
||||
@@ -39012,7 +39054,11 @@ void ApiTest(void)
|
||||
AssertFalse(test_wc_Sha224GetHash());
|
||||
AssertFalse(test_wc_Sha224Copy());
|
||||
AssertFalse(test_wc_InitBlake2b());
|
||||
<<<<<<< HEAD
|
||||
AssertFalse(test_wc_InitBlake2s_WithKey());
|
||||
=======
|
||||
AssertFalse(test_wc_InitBlake2b_WithKey());
|
||||
>>>>>>> Added unit tests for blake2b
|
||||
AssertFalse(test_wc_InitRipeMd());
|
||||
AssertFalse(test_wc_RipeMdUpdate());
|
||||
AssertFalse(test_wc_RipeMdFinal());
|
||||
|
Reference in New Issue
Block a user