additional changes made

This commit is contained in:
Tim
2018-05-22 17:25:22 -06:00
parent 58ac951471
commit 83e67a4197

View File

@@ -14844,9 +14844,13 @@ static void test_wc_PKCS7_EncodeEncryptedData (void)
/*----------------------------------------------------------------------------* /*----------------------------------------------------------------------------*
| hash.h Tests | hash.h Tests
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static void test_wc_HashInit(void) static int test_wc_HashInit(void)
{ {
/*enum for holding supported algorithms, #ifndef's restrict if disabled*/ int ret = 0, 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[] = { enum wc_HashType enumArray[] = {
#ifndef NO_MD5 #ifndef NO_MD5
WC_HASH_TYPE_MD5, WC_HASH_TYPE_MD5,
@@ -14866,30 +14870,33 @@ static void test_wc_HashInit(void)
#ifndef WOLFSSL_SHA512 #ifndef WOLFSSL_SHA512
WC_HASH_TYPE_SHA512, WC_HASH_TYPE_SHA512,
#endif #endif
}; };
int ret = 0; /*0 indicates tests passed, 1 indicates failure*/ /* dynamically finds the length */
int enumlen = (sizeof(enumArray))/4;/*dynamically finds the length*/ int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
/*For loop to test various arguments...*/ /* For loop to test various arguments... */
for(int i =0; i < enumlen; i++){ for(i = 0; i < enumlen; i++) {
wc_HashAlg hash; /* check for bad args */
if(wc_HashInit(&hash, enumArray[i])==BAD_FUNC_ARG){/*checking for bad args*/ if(wc_HashInit(&hash, enumArray[i]) == BAD_FUNC_ARG) {
ret = 1; ret = 1;
} break;
if(wc_HashInit(NULL, enumArray[i])!=BAD_FUNC_ARG){/*checking for null ptr*/ }
ret = 1; /* check for null ptr */
} if(wc_HashInit(NULL, enumArray[i]) != BAD_FUNC_ARG) {
ret = 1;
break;
}
}/* end of for loop */ }/* end of for loop */
printf(testingFmt, "wc_HashInit()"); printf(testingFmt, "wc_HashInit()");
if(ret==0){/* all tests have passed */ if(ret==0) { /* all tests have passed */
printf(resultFmt, passed); printf(resultFmt, passed);
} }
if(ret==1){/* a test has failed */ if(ret==1) { /* a test has failed */
printf(resultFmt, failed); printf(resultFmt, failed);
} }
return ret;
}/* end of test_wc_HashInit */ }/* end of test_wc_HashInit */
@@ -18919,6 +18926,8 @@ void ApiTest(void)
AssertFalse(test_wc_Sha384HmacUpdate()); AssertFalse(test_wc_Sha384HmacUpdate());
AssertFalse(test_wc_Sha384HmacFinal()); AssertFalse(test_wc_Sha384HmacFinal());
AssertIntEQ(test_wc_HashInit(), 0);
AssertIntEQ(test_wc_InitCmac(), 0); AssertIntEQ(test_wc_InitCmac(), 0);
AssertIntEQ(test_wc_CmacUpdate(), 0); AssertIntEQ(test_wc_CmacUpdate(), 0);
AssertIntEQ(test_wc_CmacFinal(), 0); AssertIntEQ(test_wc_CmacFinal(), 0);
@@ -19040,8 +19049,7 @@ void ApiTest(void)
test_wc_PKCS7_VerifySignedData(); test_wc_PKCS7_VerifySignedData();
test_wc_PKCS7_EncodeDecodeEnvelopedData(); test_wc_PKCS7_EncodeDecodeEnvelopedData();
test_wc_PKCS7_EncodeEncryptedData(); test_wc_PKCS7_EncodeEncryptedData();
test_wc_HashInit();
printf(" End API Tests\n"); printf(" End API Tests\n");