From 1b80e5a75fa6367232ac48c79baca64568235d39 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Tue, 25 Jul 2017 09:32:01 -0600 Subject: [PATCH] check return values with new unit tests --- tests/api.c | 405 ++++++++++++++++++++++++++-------------------------- 1 file changed, 203 insertions(+), 202 deletions(-) diff --git a/tests/api.c b/tests/api.c index d72c50bb1..f7a4ddc97 100644 --- a/tests/api.c +++ b/tests/api.c @@ -2396,15 +2396,14 @@ static void test_wolfSSL_mcast(void) */ static int test_wc_InitMd5 (void) { + int flag = 0; #ifndef NO_MD5 Md5 md5; - int ret, flag; + int ret; printf(testingFmt, "wc_InitMd5()"); - flag = 0; - /* Test good arg. */ ret = wc_InitMd5(&md5); if (ret != 0) { @@ -2424,7 +2423,7 @@ static int test_wc_InitMd5 (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitMd5 */ /* @@ -2432,11 +2431,10 @@ static int test_wc_InitMd5 (void) */ static int test_wc_InitSha(void) { + int flag = 0; #ifndef NO_SHA Sha sha; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitSha()"); @@ -2459,7 +2457,7 @@ static int test_wc_InitSha(void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitSha */ @@ -2468,11 +2466,10 @@ static int test_wc_InitSha(void) */ static int test_wc_InitSha256 (void) { + int flag = 0; #ifndef NO_SHA256 Sha256 sha256; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitSha256()"); @@ -2495,7 +2492,7 @@ static int test_wc_InitSha256 (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitSha256 */ @@ -2504,11 +2501,10 @@ static int test_wc_InitSha256 (void) */ static int test_wc_InitSha512 (void) { + int flag = 0; #ifdef WOLFSSL_SHA512 Sha512 sha512; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitSha512()"); @@ -2531,7 +2527,7 @@ static int test_wc_InitSha512 (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitSha512 */ @@ -2540,11 +2536,10 @@ static int test_wc_InitSha512 (void) */ static int test_wc_InitSha384 (void) { + int flag = 0; #ifdef WOLFSSL_SHA384 Sha384 sha384; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitSha384()"); @@ -2566,7 +2561,7 @@ static int test_wc_InitSha384 (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitSha384 */ /* @@ -2574,11 +2569,10 @@ static int test_wc_InitSha384 (void) */ static int test_wc_InitSha224 (void) { + int flag = 0; #ifdef WOLFSSL_SHA224 Sha224 sha224; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitSha224()"); @@ -2600,7 +2594,7 @@ static int test_wc_InitSha224 (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitSha224 */ @@ -2609,11 +2603,10 @@ static int test_wc_InitSha224 (void) */ static int test_wc_InitRipeMd (void) { + int flag = 0; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; - int ret, flag; - - flag = 0; + int ret; printf(testingFmt, "wc_InitRipeMd()"); @@ -2634,7 +2627,7 @@ static int test_wc_InitRipeMd (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_InitRipeMd */ @@ -2644,13 +2637,12 @@ static int test_wc_InitRipeMd (void) static int test_wc_Md5Update (void) { + int flag = 0; #ifndef NO_MD5 Md5 md5; byte hash[MD5_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitMd5(&md5); if (ret != 0) { @@ -2739,7 +2731,7 @@ static int test_wc_Md5Update (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Md5Update() */ /* @@ -2748,13 +2740,12 @@ static int test_wc_Md5Update (void) static int test_wc_ShaUpdate (void) { + int flag = 0; #ifndef NO_SHA Sha sha; byte hash[SHA_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitSha(&sha); if (ret != 0) { @@ -2843,7 +2834,7 @@ static int test_wc_ShaUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_ShaUpdate() */ @@ -2853,13 +2844,12 @@ static int test_wc_ShaUpdate (void) */ static int test_wc_Sha256Update (void) { + int flag = 0; #ifndef NO_SHA256 Sha256 sha256; byte hash[SHA256_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitSha256(&sha256); if (ret != 0) { @@ -2949,7 +2939,7 @@ static int test_wc_Sha256Update (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha256Update */ @@ -2959,13 +2949,12 @@ static int test_wc_Sha256Update (void) static int test_wc_Sha384Update (void) { + int flag = 0; #ifdef WOLFSSL_SHA384 Sha384 sha384; byte hash[SHA384_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitSha384(&sha384); if (ret != 0) { @@ -3057,7 +3046,7 @@ static int test_wc_Sha384Update (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha384Update */ /* @@ -3066,13 +3055,12 @@ static int test_wc_Sha384Update (void) static int test_wc_RipeMdUpdate (void) { + int flag = 0; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; byte hash[RIPEMD_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitRipeMd(&ripemd); if (ret != 0) { @@ -3159,7 +3147,7 @@ static int test_wc_RipeMdUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_RipeMdUdpate */ @@ -3169,13 +3157,12 @@ static int test_wc_RipeMdUpdate (void) static int test_wc_Sha512Update (void) { + int flag = 0; #ifdef WOLFSSL_SHA512 Sha512 sha512; byte hash[SHA512_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitSha512(&sha512); if (ret != 0) { @@ -3268,7 +3255,7 @@ static int test_wc_Sha512Update (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha512Update */ @@ -3277,13 +3264,12 @@ static int test_wc_Sha512Update (void) */ static int test_wc_Sha224Update (void) { + int flag = 0; #ifdef WOLFSSL_SHA224 Sha224 sha224; byte hash[SHA224_DIGEST_SIZE]; testVector a, b, c; - int ret, flag; - - flag = 0; + int ret; ret = wc_InitSha224(&sha224); if (ret != 0) { @@ -3373,7 +3359,7 @@ static int test_wc_Sha224Update (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha224Update */ @@ -3383,6 +3369,7 @@ static int test_wc_Sha224Update (void) static int test_wc_Md5Final (void) { + int flag = 0; #ifndef NO_MD5 /* Instantiate */ Md5 md5; @@ -3390,9 +3377,7 @@ static int test_wc_Md5Final (void) byte hash1[MD5_DIGEST_SIZE]; byte hash2[2*MD5_DIGEST_SIZE]; byte hash3[5*MD5_DIGEST_SIZE]; - int times, i, flag, ret; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitMd5(&md5); @@ -3447,7 +3432,7 @@ static int test_wc_Md5Final (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* @@ -3455,15 +3440,14 @@ static int test_wc_Md5Final (void) */ static int test_wc_ShaFinal (void) { + int flag = 0; #ifndef NO_SHA Sha sha; byte* hash_test[3]; byte hash1[SHA_DIGEST_SIZE]; byte hash2[2*SHA_DIGEST_SIZE]; byte hash3[5*SHA_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /*Initialize*/ ret = wc_InitSha(&sha); @@ -3518,7 +3502,7 @@ static int test_wc_ShaFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_ShaFinal */ /* @@ -3526,15 +3510,14 @@ static int test_wc_ShaFinal (void) */ static int test_wc_Sha256Final (void) { + int flag = 0; #ifndef NO_SHA256 Sha256 sha256; byte* hash_test[3]; byte hash1[SHA256_DIGEST_SIZE]; byte hash2[2*SHA256_DIGEST_SIZE]; byte hash3[5*SHA256_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitSha256(&sha256); @@ -3589,7 +3572,7 @@ static int test_wc_Sha256Final (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha256Final */ @@ -3598,15 +3581,14 @@ static int test_wc_Sha256Final (void) */ static int test_wc_Sha512Final (void) { + int flag = 0; #ifdef WOLFSSL_SHA512 Sha512 sha512; byte* hash_test[3]; byte hash1[SHA512_DIGEST_SIZE]; byte hash2[2*SHA512_DIGEST_SIZE]; byte hash3[5*SHA512_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitSha512(&sha512); @@ -3659,7 +3641,7 @@ static int test_wc_Sha512Final (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha512Final */ /* @@ -3667,15 +3649,14 @@ static int test_wc_Sha512Final (void) */ static int test_wc_Sha384Final (void) { + int flag = 0; #ifdef WOLFSSL_SHA384 Sha384 sha384; byte* hash_test[3]; byte hash1[SHA384_DIGEST_SIZE]; byte hash2[2*SHA384_DIGEST_SIZE]; byte hash3[5*SHA384_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitSha384(&sha384); @@ -3730,7 +3711,7 @@ static int test_wc_Sha384Final (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha384Final */ @@ -3739,15 +3720,14 @@ static int test_wc_Sha384Final (void) */ static int test_wc_RipeMdFinal (void) { + int flag = 0; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; byte* hash_test[3]; byte hash1[RIPEMD_DIGEST_SIZE]; byte hash2[2*RIPEMD_DIGEST_SIZE]; byte hash3[5*RIPEMD_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitRipeMd(&ripemd); @@ -3800,7 +3780,7 @@ static int test_wc_RipeMdFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_RipeMdFinal */ /* @@ -3808,15 +3788,14 @@ static int test_wc_RipeMdFinal (void) */ static int test_wc_Sha224Final (void) { + int flag = 0; #ifdef WOLFSSL_SHA224 Sha224 sha224; byte* hash_test[3]; byte hash1[SHA224_DIGEST_SIZE]; byte hash2[2*SHA224_DIGEST_SIZE]; byte hash3[5*SHA224_DIGEST_SIZE]; - int times, i, ret, flag; - - flag = 0; + int times, i, ret; /* Initialize */ ret = wc_InitSha224(&sha224); @@ -3871,7 +3850,7 @@ static int test_wc_Sha224Final (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha224Final */ /* @@ -3879,6 +3858,7 @@ static int test_wc_Sha224Final (void) */ static int test_wc_IdeaSetKey (void) { + int ret = 0; #ifdef HAVE_IDEA Idea idea; @@ -3887,7 +3867,7 @@ static int test_wc_IdeaSetKey (void) 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37 }; - int ret, flag = 0; + int flag = 0; printf(testingFmt, "wc_IdeaSetKey()"); /*IV can be NULL, default value is 0*/ @@ -3924,7 +3904,7 @@ static int test_wc_IdeaSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_IdeaSetKey */ @@ -3933,9 +3913,9 @@ static int test_wc_IdeaSetKey (void) */ static int test_wc_IdeaSetIV (void) { + int ret = 0; #ifdef HAVE_IDEA Idea idea; - int ret; printf(testingFmt, "wc_IdeaSetIV()"); @@ -3952,7 +3932,7 @@ static int test_wc_IdeaSetIV (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_IdeaSetIV */ @@ -3961,6 +3941,7 @@ static int test_wc_IdeaSetIV (void) */ static int test_wc_IdeaCipher (void) { + int ret = 0; #ifdef HAVE_IDEA Idea idea; const byte key[] = @@ -3974,7 +3955,6 @@ static int test_wc_IdeaCipher (void) }; byte enc[sizeof(plain)]; byte dec[sizeof(enc)]; - int ret; printf(testingFmt, "wc_IdeaCipher()"); @@ -4016,7 +3996,7 @@ static int test_wc_IdeaCipher (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_IdeaCipher */ /* @@ -4024,6 +4004,7 @@ static int test_wc_IdeaCipher (void) */ static int test_wc_IdeaCbcEncyptDecrypt (void) { + int ret = 0; #ifdef HAVE_IDEA Idea idea; const byte key[] = @@ -4034,7 +4015,6 @@ static int test_wc_IdeaCbcEncyptDecrypt (void) const char* message = "International Data Encryption Algorithm"; byte msg_enc[40]; byte msg_dec[40]; - int ret; printf(testingFmt, "wc_IdeaCbcEncrypt()"); @@ -4095,7 +4075,7 @@ static int test_wc_IdeaCbcEncyptDecrypt (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_IdeaCbcEncryptDecrypt */ @@ -4105,9 +4085,10 @@ static int test_wc_IdeaCbcEncyptDecrypt (void) */ static int test_wc_Md5HmacSetKey (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_MD5) Hmac hmac; - int ret, flag, times, itr; + int ret, times, itr; const char* keys[]= { @@ -4163,7 +4144,7 @@ static int test_wc_Md5HmacSetKey (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Md5HmacSetKey */ @@ -4173,9 +4154,10 @@ static int test_wc_Md5HmacSetKey (void) static int test_wc_ShaHmacSetKey (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; - int ret, flag, times, itr; + int ret, times, itr; const char* keys[]= { @@ -4233,7 +4215,7 @@ static int test_wc_ShaHmacSetKey (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_ShaHmacSetKey() */ /* @@ -4242,9 +4224,10 @@ static int test_wc_ShaHmacSetKey (void) static int test_wc_Sha224HmacSetKey (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; - int ret, flag, times, itr; + int ret, times, itr; const char* keys[]= { @@ -4302,7 +4285,7 @@ static int test_wc_Sha224HmacSetKey (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha224HmacSetKey() */ /* @@ -4311,9 +4294,10 @@ static int test_wc_Sha224HmacSetKey (void) static int test_wc_Sha256HmacSetKey (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; - int ret, flag, times, itr; + int ret, times, itr; const char* keys[]= { @@ -4371,7 +4355,7 @@ static int test_wc_Sha256HmacSetKey (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha256HmacSetKey() */ @@ -4380,9 +4364,10 @@ static int test_wc_Sha256HmacSetKey (void) */ static int test_wc_Sha384HmacSetKey (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; - int ret, flag, times, itr; + int ret, times, itr; const char* keys[]= { @@ -4440,7 +4425,7 @@ static int test_wc_Sha384HmacSetKey (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha384HmacSetKey() */ @@ -4449,10 +4434,11 @@ static int test_wc_Sha384HmacSetKey (void) */ static int test_wc_Md5HmacUpdate (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_MD5) Hmac hmac; testVector a, b; - int ret, flag; + int ret; const char* keys = "Jefe"; a.input = "what do ya want for nothing?"; @@ -4509,7 +4495,7 @@ static int test_wc_Md5HmacUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Md5HmacUpdate */ /* @@ -4517,10 +4503,11 @@ static int test_wc_Md5HmacUpdate (void) */ static int test_wc_ShaHmacUpdate (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; testVector a, b; - int ret, flag; + int ret; const char* keys = "Jefe"; a.input = "what do ya want for nothing?"; @@ -4577,7 +4564,7 @@ static int test_wc_ShaHmacUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_ShaHmacUpdate */ /* @@ -4585,10 +4572,11 @@ static int test_wc_ShaHmacUpdate (void) */ static int test_wc_Sha224HmacUpdate (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; testVector a, b; - int ret, flag; + int ret; const char* keys = "Jefe"; a.input = "what do ya want for nothing?"; @@ -4645,7 +4633,7 @@ static int test_wc_Sha224HmacUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha224HmacUpdate */ /* @@ -4653,10 +4641,11 @@ static int test_wc_Sha224HmacUpdate (void) */ static int test_wc_Sha256HmacUpdate (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; testVector a, b; - int ret, flag; + int ret; const char* keys = "Jefe"; a.input = "what do ya want for nothing?"; @@ -4713,7 +4702,7 @@ static int test_wc_Sha256HmacUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha256HmacUpdate */ /* @@ -4721,10 +4710,11 @@ static int test_wc_Sha256HmacUpdate (void) */ static int test_wc_Sha384HmacUpdate (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; testVector a, b; - int ret, flag; + int ret; const char* keys = "Jefe"; a.input = "what do ya want for nothing?"; @@ -4781,7 +4771,7 @@ static int test_wc_Sha384HmacUpdate (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha384HmacUpdate */ /* @@ -4790,11 +4780,12 @@ static int test_wc_Sha384HmacUpdate (void) static int test_wc_Md5HmacFinal (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_MD5) Hmac hmac; byte hash[MD5_DIGEST_SIZE]; testVector a; - int ret, flag; + int ret; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -4852,7 +4843,7 @@ static int test_wc_Md5HmacFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Md5HmacFinal */ @@ -4861,11 +4852,12 @@ static int test_wc_Md5HmacFinal (void) */ static int test_wc_ShaHmacFinal (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; byte hash[SHA_DIGEST_SIZE]; testVector a; - int ret, flag; + int ret; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -4924,7 +4916,7 @@ static int test_wc_ShaHmacFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_ShaHmacFinal */ @@ -4934,11 +4926,12 @@ static int test_wc_ShaHmacFinal (void) */ static int test_wc_Sha224HmacFinal (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; byte hash[SHA224_DIGEST_SIZE]; testVector a; - int ret, flag; + int ret; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -4997,7 +4990,7 @@ static int test_wc_Sha224HmacFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha224HmacFinal */ /* @@ -5005,11 +4998,12 @@ static int test_wc_Sha224HmacFinal (void) */ static int test_wc_Sha256HmacFinal (void) { + int flag = 0; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; byte hash[SHA256_DIGEST_SIZE]; testVector a; - int ret, flag; + int ret; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -5069,7 +5063,7 @@ static int test_wc_Sha256HmacFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha256HmacFinal */ /* @@ -5077,11 +5071,12 @@ static int test_wc_Sha256HmacFinal (void) */ static int test_wc_Sha384HmacFinal (void) { + int flag = 0; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; byte hash[SHA384_DIGEST_SIZE]; testVector a; - int ret, flag; + int ret; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -5141,7 +5136,7 @@ static int test_wc_Sha384HmacFinal (void) printf(resultFmt, flag == 0 ? passed : failed); #endif - return 0; + return flag; } /* END test_wc_Sha384HmacFinal */ @@ -5151,9 +5146,9 @@ static int test_wc_Sha384HmacFinal (void) */ static int test_wc_Des3_SetIV (void) { + int ret = 0; #ifndef NO_DES3 Des3 des; - int ret; const byte key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, @@ -5192,7 +5187,7 @@ static int test_wc_Des3_SetIV (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Des3_SetIV */ @@ -5201,9 +5196,9 @@ static int test_wc_Des3_SetIV (void) */ static int test_wc_Des3_SetKey (void) { + int ret = 0; #ifndef NO_DES3 Des3 des; - int ret; const byte key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, @@ -5246,7 +5241,7 @@ static int test_wc_Des3_SetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Des3_SetKey */ @@ -5255,11 +5250,11 @@ static int test_wc_Des3_SetKey (void) */ static int test_wc_Des3_CbcEncryptDecrypt (void) { + int ret = 0; #ifndef NO_DES3 Des3 des; byte cipher[24]; byte plain[24]; - int ret; const byte key[] = { @@ -5336,7 +5331,7 @@ static int test_wc_Des3_CbcEncryptDecrypt (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END wc_Des3_CbcEncrypt */ @@ -5345,6 +5340,7 @@ static int test_wc_Des3_CbcEncryptDecrypt (void) */ static int test_wc_Des3_CbcEncryptDecryptWithKey (void) { + int ret = 0; #ifndef NO_DES3 word32 vectorSz, cipherSz; @@ -5372,7 +5368,6 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey (void) 0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81 }; - int ret; vectorSz = sizeof(byte) * 24; cipherSz = sizeof(byte) * 24; @@ -5425,7 +5420,7 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Des3_CbcEncryptDecryptWithKey */ @@ -5434,6 +5429,7 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey (void) */ static int test_wc_Chacha_SetKey (void) { + int ret = 0; #ifdef HAVE_CHACHA ChaCha ctx; const byte key[] = @@ -5444,7 +5440,6 @@ static int test_wc_Chacha_SetKey (void) 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01 }; byte cipher[128]; - int ret; printf(testingFmt, "wc_Chacha_SetKey()"); @@ -5477,7 +5472,7 @@ static int test_wc_Chacha_SetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Chacha_SetKey */ /* @@ -5485,11 +5480,11 @@ static int test_wc_Chacha_SetKey (void) */ static int test_wc_Chacha_Process (void) { + int ret = 0; #ifdef HAVE_CHACHA ChaCha enc, dec; byte cipher[128]; byte plain[128]; - int ret; const byte key[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -5539,7 +5534,7 @@ static int test_wc_Chacha_Process (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Chacha_Process */ /* @@ -5547,6 +5542,7 @@ static int test_wc_Chacha_Process (void) */ static int test_wc_ChaCha20Poly1305_aead (void) { + int ret = 0; #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) const byte key[] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, @@ -5606,7 +5602,6 @@ static int test_wc_ChaCha20Poly1305_aead (void) byte generatedCiphertext[272]; byte generatedPlaintext[272]; byte generatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]; - int ret; /* Initialize stack variables. */ XMEMSET(generatedCiphertext, 0, 272); @@ -5694,7 +5689,7 @@ static int test_wc_ChaCha20Poly1305_aead (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test-wc_ChaCha20Poly1305_EncryptDecrypt */ @@ -5704,6 +5699,7 @@ static int test_wc_ChaCha20Poly1305_aead (void) */ static int test_wc_AesSetIV (void) { + int ret = 0; #ifndef NO_AES Aes aes; byte key16[] = @@ -5713,7 +5709,6 @@ static int test_wc_AesSetIV (void) }; byte iv1[] = "1234567890abcdef"; byte iv2[] = "0987654321fedcba"; - int ret; printf(testingFmt, "wc_AesSetIV()"); @@ -5736,7 +5731,7 @@ static int test_wc_AesSetIV (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* test_wc_AesSetIV */ @@ -5745,6 +5740,7 @@ static int test_wc_AesSetIV (void) */ static int test_wc_AesSetKey (void) { + int ret = 0; #ifndef NO_AES Aes aes; byte key16[] = @@ -5771,7 +5767,6 @@ static int test_wc_AesSetKey (void) 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65 }; byte iv[] = "1234567890abcdef"; - int ret; printf(testingFmt, "wc_AesSetKey()"); @@ -5807,7 +5802,7 @@ static int test_wc_AesSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_AesSetKey */ @@ -5818,6 +5813,7 @@ static int test_wc_AesSetKey (void) */ static int test_wc_AesCbcEncryptDecrypt (void) { + int ret = 0; #if !defined(NO_AES) && defined(HAVE_AES_CBC) && defined(HAVE_AES_DECRYPT) Aes aes; byte key32[] = @@ -5840,7 +5836,6 @@ static int test_wc_AesCbcEncryptDecrypt (void) int cbcD = SSL_FATAL_ERROR; int cbcDWK = SSL_FATAL_ERROR; byte dec2[sizeof(vector)]; - int ret; /* Init stack variables. */ XMEMSET(enc, 0, sizeof(enc)); @@ -5940,7 +5935,7 @@ static int test_wc_AesCbcEncryptDecrypt (void) } printf(resultFmt, cbcDWK == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_AesCbcEncryptDecrypt */ /* @@ -5948,6 +5943,7 @@ static int test_wc_AesCbcEncryptDecrypt (void) */ static int test_wc_AesCtrEncryptDecrypt (void) { + int ret = 0; #if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER) Aes aesEnc, aesDec; byte key32[] = @@ -5966,7 +5962,6 @@ static int test_wc_AesCtrEncryptDecrypt (void) byte iv[] = "1234567890abcdef"; byte enc[AES_BLOCK_SIZE * 2]; byte dec[AES_BLOCK_SIZE * 2]; - int ret; /* Init stack variables. */ XMEMSET(enc, 0, AES_BLOCK_SIZE * 2); @@ -6017,7 +6012,7 @@ static int test_wc_AesCtrEncryptDecrypt (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_AesCtrEncryptDecrypt */ @@ -6026,6 +6021,7 @@ static int test_wc_AesCtrEncryptDecrypt (void) */ static int test_wc_AesGcmSetKey (void) { + int ret = 0; #if !defined(NO_AES) && defined(HAVE_AESGCM) Aes aes; @@ -6065,7 +6061,6 @@ static int test_wc_AesGcmSetKey (void) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65 }; - int ret; printf(testingFmt, "wc_AesGcmSetKey()"); @@ -6096,7 +6091,7 @@ static int test_wc_AesGcmSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_AesGcmSetKey */ /* @@ -6104,6 +6099,7 @@ static int test_wc_AesGcmSetKey (void) */ static int test_wc_AesGcmEncryptDecrypt (void) { + int ret = 0; #if !defined(NO_AES) && defined(HAVE_AESGCM) Aes aes; @@ -6131,7 +6127,6 @@ static int test_wc_AesGcmEncryptDecrypt (void) byte enc[sizeof(vector)]; byte resultT[AES_BLOCK_SIZE]; byte dec[sizeof(vector)]; - int ret; int gcmD = SSL_FATAL_ERROR; int gcmE = SSL_FATAL_ERROR; @@ -6227,7 +6222,7 @@ static int test_wc_AesGcmEncryptDecrypt (void) printf(resultFmt, gcmD == 0 ? passed : failed); #endif /* HAVE_AES_DECRYPT */ #endif - return 0; + return ret; } /* END test_wc_AesGcmEncryptDecrypt */ @@ -6236,6 +6231,7 @@ static int test_wc_AesGcmEncryptDecrypt (void) */ static int test_wc_GmacSetKey (void) { + int ret = 0; #if !defined(NO_AES) && defined(HAVE_AESGCM) Gmac gmac; byte key16[] = @@ -6274,7 +6270,6 @@ static int test_wc_GmacSetKey (void) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 }; - int ret; printf(testingFmt, "wc_GmacSetKey()"); @@ -6311,7 +6306,7 @@ static int test_wc_GmacSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_GmacSetKey */ @@ -6320,6 +6315,7 @@ static int test_wc_GmacSetKey (void) */ static int test_wc_GmacUpdate (void) { + int ret = 0; #if !defined(NO_AES) && defined(HAVE_AESGCM) Gmac gmac; const byte key16[] = @@ -6388,7 +6384,6 @@ static int test_wc_GmacUpdate (void) byte tagOut[16]; byte tagOut2[24]; byte tagOut3[32]; - int ret; /* Init stack varaibles. */ XMEMSET(tagOut, 0, sizeof(tagOut)); @@ -6450,7 +6445,7 @@ static int test_wc_GmacUpdate (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_GmacUpdate */ @@ -6460,6 +6455,7 @@ static int test_wc_GmacUpdate (void) */ static int test_wc_CamelliaSetKey (void) { + int ret = 0; #ifdef HAVE_CAMELLIA Camellia camellia; /*128-bit key*/ @@ -6488,7 +6484,6 @@ static int test_wc_CamelliaSetKey (void) 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - int ret; printf(testingFmt, "wc_CamelliaSetKey()"); @@ -6526,7 +6521,7 @@ static int test_wc_CamelliaSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_CammeliaSetKey */ @@ -6535,6 +6530,7 @@ static int test_wc_CamelliaSetKey (void) */ static int test_wc_CamelliaSetIV (void) { + int ret = 0; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte iv[] = @@ -6542,7 +6538,6 @@ static int test_wc_CamelliaSetIV (void) 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - int ret; printf(testingFmt, "wc_CamelliaSetIV()"); @@ -6563,7 +6558,7 @@ static int test_wc_CamelliaSetIV (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /*END test_wc_CamelliaSetIV*/ /* @@ -6571,6 +6566,7 @@ static int test_wc_CamelliaSetIV (void) */ static int test_wc_CamelliaEncryptDecryptDirect (void) { + int ret = 0; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte key24[] = @@ -6593,7 +6589,6 @@ static int test_wc_CamelliaEncryptDecryptDirect (void) byte dec[sizeof(enc)]; int camE = SSL_FATAL_ERROR; int camD = SSL_FATAL_ERROR; - int ret; /*Init stack variables.*/ XMEMSET(enc, 0, 16); @@ -6647,7 +6642,7 @@ static int test_wc_CamelliaEncryptDecryptDirect (void) printf(resultFmt, camD == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test-wc_CamelliaEncryptDecryptDirect */ @@ -6656,6 +6651,7 @@ static int test_wc_CamelliaEncryptDecryptDirect (void) */ static int test_wc_CamelliaCbcEncryptDecrypt (void) { + int ret = 0; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte key24[] = @@ -6673,7 +6669,6 @@ static int test_wc_CamelliaCbcEncryptDecrypt (void) byte dec[CAMELLIA_BLOCK_SIZE]; int camCbcE = SSL_FATAL_ERROR; int camCbcD = SSL_FATAL_ERROR; - int ret; /* Init stack variables. */ XMEMSET(enc, 0, CAMELLIA_BLOCK_SIZE); @@ -6738,7 +6733,7 @@ static int test_wc_CamelliaCbcEncryptDecrypt (void) printf(resultFmt, camCbcD == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_CamelliaCbcEncryptDecrypt */ @@ -6747,9 +6742,9 @@ static int test_wc_CamelliaCbcEncryptDecrypt (void) */ static int test_wc_RabbitSetKey (void) { + int ret = 0; #ifndef NO_RABBIT Rabbit rabbit; - int ret; const char* key = "\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B" "\xFE\x36\x3D\x2E\x29\x13\x28\x91"; const char* iv = "\x59\x7E\x26\xC1\x75\xF5\x73\xC3"; @@ -6772,7 +6767,7 @@ static int test_wc_RabbitSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RabbitSetKey */ @@ -6781,11 +6776,11 @@ static int test_wc_RabbitSetKey (void) */ static int test_wc_RabbitProcess (void) { + int ret = 0; #ifndef NO_RABBIT Rabbit enc, dec; byte cipher[25]; byte plain[25]; - int ret; const char* key = "\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B" "\xFE\x36\x3D\x2E\x29\x13\x28\x91"; const char* iv = "\x59\x7E\x26\xC1\x75\xF5\x73\xC3"; @@ -6832,7 +6827,7 @@ static int test_wc_RabbitProcess (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RabbitProcess */ @@ -6845,6 +6840,7 @@ static int test_wc_RabbitProcess (void) */ static int test_wc_Arc4SetKey (void) { + int ret = 0; #ifndef NO_RC4 Arc4 arc; const char* key[] = @@ -6852,7 +6848,6 @@ static int test_wc_Arc4SetKey (void) "\x01\x23\x45\x67\x89\xab\xcd\xef" }; int keyLen = 8; - int ret; printf(testingFmt, "wc_Arch4SetKey()"); @@ -6874,7 +6869,7 @@ static int test_wc_Arc4SetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Arc4SetKey */ @@ -6883,13 +6878,13 @@ static int test_wc_Arc4SetKey (void) */ static int test_wc_Arc4Process (void) { + int ret = 0; #ifndef NO_RC4 Arc4 enc, dec; const char* key = "\x01\x23\x45\x67\x89\xab\xcd\xef"; const char* input = "\x01\x23\x45\x67\x89\xab\xcd\xef"; byte cipher[8]; byte plain[8]; - int ret; /* Init stack variables */ XMEMSET(cipher, 0, sizeof(cipher)); @@ -6949,7 +6944,7 @@ static int test_wc_Arc4Process (void) wc_Arc4Free(&dec); #endif - return 0; + return ret; }/* END test_wc_Arc4Process */ @@ -6959,9 +6954,9 @@ static int test_wc_Arc4Process (void) */ static int test_wc_InitRsaKey (void) { + int ret = 0; #ifndef NO_RSA RsaKey key; - int ret; printf(testingFmt, "wc_InitRsaKey()"); @@ -6990,7 +6985,7 @@ static int test_wc_InitRsaKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_InitRsaKey */ @@ -6999,12 +6994,12 @@ static int test_wc_InitRsaKey (void) */ static int test_wc_RsaPrivateKeyDecode (void) { + int ret = 0; #if !defined(NO_RSA) && (defined(USE_CERT_BUFFERS_1024)\ || defined(USE_CERT_BUFFERS_2048)) && !defined(HAVE_FIPS) RsaKey key; byte* tmp; word32 idx = 0; - int ret = 0; int bytes = 0; printf(testingFmt, "wc_RsaPrivateKeyDecode()"); @@ -7071,7 +7066,7 @@ static int test_wc_RsaPrivateKeyDecode (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaPrivateKeyDecode */ @@ -7080,13 +7075,13 @@ static int test_wc_RsaPrivateKeyDecode (void) */ static int test_wc_RsaPublicKeyDecode (void) { + int ret = 0; #if !defined(NO_RSA) && (defined(USE_CERT_BUFFERS_1024)\ || defined(USE_CERT_BUFFERS_2048)) && !defined(HAVE_FIPS) RsaKey keyPub; byte* tmp; word32 idx = 0; int bytes = 0; - int ret = 0; tmp = (byte*)XMALLOC(GEN_BUF, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) { @@ -7153,7 +7148,7 @@ static int test_wc_RsaPublicKeyDecode (void) #endif - return 0; + return ret; } /* END test_wc_RsaPublicKeyDecode */ @@ -7162,9 +7157,9 @@ static int test_wc_RsaPublicKeyDecode (void) */ static int test_wc_RsaPublicKeyDecodeRaw (void) { + int ret = 0; #if !defined(NO_RSA) RsaKey key; - int ret; const byte n = 0x23; const byte e = 0x03; int nSz = sizeof(n); @@ -7217,7 +7212,7 @@ static int test_wc_RsaPublicKeyDecodeRaw (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaPublicKeyDecodeRaw */ @@ -7226,11 +7221,11 @@ static int test_wc_RsaPublicKeyDecodeRaw (void) */ static int test_wc_MakeRsaKey (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey genKey; WC_RNG rng; - int ret; printf(testingFmt, "wc_MakeRsaKey()"); @@ -7295,7 +7290,7 @@ static int test_wc_MakeRsaKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_MakeRsaKey */ @@ -7304,9 +7299,9 @@ static int test_wc_MakeRsaKey (void) */ static int test_wc_SetKeyUsage (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_CERT_EXT) && !defined(HAVE_FIPS) Cert myCert; - int ret; ret = wc_InitCert(&myCert); @@ -7351,7 +7346,7 @@ static int test_wc_SetKeyUsage (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_SetKeyUsage */ @@ -7360,11 +7355,11 @@ static int test_wc_SetKeyUsage (void) */ static int test_wc_RsaKeyToDer (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey genKey; WC_RNG rng; byte* der; - int ret = 0; der = (byte*)XMALLOC(610, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (der == NULL) { @@ -7446,7 +7441,7 @@ static int test_wc_RsaKeyToDer (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaKeyToDer */ /* @@ -7454,12 +7449,12 @@ static int test_wc_RsaKeyToDer (void) */ static int test_wc_RsaKeyToPublicDer (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; byte* der; word32 derLen = 162; - int ret = 0; der = (byte*)XMALLOC(derLen, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (der == NULL) { @@ -7533,7 +7528,7 @@ static int test_wc_RsaKeyToPublicDer (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaKeyToPublicDer */ @@ -7542,6 +7537,7 @@ static int test_wc_RsaKeyToPublicDer (void) */ static int test_wc_RsaPublicEncryptDecrypt (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; @@ -7549,7 +7545,6 @@ static int test_wc_RsaPublicEncryptDecrypt (void) word32 cipherLen = 128; word32 plainLen = 25; word32 inLen = (word32)XSTRLEN(inStr); - int ret; DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL); DECLARE_VAR(plain, byte, plainLen, NULL); @@ -7610,7 +7605,7 @@ static int test_wc_RsaPublicEncryptDecrypt (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaPublicEncryptDecrypt */ @@ -7619,6 +7614,7 @@ static int test_wc_RsaPublicEncryptDecrypt (void) */ static int test_wc_RsaPublicEncryptDecrypt_ex (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_FIPS)\ && !defined(WC_NO_RSA_OAEP) && !defined(HAVE_USER_RSA) RsaKey key; @@ -7628,7 +7624,6 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void) const word32 cipherSz = 128; const word32 plainSz = 25; byte* res = NULL; - int ret = 0; int idx = 0; DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL); @@ -7715,7 +7710,7 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaPublicEncryptDecrypt_ex */ @@ -7724,6 +7719,7 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void) */ static int test_wc_RsaSSL_SignVerify (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; @@ -7732,7 +7728,6 @@ static int test_wc_RsaSSL_SignVerify (void) const word32 plainSz = 25; word32 inLen = (word32)XSTRLEN(inStr); word32 idx = 0; - int ret; DECLARE_VAR_INIT(in, byte, inLen, inStr, NULL); DECLARE_VAR(out, byte, outSz, NULL); @@ -7864,7 +7859,7 @@ static int test_wc_RsaSSL_SignVerify (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaSSL_SignVerify */ @@ -7873,10 +7868,10 @@ static int test_wc_RsaSSL_SignVerify (void) */ static int test_wc_RsaEncryptSize (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; - int ret; int enc128 = 128; int enc512 = 512; @@ -7938,7 +7933,7 @@ static int test_wc_RsaEncryptSize (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaEncryptSize*/ @@ -7947,10 +7942,10 @@ static int test_wc_RsaEncryptSize (void) */ static int test_wc_RsaFlattenPublicKey (void) { + int ret = 0; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; - int ret; byte e[256]; byte n[256]; word32 eSz = sizeof(e); @@ -8030,7 +8025,7 @@ static int test_wc_RsaFlattenPublicKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_RsaFlattenPublicKey */ @@ -8041,6 +8036,7 @@ static int test_wc_RsaFlattenPublicKey (void) */ static int test_wc_AesCcmSetKey (void) { + int ret = 0; #ifdef HAVE_AESCCM Aes aes; const byte key16[] = @@ -8061,7 +8057,6 @@ static int test_wc_AesCcmSetKey (void) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 }; - int ret; printf(testingFmt, "wc_AesCcmSetKey()"); @@ -8092,7 +8087,7 @@ static int test_wc_AesCcmSetKey (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_AesCcmSetKey */ @@ -8101,6 +8096,7 @@ static int test_wc_AesCcmSetKey (void) */ static int test_wc_AesCcmEncryptDecrypt (void) { + int ret = 0; #ifdef HAVE_AESCCM Aes aes; const byte key16[] = @@ -8138,7 +8134,6 @@ static int test_wc_AesCcmEncryptDecrypt (void) byte cipherOut[sizeof(plainT)]; byte authTag[sizeof(t)]; int ccmE = SSL_FATAL_ERROR; - int ret; #ifdef HAVE_AES_DECRYPT int ccmD = SSL_FATAL_ERROR; byte plainOut[sizeof(cipherOut)]; @@ -8213,6 +8208,9 @@ static int test_wc_AesCcmEncryptDecrypt (void) } /* End Encrypt */ printf(resultFmt, ccmE == 0 ? passed : failed); + if (ccmE != 0) { + return ccmE; + } #ifdef HAVE_AES_DECRYPT printf(testingFmt, "wc_AesCcmDecrypt()"); @@ -8262,11 +8260,14 @@ static int test_wc_AesCcmEncryptDecrypt (void) } /* END Decrypt */ printf(resultFmt, ccmD == 0 ? passed : failed); + if (ccmD != 0) { + return ccmD; + } #endif #endif /* HAVE_AESCCM */ - return 0; + return ret; } /* END test_wc_AesCcmEncryptDecrypt */ @@ -8277,13 +8278,13 @@ static int test_wc_AesCcmEncryptDecrypt (void) */ static int test_wc_Hc128_SetKey (void) { + int ret = 0; #ifdef HAVE_HC128 HC128 ctx; const char* key = "\x80\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; const char* iv = "\x0D\x74\xDB\x42\xA9\x10\x77\xDE" "\x45\xAC\x13\x7A\xE1\x48\xAF\x16"; - int ret; printf(testingFmt, "wc_Hc128_SetKey()"); ret = wc_Hc128_SetKey(&ctx, (byte*)key, (byte*)iv); @@ -8302,7 +8303,7 @@ static int test_wc_Hc128_SetKey (void) #endif - return 0; + return ret; } /* END test_wc_Hc128_SetKey */ @@ -8311,6 +8312,7 @@ static int test_wc_Hc128_SetKey (void) */ static int test_wc_Hc128_Process (void) { + int ret = 0; #ifdef HAVE_HC128 HC128 enc; HC128 dec; @@ -8320,7 +8322,6 @@ static int test_wc_Hc128_Process (void) size_t inlen = XSTRLEN(input); byte cipher[inlen]; byte plain[inlen]; - int ret; printf(testingFmt, "wc_Hc128_Process()"); ret = wc_Hc128_SetKey(&enc, (byte*)key, NULL); @@ -8353,7 +8354,7 @@ static int test_wc_Hc128_Process (void) printf(resultFmt, ret == 0 ? passed : failed); #endif - return 0; + return ret; } /* END test_wc_Hc128_Process */