Removed unnecessary comments and added HashInit's and checked that they returned errors when they should

This commit is contained in:
Ethan Looney
2020-07-16 12:38:55 -07:00
parent 6be76e84ec
commit 2275b89654

View File

@ -9271,8 +9271,8 @@ static int test_wc_Shake256Hash(void)
const byte data[] = { /* Hello World */ const byte data[] = { /* Hello World */
0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f, 0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f,
0x72,0x6c,0x64 0x72,0x6c,0x64
}; };
word32 len = sizeof(data); word32 len = sizeof(data);
byte hash[144]; byte hash[144];
word32 hashLen = sizeof(hash); word32 hashLen = sizeof(hash);
@ -22676,7 +22676,6 @@ static int test_wc_HashInit(void)
/* For loop to test various arguments... */ /* For loop to test various arguments... */
for (i = 0; i < enumlen; i++) { for (i = 0; i < enumlen; i++) {
//printf("%d", i);
/* check for bad args */ /* check for bad args */
if (wc_HashInit(&hash, enumArray[i]) == BAD_FUNC_ARG) { if (wc_HashInit(&hash, enumArray[i]) == BAD_FUNC_ARG) {
ret = 1; ret = 1;
@ -22711,8 +22710,6 @@ static int test_wc_HashSetFlags(void)
wc_HashAlg hash; wc_HashAlg hash;
word32 flags = 0; word32 flags = 0;
int i, j; int i, j;
//byte data[FOURK_BUF];
//byte hashBuf[WC_MAX_DIGEST_SIZE];
printf(testingFmt, "wc_HashSetFlags()"); printf(testingFmt, "wc_HashSetFlags()");
@ -22771,23 +22768,26 @@ static int test_wc_HashSetFlags(void)
} }
wc_HashFree(&hash, enumArray[i]); wc_HashFree(&hash, enumArray[i]);
if (ret != 0) {
break;
}
} }
/* For loop to test not supported sites */ /* For loop to test not supported cases */
int notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType)); int notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
for (j = 0; j < notSupportedLen; j++){ for (j = 0; j < notSupportedLen; j++){
if (ret == 0) { if (ret == 0) {
ret = wc_HashSetFlags(&hash, notSupported[j], flags); ret = wc_HashInit(&hash, notSupported[j]);
if (ret == BAD_FUNC_ARG) { if (ret == BAD_FUNC_ARG){
ret = 0; ret = 0;
} if (ret == 0){
} ret = wc_HashSetFlags(&hash, notSupported[j], flags);
wc_HashFree(&hash, notSupported[j]); if (ret == BAD_FUNC_ARG) {
if (ret != 0) { ret = 0;
break; }
}
}
}
ret = wc_HashFree(&hash, notSupported[j]);
if (ret == BAD_FUNC_ARG) {
ret = 0;
} }
} }
@ -22807,8 +22807,6 @@ static int test_wc_HashGetFlags(void)
wc_HashAlg hash; wc_HashAlg hash;
word32 flags = 0; word32 flags = 0;
int i, j; int i, j;
//byte data[FOURK_BUF];
//byte hashBuf[WC_MAX_DIGEST_SIZE];
printf(testingFmt, "wc_HashGetFlags()"); printf(testingFmt, "wc_HashGetFlags()");
@ -22868,19 +22866,26 @@ static int test_wc_HashGetFlags(void)
break; break;
} }
} }
/* For loop to test not supported sites */ /* For loop to test not supported cases */
int notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType)); int notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
for (j = 0; j < notSupportedLen; j++) { for (j = 0; j < notSupportedLen; j++){
if (ret == 0) { if (ret == 0) {
ret = wc_HashGetFlags(&hash, notSupported[j], &flags); ret = wc_HashInit(&hash, notSupported[j]);
if (ret == BAD_FUNC_ARG) { if (ret == BAD_FUNC_ARG){
ret = 0; ret = 0;
} if (ret == 0){
} ret = wc_HashGetFlags(&hash, notSupported[j], &flags);
wc_HashFree(&hash, notSupported[j]); if (ret == BAD_FUNC_ARG) {
if (ret != 0) { ret = 0;
break; }
}
}
}
ret = wc_HashFree(&hash, notSupported[j]);
if (ret == BAD_FUNC_ARG) {
ret = 0;
} }
} }
printf(resultFmt, ret == 0 ? passed : failed); printf(resultFmt, ret == 0 ? passed : failed);