From 1e94f0478cc77d3fcf276d03cae0b9a86a451c75 Mon Sep 17 00:00:00 2001 From: TakayukiMatsuo Date: Fri, 24 Apr 2020 18:55:03 +0900 Subject: [PATCH] Added resetting size info output-buffer before calling export APIs Added resetting size into output-buffer before calling export APIs --- tests/api.c | 502 ++++++++++++++++++++++++++-------------------------- 1 file changed, 251 insertions(+), 251 deletions(-) diff --git a/tests/api.c b/tests/api.c index 553b74d38..fa95d5284 100644 --- a/tests/api.c +++ b/tests/api.c @@ -6504,9 +6504,9 @@ static int test_wc_Sha256GetFlags (void) wc_Sha256 sha256; word32 flags = 0; - + printf(testingFmt, "wc_Sha256GetFlags()"); - + /* Initialize */ flag = wc_InitSha256(&sha256); if (flag == 0) { @@ -6517,7 +6517,7 @@ static int test_wc_Sha256GetFlags (void) flag = 0; } } - + wc_Sha256Free(&sha256); printf(resultFmt, flag == 0 ? passed : failed); @@ -6533,10 +6533,10 @@ static int test_wc_Sha256Free (void) { int flag = 0; #ifndef NO_SHA256 - + printf(testingFmt, "wc_Sha256Free()"); wc_Sha256Free(NULL); - + printf(resultFmt, flag == 0 ? passed : failed); #endif @@ -6552,12 +6552,12 @@ static int test_wc_Sha256GetHash (void) #ifndef NO_SHA256 wc_Sha256 sha256; byte hash1[WC_SHA256_DIGEST_SIZE]; - + printf(testingFmt, "wc_Sha256GetHash()"); - + /* Initialize */ flag = wc_InitSha256(&sha256); - + if (flag == 0) { flag = wc_Sha256GetHash(&sha256, hash1); } @@ -6580,7 +6580,7 @@ static int test_wc_Sha256GetHash (void) flag = 0; } } - + wc_Sha256Free(&sha256); printf(resultFmt, flag == 0 ? passed : failed); @@ -6597,10 +6597,10 @@ static int test_wc_Sha256Copy (void) int flag = 0; #ifndef NO_SHA256 wc_Sha256 sha256; - wc_Sha256 temp; - + wc_Sha256 temp; + printf(testingFmt, "wc_Sha256Copy()"); - + /* Initialize */ flag = wc_InitSha256(&sha256); if (flag == 0) { @@ -6612,7 +6612,7 @@ static int test_wc_Sha256Copy (void) /*test bad arguements*/ if (flag == 0) { flag = wc_Sha256Copy(NULL, NULL); - if (flag == BAD_FUNC_ARG) { + if (flag == BAD_FUNC_ARG) { flag = 0; } } @@ -6630,7 +6630,7 @@ static int test_wc_Sha256Copy (void) } wc_Sha256Free(&sha256); - wc_Sha256Free(&temp); + wc_Sha256Free(&temp); printf(resultFmt, flag == 0 ? passed : failed); @@ -7279,9 +7279,9 @@ static int test_wc_Sha224SetFlags (void) (defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)) wc_Sha224 sha224; word32 flags = 0; - + printf(testingFmt, "wc_Sha224SetFlags()"); - + /* Initialize */ flag = wc_InitSha224(&sha224); if (flag == 0) { @@ -7292,7 +7292,7 @@ static int test_wc_Sha224SetFlags (void) flag = 0; } } - + wc_Sha224Free(&sha224); printf(resultFmt, flag == 0 ? passed : failed); @@ -7311,9 +7311,9 @@ static int test_wc_Sha224GetFlags (void) (defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)) wc_Sha224 sha224; word32 flags = 0; - + printf(testingFmt, "wc_Sha224GetFlags()"); - + /* Initialize */ flag = wc_InitSha224(&sha224); if (flag == 0) { @@ -7324,7 +7324,7 @@ static int test_wc_Sha224GetFlags (void) flag = 0; } } - + wc_Sha224Free(&sha224); @@ -7342,10 +7342,10 @@ static int test_wc_Sha224Free (void) int flag = 0; #if !defined(NO_SHA224) && \ (defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)) - + printf(testingFmt, "wc_Sha224Free()"); wc_Sha224Free(NULL); - + printf(resultFmt, flag == 0 ? passed : failed); @@ -7363,12 +7363,12 @@ static int test_wc_Sha224GetHash (void) (defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)) wc_Sha224 sha224; byte hash1[WC_SHA224_DIGEST_SIZE]; - + printf(testingFmt, "wc_Sha224GetHash()"); - + /* Initialize */ flag = wc_InitSha224(&sha224); - + if (flag == 0) { flag = wc_Sha224GetHash(&sha224, hash1); } @@ -7391,7 +7391,7 @@ static int test_wc_Sha224GetHash (void) flag = 0; } } - + wc_Sha224Free(&sha224); printf(resultFmt, flag == 0 ? passed : failed); @@ -7409,10 +7409,10 @@ static int test_wc_Sha224Copy (void) #if !defined(NO_SHA224) && \ (defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)) wc_Sha224 sha224; - wc_Sha224 temp; - + wc_Sha224 temp; + printf(testingFmt, "wc_Sha224Copy()"); - + /* Initialize */ flag = wc_InitSha224(&sha224); if (flag == 0) { @@ -7440,10 +7440,10 @@ static int test_wc_Sha224Copy (void) flag = 0; } } - + wc_Sha224Free(&sha224); - wc_Sha224Free(&temp); + wc_Sha224Free(&temp); printf(resultFmt, flag == 0 ? passed : failed); @@ -15792,7 +15792,7 @@ static int test_wc_curve25519_export_key_raw (void) { #if defined(HAVE_CURVE25519) && defined(HAVE_CURVE25519_KEY_EXPORT) - + curve25519_key key; WC_RNG rng; @@ -15805,7 +15805,7 @@ static int test_wc_curve25519_export_key_raw (void) byte pubk[CURVE25519_KEYSIZE]; word32 prksz; word32 pbksz; - + printf(testingFmt, "wc_curve25519_export_key_raw()"); @@ -15814,30 +15814,30 @@ static int test_wc_curve25519_export_key_raw (void) fflush( stdout ); return 1; } - + if(0 != wc_curve25519_init(&key)){ printf(testingFmt, "failed due to wc_curve25519_init"); fflush( stdout ); wc_FreeRng(&rng); return 1; } - + if(0 != wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key)){ printf(testingFmt, "failed due to wc_curve25519_make_key"); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } - /* + /* bad-argument-test cases - target function sould return BAD_FUNC_ARG + target function sould return BAD_FUNC_ARG */ prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( + if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( NULL , privateKey, &prvkSz, publicKey, &pubkSz)){ printf(testingFmt,"failed at bad-arg-case-1."); @@ -15905,7 +15905,7 @@ static int test_wc_curve25519_export_key_raw (void) } /* - cross-testing + cross-testing */ prksz = CURVE25519_KEYSIZE; @@ -15936,21 +15936,21 @@ static int test_wc_curve25519_export_key_raw (void) if(0 != wc_curve25519_export_key_raw(&key, privateKey, &prvkSz, publicKey, &pubkSz)){ - + printf(testingFmt,"failed due to wc_curve25519_export_key_raw"); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; - + return 1; + } - + if((prksz == CURVE25519_KEYSIZE) && (pbksz == CURVE25519_KEYSIZE) && (prvkSz == CURVE25519_KEYSIZE) && (pubkSz == CURVE25519_KEYSIZE)){ - - if( 0 == XMEMCMP(privateKey, prik, CURVE25519_KEYSIZE) && + + if( 0 == XMEMCMP(privateKey, prik, CURVE25519_KEYSIZE) && 0 == XMEMCMP(publicKey, pubk, CURVE25519_KEYSIZE)){ printf(resultFmt,passed); @@ -15966,21 +15966,21 @@ static int test_wc_curve25519_export_key_raw (void) fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } } else{ - + printf(testingFmt,"failed due to bad-key-size."); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } #endif fflush( stdout ); - + return 0; } /* end of test_wc_curve25519_export_key_raw */ @@ -16004,7 +16004,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) byte pubk[CURVE25519_KEYSIZE]; word32 prksz; word32 pbksz; - + printf(testingFmt, "wc_curve25519_export_key_raw_ex()"); if(0 != wc_InitRng(&rng)){ @@ -16012,32 +16012,32 @@ static int test_wc_curve25519_export_key_raw_ex (void) fflush( stdout ); return 1; } - + if(0 != wc_curve25519_init(&key)){ printf(testingFmt, "failed due to wc_curve25519_init"); fflush( stdout ); wc_FreeRng(&rng); return 1; } - + if(0 != wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key)){ printf(testingFmt, "failed due to wc_curve25519_make_key"); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } - /* + /* bad-argument-test cases - target function sould return BAD_FUNC_ARG + target function sould return BAD_FUNC_ARG */ prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL , privateKey, + if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL , privateKey, &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)){ - + printf(testingFmt,"failed at bad-arg-case-1."); fflush( stdout ); wc_curve25519_free(&key); @@ -16049,7 +16049,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key , NULL, + if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key , NULL, &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)){ printf(testingFmt,"failed at bad-arg-case-2."); @@ -16058,20 +16058,20 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_FreeRng(&rng); return 1; } - + prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; - + if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key,privateKey, NULL,publicKey, &pubkSz,EC25519_LITTLE_ENDIAN)){ - + printf(testingFmt,"failed at bad-arg-case-3."); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); return 1; } - + prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; @@ -16123,7 +16123,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_FreeRng(&rng); return 1; } - + prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; @@ -16140,7 +16140,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, NULL, &pubkSz, EC25519_BIG_ENDIAN)){ printf(testingFmt,"failed at bad-arg-case-9."); @@ -16149,7 +16149,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_FreeRng(&rng); return 1; } - + prvkSz = CURVE25519_KEYSIZE; pubkSz = CURVE25519_KEYSIZE; @@ -16161,7 +16161,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_curve25519_free(&key); wc_FreeRng(&rng); return 1; - } + } /* illegal value for endien */ @@ -16176,11 +16176,11 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_curve25519_free(&key); wc_FreeRng(&rng); return 1; - } - + } + /* - cross-testing - */ + cross-testing + */ prksz = CURVE25519_KEYSIZE; if(0 != wc_curve25519_export_private_raw( &key, prik, &prksz )){ @@ -16190,8 +16190,8 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_curve25519_free(&key); wc_FreeRng(&rng); return 1; - } - + } + pbksz = CURVE25519_KEYSIZE; if(0 != wc_curve25519_export_public( &key, pubk, &pbksz )){ @@ -16217,18 +16217,18 @@ static int test_wc_curve25519_export_key_raw_ex (void) return 1; } - if( prksz == CURVE25519_KEYSIZE && + if( prksz == CURVE25519_KEYSIZE && pbksz == CURVE25519_KEYSIZE && prvkSz == CURVE25519_KEYSIZE && pubkSz == CURVE25519_KEYSIZE ){ - if( 0 == XMEMCMP( privateKey, prik, CURVE25519_KEYSIZE ) && + if( 0 == XMEMCMP( privateKey, prik, CURVE25519_KEYSIZE ) && 0 == XMEMCMP( publicKey, pubk, CURVE25519_KEYSIZE )){ if( 0 == wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)){ - if( prvkSz == CURVE25519_KEYSIZE && + if( prvkSz == CURVE25519_KEYSIZE && pubkSz == CURVE25519_KEYSIZE ){ ; /* proceed to the next test */ @@ -16239,7 +16239,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } } else{ @@ -16259,20 +16259,20 @@ static int test_wc_curve25519_export_key_raw_ex (void) fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; - } - } + } + } else{ printf(testingFmt,"failed due to bad-key-size"); fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; - } + return 1; + } - /* + /* try once with another endian */ @@ -16282,7 +16282,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) if( 0 == wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)){ - if( prvkSz == CURVE25519_KEYSIZE && + if( prvkSz == CURVE25519_KEYSIZE && pubkSz == CURVE25519_KEYSIZE ){ /* no more test*/ @@ -16298,7 +16298,7 @@ static int test_wc_curve25519_export_key_raw_ex (void) fflush( stdout ); wc_curve25519_free(&key); wc_FreeRng(&rng); - return 1; + return 1; } } else{ @@ -16309,7 +16309,6 @@ static int test_wc_curve25519_export_key_raw_ex (void) wc_curve25519_free(&key); wc_FreeRng(&rng); return 1; - } #endif @@ -16318,30 +16317,30 @@ static int test_wc_curve25519_export_key_raw_ex (void) /* * Testing wc_curve25519_make_key */ -static int test_wc_curve25519_make_key (void) +static int test_wc_curve25519_make_key (void) { int ret = 0; #if defined(HAVE_CURVE25519) WC_RNG rng; curve25519_key key; int keysize; - + printf(testingFmt, "wc_curve25519_make_key()"); - + ret = wc_curve25519_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); if (ret == 0) { - keysize = wc_curve25519_size(&key); + keysize = wc_curve25519_size(&key); if (keysize != CURVE25519_KEYSIZE) { ret = SSL_FATAL_ERROR; } - } + } if (ret == 0) { ret = wc_curve25519_make_key(&rng, keysize, &key); } @@ -16352,7 +16351,7 @@ static int test_wc_curve25519_make_key (void) if (ret == BAD_FUNC_ARG) { ret = 0; } - } + } if (ret == 0) { ret = wc_curve25519_make_key(&rng, keysize, NULL); if (ret == BAD_FUNC_ARG) { @@ -16363,7 +16362,7 @@ static int test_wc_curve25519_make_key (void) ret = wc_curve25519_make_key(NULL, keysize, &key); if (ret == BAD_FUNC_ARG) { ret = 0; - } + } } if (ret == 0) { ret = wc_curve25519_make_key(&rng, 0, &key); @@ -16375,7 +16374,7 @@ static int test_wc_curve25519_make_key (void) wc_curve25519_free(&key); wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve25519_make_key*/ /* * Testing wc_curve25519_shared_secret_ex @@ -16389,22 +16388,22 @@ static int test_wc_curve25519_shared_secret_ex (void) byte out[CURVE25519_KEYSIZE]; word32 outLen = sizeof(out); int endian = EC25519_BIG_ENDIAN; - + printf(testingFmt, "wc_curve25519_shared_secret_ex()"); - + ret = wc_curve25519_init(&private_key); if (ret == 0) { ret = wc_InitRng(&rng); if (ret == 0) { ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &private_key); } - } + } if (ret == 0) { ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &public_key); - + } - if (ret == 0) { + if (ret == 0) { ret = wc_curve25519_shared_secret_ex(&private_key, &public_key, out, &outLen, endian); } @@ -16416,16 +16415,16 @@ static int test_wc_curve25519_shared_secret_ex (void) ret = 0; } } - if (ret == 0) { + if (ret == 0) { ret = wc_curve25519_shared_secret_ex(NULL, &public_key, out, - &outLen, endian); + &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } } if (ret == 0) { ret = wc_curve25519_shared_secret_ex(&private_key, NULL, out, - &outLen, endian); + &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } @@ -16437,41 +16436,41 @@ static int test_wc_curve25519_shared_secret_ex (void) ret = 0; } } - if (ret == 0) { + if (ret == 0) { ret = wc_curve25519_shared_secret_ex(&private_key, &public_key, out, NULL, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } } - + if (ret == 0) { /*curve25519.c is checking for public_key size less than or equal to 0x7f, *increasing to 0x8f checks for error being returned*/ - public_key.p.point[CURVE25519_KEYSIZE-1] = 0x8F; + public_key.p.point[CURVE25519_KEYSIZE-1] = 0x8F; ret = wc_curve25519_shared_secret_ex(&private_key, &public_key, out, &outLen, endian); if (ret == ECC_BAD_ARG_E) { ret = 0; - } + } } - + outLen = outLen - 2; if (ret == 0) { ret = wc_curve25519_shared_secret_ex(&private_key, &public_key, out, - &outLen, endian); + &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } - } - + } + printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&private_key); wc_curve25519_free(&public_key); wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve25519_shared_secret_ex*/ /* * Testing test_wc_curve25519_export_public_ex @@ -16479,31 +16478,31 @@ static int test_wc_curve25519_shared_secret_ex (void) static int test_wc_curve25519_export_public_ex (void) { int ret = 0; -#if defined(HAVE_CURVE25519) - +#if defined(HAVE_CURVE25519) + WC_RNG rng; curve25519_key key; byte out[CURVE25519_KEYSIZE]; word32 outLen = sizeof(out); int endian = EC25519_BIG_ENDIAN; - + printf(testingFmt, "wc_curve25519_export_public_ex()"); - + ret = wc_curve25519_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); if (ret == 0) { ret = wc_curve25519_export_public(&key, out, &outLen); - } + } if (ret == 0) { ret = wc_curve25519_export_public_ex(&key, out, &outLen, endian); } } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve25519_export_public_ex(NULL, NULL, NULL, endian); if (ret == BAD_FUNC_ARG) { @@ -16511,13 +16510,13 @@ static int test_wc_curve25519_export_public_ex (void) } } if (ret == 0) { - ret = wc_curve25519_export_public_ex(NULL, out, &outLen, endian); + ret = wc_curve25519_export_public_ex(NULL, out, &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } } if (ret == 0) { - ret = wc_curve25519_export_public_ex(&key, NULL, &outLen, endian); + ret = wc_curve25519_export_public_ex(&key, NULL, &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } @@ -16540,7 +16539,7 @@ static int test_wc_curve25519_export_public_ex (void) wc_curve25519_free(&key); wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve25519_export_public_ex*/ /* @@ -16550,7 +16549,7 @@ static int test_wc_curve25519_import_private_raw_ex (void) { int ret = 0; #if defined(HAVE_CURVE25519) - WC_RNG rng; + WC_RNG rng; curve25519_key key; byte priv[CURVE25519_KEYSIZE]; byte pub[CURVE25519_KEYSIZE]; @@ -16560,26 +16559,26 @@ static int test_wc_curve25519_import_private_raw_ex (void) printf(testingFmt, "wc_curve25519_import_private_raw_ex()"); - + ret = wc_curve25519_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); if (ret == 0) { ret = wc_curve25519_export_private_raw_ex(&key, priv, &privSz, endian); } if (ret == 0) { ret = wc_curve25519_export_public(&key, pub, &pubSz); - } + } if (ret == 0) { ret = wc_curve25519_import_private_raw_ex(priv, privSz, pub, pubSz, &key, endian); } } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve25519_import_private_raw_ex(NULL, 0, NULL, 0, NULL, endian); @@ -16627,13 +16626,13 @@ static int test_wc_curve25519_import_private_raw_ex (void) &key, EC25519_LITTLE_ENDIAN); } - + printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&key); wc_FreeRng(&rng); - + #endif - return ret; + return ret; } /*END test_wc_curve25519_import_private_raw_ex*/ /* * Testing test_wc_curve25519_import_private @@ -16642,20 +16641,20 @@ static int test_wc_curve25519_import_private (void) { int ret = 0; #if defined(HAVE_CURVE25519) - + curve25519_key key; - WC_RNG rng; + WC_RNG rng; byte priv[CURVE25519_KEYSIZE]; word32 privSz = sizeof(priv); - + printf(testingFmt, "wc_curve25519_import_private()"); - + ret = wc_curve25519_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); if (ret == 0) { ret = wc_curve25519_export_private_raw(&key, priv, &privSz); @@ -16663,39 +16662,39 @@ static int test_wc_curve25519_import_private (void) } if (ret == 0) { ret = wc_curve25519_import_private(priv, privSz, &key); - } + } printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&key); - wc_FreeRng(&rng); + wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve25519_import*/ /* * Testing test_wc_curve25519_export_private_raw_ex */ -static int test_wc_curve25519_export_private_raw_ex (void) +static int test_wc_curve25519_export_private_raw_ex (void) { int ret = 0; -#if defined(HAVE_CURVE25519) - +#if defined(HAVE_CURVE25519) + WC_RNG rng; curve25519_key key; byte out[CURVE25519_KEYSIZE]; word32 outLen = sizeof(out); int endian = EC25519_BIG_ENDIAN; - + printf(testingFmt, "wc_curve25519_export_private_raw_ex()"); - + ret = wc_curve25519_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { ret = wc_curve25519_export_private_raw_ex(&key, out, &outLen, endian); } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve25519_export_private_raw_ex(NULL, NULL, NULL, endian); if (ret == BAD_FUNC_ARG) { @@ -16731,14 +16730,15 @@ static int test_wc_curve25519_export_private_raw_ex (void) ret = 0; } } - + printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&key); wc_FreeRng(&rng); #endif - return ret; + return ret; }/*END test_wc_curve25519_export_private_raw_ex*/ + /* * Testing wc_ed448_make_key(). */ @@ -17479,23 +17479,23 @@ static int test_wc_curve448_make_key (void) WC_RNG rng; curve448_key key; int keysize; - + printf(testingFmt, "wc_curve448_make_key()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); if (ret == 0) { - keysize = wc_curve448_size(&key); + keysize = wc_curve448_size(&key); if (keysize != CURVE448_KEY_SIZE) { ret = SSL_FATAL_ERROR; } - } + } if (ret == 0) { ret = wc_curve448_make_key(&rng, keysize, &key); } @@ -17506,7 +17506,7 @@ static int test_wc_curve448_make_key (void) if (ret == BAD_FUNC_ARG) { ret = 0; } - } + } if (ret == 0) { ret = wc_curve448_make_key(&rng, keysize, NULL); if (ret == BAD_FUNC_ARG) { @@ -17517,7 +17517,7 @@ static int test_wc_curve448_make_key (void) ret = wc_curve448_make_key(NULL, keysize, &key); if (ret == BAD_FUNC_ARG) { ret = 0; - } + } } if (ret == 0) { ret = wc_curve448_make_key(&rng, 0, &key); @@ -17525,7 +17525,7 @@ static int test_wc_curve448_make_key (void) ret = 0; } } - + if (wc_FreeRng(&rng) != 0 && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -17533,7 +17533,7 @@ static int test_wc_curve448_make_key (void) printf(resultFmt, ret == 0 ? passed : failed); wc_curve448_free(&key); #endif - return ret; + return ret; } /*END test_wc_curve448_make_key*/ /* * Testing test_wc_curve448_shared_secret_ex @@ -17541,21 +17541,21 @@ static int test_wc_curve448_make_key (void) static int test_wc_curve448_shared_secret_ex (void) { int ret = 0; -#if defined(HAVE_CURVE448) +#if defined(HAVE_CURVE448) WC_RNG rng; curve448_key private_key, public_key; byte out[CURVE448_KEY_SIZE]; word32 outLen = sizeof(out); int endian = EC448_BIG_ENDIAN; - + printf(testingFmt, "wc_curve448_shared_secret_ex()"); - + ret = wc_curve448_init(&private_key); if (ret == 0) { - ret = wc_InitRng(&rng); + ret = wc_InitRng(&rng); if (ret == 0) { ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &private_key); - } + } } if (ret == 0) { ret = wc_curve448_init(&public_key); @@ -17565,12 +17565,12 @@ static int test_wc_curve448_shared_secret_ex (void) ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &public_key); } } - + if (ret == 0) { ret = wc_curve448_shared_secret_ex(&private_key, &public_key, out, &outLen, endian); } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve448_shared_secret_ex(NULL, NULL, NULL, 0, endian); @@ -17578,16 +17578,16 @@ static int test_wc_curve448_shared_secret_ex (void) ret = 0; } } - if (ret == 0) { + if (ret == 0) { ret = wc_curve448_shared_secret_ex(NULL, &public_key, out, - &outLen, endian); + &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } } if (ret == 0) { ret = wc_curve448_shared_secret_ex(&private_key, NULL, out, - &outLen, endian); + &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } @@ -17620,39 +17620,39 @@ static int test_wc_curve448_shared_secret_ex (void) wc_curve448_free(&public_key); wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve448_shared_secret_ex*/ /* * Testing test_wc_curve448_export_public_ex */ -static int test_wc_curve448_export_public_ex (void) +static int test_wc_curve448_export_public_ex (void) { int ret = 0; -#if defined(HAVE_CURVE448) - +#if defined(HAVE_CURVE448) + WC_RNG rng; curve448_key key; byte out[CURVE448_KEY_SIZE]; word32 outLen = sizeof(out); int endian = EC448_BIG_ENDIAN; - + printf(testingFmt, "wc_curve448_export_public_ex()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); if (ret == 0){ ret = wc_curve448_export_public(&key, out, &outLen); - } + } if (ret == 0) { ret = wc_curve448_export_public_ex(&key, out, &outLen, endian); } } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve448_export_public_ex(NULL, NULL, NULL, endian); if (ret == BAD_FUNC_ARG) { @@ -17660,13 +17660,13 @@ static int test_wc_curve448_export_public_ex (void) } } if (ret == 0) { - ret = wc_curve448_export_public_ex(NULL, out, &outLen, endian); + ret = wc_curve448_export_public_ex(NULL, out, &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } } if (ret == 0) { - ret = wc_curve448_export_public_ex(&key, NULL, &outLen, endian); + ret = wc_curve448_export_public_ex(&key, NULL, &outLen, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } @@ -17689,34 +17689,34 @@ static int test_wc_curve448_export_public_ex (void) wc_curve448_free(&key); wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve448_export_public_ex*/ /* * Testing test_wc_curve448_export_private_raw_ex */ -static int test_wc_curve448_export_private_raw_ex (void) +static int test_wc_curve448_export_private_raw_ex (void) { int ret = 0; -#if defined(HAVE_CURVE448) - +#if defined(HAVE_CURVE448) + WC_RNG rng; curve448_key key; byte out[CURVE448_KEY_SIZE]; word32 outLen = sizeof(out); int endian = EC448_BIG_ENDIAN; - + printf(testingFmt, "wc_curve448_export_private_raw_ex()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { ret = wc_curve448_export_private_raw_ex(&key, out, &outLen, endian); } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve448_export_private_raw_ex(NULL, NULL, NULL, endian); if (ret == BAD_FUNC_ARG) { @@ -17752,12 +17752,12 @@ static int test_wc_curve448_export_private_raw_ex (void) ret = 0; } } - + printf(resultFmt, ret == 0 ? passed : failed); wc_curve448_free(&key); wc_FreeRng(&rng); #endif - return ret; + return ret; }/*END test_wc_curve448_export_private_raw_ex*/ /* @@ -17767,7 +17767,7 @@ static int test_wc_curve448_import_private_raw_ex (void) { int ret = 0; #if defined(HAVE_CURVE448) - WC_RNG rng; + WC_RNG rng; curve448_key key; byte priv[CURVE448_KEY_SIZE]; byte pub[CURVE448_KEY_SIZE]; @@ -17776,26 +17776,26 @@ static int test_wc_curve448_import_private_raw_ex (void) int endian = EC448_BIG_ENDIAN; printf(testingFmt, "wc_curve448_import_private_raw_ex()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); if (ret == 0){ ret = wc_curve448_export_private_raw(&key, priv, &privSz); } if (ret == 0){ ret = wc_curve448_export_public(&key, pub, &pubSz); - } + } if (ret == 0) { ret = wc_curve448_import_private_raw_ex(priv, privSz, pub, pubSz, &key, endian); } } - /*test bad cases*/ + /*test bad cases*/ if (ret == 0) { ret = wc_curve448_import_private_raw_ex(NULL, 0, NULL, 0, NULL, 0); if (ret == BAD_FUNC_ARG) { @@ -17842,16 +17842,16 @@ static int test_wc_curve448_import_private_raw_ex (void) &key, EC448_LITTLE_ENDIAN); } - + if (wc_FreeRng(&rng) != 0 && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } - + printf(resultFmt, ret == 0 ? passed : failed); wc_curve448_free(&key); - + #endif - return ret; + return ret; } /*END test_wc_curve448_import_private_raw_ex*/ /* * Testing test_curve448_export_key_raw @@ -17860,38 +17860,38 @@ static int test_wc_curve448_export_key_raw (void) { int ret = 0; #if defined(HAVE_CURVE448) - WC_RNG rng; + WC_RNG rng; curve448_key key; byte priv[CURVE448_KEY_SIZE]; byte pub[CURVE448_KEY_SIZE]; word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); - + printf(testingFmt, "wc_curve448_export_key_raw()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); if (ret == 0) { ret = wc_curve448_export_private_raw(&key, priv, &privSz); } if (ret == 0) { ret = wc_curve448_export_public(&key, pub, &pubSz); - } + } if (ret == 0) { ret = wc_curve448_export_key_raw(&key, priv, &privSz, pub, &pubSz); } } - + printf(resultFmt, ret == 0 ? passed : failed); wc_curve448_free(&key); - wc_FreeRng(&rng); + wc_FreeRng(&rng); #endif - return ret; + return ret; }/*END test_wc_curve448_import_private_raw_ex*/ @@ -17899,24 +17899,24 @@ static int test_wc_curve448_export_key_raw (void) /* * Testing test_wc_curve448_import_private */ -static int test_wc_curve448_import_private (void) +static int test_wc_curve448_import_private (void) { int ret = 0; #if defined(HAVE_CURVE448) - + curve448_key key; - WC_RNG rng; + WC_RNG rng; byte priv[CURVE448_KEY_SIZE]; word32 privSz = sizeof(priv); - + printf(testingFmt, "wc_curve448_import_private()"); - + ret = wc_curve448_init(&key); if (ret == 0) { - ret = wc_InitRng(&rng); - } + ret = wc_InitRng(&rng); + } if (ret == 0) { - + ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); if (ret == 0) { ret = wc_curve448_export_private_raw(&key, priv, &privSz); @@ -17924,12 +17924,12 @@ static int test_wc_curve448_import_private (void) } if (ret == 0) { ret = wc_curve448_import_private(priv, privSz, &key); - } + } printf(resultFmt, ret == 0 ? passed : failed); wc_curve448_free(&key); - wc_FreeRng(&rng); + wc_FreeRng(&rng); #endif - return ret; + return ret; } /*END test_wc_curve448_import*/ /* @@ -18926,21 +18926,21 @@ static int test_wc_ecc_import_unsigned(void) (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) ecc_key key; const byte qx[] = { - 0xbb, 0x33, 0xac, 0x4c, 0x27, 0x50, 0x4a, 0xc6, - 0x4a, 0xa5, 0x04, 0xc3, 0x3c, 0xde, 0x9f, 0x36, - 0xdb, 0x72, 0x2d, 0xce, 0x94, 0xea, 0x2b, 0xfa, + 0xbb, 0x33, 0xac, 0x4c, 0x27, 0x50, 0x4a, 0xc6, + 0x4a, 0xa5, 0x04, 0xc3, 0x3c, 0xde, 0x9f, 0x36, + 0xdb, 0x72, 0x2d, 0xce, 0x94, 0xea, 0x2b, 0xfa, 0xcb, 0x20, 0x09, 0x39, 0x2c, 0x16, 0xe8, 0x61 }; const byte qy[] = { - 0x02, 0xe9, 0xaf, 0x4d, 0xd3, 0x02, 0x93, 0x9a, - 0x31, 0x5b, 0x97, 0x92, 0x21, 0x7f, 0xf0, 0xcf, - 0x18, 0xda, 0x91, 0x11, 0x02, 0x34, 0x86, 0xe8, + 0x02, 0xe9, 0xaf, 0x4d, 0xd3, 0x02, 0x93, 0x9a, + 0x31, 0x5b, 0x97, 0x92, 0x21, 0x7f, 0xf0, 0xcf, + 0x18, 0xda, 0x91, 0x11, 0x02, 0x34, 0x86, 0xe8, 0x20, 0x58, 0x33, 0x0b, 0x80, 0x34, 0x89, 0xd8 }; const byte d[] = { - 0x45, 0xb6, 0x69, 0x02, 0x73, 0x9c, 0x6c, 0x85, + 0x45, 0xb6, 0x69, 0x02, 0x73, 0x9c, 0x6c, 0x85, 0xa1, 0x38, 0x5b, 0x72, 0xe8, 0xe8, 0xc7, 0xac, - 0xc4, 0x03, 0x8d, 0x53, 0x35, 0x04, 0xfa, 0x6c, + 0xc4, 0x03, 0x8d, 0x53, 0x35, 0x04, 0xfa, 0x6c, 0x28, 0xdc, 0x34, 0x8d, 0xe1, 0xa8, 0x09, 0x8c }; #ifdef WOLFSSL_VALIDATE_ECC_IMPORT @@ -18949,32 +18949,32 @@ static int test_wc_ecc_import_unsigned(void) int curveId = ECC_SECP256R1; ret = wc_ecc_init(&key); - + printf(testingFmt, "wc_ecc_import_unsigned()"); if (ret == 0) { - ret = wc_ecc_import_unsigned(&key, (byte*)qx, (byte*)qy, (byte*)d, + ret = wc_ecc_import_unsigned(&key, (byte*)qx, (byte*)qy, (byte*)d, curveId); } /* Test bad args. */ if (ret == 0) { - ret = wc_ecc_import_unsigned(NULL, (byte*)qx, (byte*)qy, (byte*)d, + ret = wc_ecc_import_unsigned(NULL, (byte*)qx, (byte*)qy, (byte*)d, curveId); if (ret == BAD_FUNC_ARG) { - ret = wc_ecc_import_unsigned(&key, NULL, (byte*)qy, (byte*)d, + ret = wc_ecc_import_unsigned(&key, NULL, (byte*)qy, (byte*)d, curveId); } if (ret == BAD_FUNC_ARG) { - ret = wc_ecc_import_unsigned(&key, (byte*)qx, NULL, (byte*)d, + ret = wc_ecc_import_unsigned(&key, (byte*)qx, NULL, (byte*)d, curveId); } if (ret == BAD_FUNC_ARG) { - ret = wc_ecc_import_unsigned(&key, (byte*)qx, (byte*)qy, (byte*)d, + ret = wc_ecc_import_unsigned(&key, (byte*)qx, (byte*)qy, (byte*)d, ECC_CURVE_INVALID); } #ifdef WOLFSSL_VALIDATE_ECC_IMPORT if (ret == BAD_FUNC_ARG) { - ret = wc_ecc_import_unsigned(&key, (byte*)nullBytes, + ret = wc_ecc_import_unsigned(&key, (byte*)nullBytes, (byte*)nullBytes, (byte*)nullBytes, curveId); } #endif @@ -25048,7 +25048,7 @@ static void test_wolfSSL_either_side(void) test_client_nofail(&client_args, NULL); join_thread(serverThread); #endif - + wolfSSL_CTX_free(client_cb.ctx); FreeTcpReady(&ready); @@ -34478,7 +34478,7 @@ void ApiTest(void) AssertFalse(test_wc_Sha256GetFlags()); AssertFalse(test_wc_Sha256Free()); AssertFalse(test_wc_Sha256GetHash()); - AssertFalse(test_wc_Sha256Copy()); + AssertFalse(test_wc_Sha256Copy()); AssertFalse(test_wc_InitSha512()); AssertFalse(test_wc_Sha512Update()); AssertFalse(test_wc_Sha512Final()); @@ -34491,7 +34491,7 @@ void ApiTest(void) AssertFalse(test_wc_Sha224SetFlags()); AssertFalse(test_wc_Sha224GetFlags()); AssertFalse(test_wc_Sha224Free()); - AssertFalse(test_wc_Sha224GetHash()); + AssertFalse(test_wc_Sha224GetHash()); AssertFalse(test_wc_Sha224Copy()); AssertFalse(test_wc_InitBlake2b()); AssertFalse(test_wc_InitRipeMd());