diff --git a/tests/api.c b/tests/api.c index f22b91fed..ccf40e40b 100644 --- a/tests/api.c +++ b/tests/api.c @@ -395,13 +395,24 @@ typedef struct testVector { | Constants *----------------------------------------------------------------------------*/ -#define TEST_SUCCESS (1) -#define TEST_FAIL (0) +/* Test result constants and macros. */ + +/* Test succeeded. */ +#define TEST_SUCCESS (1) +/* Test failed. */ +#define TEST_FAIL (0) +/* Test skipped - not run. */ +#define TEST_SKIPPED (-1) + +/* Returns the result based on whether check is true. + * + * @param [in] check Condition for success. + * @return When condition is true: TEST_SUCCESS. + * @return When condition is false: TEST_FAIL. + */ +#define TEST_RES_CHECK(check) \ + ((check) ? TEST_SUCCESS : TEST_FAIL) -#define testingFmt " %s:" -#define resultFmt " %s\n" -static const char* passed = "passed"; -static const char* failed = "failed"; #define TEST_STRING "Everyone gets Friday off." #define TEST_STRING_SZ 25 @@ -445,13 +456,9 @@ static int test_wolfSSL_Init(void) { int result; - printf(testingFmt, "wolfSSL_Init()"); result = wolfSSL_Init(); - printf(resultFmt, result == WOLFSSL_SUCCESS ? passed : failed); - if (result == WOLFSSL_SUCCESS) { - result = 0; - } + result = TEST_RES_CHECK(result == WOLFSSL_SUCCESS); return result; } @@ -460,13 +467,9 @@ static int test_wolfSSL_Cleanup(void) { int result; - printf(testingFmt, "wolfSSL_Cleanup()"); result = wolfSSL_Cleanup(); - printf(resultFmt, result == WOLFSSL_SUCCESS ? passed : failed); - if (result == WOLFSSL_SUCCESS) { - result = 0; - } + result = TEST_RES_CHECK(result == WOLFSSL_SUCCESS); return result; } @@ -478,10 +481,9 @@ static int test_wolfCrypt_Init(void) { int result; - printf(testingFmt, "wolfCrypt_Init()"); result = wolfCrypt_Init(); - printf(resultFmt, result == 0 ? passed : failed); + result = TEST_RES_CHECK(result == 0); return result; } /* END test_wolfCrypt_Init */ @@ -490,19 +492,18 @@ static int test_wolfCrypt_Cleanup(void) { int result; - printf(testingFmt, "wolfCrypt_Cleanup()"); result = wolfCrypt_Cleanup(); - printf(resultFmt, result == 0 ? passed : failed); + result = TEST_RES_CHECK(result == 0); return result; - } /*----------------------------------------------------------------------------* | Platform dependent function test *----------------------------------------------------------------------------*/ - static int test_fileAccess(void) +static int test_fileAccess(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_TEST_PLATFORMDEPEND) && !defined(NO_FILESYSTEM) const char *fname[] = { svrCertFile, svrKeyFile, caCertFile, @@ -519,10 +520,8 @@ static int test_wolfCrypt_Cleanup(void) byte *buff; int i; - printf(testingFmt, "test_fileAccess()"); - AssertTrue(XFOPEN("badfilename", "rb") == XBADFILE); - for(i=0; fname[i] != NULL ; i++){ + for (i=0; fname[i] != NULL ; i++) { AssertTrue((f = XFOPEN(fname[i], "rb")) != XBADFILE); XFCLOSE(f); } @@ -535,10 +534,10 @@ static int test_wolfCrypt_Cleanup(void) AssertTrue((buff = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE)) != NULL) ; AssertTrue(XFREAD(buff, 1, sz, f) == sz); XMEMCMP(server_cert_der_2048, buff, sz); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /*----------------------------------------------------------------------------* @@ -665,7 +664,7 @@ static int test_wolfSSL_Method_Allocators(void) #endif /* WOLFSSL_DTLS */ #endif /* OPENSSL_EXTRA || WOLFSSL_EITHER_SIDE */ - return 0; + return TEST_SUCCESS; } @@ -684,7 +683,7 @@ static int test_wolfSSL_CTX_new(void) wolfSSL_CTX_free(ctx); - return 0; + return TEST_RES_CHECK(1); } #endif @@ -833,13 +832,14 @@ static int test_for_double_Free(void) wolfSSL_free(ssl); } - return 0; + return TEST_RES_CHECK(1); } #endif static int test_wolfSSL_CTX_set_cipher_list_bytes(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(WOLFSSL_SET_CIPHER_BYTES)) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) && \ (!defined(NO_RSA) || defined(HAVE_ECC)) @@ -1033,15 +1033,17 @@ static int test_wolfSSL_CTX_set_cipher_list_bytes(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + res = TEST_RES_CHECK(1); #endif /* (OPENSSL_EXTRA || WOLFSSL_SET_CIPHER_BYTES) && (!NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER) && (!NO_RSA || HAVE_ECC) */ - return 0; + return res; } static int test_wolfSSL_CTX_use_certificate_file(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx; @@ -1065,34 +1067,31 @@ static int test_wolfSSL_CTX_use_certificate_file(void) #endif wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if (defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO)) && !defined(NO_RSA) static int test_wolfSSL_CTX_use_certificate_ASN1(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_WOLFSSL_SERVER) && !defined(NO_ASN) WOLFSSL_CTX* ctx; int ret; - printf(testingFmt, "wolfSSL_CTX_use_certificate_ASN1()"); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); ret = SSL_CTX_use_certificate_ASN1(ctx, sizeof_server_cert_der_2048, server_cert_der_2048); - printf(resultFmt, ret == WOLFSSL_SUCCESS ? passed : failed); wolfSSL_CTX_free(ctx); - if (ret == WOLFSSL_SUCCESS) { - ret = 0; - } - return ret; -#else - return 0; + res = TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); #endif + return res; } #endif /* (OPENSSL_ALL || WOLFSSL_ASIO) && !NO_RSA */ @@ -1103,32 +1102,28 @@ static int test_wolfSSL_CTX_use_certificate_ASN1(void) */ static int test_wolfSSL_CTX_use_certificate_buffer(void) { - #if !defined(NO_CERTS) && defined(USE_CERT_BUFFERS_2048) && \ - !defined(NO_RSA) && !defined(NO_WOLFSSL_SERVER) - WOLFSSL_CTX* ctx; - int ret; + int res = TEST_SKIPPED; +#if !defined(NO_CERTS) && defined(USE_CERT_BUFFERS_2048) && \ + !defined(NO_RSA) && !defined(NO_WOLFSSL_SERVER) + WOLFSSL_CTX* ctx; + int ret; - printf(testingFmt, "wolfSSL_CTX_use_certificate_buffer()"); - AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); + AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); - ret = wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, - sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1); + ret = wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, + sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1); - printf(resultFmt, ret == WOLFSSL_SUCCESS ? passed : failed); - wolfSSL_CTX_free(ctx); + wolfSSL_CTX_free(ctx); - if (ret == WOLFSSL_SUCCESS) { - ret = 0; - } - return ret; - #else - return 0; - #endif + res = TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); +#endif + return res; } /*END test_wolfSSL_CTX_use_certificate_buffer*/ static int test_wolfSSL_CTX_use_PrivateKey_file(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx; @@ -1153,15 +1148,18 @@ static int test_wolfSSL_CTX_use_PrivateKey_file(void) #endif wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } /* test both file and buffer versions along with unloading trusted peer certs */ static int test_wolfSSL_CTX_trust_peer_cert(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && defined(WOLFSSL_TRUST_PEER_CERT) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_RSA) WOLFSSL_CTX *ctx; @@ -1228,14 +1226,17 @@ static int test_wolfSSL_CTX_trust_peer_cert(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_load_verify_locations(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx; #ifndef NO_RSA @@ -1340,19 +1341,21 @@ static int test_wolfSSL_CTX_load_verify_locations(void) #endif wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_load_system_CA_certs(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SYS_CA_CERTS) && !defined(NO_WOLFSSL_CLIENT) && \ (!defined(NO_RSA) || defined(HAVE_ECC)) WOLFSSL_CTX* ctx; byte dirValid = 0; + int ret = 0; ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); if (ctx == NULL) { @@ -1404,9 +1407,11 @@ static int test_wolfSSL_CTX_load_system_CA_certs(void) #endif /* OPENSSL_EXTRA */ wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(ret == 0); #endif /* WOLFSSL_SYS_CA_CERTS && !NO_WOLFSSL_CLIENT */ - return ret; + return res; } #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) @@ -1417,7 +1422,7 @@ static int test_cm_load_ca_buffer(const byte* cert_buf, size_t cert_sz, int file cm = wolfSSL_CertManagerNew(); if (cm == NULL) { - printf("test_cm_load_ca failed\n"); + fprintf(stderr, "test_cm_load_ca failed\n"); return -1; } @@ -1479,6 +1484,7 @@ static int test_cm_load_ca_file(const char* ca_cert_file) static int test_wolfSSL_CertManagerCheckOCSPResponse(void) { + int res = TEST_SKIPPED; #if defined(HAVE_OCSP) && !defined(NO_RSA) /* Need one of these for wolfSSL_OCSP_REQUEST_new. */ #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \ @@ -1626,7 +1632,6 @@ static int test_wolfSSL_CertManagerCheckOCSPResponse(void) byte issuerHash[] = {0x71, 0x4d, 0x82, 0x23, 0x40, 0x59, 0xc0, 0x96, 0xa1, 0x37, 0x43, 0xfa, 0x31, 0xdb, 0xba, 0xb1, 0x43, 0x18, 0xda, 0x04}; byte issuerKeyHash[] = {0x83, 0xc6, 0x3a, 0x89, 0x2c, 0x81, 0xf4, 0x02, 0xd7, 0x9d, 0x4c, 0xe2, 0x2a, 0xc0, 0x71, 0x82, 0x64, 0x44, 0xda, 0x0e}; - printf(testingFmt, "wolfSSL_CertManagerCheckOCSPResponse()"); XMEMSET(entry, 0, sizeof(OcspEntry)); XMEMSET(status, 0, sizeof(CertStatus)); @@ -1660,16 +1665,16 @@ static int test_wolfSSL_CertManagerCheckOCSPResponse(void) wolfSSL_OCSP_REQUEST_free(request); wolfSSL_CertManagerFree(cm); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY || * WOLFSSL_APACHE_HTTPD || HAVE_LIGHTY */ #endif /* HAVE_OCSP */ - - return 0; + return res; } static int test_wolfSSL_CheckOCSPResponse(void) { + int result = TEST_SKIPPED; #if defined(HAVE_OCSP) && !defined(NO_RSA) && defined(OPENSSL_ALL) const char* responseFile = "./certs/ocsp/test-response.der"; const char* responseMultiFile = "./certs/ocsp/test-multi-response.der"; @@ -1685,8 +1690,6 @@ static int test_wolfSSL_CheckOCSPResponse(void) WOLFSSL_X509* issuer; - printf(testingFmt, "wolfSSL_CheckOCSPResponse()"); - f = XFOPEN(responseFile, "rb"); AssertTrue(f != XBADFILE); dataSz = (word32)XFREAD(data, 1, sizeof(data), f); @@ -1835,18 +1838,18 @@ static int test_wolfSSL_CheckOCSPResponse(void) } #endif - printf(resultFmt, passed); + result = TEST_RES_CHECK(1); #endif /* HAVE_OCSP */ - return 0; + return result; } static int test_wolfSSL_CertManagerLoadCABuffer(void) { - int ret; - + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) const char* ca_cert = "./certs/ca-cert.pem"; const char* ca_expired_cert = "./certs/test/expired/expired-ca.pem"; + int ret; ret = test_cm_load_ca_file(ca_cert); #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) @@ -1860,28 +1863,26 @@ static int test_wolfSSL_CertManagerLoadCABuffer(void) ret = test_cm_load_ca_file(ca_expired_cert); #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) AssertIntEQ(ret, WOLFSSL_FATAL_ERROR); - if (ret == WOLFSSL_FATAL_ERROR) + res = TEST_RES_CHECK(ret == WOLFSSL_FATAL_ERROR); #elif defined(NO_RSA) AssertIntEQ(ret, ASN_UNKNOWN_OID_E); - if (ret == ASN_UNKNOWN_OID_E) + res = TEST_RES_CHECK(ret == ASN_UNKNOWN_OID_E); #elif !(WOLFSSL_LOAD_VERIFY_DEFAULT_FLAGS & WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY) && \ !defined(OPENSSL_COMPATIBLE_DEFAULTS) AssertIntEQ(ret, ASN_AFTER_DATE_E); - if (ret == ASN_AFTER_DATE_E) + res = TEST_RES_CHECK(ret == ASN_AFTER_DATE_E); #else AssertIntEQ(ret, WOLFSSL_SUCCESS); - if (ret == WOLFSSL_SUCCESS) + res = TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); #endif #endif - { - ret = 0; - } - return ret; + return res; } static int test_wolfSSL_CertManagerGetCerts(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \ defined(WOLFSSL_SIGNER_DER_CERT) @@ -1899,7 +1900,6 @@ static int test_wolfSSL_CertManagerGetCerts(void) const byte* der; int derSz = 0; - printf(testingFmt, "wolfSSL_CertManagerGetCerts()"); AssertNotNull(file1=fopen("./certs/ca-cert.pem", "rb")); AssertNotNull(cert1 = wolfSSL_PEM_read_X509(file1, NULL, NULL, NULL)); @@ -1930,7 +1930,7 @@ static int test_wolfSSL_CertManagerGetCerts(void) #ifdef DEBUG_WOLFSSL_VERBOSE bio = BIO_new(wolfSSL_BIO_s_file()); if (bio != NULL) { - BIO_set_fp(bio, stdout, BIO_NOCLOSE); + BIO_set_fp(bio, stderr, BIO_NOCLOSE); X509_print(bio, x509); BIO_free(bio); } @@ -1939,16 +1939,18 @@ static int test_wolfSSL_CertManagerGetCerts(void) wolfSSL_X509_free(cert1); sk_X509_pop_free(sk, NULL); wolfSSL_CertManagerFree(cm); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \ defined(WOLFSSL_SIGNER_DER_CERT) */ - return 0; + return res; } static int test_wolfSSL_CertManagerSetVerify(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(WOLFSSL_NO_CLIENT_AUTH)) @@ -1988,9 +1990,11 @@ static int test_wolfSSL_CertManagerSetVerify(void) wolfSSL_CertManagerFree(cm); myVerifyAction = tmp; + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ @@ -2021,6 +2025,7 @@ void DEBUG_WRITE_DER(const byte* der, int derSz, const char* fileName) static int test_wolfSSL_CertManagerNameConstraint(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && \ @@ -2163,14 +2168,17 @@ static int test_wolfSSL_CertManagerNameConstraint(void) wolfSSL_X509_free(x509); wolfSSL_X509_free(ca); wolfSSL_EVP_PKEY_free(priv); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertManagerNameConstraint2(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && \ @@ -2355,13 +2363,16 @@ static int test_wolfSSL_CertManagerNameConstraint2(void) wolfSSL_X509_free(x509); wolfSSL_X509_free(ca); wolfSSL_EVP_PKEY_free(priv); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertManagerNameConstraint3(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && \ @@ -2472,13 +2483,16 @@ static int test_wolfSSL_CertManagerNameConstraint3(void) wolfSSL_X509_free(x509); wolfSSL_X509_free(ca); wolfSSL_EVP_PKEY_free(priv); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertManagerNameConstraint4(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && \ @@ -2630,13 +2644,16 @@ static int test_wolfSSL_CertManagerNameConstraint4(void) wolfSSL_X509_free(x509); wolfSSL_X509_free(ca); wolfSSL_EVP_PKEY_free(priv); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertManagerNameConstraint5(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CM_VERIFY) && !defined(NO_RSA) && \ defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && \ @@ -2784,13 +2801,16 @@ static int test_wolfSSL_CertManagerNameConstraint5(void) wolfSSL_CertManagerFree(cm); wolfSSL_X509_free(ca); wolfSSL_EVP_PKEY_free(priv); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_FPKI(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_FPKI) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) XFILE f; const char* fpkiCert = "./certs/fpki-cert.der"; @@ -2802,7 +2822,6 @@ static int test_wolfSSL_FPKI(void) word32 uuidSz; int bytes; - printf(testingFmt, "test_wolfSSL_FPKI"); f = XFOPEN(fpkiCert, "rb"); AssertTrue((f != XBADFILE)); bytes = (int)XFREAD(buf, 1, sizeof(buf), f); @@ -2823,14 +2842,15 @@ static int test_wolfSSL_FPKI(void) XFREE(uuid, NULL, DYNAMIC_TYPE_TMP_BUFFER); wc_FreeDecodedCert(&cert); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertRsaPss(void) { + int res = TEST_SKIPPED; /* FIPS v2 and below don't support long salts. */ #if !defined(NO_RSA) && defined(WC_RSA_PSS) && !defined(NO_FILESYSTEM) && \ (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && \ @@ -2848,8 +2868,6 @@ static int test_wolfSSL_CertRsaPss(void) int bytes; WOLFSSL_CERT_MANAGER* cm; - printf(testingFmt, "test_CertRsaPss"); - cm = wolfSSL_CertManagerNew(); AssertNotNull(cm); AssertIntEQ(WOLFSSL_SUCCESS, @@ -2880,14 +2898,15 @@ static int test_wolfSSL_CertRsaPss(void) wolfSSL_CertManagerFree(cm); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CertManagerCRL(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && defined(HAVE_CRL) && \ !defined(NO_RSA) @@ -2912,13 +2931,15 @@ static int test_wolfSSL_CertManagerCRL(void) wolfSSL_CertManagerLoadCA(cm, ca_cert, NULL)); wolfSSL_CertManagerFree(cm); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_load_verify_locations_ex(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx; @@ -2945,13 +2966,15 @@ static int test_wolfSSL_CTX_load_verify_locations_ex(void) wolfSSL_CTX_free(ctx); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_load_verify_buffer_ex(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ defined(USE_CERT_BUFFERS_2048) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -3001,13 +3024,16 @@ static int test_wolfSSL_CTX_load_verify_buffer_ex(void) wolfSSL_CTX_free(ctx); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_load_verify_chain_buffer_format(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(USE_CERT_BUFFERS_2048) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) @@ -3019,19 +3045,21 @@ static int test_wolfSSL_CTX_load_verify_chain_buffer_format(void) AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #endif - AssertTrue(WOLFSSL_SUCCESS == - wolfSSL_CTX_load_verify_chain_buffer_format(ctx, ca_cert_chain_der, - sizeof_ca_cert_chain_der, - WOLFSSL_FILETYPE_ASN1)); + AssertTrue(WOLFSSL_SUCCESS == wolfSSL_CTX_load_verify_chain_buffer_format( + ctx, ca_cert_chain_der, sizeof_ca_cert_chain_der, + WOLFSSL_FILETYPE_ASN1)); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_add1_chain_cert(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && defined(OPENSSL_EXTRA) && \ defined(KEEP_OUR_CERT) && !defined(NO_RSA) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx; @@ -3070,19 +3098,21 @@ static int test_wolfSSL_CTX_add1_chain_cert(void) SSL_free(ssl); SSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_CTX_use_certificate_chain_file_format(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) const char* server_chain_der = "./certs/server-cert-chain.der"; const char* client_single_pem = "./certs/client-cert.pem"; WOLFSSL_CTX* ctx; + int ret = 0; (void)server_chain_der; (void)client_single_pem; @@ -3101,12 +3131,15 @@ static int test_wolfSSL_CTX_use_certificate_chain_file_format(void) client_single_pem, WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } static int test_wolfSSL_CTX_SetTmpDH_file(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_DH) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX *ctx; @@ -3133,13 +3166,15 @@ static int test_wolfSSL_CTX_SetTmpDH_file(void) WOLFSSL_FILETYPE_PEM)); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_CTX_SetTmpDH_buffer(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_DH) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX *ctx; @@ -3166,13 +3201,15 @@ static int test_wolfSSL_CTX_SetTmpDH_buffer(void) sizeof_dh_key_der_2048, WOLFSSL_FILETYPE_ASN1)); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_CTX_SetMinMaxDhKey_Sz(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_DH) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX *ctx; @@ -3206,13 +3243,15 @@ static int test_wolfSSL_CTX_SetMinMaxDhKey_Sz(void) sizeof_dh_key_der_2048, WOLFSSL_FILETYPE_ASN1)); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_CTX_der_load_verify_locations(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_DER_LOAD) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER)) WOLFSSL_CTX* ctx = NULL; @@ -3250,13 +3289,16 @@ static int test_wolfSSL_CTX_der_load_verify_locations(void) #endif wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_enable_disable(void) { + int res = TEST_SKIPPED; #ifndef NO_CERTS WOLFSSL_CTX* ctx = NULL; @@ -3293,7 +3335,7 @@ static int test_wolfSSL_CTX_enable_disable(void) #elif !defined(NO_WOLFSSL_SERVER) AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #else - return 0; + return TEST_SUCCESS; #endif #ifdef HAVE_CRL @@ -3319,13 +3361,16 @@ static int test_wolfSSL_CTX_enable_disable(void) AssertIntEQ(wolfSSL_CTX_DisableOCSPMustStaple(ctx), WOLFSSL_SUCCESS); #endif wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* NO_CERTS */ - return 0; + return res; } static int test_wolfSSL_CTX_ticket_API(void) { + int res = TEST_SKIPPED; #if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX* ctx = NULL; void *userCtx = (void*)"this is my ctx"; @@ -3339,20 +3384,21 @@ static int test_wolfSSL_CTX_ticket_API(void) AssertIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_set_TicketEncCtx(NULL, userCtx)); AssertNull(wolfSSL_CTX_get_TicketEncCtx(NULL)); -#endif /* HAVE_SESSION_TICKET && !NO_WOLFSSL_SERVER */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_SESSION_TICKET && !NO_WOLFSSL_SERVER */ + return res; } static int test_wolfSSL_set_minmax_proto_version(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA WOLFSSL_CTX *ctx; WOLFSSL *ssl; int ret; (void)ret; (void)ssl; - printf(testingFmt, "test_wolfSSL_set_minmax_proto_version"); #ifndef NO_WOLFSSL_CLIENT AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); @@ -3382,10 +3428,10 @@ static int test_wolfSSL_set_minmax_proto_version(void) wolfSSL_CTX_free(ctx); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } /*----------------------------------------------------------------------------* @@ -3394,6 +3440,7 @@ static int test_wolfSSL_set_minmax_proto_version(void) static int test_server_wolfSSL_new(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx; @@ -3418,14 +3465,17 @@ static int test_server_wolfSSL_new(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx_nocert); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_client_wolfSSL_new(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx; @@ -3450,13 +3500,16 @@ static int test_client_wolfSSL_new(void) wolfSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx_nocert); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_SetTmpDH_file(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_DH) && \ !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx; @@ -3502,13 +3555,16 @@ static int test_wolfSSL_SetTmpDH_file(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_SetTmpDH_buffer(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_DH) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx; WOLFSSL *ssl; @@ -3536,13 +3592,16 @@ static int test_wolfSSL_SetTmpDH_buffer(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_SetMinMaxDhKey_Sz(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_DH) && !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX *ctx, *ctx2; WOLFSSL *ssl, *ssl2; @@ -3591,9 +3650,10 @@ static int test_wolfSSL_SetMinMaxDhKey_Sz(void) wolfSSL_CTX_free(ctx2); wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } @@ -3603,8 +3663,9 @@ static int test_wolfSSL_SetMinMaxDhKey_Sz(void) */ static int test_wolfSSL_SetMinVersion(void) { - int failFlag = WOLFSSL_SUCCESS; + int res = TEST_SKIPPED; #ifndef NO_WOLFSSL_CLIENT + int failFlag = WOLFSSL_SUCCESS; WOLFSSL_CTX* ctx; WOLFSSL* ssl; int itr; @@ -3625,23 +3686,18 @@ static int test_wolfSSL_SetMinVersion(void) ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); ssl = wolfSSL_new(ctx); - printf(testingFmt, "wolfSSL_SetMinVersion()"); - - for (itr = 0; itr < (int)(sizeof(versions)/sizeof(int)); itr++){ - if(wolfSSL_SetMinVersion(ssl, *(versions + itr)) != WOLFSSL_SUCCESS){ + for (itr = 0; itr < (int)(sizeof(versions)/sizeof(int)); itr++) { + if (wolfSSL_SetMinVersion(ssl, *(versions + itr)) != WOLFSSL_SUCCESS) { failFlag = WOLFSSL_FAILURE; } } - printf(resultFmt, failFlag == WOLFSSL_SUCCESS ? passed : failed); - wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(failFlag == WOLFSSL_SUCCESS); #endif - if (failFlag == WOLFSSL_SUCCESS) { - failFlag = 0; - } - return failFlag; + return res; } /* END test_wolfSSL_SetMinVersion */ @@ -3656,6 +3712,7 @@ static int test_wolfSSL_SetMinVersion(void) #ifdef OPENSSL_EXTRA static int test_wolfSSL_EC(void) { + int res = TEST_SKIPPED; #if !defined(WOLFSSL_SP_MATH) && \ (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))) @@ -3781,24 +3838,24 @@ static int test_wolfSSL_EC(void) hexStr = BN_bn2hex(k); AssertStrEQ(hexStr, kTest); #ifndef NO_FILESYSTEM - BN_print_fp(stdout, k); - printf("\n"); + BN_print_fp(stderr, k); + fprintf(stderr, "\n"); #endif XFREE(hexStr, NULL, DYNAMIC_TYPE_ECC); hexStr = BN_bn2hex(Gx); AssertStrEQ(hexStr, kGx); #ifndef NO_FILESYSTEM - BN_print_fp(stdout, Gx); - printf("\n"); + BN_print_fp(stderr, Gx); + fprintf(stderr, "\n"); #endif XFREE(hexStr, NULL, DYNAMIC_TYPE_ECC); hexStr = BN_bn2hex(Gy); AssertStrEQ(hexStr, kGy); #ifndef NO_FILESYSTEM - BN_print_fp(stdout, Gy); - printf("\n"); + BN_print_fp(stderr, Gy); + fprintf(stderr, "\n"); #endif XFREE(hexStr, NULL, DYNAMIC_TYPE_ECC); @@ -3860,16 +3917,18 @@ static int test_wolfSSL_EC(void) EC_GROUP_free(group); EC_GROUP_free(group2); BN_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ #endif /* OPENSSL_EXTRA && !WOLFSSL_SP_MATH && ( !HAVE_FIPS || HAVE_FIPS_VERSION > 2) */ - - return 0; + return res; } #endif /* OPENSSL_EXTRA */ #ifndef NO_BIO static int test_wolfSSL_PEM_read_bio_ECPKParameters(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) EC_GROUP *group; BIO* bio; @@ -3880,15 +3939,17 @@ static int test_wolfSSL_PEM_read_bio_ECPKParameters(void) AssertIntEQ(EC_GROUP_get_curve_name(group), NID_X9_62_prime256v1); EC_GROUP_free(group); BIO_free(bio); -#endif /* HAVE_ECC */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ECC */ + return res; } #endif /* !NO_BIO */ # if defined(OPENSSL_EXTRA) static int test_wolfSSL_ECDSA_SIG(void) { + int res = TEST_SKIPPED; #ifdef HAVE_ECC WOLFSSL_ECDSA_SIG* sig = NULL; WOLFSSL_ECDSA_SIG* sig2 = NULL; @@ -3917,13 +3978,15 @@ static int test_wolfSSL_ECDSA_SIG(void) AssertIntEQ(XMEMCMP(sigData, outSig, 8), 0); wolfSSL_ECDSA_SIG_free(sig); -#endif /* HAVE_ECC */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ECC */ + return res; } static int test_EC_i2d(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(HAVE_FIPS) EC_KEY *key; EC_KEY *copy; @@ -3956,13 +4019,15 @@ static int test_EC_i2d(void) EC_KEY_free(key); EC_KEY_free(copy); -#endif /* HAVE_ECC */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ECC */ + return res; } static int test_ECDSA_size_sign(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ECC256) && !defined(NO_ECC_SECP) EC_KEY *key; int id; @@ -3983,13 +4048,14 @@ static int test_ECDSA_size_sign(void) EC_KEY_free(key); + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC && !NO_ECC256 && !NO_ECC_SECP */ - - return 0; + return res; } static int test_ED25519(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \ defined(WOLFSSL_KEY_GEN) byte priv[ED25519_PRV_KEY_SIZE]; @@ -4018,13 +4084,15 @@ static int test_ED25519(void) sigSz), WOLFSSL_SUCCESS); #endif /* HAVE_ED25519_VERIFY */ #endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_IMPORT */ -#endif /* HAVE_ED25519 && HAVE_ED25519_KEY_EXPORT && WOLFSSL_KEY_GEN */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ED25519 && HAVE_ED25519_KEY_EXPORT && WOLFSSL_KEY_GEN */ + return res; } static int test_ED448(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) && \ defined(WOLFSSL_KEY_GEN) byte priv[ED448_PRV_KEY_SIZE]; @@ -4053,9 +4121,10 @@ static int test_ED448(void) sigSz), WOLFSSL_SUCCESS); #endif /* HAVE_ED448_VERIFY */ #endif /* HAVE_ED448_SIGN && HAVE_ED448_KEY_IMPORT */ -#endif /* HAVE_ED448 && HAVE_ED448_KEY_EXPORT && WOLFSSL_KEY_GEN */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ED448 && HAVE_ED448_KEY_EXPORT && WOLFSSL_KEY_GEN */ + return res; } #endif /* OPENSSL_EXTRA */ @@ -4066,8 +4135,8 @@ static int test_ED448(void) static int test_wolfSSL_EVP_PKEY_print_public(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_BIO) - WOLFSSL_BIO* rbio = NULL; WOLFSSL_BIO* wbio = NULL; WOLFSSL_EVP_PKEY* pkey = NULL; @@ -4075,7 +4144,6 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) char line1[256] = { 0 }; int i; - printf(testingFmt, "EVP_PKEY_print_public()"); /* test error cases */ AssertIntEQ( EVP_PKEY_print_public(NULL,NULL,0,NULL),0L); @@ -4111,7 +4179,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) /* skip to the end of modulus element*/ - for( i = 0; i < 8 ;i++) { + for (i = 0; i < 8 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4162,7 +4230,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of pub element*/ - for( i = 0; i < 17 ;i++) { + for (i = 0; i < 17 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4171,7 +4239,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of P element*/ - for( i = 0; i < 18 ;i++) { + for (i = 0; i < 18 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4180,7 +4248,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of Q element*/ - for( i = 0; i < 3 ;i++) { + for (i = 0; i < 3 ;i++) { BIO_gets(wbio, line, sizeof(line)); } BIO_gets(wbio, line, sizeof(line)); @@ -4188,7 +4256,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of G element*/ - for( i = 0; i < 18 ;i++) { + for (i = 0; i < 18 ;i++) { BIO_gets(wbio, line, sizeof(line)); } /* should reach EOF */ @@ -4234,7 +4302,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of pub element*/ - for( i = 0; i < 4 ;i++) { + for (i = 0; i < 4 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4290,7 +4358,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of public-key element*/ - for( i = 0; i < 17 ;i++) { + for (i = 0; i < 17 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4304,7 +4372,7 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) AssertIntEQ(XSTRNCMP( line, line1, XSTRLEN(line1)), 0); /* skip to the end of prime element*/ - for( i = 0; i < 17 ;i++) { + for (i = 0; i < 17 ;i++) { BIO_gets(wbio, line, sizeof(line)); } @@ -4331,54 +4399,50 @@ static int test_wolfSSL_EVP_PKEY_print_public(void) (void)line; (void)line1; (void)i; - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } /* Test functions for base64 encode/decode */ static int test_wolfSSL_EVP_ENCODE_CTX_new(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && \ ( defined(WOLFSSL_BASE64_ENCODE) || defined(WOLFSSL_BASE64_DECODE)) EVP_ENCODE_CTX* ctx = NULL; - printf(testingFmt, "EVP_ENCODE_CTX_new()"); - AssertNotNull( ctx = EVP_ENCODE_CTX_new()); AssertIntEQ( ctx->remaining,0); AssertIntEQ( ctx->data[0],0); AssertIntEQ( ctx->data[sizeof(ctx->data) -1],0); EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && (WOLFSSL_BASE64_ENCODE || WOLFSSL_BASE64_DECODE)*/ - - return 0; + return res; } static int test_wolfSSL_EVP_ENCODE_CTX_free(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && \ ( defined(WOLFSSL_BASE64_ENCODE) || defined(WOLFSSL_BASE64_DECODE)) EVP_ENCODE_CTX* ctx = NULL; - printf(testingFmt, "EVP_ENCODE_CTX_free()"); - AssertNotNull( ctx = EVP_ENCODE_CTX_new()); EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); -#endif /*OPENSSL_EXTRA && (WOLFSSL_BASE64_ENCODE || WOLFSSL_BASE64_DECODE)*/ - return 0; + res = TEST_RES_CHECK(1); +#endif /*OPENSSL_EXTRA && (WOLFSSL_BASE64_ENCODE || WOLFSSL_BASE64_DECODE)*/ + return res; } static int test_wolfSSL_EVP_EncodeInit(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_ENCODE) EVP_ENCODE_CTX* ctx = NULL; - printf(testingFmt, "EVP_EncodeInit()"); - AssertNotNull( ctx = EVP_ENCODE_CTX_new()); AssertIntEQ( ctx->remaining,0); AssertIntEQ( ctx->data[0],0); @@ -4395,13 +4459,14 @@ static int test_wolfSSL_EVP_EncodeInit(void) AssertIntEQ( ctx->data[sizeof(ctx->data) -1],0); EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/ + return res; } static int test_wolfSSL_EVP_EncodeUpdate(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_ENCODE) int outl; int total; @@ -4421,8 +4486,6 @@ static int test_wolfSSL_EVP_EncodeUpdate(void) EVP_ENCODE_CTX* ctx = NULL; - printf(testingFmt, "EVP_EncodeUpdate()"); - AssertNotNull( ctx = EVP_ENCODE_CTX_new()); EVP_EncodeInit(ctx); @@ -4590,33 +4653,30 @@ static int test_wolfSSL_EVP_EncodeUpdate(void) EVP_EncodeFinal(NULL, NULL, NULL); EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/ + return res; } static int test_wolfSSL_EVP_EncodeFinal(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_ENCODE) - printf(testingFmt, "wolfSSL_EVP_EncodeFinal()"); - /* tests for wolfSSL_EVP_EncodeFinal are included in * test_wolfSSL_EVP_EncodeUpdate */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/ - - return 0; + return res; } static int test_wolfSSL_EVP_DecodeInit(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_DECODE) EVP_ENCODE_CTX* ctx = NULL; - printf(testingFmt, "EVP_DecodeInit()"); - AssertNotNull( ctx = EVP_ENCODE_CTX_new()); AssertIntEQ( ctx->remaining,0); AssertIntEQ( ctx->data[0],0); @@ -4633,13 +4693,14 @@ static int test_wolfSSL_EVP_DecodeInit(void) AssertIntEQ( ctx->data[sizeof(ctx->data) -1],0); EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); -#endif /* OPENSSL && WOLFSSL_BASE_DECODE */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL && WOLFSSL_BASE_DECODE */ + return res; } static int test_wolfSSL_EVP_DecodeUpdate(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_DECODE) int outl; unsigned char decOutBuff[300]; @@ -4651,8 +4712,6 @@ static int test_wolfSSL_EVP_DecodeUpdate(void) /* const unsigned char plain1[] = {"This is a base64 decoding test."} */ - printf(testingFmt, "EVP_DecodeUpdate()"); - ctx = EVP_ENCODE_CTX_new(); EVP_DecodeInit(ctx); @@ -4874,22 +4933,20 @@ static int test_wolfSSL_EVP_DecodeUpdate(void) EVP_ENCODE_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL && WOLFSSL_BASE_DECODE */ - - return 0; + return res; } static int test_wolfSSL_EVP_DecodeFinal(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_DECODE) - printf(testingFmt, "EVP_DecodeFinal()"); /* tests for wolfSSL_EVP_DecodeFinal are included in * test_wolfSSL_EVP_DecodeUpdate */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL && WOLFSSL_BASE_DECODE */ - - return 0; + return res; } /* Test function for wolfSSL_EVP_get_cipherbynid. @@ -4992,15 +5049,15 @@ static int test_wolfSSL_EVP_get_cipherbynid(void) AssertNotNull(strcmp("EVP_CHACHA20_POLY13O5", EVP_get_cipherbynid(1018))); #endif - /* test for nid is out of range */ - AssertNull(wolfSSL_EVP_get_cipherbynid(1)); + /* test for nid is out of range */ + AssertNull(wolfSSL_EVP_get_cipherbynid(1)); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_CIPHER_CTX(void) { + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128) EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); const EVP_CIPHER *init = EVP_aes_128_cbc(); @@ -5021,9 +5078,10 @@ static int test_wolfSSL_EVP_CIPHER_CTX(void) EVP_CIPHER_CTX_free(ctx); /* test EVP_CIPHER_CTX_cleanup with NULL */ AssertIntEQ(EVP_CIPHER_CTX_cleanup(NULL), WOLFSSL_SUCCESS); -#endif /* !NO_AES && HAVE_AES_CBC && WOLFSSL_AES_128 */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* !NO_AES && HAVE_AES_CBC && WOLFSSL_AES_128 */ + return res; } #endif /* OPENSSL_EXTRA */ @@ -5102,7 +5160,8 @@ static int nonblocking_accept_read(void* args, WOLFSSL* ssl, SOCKET_T* sockfd) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); return ret; } @@ -5119,7 +5178,7 @@ static int nonblocking_accept_read(void* args, WOLFSSL* ssl, SOCKET_T* sockfd) ret = wolfSSL_read(ssl, input, sizeof(input)-1); if (ret > 0) { input[ret] = '\0'; - printf("Client message: %s\n", input); + fprintf(stderr, "Client message: %s\n", input); } } while (err == WOLFSSL_ERROR_WANT_READ && ret != WOLFSSL_SUCCESS); @@ -5436,7 +5495,8 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_accept failed");*/ goto done; } @@ -5454,7 +5514,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) idx = wolfSSL_read(ssl, input, sizeof(input)-1); if (idx > 0) { input[idx] = '\0'; - printf("Client message: %s\n", input); + fprintf(stderr, "Client message: %s\n", input); } if (wolfSSL_write(ssl, msg, sizeof(msg)) != sizeof(msg)) { @@ -5595,7 +5655,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) cbf->ctx_ready(ctx); } - while(count != loop_count) { + while (count != loop_count) { ssl = wolfSSL_new(ctx); if (ssl == NULL) { goto done; @@ -5645,7 +5705,8 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_accept failed");*/ goto done; } @@ -5653,7 +5714,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) idx = wolfSSL_read(ssl, input, sizeof(input)-1); if (idx > 0) { input[idx] = '\0'; - printf("Client message: %s\n", input); + fprintf(stderr, "Client message: %s\n", input); } if (wolfSSL_write(ssl, msg, sizeof(msg)) != sizeof(msg)) { @@ -5678,7 +5739,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args) ((func_args*)args)->return_code = TEST_SUCCESS; done: - if(ssl != NULL) { + if (ssl != NULL) { wolfSSL_shutdown(ssl); wolfSSL_free(ssl); } @@ -5861,7 +5922,8 @@ static int test_client_nofail(void* args, cbType cb) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_connect failed");*/ goto done; } @@ -5899,7 +5961,7 @@ static int test_client_nofail(void* args, cbType cb) input = wolfSSL_read(ssl, reply, sizeof(reply)-1); if (input > 0) { reply[input] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } if (cbf != NULL && cbf->on_result != NULL) @@ -6056,7 +6118,7 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args } /* keep handshakre resources for re-using WOLFSSL obj */ wolfSSL_KeepArrays(ssl); - if(wolfSSL_KeepHandshakeResources(ssl)) { + if (wolfSSL_KeepHandshakeResources(ssl)) { /* err_sys("SSL_KeepHandshakeResources failed"); */ goto done; } @@ -6098,7 +6160,8 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_connect failed");*/ goto done; } @@ -6114,7 +6177,7 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args input = wolfSSL_read(ssl, reply, sizeof(reply)-1); if (input > 0) { reply[input] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } /* Session Resumption by re-using WOLFSSL object */ @@ -6136,7 +6199,7 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args sockfd = 0; /* wait until server ready */ wait_tcp_ready((func_args*)server_args); - printf("session resumption\n"); + fprintf(stderr, "session resumption\n"); /* Do re-connect */ tcp_connect(&sockfd, wolfSSLIP, ((func_args*)args)->signal->port, 0, 0, NULL); @@ -6160,7 +6223,8 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_connect failed");*/ goto done; } @@ -6176,7 +6240,7 @@ static void test_client_reuse_WOLFSSLobj(void* args, void *cb, void* server_args input = wolfSSL_read(ssl, reply, sizeof(reply)-1); if (input > 0) { reply[input] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } ((func_args*)args)->return_code = TEST_SUCCESS; @@ -6257,10 +6321,12 @@ static int test_client_verifyDepth(void* args) if (verify_depth == 0) { myVerifyAction = VERIFY_OVERRIDE_ERROR; SSL_CTX_set_verify_depth(ctx, verify_depth); - } else if (verify_depth == -1) { + } + else if (verify_depth == -1) { myVerifyAction = VERIFY_USE_PREVERFIY; SSL_CTX_set_verify_depth(ctx, 0); - } else if (verify_depth > 0) { + } + else if (verify_depth > 0) { myVerifyAction = VERIFY_USE_PREVERFIY; SSL_CTX_set_verify_depth(ctx, verify_depth); } @@ -6290,7 +6356,8 @@ static int test_client_verifyDepth(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); goto done; } @@ -6301,7 +6368,7 @@ static int test_client_verifyDepth(void* args) input = wolfSSL_read(ssl, reply, sizeof(reply)-1); if (input > 0) { reply[input] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } ((func_args*)args)->return_code = TEST_SUCCESS; @@ -6359,7 +6426,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) ret = wolfSSL_CTX_load_static_memory(&ctx, callbacks->method_ex, callbacks->mem, callbacks->memSz, 0, 1); if (ret != WOLFSSL_SUCCESS) { - printf("CTX static new failed %d\n", ret); + fprintf(stderr, "CTX static new failed %d\n", ret); return 0; } } @@ -6368,7 +6435,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) ctx = wolfSSL_CTX_new(callbacks->method()); } if (ctx == NULL) { - printf("CTX new failed\n"); + fprintf(stderr, "CTX new failed\n"); return 0; } #endif @@ -6425,7 +6492,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) ssl = wolfSSL_new(ctx); if (ssl == NULL) { - printf("SSL new failed\n"); + fprintf(stderr, "SSL new failed\n"); wolfSSL_CTX_free(ctx); return 0; } @@ -6485,8 +6552,8 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("accept error = %d, %s\n", - err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "accept error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_accept failed");*/ } else { @@ -6505,7 +6572,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) } while (err == WC_PENDING_E); if (idx > 0) { input[idx] = 0; - printf("Client message: %s\n", input); + fprintf(stderr, "Client message: %s\n", input); } #ifdef WOLFSSL_ASYNC_CRYPT @@ -6597,7 +6664,7 @@ static void run_wolfssl_client(void* args) ret = wolfSSL_CTX_load_static_memory(&ctx, callbacks->method_ex, callbacks->mem, callbacks->memSz, 0, 1); if (ret != WOLFSSL_SUCCESS) { - printf("CTX static new failed %d\n", ret); + fprintf(stderr, "CTX static new failed %d\n", ret); return; } } @@ -6606,7 +6673,7 @@ static void run_wolfssl_client(void* args) ctx = wolfSSL_CTX_new(callbacks->method()); } if (ctx == NULL) { - printf("CTX new failed\n"); + fprintf(stderr, "CTX new failed\n"); return; } #endif @@ -6680,7 +6747,8 @@ static void run_wolfssl_client(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); /*err_sys("SSL_connect failed");*/ } else { @@ -6714,7 +6782,7 @@ static void run_wolfssl_client(void* args) } while (err == WC_PENDING_E); if (ret > 0) { input[ret] = '\0'; /* null term */ - printf("Server response: %s\n", input); + fprintf(stderr, "Server response: %s\n", input); } ((func_args*)args)->return_code = TEST_SUCCESS; } @@ -6791,12 +6859,13 @@ static int test_wolfSSL_read_write(void) fdOpenSession(Task_self()); #endif - return 0; + return TEST_RES_CHECK(1); } -#if defined(OPENSSL_EXTRA) && !defined(NO_SESSION_CACHE) && !defined(WOLFSSL_TLS13) static int test_wolfSSL_reuse_WOLFSSLobj(void) { + int res = TEST_SKIPPED; +#if defined(OPENSSL_EXTRA) && !defined(NO_SESSION_CACHE) && !defined(WOLFSSL_TLS13) /* The unit test for session resumption by re-using WOLFSSL object. * WOLFSSL object is not cleared after first session. It re-use the obeject * for second connection. @@ -6839,13 +6908,14 @@ static int test_wolfSSL_reuse_WOLFSSLobj(void) fdOpenSession(Task_self()); #endif - - return 0; -} + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_SESSION_CACHE) && !defined(WOLFSSL_TLS13) */ + return res; +} static int test_wolfSSL_CTX_verifyDepth_ServerClient(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && !defined(NO_WOLFSSL_CLIENT) /* This unit test is to check set verify Depth */ @@ -6859,8 +6929,6 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient(void) XMEMSET(&server_args, 0, sizeof(func_args)); XMEMSET(&client_cbf, 0, sizeof(callback_functions)); - printf(testingFmt, "test_wolfSSL_CTX_verifyDepth_ServerClient()\n"); - #ifdef WOLFSSL_TLS13 client_cbf.method = wolfTLSv1_3_client_method; #endif /* WOLFSSL_TLS13 */ @@ -6929,12 +6997,13 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient(void) } FreeTcpReady(&ready); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #else (void)test_client_verifyDepth; #endif /* (OPENSSL_EXTRA) && !(WOLFSSL_TIRTOS) && (NO_WOLFSSL_CLIENT) */ - return 0; + return res; } static int test_client_get_finished(void* args, cbType cb) @@ -7020,7 +7089,8 @@ static int test_client_get_finished(void* args, cbType cb) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); goto done; } @@ -7070,7 +7140,7 @@ static int test_client_get_finished(void* args, cbType cb) } while (err == WC_PENDING_E); if (ret > 0) { reply[ret] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } ((func_args*)args)->return_code = TEST_SUCCESS; @@ -7090,8 +7160,8 @@ done: static int test_wolfSSL_get_finished(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_HAVE_TLS_UNIQUE) - tcp_ready ready; func_args client_args; func_args server_args; @@ -7124,11 +7194,13 @@ static int test_wolfSSL_get_finished(void) AssertIntEQ(0, XMEMCMP(client_side_msg2, server_side_msg1, MD_MAX_SIZE)); FreeTcpReady(&ready); + + res = TEST_RES_CHECK(1); #else (void)test_client_get_finished; #endif /* !NO_RSA && WOLFSSL_HAVE_TLS_UNIQUE */ - return 0; + return res; } #if defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_EXT_CACHE) && \ @@ -7222,6 +7294,7 @@ static void test_wolfSSL_CTX_add_session_ssl_ready(WOLFSSL* ssl) static int test_wolfSSL_CTX_add_session(void) { + int res = TEST_SKIPPED; #if defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_EXT_CACHE) && \ !defined(SINGLE_THREADED) && defined(WOLFSSL_TLS13) && \ !defined(NO_SESSION_CACHE) @@ -7252,8 +7325,6 @@ static int test_wolfSSL_CTX_add_session(void) const size_t methodsLen = sizeof(methods)/sizeof(*methods); size_t i, j; - printf(testingFmt, "wolfSSL_CTX_add_session()"); - for (i = 0; i < methodsLen; i++) { /* First run creates a connection while the second+ run will attempt * to resume the connection. The trick is that the internal cache @@ -7311,11 +7382,10 @@ static int test_wolfSSL_CTX_add_session(void) wolfSSL_CTX_free(test_wolfSSL_CTX_add_session_server_ctx); } - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(WOLFSSL_DTLS) && defined(WOLFSSL_SESSION_EXPORT) @@ -7376,6 +7446,7 @@ static unsigned char version_3[] = { static int test_wolfSSL_dtls_export(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_DTLS) && defined(WOLFSSL_SESSION_EXPORT) tcp_ready ready; func_args client_args; @@ -7537,7 +7608,7 @@ static int test_wolfSSL_dtls_export(void) XFREE(window, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wolfSSL_CTX_free(ctx); - printf("done and waiting for server\n"); + fprintf(stderr, "done and waiting for server\n"); join_thread(serverThread); AssertIntEQ(server_args.return_code, TEST_SUCCESS); @@ -7548,12 +7619,10 @@ static int test_wolfSSL_dtls_export(void) #endif } - - printf(testingFmt, "wolfSSL_dtls_export()"); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } @@ -7797,10 +7866,11 @@ static THREAD_RETURN WOLFSSL_THREAD tls_export_server(void* args) idx = wolfSSL_read(ssl, input, sizeof(input)-1); if (idx > 0) { input[idx] = '\0'; - printf("Client message export/import: %s\n", input); + fprintf(stderr, "Client message export/import: %s\n", input); } else { - printf("ret = %d error = %d\n", idx, wolfSSL_get_error(ssl, idx)); + fprintf(stderr, "ret = %d error = %d\n", idx, + wolfSSL_get_error(ssl, idx)); goto done; } @@ -7975,22 +8045,22 @@ static int test_wolfSSL_tls_export_run(int v) #endif - return 0; + return TEST_RES_CHECK(1); } #endif static int test_wolfSSL_tls_export(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_SESSION_EXPORT) && !defined(WOLFSSL_NO_TLS12) - printf(testingFmt, "wolfSSL_tls_export()"); test_wolfSSL_tls_export_run(WOLFSSL_TLSV1_2); #ifdef WOLFSSL_TLS13 test_wolfSSL_tls_export_run(WOLFSSL_TLSV1_3); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } /*----------------------------------------------------------------------------* @@ -8050,6 +8120,7 @@ static void test_wolfSSL_client_server(callback_functions* client_callbacks, #ifdef HAVE_SNI static int test_wolfSSL_UseSNI_params(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); WOLFSSL *ssl = wolfSSL_new(ctx); @@ -8072,9 +8143,11 @@ static int test_wolfSSL_UseSNI_params(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT */ - return 0; + return res; } /* BEGIN of connection tests callbacks */ @@ -8182,6 +8255,7 @@ static void verify_FATAL_ERROR_on_client(WOLFSSL* ssl) static int test_wolfSSL_UseSNI_connection(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) callback_functions client_cb; callback_functions server_cb; @@ -8260,9 +8334,11 @@ static int test_wolfSSL_UseSNI_connection(void) server_cb.ctx_ready = use_PSEUDO_MANDATORY_SNI_at_ctx; server_cb.ssl_ready = NULL; server_cb.on_result = verify_SNI_fake_matching; test_wolfSSL_client_server(&client_cb, &server_cb); } + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT && !NO_WOLFSSL_SERVER */ - return 0; + return res; } static int test_wolfSSL_SNI_GetFromBuffer(void) @@ -8393,27 +8469,16 @@ static int test_wolfSSL_SNI_GetFromBuffer(void) AssertIntEQ(BUFFER_ERROR, wolfSSL_SNI_GetFromBuffer(buff5, sizeof(buff5), 0, result, &length)); - return 0; + return TEST_RES_CHECK(1); } #endif /* HAVE_SNI */ -static int test_wolfSSL_UseSNI(void) -{ -#ifdef HAVE_SNI - test_wolfSSL_UseSNI_params(); - test_wolfSSL_UseSNI_connection(); - - test_wolfSSL_SNI_GetFromBuffer(); -#endif - - return 0; -} - #endif /* HAVE_IO_TESTS_DEPENDENCIES */ static int test_wolfSSL_UseTrustedCA(void) { + int res = TEST_SKIPPED; #if defined(HAVE_TRUSTED_CA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) \ && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -8458,14 +8523,16 @@ static int test_wolfSSL_UseTrustedCA(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* HAVE_TRUSTED_CA */ - - return 0; + return res; } static int test_wolfSSL_UseMaxFragment(void) { + int res = TEST_SKIPPED; #if defined(HAVE_MAX_FRAGMENT) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) @@ -8542,14 +8609,16 @@ static int test_wolfSSL_UseMaxFragment(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } static int test_wolfSSL_UseTruncatedHMAC(void) { + int res = TEST_SKIPPED; #if defined(HAVE_TRUNCATED_HMAC) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -8580,14 +8649,16 @@ static int test_wolfSSL_UseTruncatedHMAC(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } static int test_wolfSSL_UseSupportedCurve(void) { + int res = TEST_SKIPPED; #if defined(HAVE_SUPPORTED_CURVES) && !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS) WOLFSSL_CTX* ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); WOLFSSL *ssl = wolfSSL_new(ctx); @@ -8612,9 +8683,11 @@ static int test_wolfSSL_UseSupportedCurve(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(HAVE_ALPN) && defined(HAVE_IO_TESTS_DEPENDENCIES) @@ -8753,6 +8826,7 @@ static void verify_ALPN_client_list(WOLFSSL* ssl) static int test_wolfSSL_UseALPN_connection(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) callback_functions client_cb; callback_functions server_cb; @@ -8804,12 +8878,15 @@ static int test_wolfSSL_UseALPN_connection(void) client_cb.ctx_ready = NULL; client_cb.ssl_ready = use_ALPN_all; client_cb.on_result = NULL; server_cb.ctx_ready = NULL; server_cb.ssl_ready = use_ALPN_unknown; server_cb.on_result = verify_ALPN_FATAL_ERROR_on_client; test_wolfSSL_client_server(&client_cb, &server_cb); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT && !NO_WOLFSSL_SERVER */ - return 0; + return res; } static int test_wolfSSL_UseALPN_params(void) { + int res = TEST_SKIPPED; #ifndef NO_WOLFSSL_CLIENT /* "http/1.1" */ char http1[] = {0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31}; @@ -8879,9 +8956,10 @@ static int test_wolfSSL_UseALPN_params(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #endif /* HAVE_ALPN */ @@ -8958,6 +9036,7 @@ static void verify_alpn_matching_http1(WOLFSSL* ssl) static int test_wolfSSL_set_alpn_protos(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) callback_functions client_cb; callback_functions server_cb; @@ -8979,29 +9058,16 @@ static int test_wolfSSL_set_alpn_protos(void) server_cb.ctx_ready = NULL; server_cb.ssl_ready = set_alpn_protos; server_cb.on_result = verify_alpn_matching_spdy3; test_wolfSSL_client_server(&client_cb, &server_cb); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT && !NO_WOLFSSL_SERVER */ - return 0; + return res; } #endif /* HAVE_ALPN_PROTOS_SUPPORT */ -static int test_wolfSSL_UseALPN(void) -{ -#if defined(HAVE_ALPN) && !defined(NO_WOLFSSL_SERVER) &&\ - defined(HAVE_IO_TESTS_DEPENDENCIES) - test_wolfSSL_UseALPN_connection(); - test_wolfSSL_UseALPN_params(); -#endif - -#ifdef HAVE_ALPN_PROTOS_SUPPORT - test_wolfSSL_set_alpn_protos(); -#endif - - return 0; -} - static int test_wolfSSL_DisableExtendedMasterSecret(void) { + int res = TEST_SKIPPED; #if defined(HAVE_EXTENDED_MASTER) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); WOLFSSL *ssl = wolfSSL_new(ctx); @@ -9019,13 +9085,15 @@ static int test_wolfSSL_DisableExtendedMasterSecret(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_wolfSSL_UseSecureRenegotiation(void) { + int res = TEST_SKIPPED; #if defined(HAVE_SECURE_RENEGOTIATION) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); WOLFSSL *ssl = wolfSSL_new(ctx); @@ -9043,9 +9111,10 @@ static int test_wolfSSL_wolfSSL_UseSecureRenegotiation(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } @@ -9054,77 +9123,75 @@ static int test_wolfSSL_wolfSSL_UseSecureRenegotiation(void) *----------------------------------------------------------------------------*/ static int test_wolfSSL_X509_NAME_get_entry(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) #if defined(OPENSSL_ALL) || \ (defined(OPENSSL_EXTRA) && \ (defined(KEEP_PEER_CERT) || defined(SESSION_CERTS))) - printf(testingFmt, "wolfSSL_X509_NAME_get_entry()"); - - { - /* use openssl like name to test mapping */ - X509_NAME_ENTRY* ne; - X509_NAME* name; - X509* x509; - #ifndef NO_FILESYSTEM - ASN1_STRING* asn; - char* subCN = NULL; - #endif - int idx; - ASN1_OBJECT *object = NULL; + /* use openssl like name to test mapping */ + X509_NAME_ENTRY* ne; + X509_NAME* name; + X509* x509; +#ifndef NO_FILESYSTEM + ASN1_STRING* asn; + char* subCN = NULL; +#endif + int idx; + ASN1_OBJECT *object = NULL; #if defined(WOLFSSL_APACHE_HTTPD) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) #ifndef NO_BIO - BIO* bio; + BIO* bio; #endif #endif - #ifndef NO_FILESYSTEM - x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); - AssertNotNull(x509); - name = X509_get_subject_name(x509); - idx = X509_NAME_get_index_by_NID(name, NID_commonName, -1); - AssertIntGE(idx, 0); - ne = X509_NAME_get_entry(name, idx); - AssertNotNull(ne); - asn = X509_NAME_ENTRY_get_data(ne); - AssertNotNull(asn); - subCN = (char*)ASN1_STRING_data(asn); - AssertNotNull(subCN); - wolfSSL_FreeX509(x509); - #endif +#ifndef NO_FILESYSTEM + x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); + AssertNotNull(x509); + name = X509_get_subject_name(x509); + idx = X509_NAME_get_index_by_NID(name, NID_commonName, -1); + AssertIntGE(idx, 0); + ne = X509_NAME_get_entry(name, idx); + AssertNotNull(ne); + asn = X509_NAME_ENTRY_get_data(ne); + AssertNotNull(asn); + subCN = (char*)ASN1_STRING_data(asn); + AssertNotNull(subCN); + wolfSSL_FreeX509(x509); +#endif - x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); - AssertNotNull(x509); - name = X509_get_subject_name(x509); - idx = X509_NAME_get_index_by_NID(name, NID_commonName, -1); - AssertIntGE(idx, 0); + x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); + AssertNotNull(x509); + name = X509_get_subject_name(x509); + idx = X509_NAME_get_index_by_NID(name, NID_commonName, -1); + AssertIntGE(idx, 0); #if defined(WOLFSSL_APACHE_HTTPD) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) #ifndef NO_BIO - AssertNotNull(bio = BIO_new(BIO_s_mem())); - AssertIntEQ(X509_NAME_print_ex(bio, name, 4, - (XN_FLAG_RFC2253 & ~XN_FLAG_DN_REV)), WOLFSSL_SUCCESS); - AssertIntEQ(X509_NAME_print_ex_fp(stdout, name, 4, - (XN_FLAG_RFC2253 & ~XN_FLAG_DN_REV)), WOLFSSL_SUCCESS); - BIO_free(bio); + AssertNotNull(bio = BIO_new(BIO_s_mem())); + AssertIntEQ(X509_NAME_print_ex(bio, name, 4, + (XN_FLAG_RFC2253 & ~XN_FLAG_DN_REV)), WOLFSSL_SUCCESS); + AssertIntEQ(X509_NAME_print_ex_fp(stderr, name, 4, + (XN_FLAG_RFC2253 & ~XN_FLAG_DN_REV)), WOLFSSL_SUCCESS); + BIO_free(bio); #endif #endif - ne = X509_NAME_get_entry(name, idx); - AssertNotNull(ne); - AssertNotNull(object = X509_NAME_ENTRY_get_object(ne)); - wolfSSL_FreeX509(x509); - } + ne = X509_NAME_get_entry(name, idx); + AssertNotNull(ne); + AssertNotNull(object = X509_NAME_ENTRY_get_object(ne)); + wolfSSL_FreeX509(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL || (OPENSSL_EXTRA && (KEEP_PEER_CERT || SESSION_CERTS) */ #endif /* !NO_CERTS && !NO_RSA */ - return 0; + return res; } /* Testing functions dealing with PKCS12 parsing out X509 certs */ static int test_wolfSSL_PKCS12(void) { + int res = TEST_SKIPPED; /* .p12 file is encrypted with DES3 */ #ifndef HAVE_FIPS /* Password used in cert "wolfSSL test" is only 12-bytes * (96-bit) FIPS mode requires Minimum of 14-byte (112-bit) @@ -9162,8 +9229,6 @@ static int test_wolfSSL_PKCS12(void) WOLF_STACK_OF(WOLFSSL_X509) *tmp_ca = NULL; #endif - printf(testingFmt, "wolfSSL_PKCS12()"); - f = XFOPEN(file, "rb"); AssertTrue((f != XBADFILE)); bytes = (int)XFREAD(buf, 1, sizeof(buf), f); @@ -9473,11 +9538,10 @@ static int test_wolfSSL_PKCS12(void) (void)order; - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ #endif /* HAVE_FIPS */ - - return 0; + return res; } @@ -9509,6 +9573,7 @@ static WC_INLINE int FailTestCallBack(char* passwd, int sz, int rw, void* userda static int test_wolfSSL_no_password_cb(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_ASN) && defined(HAVE_PKCS8) \ && defined(HAVE_ECC) && defined(WOLFSSL_ENCRYPTED_KEYS) WOLFSSL_CTX* ctx; @@ -9518,8 +9583,6 @@ static int test_wolfSSL_no_password_cb(void) XFILE f; int bytes; - printf(testingFmt, "test_wolfSSL_no_password_cb()"); - #ifndef NO_WOLFSSL_CLIENT AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLS_client_method())); #else @@ -9549,11 +9612,9 @@ static int test_wolfSSL_no_password_cb(void) "to first decipher private key without password.")); } - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifdef TEST_PKCS8_ENC @@ -9583,6 +9644,7 @@ static int PKCS8TestCallBack(char* passwd, int sz, int rw, void* userdata) /* Testing functions dealing with PKCS8 */ static int test_wolfSSL_PKCS8(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_ASN) && defined(HAVE_PKCS8) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) byte buff[FOURK_BUF]; @@ -9617,8 +9679,6 @@ static int test_wolfSSL_PKCS8(void) (void)der; - printf(testingFmt, "wolfSSL_PKCS8()"); - #ifndef NO_WOLFSSL_CLIENT #ifndef WOLFSSL_NO_TLS12 AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())); @@ -9775,15 +9835,15 @@ static int test_wolfSSL_PKCS8(void) wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* !NO_FILESYSTEM && !NO_ASN && HAVE_PKCS8 */ - - return 0; + return res; } static int test_wolfSSL_PKCS8_ED25519(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && defined(HAVE_PKCS8) && defined(HAVE_AES_CBC) && \ defined(WOLFSSL_ENCRYPTED_KEYS) && defined(HAVE_ED25519) && \ defined(HAVE_ED25519_KEY_IMPORT) @@ -9812,14 +9872,16 @@ static int test_wolfSSL_PKCS8_ED25519(void) WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } static int test_wolfSSL_PKCS8_ED448(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && defined(HAVE_PKCS8) && defined(HAVE_AES_CBC) && \ defined(WOLFSSL_ENCRYPTED_KEYS) && defined(HAVE_ED448) && \ defined(HAVE_ED448_KEY_IMPORT) @@ -9848,15 +9910,17 @@ static int test_wolfSSL_PKCS8_ED448(void) WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } /* Testing functions dealing with PKCS5 */ static int test_wolfSSL_PKCS5(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA) && !defined(NO_PWDBASED) #ifdef HAVE_FIPS /* Password minimum length is 14 (112-bit) in FIPS MODE */ const char* passwd = "myfipsPa$$W0rd"; @@ -9882,14 +9946,16 @@ static int test_wolfSSL_PKCS5(void) #endif XFREE(out, NULL, DYNAMIC_TYPE_TMP_BUFFER); -#endif /* defined(OPENSSL_EXTRA) && !defined(NO_SHA) */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* defined(OPENSSL_EXTRA) && !defined(NO_SHA) */ + return res; } /* test parsing URI from certificate */ static int test_wolfSSL_URI(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) \ && (defined(KEEP_PEER_CERT) || defined(SESSION_CERTS) || \ defined(OPENSSL_EXTRA)) @@ -9897,8 +9963,6 @@ static int test_wolfSSL_URI(void) const char uri[] = "./certs/client-uri-cert.pem"; const char badUri[] = "./certs/client-relative-uri.pem"; - printf(testingFmt, "wolfSSL URI parse"); - x509 = wolfSSL_X509_load_certificate_file(uri, WOLFSSL_FILETYPE_PEM); AssertNotNull(x509); wolfSSL_FreeX509(x509); @@ -9912,23 +9976,21 @@ static int test_wolfSSL_URI(void) wolfSSL_FreeX509(x509); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_TBS(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) \ && defined(OPENSSL_EXTRA) WOLFSSL_X509* x509; const unsigned char* tbs; int tbsSz; - printf(testingFmt, "wolfSSL TBS"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(caCertFile, WOLFSSL_FILETYPE_PEM)); @@ -9939,14 +10001,14 @@ static int test_wolfSSL_TBS(void) wolfSSL_FreeX509(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_verify(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) \ && defined(OPENSSL_EXTRA) WOLFSSL_X509* ca; @@ -9956,8 +10018,6 @@ static int test_wolfSSL_X509_verify(void) const unsigned char* pt = NULL; int bufSz; - printf(testingFmt, "wolfSSL X509 verify"); - AssertNotNull(ca = wolfSSL_X509_load_certificate_file(caCertFile, WOLFSSL_FILETYPE_PEM)); @@ -10001,10 +10061,9 @@ static int test_wolfSSL_X509_verify(void) wolfSSL_FreeX509(ca); wolfSSL_FreeX509(serv); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } @@ -10096,6 +10155,7 @@ static void test_set_override_x509(WOLFSSL_CTX* ctx) static int test_wolfSSL_X509_TLS_version(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_DH) && !defined(NO_AES) && \ defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(SINGLE_THREADED) && \ @@ -10107,8 +10167,6 @@ static int test_wolfSSL_X509_TLS_version(void) callback_functions func_cb_client; callback_functions func_cb_server; - printf(testingFmt, "test_wolfSSL_X509_TLS_version"); - /* test server rejects a client certificate that is not version 3 */ #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -10217,10 +10275,10 @@ static int test_wolfSSL_X509_TLS_version(void) fdCloseSession(Task_self()); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } /* Testing function wolfSSL_CTX_SetMinVersion; sets the minimum downgrade @@ -10229,8 +10287,9 @@ static int test_wolfSSL_X509_TLS_version(void) */ static int test_wolfSSL_CTX_SetMinVersion(void) { - int failFlag = WOLFSSL_SUCCESS; + int res = TEST_SKIPPED; #ifndef NO_WOLFSSL_CLIENT + int failFlag = WOLFSSL_SUCCESS; WOLFSSL_CTX* ctx; int itr; @@ -10251,22 +10310,17 @@ static int test_wolfSSL_CTX_SetMinVersion(void) ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); - printf(testingFmt, "wolfSSL_CTX_SetMinVersion()"); - - for (itr = 0; itr < (int)(sizeof(versions)/sizeof(int)); itr++){ - if(wolfSSL_CTX_SetMinVersion(ctx, *(versions + itr)) != WOLFSSL_SUCCESS){ + for (itr = 0; itr < (int)(sizeof(versions)/sizeof(int)); itr++) { + if (wolfSSL_CTX_SetMinVersion(ctx, *(versions + itr)) != WOLFSSL_SUCCESS) { failFlag = WOLFSSL_FAILURE; } } - printf(resultFmt, failFlag == WOLFSSL_SUCCESS ? passed : failed); - wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(failFlag == WOLFSSL_SUCCESS); #endif - if (failFlag == WOLFSSL_SUCCESS) { - failFlag = 0; - } - return failFlag; + return res; } /* END test_wolfSSL_CTX_SetMinVersion */ @@ -10283,6 +10337,7 @@ static int test_wolfSSL_CTX_SetMinVersion(void) */ static int test_wolfSSL_UseOCSPStapling(void) { + int res = TEST_SKIPPED; #if defined(HAVE_CERTIFICATE_STATUS_REQUEST) && defined(HAVE_OCSP) && \ !defined(NO_WOLFSSL_CLIENT) int ret; @@ -10303,25 +10358,16 @@ static int test_wolfSSL_UseOCSPStapling(void) #endif #endif ssl = wolfSSL_new(ctx); - printf(testingFmt, "wolfSSL_UseOCSPStapling()"); ret = wolfSSL_UseOCSPStapling(ssl, WOLFSSL_CSR2_OCSP, WOLFSSL_CSR2_OCSP_USE_NONCE); - printf(resultFmt, ret == WOLFSSL_SUCCESS ? passed : failed); - - wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); - if (ret == WOLFSSL_SUCCESS) { - ret = 0; - } - return ret; - #else - return 0; + res = TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); #endif - + return res; } /*END test_wolfSSL_UseOCSPStapling */ @@ -10332,6 +10378,7 @@ static int test_wolfSSL_UseOCSPStapling(void) */ static int test_wolfSSL_UseOCSPStaplingV2(void) { + int res = TEST_SKIPPED; #if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) && defined(HAVE_OCSP) && \ !defined(NO_WOLFSSL_CLIENT) int ret; @@ -10352,23 +10399,16 @@ static int test_wolfSSL_UseOCSPStaplingV2(void) #endif #endif ssl = wolfSSL_new(ctx); - printf(testingFmt, "wolfSSL_UseOCSPStaplingV2()"); ret = wolfSSL_UseOCSPStaplingV2(ssl, WOLFSSL_CSR2_OCSP, WOLFSSL_CSR2_OCSP_USE_NONCE ); - printf(resultFmt, ret == WOLFSSL_SUCCESS ? passed : failed); - wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); - if (ret == WOLFSSL_SUCCESS) { - ret = 0; - } - return ret; - #else - return 0; + res = TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); #endif + return res; } /*END test_wolfSSL_UseOCSPStaplingV2*/ @@ -10377,6 +10417,7 @@ static int test_wolfSSL_UseOCSPStaplingV2(void) *----------------------------------------------------------------------------*/ static int test_wolfSSL_mcast(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_DTLS) && defined(WOLFSSL_MULTICAST) && \ (defined(WOLFSSL_TLS13) || defined(WOLFSSL_SNIFFER)) WOLFSSL_CTX* ctx; @@ -10412,9 +10453,10 @@ static int test_wolfSSL_mcast(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif /* WOLFSSL_DTLS && WOLFSSL_MULTICAST && (WOLFSSL_TLS13 || WOLFSSL_SNIFFER) */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* WOLFSSL_DTLS && WOLFSSL_MULTICAST && (WOLFSSL_TLS13 || WOLFSSL_SNIFFER) */ + return res; } @@ -10427,12 +10469,10 @@ static int test_wolfSSL_mcast(void) */ static int test_wc_InitBlake2b(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_BLAKE2 - Blake2b blake; - - printf(testingFmt, "wc_InitBlake2B()"); + int ret = 0; /* Test good arg. */ ret = wc_InitBlake2b(&blake, 64); @@ -10445,7 +10485,8 @@ static int test_wc_InitBlake2b(void) ret = wc_InitBlake2b(NULL, 64); if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -10454,7 +10495,8 @@ static int test_wc_InitBlake2b(void) ret = wc_InitBlake2b(NULL, 128); if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -10463,7 +10505,8 @@ static int test_wc_InitBlake2b(void) ret = wc_InitBlake2b(&blake, 128); if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -10472,7 +10515,8 @@ static int test_wc_InitBlake2b(void) ret = wc_InitBlake2b(NULL, 0); if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -10481,15 +10525,16 @@ static int test_wc_InitBlake2b(void) ret = wc_InitBlake2b(&blake, 0); if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_InitBlake2b*/ /* @@ -10497,16 +10542,15 @@ static int test_wc_InitBlake2b(void) */ static int test_wc_InitBlake2b_WithKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_BLAKE2 Blake2b blake; word32 digestSz = BLAKE2B_KEYBYTES; byte key[BLAKE2B_KEYBYTES]; word32 keylen = BLAKE2B_KEYBYTES; + int ret = 0; - - - printf(testingFmt, "wc_InitBlake2b_WithKey()"); + XMEMSET(key, 0, sizeof(key)); /* Test good arg. */ ret = wc_InitBlake2b_WithKey(&blake, digestSz, key, keylen); @@ -10530,10 +10574,9 @@ static int test_wc_InitBlake2b_WithKey(void) ret = wc_InitBlake2b_WithKey(&blake, digestSz, NULL, keylen); } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END wc_InitBlake2b_WithKey*/ /* @@ -10541,14 +10584,13 @@ static int test_wc_InitBlake2b_WithKey(void) */ static int test_wc_InitBlake2s_WithKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_BLAKE2S Blake2s blake; word32 digestSz = BLAKE2S_KEYBYTES; byte *key = (byte*)"01234567890123456789012345678901"; word32 keylen = BLAKE2S_KEYBYTES; - - printf(testingFmt, "wc_InitBlake2s_WithKey()"); + int ret = 0; /* Test good arg. */ ret = wc_InitBlake2s_WithKey(&blake, digestSz, key, keylen); @@ -10572,10 +10614,9 @@ static int test_wc_InitBlake2s_WithKey(void) ret = wc_InitBlake2s_WithKey(&blake, digestSz, NULL, keylen); } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END wc_InitBlake2s_WithKey*/ /* @@ -10583,13 +10624,11 @@ static int test_wc_InitBlake2s_WithKey(void) */ static int test_wc_InitMd5(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_MD5 - wc_Md5 md5; int ret; - - printf(testingFmt, "wc_InitMd5()"); + int flag = 0; /* Test good arg. */ ret = wc_InitMd5(&md5); @@ -10607,10 +10646,9 @@ static int test_wc_InitMd5(void) wc_Md5Free(&md5); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitMd5 */ @@ -10619,21 +10657,19 @@ static int test_wc_InitMd5(void) */ static int test_wc_Md5Update(void) { - - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_MD5 wc_Md5 md5; byte hash[WC_MD5_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitMd5(&md5); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Md5Update()"); - /* Input */ if (!flag) { a.input = "a"; @@ -10709,10 +10745,9 @@ static int test_wc_Md5Update(void) wc_Md5Free(&md5); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Md5Update() */ @@ -10721,8 +10756,7 @@ static int test_wc_Md5Update(void) */ static int test_wc_Md5Final(void) { - - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_MD5 /* Instantiate */ wc_Md5 md5; @@ -10731,6 +10765,7 @@ static int test_wc_Md5Final(void) byte hash2[2*WC_MD5_DIGEST_SIZE]; byte hash3[5*WC_MD5_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitMd5(&md5); @@ -10746,9 +10781,6 @@ static int test_wc_Md5Final(void) times = sizeof(hash_test)/sizeof(byte*); - /* Test good args. */ - printf(testingFmt, "wc_Md5Final()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Md5Final(&md5, hash_test[i]); @@ -10782,10 +10814,9 @@ static int test_wc_Md5Final(void) wc_Md5Free(&md5); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* @@ -10793,12 +10824,11 @@ static int test_wc_Md5Final(void) */ static int test_wc_InitSha(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA wc_Sha sha; int ret; - - printf(testingFmt, "wc_InitSha()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha(&sha); @@ -10816,9 +10846,9 @@ static int test_wc_InitSha(void) wc_ShaFree(&sha); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitSha */ @@ -10827,11 +10857,12 @@ static int test_wc_InitSha(void) */ static int test_wc_ShaUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA wc_Sha sha; byte hash[WC_SHA_DIGEST_SIZE]; testVector a, b, c; + int flag = 0; int ret; ret = wc_InitSha(&sha); @@ -10839,8 +10870,6 @@ static int test_wc_ShaUpdate(void) flag = ret; } - printf(testingFmt, "wc_ShaUpdate()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -10925,11 +10954,10 @@ static int test_wc_ShaUpdate(void) } wc_ShaFree(&sha); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_ShaUpdate() */ @@ -10939,7 +10967,7 @@ static int test_wc_ShaUpdate(void) */ static int test_wc_ShaFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA wc_Sha sha; byte* hash_test[3]; @@ -10947,6 +10975,7 @@ static int test_wc_ShaFinal(void) byte hash2[2*WC_SHA_DIGEST_SIZE]; byte hash3[5*WC_SHA_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /*Initialize*/ ret = wc_InitSha(&sha); @@ -10962,9 +10991,6 @@ static int test_wc_ShaFinal(void) times = sizeof(hash_test)/sizeof(byte*); - /* Good test args. */ - printf(testingFmt, "wc_ShaFinal()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_ShaFinal(&sha, hash_test[i]); @@ -10998,10 +11024,9 @@ static int test_wc_ShaFinal(void) wc_ShaFree(&sha); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_ShaFinal */ @@ -11010,12 +11035,11 @@ static int test_wc_ShaFinal(void) */ static int test_wc_InitSha256(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 wc_Sha256 sha256; int ret; - - printf(testingFmt, "wc_InitSha256()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha256(&sha256); @@ -11033,10 +11057,9 @@ static int test_wc_InitSha256(void) wc_Sha256Free(&sha256); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitSha256 */ @@ -11045,20 +11068,19 @@ static int test_wc_InitSha256(void) */ static int test_wc_Sha256Update(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 wc_Sha256 sha256; byte hash[WC_SHA256_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitSha256(&sha256); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha256Update()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -11145,10 +11167,9 @@ static int test_wc_Sha256Update(void) wc_Sha256Free(&sha256); - /* If not returned then the unit test passed. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256Update */ @@ -11158,7 +11179,7 @@ static int test_wc_Sha256Update(void) */ static int test_wc_Sha256Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 wc_Sha256 sha256; byte* hash_test[3]; @@ -11166,6 +11187,7 @@ static int test_wc_Sha256Final(void) byte hash2[2*WC_SHA256_DIGEST_SIZE]; byte hash3[5*WC_SHA256_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha256(&sha256); @@ -11181,9 +11203,6 @@ static int test_wc_Sha256Final(void) times = sizeof(hash_test) / sizeof(byte*); - /* Good test args. */ - printf(testingFmt, "wc_Sha256Final()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha256Final(&sha256, hash_test[i]); @@ -11217,10 +11236,9 @@ static int test_wc_Sha256Final(void) wc_Sha256Free(&sha256); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256Final */ /* @@ -11228,7 +11246,7 @@ static int test_wc_Sha256Final(void) */ static int test_wc_Sha256FinalRaw(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_SHA256) && !defined(HAVE_SELFTEST) && !defined(WOLFSSL_DEVCRYPTO) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \ !defined(WOLFSSL_NO_HASH_RAW) @@ -11238,6 +11256,7 @@ static int test_wc_Sha256FinalRaw(void) byte hash2[2*WC_SHA256_DIGEST_SIZE]; byte hash3[5*WC_SHA256_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha256(&sha256); @@ -11253,9 +11272,6 @@ static int test_wc_Sha256FinalRaw(void) times = sizeof(hash_test) / sizeof(byte*); - /* Good test args. */ - printf(testingFmt, "wc_Sha256FinalRaw()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha256FinalRaw(&sha256, hash_test[i]); @@ -11266,7 +11282,7 @@ static int test_wc_Sha256FinalRaw(void) } /* Test bad args. */ - if (!flag ) { + if (!flag) { ret = wc_Sha256FinalRaw(NULL, NULL); if (ret != BAD_FUNC_ARG) { flag = WOLFSSL_FATAL_ERROR; @@ -11289,9 +11305,9 @@ static int test_wc_Sha256FinalRaw(void) wc_Sha256Free(&sha256); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256FinalRaw */ /* @@ -11299,12 +11315,11 @@ static int test_wc_Sha256FinalRaw(void) */ static int test_wc_Sha256GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_SHA256) && defined(WOLFSSL_HASH_FLAGS) wc_Sha256 sha256; word32 flags = 0; - - printf(testingFmt, "wc_Sha256GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha256(&sha256); @@ -11319,9 +11334,9 @@ static int test_wc_Sha256GetFlags(void) wc_Sha256Free(&sha256); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256GetFlags */ /* @@ -11329,14 +11344,13 @@ static int test_wc_Sha256GetFlags(void) */ static int test_wc_Sha256Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 - printf(testingFmt, "wc_Sha256Free()"); wc_Sha256Free(NULL); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(1); #endif - return flag; + return res; } /* END test_wc_Sha256Free */ /* @@ -11344,12 +11358,11 @@ static int test_wc_Sha256Free(void) */ static int test_wc_Sha256GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 wc_Sha256 sha256; byte hash1[WC_SHA256_DIGEST_SIZE]; - - printf(testingFmt, "wc_Sha256GetHash()"); + int flag = 0; /* Initialize */ flag = wc_InitSha256(&sha256); @@ -11379,22 +11392,20 @@ static int test_wc_Sha256GetHash(void) wc_Sha256Free(&sha256); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha256GetHash */ /* * Unit test function for wc_Sha256Copy() */ static int test_wc_Sha256Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifndef NO_SHA256 wc_Sha256 sha256; wc_Sha256 temp; - - printf(testingFmt, "wc_Sha256Copy()"); + int flag = 0; /* Initialize */ flag = wc_InitSha256(&sha256); @@ -11427,9 +11438,9 @@ static int test_wc_Sha256Copy(void) wc_Sha256Free(&sha256); wc_Sha256Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256Copy */ /* @@ -11437,12 +11448,11 @@ static int test_wc_Sha256Copy(void) */ static int test_wc_InitSha512(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 wc_Sha512 sha512; int ret; - - printf(testingFmt, "wc_InitSha512()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha512(&sha512); @@ -11460,10 +11470,9 @@ static int test_wc_InitSha512(void) wc_Sha512Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitSha512 */ @@ -11473,21 +11482,19 @@ static int test_wc_InitSha512(void) */ static int test_wc_Sha512Update(void) { - - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 wc_Sha512 sha512; byte hash[WC_SHA512_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitSha512(&sha512); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha512Update()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -11574,10 +11581,9 @@ static int test_wc_Sha512Update(void) wc_Sha512Free(&sha512); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha512Update */ @@ -11642,7 +11648,7 @@ static int test_Sha512_Family_Final(int type, int isRaw) #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ else - return BAD_FUNC_ARG; + return TEST_FAIL; /* Initialize */ ret = initFp(&sha512); @@ -11678,6 +11684,7 @@ static int test_Sha512_Family_Final(int type, int isRaw) } freeFp(&sha512); + return ret; } #endif /* !HAVE_FIPS && !HAVE_SELFTEST && @@ -11688,7 +11695,7 @@ static int test_Sha512_Family_Final(int type, int isRaw) */ static int test_wc_Sha512Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 wc_Sha512 sha512; byte* hash_test[3]; @@ -11696,6 +11703,7 @@ static int test_wc_Sha512Final(void) byte hash2[2*WC_SHA512_DIGEST_SIZE]; byte hash3[5*WC_SHA512_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha512(&sha512); @@ -11711,9 +11719,6 @@ static int test_wc_Sha512Final(void) times = sizeof(hash_test) / sizeof(byte *); - /* Good test args. */ - printf(testingFmt, "wc_Sha512Final()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha512Final(&sha512, hash_test[i]); @@ -11728,8 +11733,9 @@ static int test_wc_Sha512Final(void) if (ret != BAD_FUNC_ARG) { flag = WOLFSSL_FATAL_ERROR; } + } - if (!flag) {} + if (!flag) { ret = wc_Sha512Final(NULL, hash1); if (ret != BAD_FUNC_ARG) { flag = WOLFSSL_FATAL_ERROR; @@ -11745,21 +11751,20 @@ static int test_wc_Sha512Final(void) wc_Sha512Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha512Final */ /* * Unit test function for wc_Sha512GetFlags() */ static int test_wc_Sha512GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA512) && defined(WOLFSSL_HASH_FLAGS) wc_Sha512 sha512; word32 flags = 0; - - printf(testingFmt, "wc_Sha512GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512(&sha512); @@ -11772,20 +11777,18 @@ static int test_wc_Sha512GetFlags(void) } } - wc_Sha512Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha512GetFlags */ /* * Unit test function for wc_Sha512FinalRaw() */ static int test_wc_Sha512FinalRaw(void) { - int flag = 0; + int res = TEST_SKIPPED; #if (defined(WOLFSSL_SHA512) && !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))) && \ !defined(WOLFSSL_NO_HASH_RAW) @@ -11795,6 +11798,7 @@ static int test_wc_Sha512FinalRaw(void) byte hash2[2*WC_SHA512_DIGEST_SIZE]; byte hash3[5*WC_SHA512_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha512(&sha512); @@ -11811,8 +11815,6 @@ static int test_wc_Sha512FinalRaw(void) times = sizeof(hash_test) / sizeof(byte*); /* Good test args. */ - printf(testingFmt, "wc_Sha512FinalRaw()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha512FinalRaw(&sha512, hash_test[i]); @@ -11846,10 +11848,9 @@ static int test_wc_Sha512FinalRaw(void) wc_Sha512Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha512FinalRaw */ /* @@ -11857,15 +11858,13 @@ static int test_wc_Sha512FinalRaw(void) */ static int test_wc_Sha512Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 - printf(testingFmt, "wc_Sha512Free()"); wc_Sha512Free(NULL); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(1); #endif - return flag; - + return res; } /* END test_wc_Sha512Free */ #ifdef WOLFSSL_SHA512 @@ -11903,7 +11902,7 @@ static int test_Sha512_Family_GetHash(int type ) } if (initFp == NULL || ghashFp == NULL) - return WOLFSSL_FATAL_ERROR; + return TEST_FAIL; if (!flag) { flag = initFp(&sha512); @@ -11940,12 +11939,11 @@ static int test_Sha512_Family_GetHash(int type ) */ static int test_wc_Sha512GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 wc_Sha512 sha512; byte hash1[WC_SHA512_DIGEST_SIZE]; - - printf(testingFmt, "wc_Sha512GetHash()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512(&sha512); @@ -11975,10 +11973,9 @@ static int test_wc_Sha512GetHash(void) wc_Sha512Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha512GetHash */ /* @@ -11986,12 +11983,11 @@ static int test_wc_Sha512GetHash(void) */ static int test_wc_Sha512Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA512 wc_Sha512 sha512; wc_Sha512 temp; - - printf(testingFmt, "wc_Sha512Copy()"); + int flag; /* Initialize */ flag = wc_InitSha512(&sha512); @@ -12024,21 +12020,19 @@ static int test_wc_Sha512Copy(void) wc_Sha512Free(&sha512); wc_Sha512Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha512Copy */ static int test_wc_InitSha512_224(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) wc_Sha512 sha512; int ret; - - printf(testingFmt, "wc_InitSha512_224()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha512_224(&sha512); @@ -12056,31 +12050,28 @@ static int test_wc_InitSha512_224(void) wc_Sha512_224Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_224 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_224Update(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) wc_Sha512 sha512; byte hash[WC_SHA512_DIGEST_SIZE]; testVector a, c; int ret; + int flag = 0; ret = wc_InitSha512_224(&sha512); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha512_224Update()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -12154,36 +12145,33 @@ static int test_wc_Sha512_224Update(void) wc_Sha512_224Free(&sha512); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_224 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_224Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) - printf(testingFmt, "wc_Sha512_224Final()"); - flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_224, 0); - printf(resultFmt, flag == 0 ? passed : failed); + int ret = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_224, 0); + + res = TEST_RES_CHECK(ret == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_224 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; + return res; } static int test_wc_Sha512_224GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) && defined(WOLFSSL_HASH_FLAGS) wc_Sha512 sha512, copy; word32 flags = 0; - - printf(testingFmt, "wc_Sha512_224GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512_224(&sha512); @@ -12205,65 +12193,58 @@ static int test_wc_Sha512_224GetFlags(void) wc_Sha512_224Free(©); wc_Sha512_224Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_224FinalRaw(void) { - int flag = 0; - + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && \ defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) && \ !defined(WOLFSSL_NO_HASH_RAW) - printf(testingFmt, "wc_Sha512_224FinalRaw()"); - flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_224, 1); - printf(resultFmt, flag == 0 ? passed : failed); + int ret = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_224, 1); + + res = TEST_RES_CHECK(ret == 0); #endif - return flag; - + return res; } static int test_wc_Sha512_224Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) - printf(testingFmt, "wc_Sha512_224Free()"); wc_Sha512_224Free(NULL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_224GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) - printf(testingFmt, "wc_Sha512_224GetHash()"); - flag = test_Sha512_Family_GetHash(WC_HASH_TYPE_SHA512_224); - printf(resultFmt, flag == 0 ? passed : failed); + int ret = test_Sha512_Family_GetHash(WC_HASH_TYPE_SHA512_224); + + res = TEST_RES_CHECK(ret == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_224Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) wc_Sha512 sha512; wc_Sha512 temp; - - printf(testingFmt, "wc_Sha512_224Copy()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512_224(&sha512); @@ -12290,22 +12271,20 @@ static int test_wc_Sha512_224Copy(void) wc_Sha512_224Free(&sha512); wc_Sha512_224Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_InitSha512_256(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; int ret; - - printf(testingFmt, "wc_InitSha512_256()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha512_256(&sha512); @@ -12323,31 +12302,28 @@ static int test_wc_InitSha512_256(void) wc_Sha512_256Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_256 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_256Update(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; byte hash[WC_SHA512_DIGEST_SIZE]; testVector a, c; int ret; + int flag = 0; ret = wc_InitSha512_256(&sha512); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha512_256Update()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -12422,36 +12398,33 @@ static int test_wc_Sha512_256Update(void) wc_Sha512_256Free(&sha512); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_256 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_256Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) - printf(testingFmt, "wc_Sha512_256Final()"); - flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_256, 0); - printf(resultFmt, flag == 0 ? passed : failed); + int ret = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_256, 0); + + res = TEST_RES_CHECK(ret == 0); #endif /* WOLFSSL_SHA512 && !WOLFSSL_NOSHA512_256 */ #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; + return res; } static int test_wc_Sha512_256GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) && defined(WOLFSSL_HASH_FLAGS) wc_Sha512 sha512, copy; word32 flags = 0; - - printf(testingFmt, "wc_Sha512_256GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512_256(&sha512); @@ -12473,64 +12446,59 @@ static int test_wc_Sha512_256GetFlags(void) wc_Sha512_256Free(&sha512); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_256FinalRaw(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && \ defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) && \ !defined(WOLFSSL_NO_HASH_RAW) - printf(testingFmt, "wc_Sha512_256FinalRaw()"); - flag = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_256, 1); - printf(resultFmt, flag == 0 ? passed : failed); -#endif - return flag; + int ret = test_Sha512_Family_Final(WC_HASH_TYPE_SHA512_256, 1); + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } static int test_wc_Sha512_256Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) - printf(testingFmt, "wc_Sha512_256Free()"); wc_Sha512_256Free(NULL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } static int test_wc_Sha512_256GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) - printf(testingFmt, "wc_Sha512_256GetHash()"); - flag = test_Sha512_Family_GetHash(WC_HASH_TYPE_SHA512_256); - printf(resultFmt, flag == 0 ? passed : failed); + int ret = test_Sha512_Family_GetHash(WC_HASH_TYPE_SHA512_256); + + res = TEST_RES_CHECK(ret == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; + return res; } static int test_wc_Sha512_256Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) wc_Sha512 sha512; wc_Sha512 temp; - - printf(testingFmt, "wc_Sha512_256Copy()"); + int flag = 0; /* Initialize */ flag = wc_InitSha512_256(&sha512); @@ -12557,11 +12525,10 @@ static int test_wc_Sha512_256Copy(void) wc_Sha512_256Free(&sha512); wc_Sha512_256Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif #endif /* !HAVE_FIPS && !HAVE_SELFTEST */ - return flag; - + return res; } @@ -12571,12 +12538,11 @@ static int test_wc_Sha512_256Copy(void) */ static int test_wc_InitSha384(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 wc_Sha384 sha384; int ret; - - printf(testingFmt, "wc_InitSha384()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha384(&sha384); @@ -12594,9 +12560,9 @@ static int test_wc_InitSha384(void) wc_Sha384Free(&sha384); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitSha384 */ @@ -12605,21 +12571,19 @@ static int test_wc_InitSha384(void) */ static int test_wc_Sha384Update(void) { - - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 wc_Sha384 sha384; byte hash[WC_SHA384_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitSha384(&sha384); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha384Update()"); - /* Input */ if (!flag) { a.input = "a"; @@ -12707,11 +12671,9 @@ static int test_wc_Sha384Update(void) wc_Sha384Free(&sha384); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384Update */ /* @@ -12719,7 +12681,7 @@ static int test_wc_Sha384Update(void) */ static int test_wc_Sha384Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 wc_Sha384 sha384; byte* hash_test[3]; @@ -12727,6 +12689,7 @@ static int test_wc_Sha384Final(void) byte hash2[2*WC_SHA384_DIGEST_SIZE]; byte hash3[5*WC_SHA384_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha384(&sha384); @@ -12743,8 +12706,6 @@ static int test_wc_Sha384Final(void) times = sizeof(hash_test) / sizeof(byte*); /* Good test args. */ - printf(testingFmt, "wc_Sha384Final()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha384Final(&sha384, hash_test[i]); @@ -12778,10 +12739,9 @@ static int test_wc_Sha384Final(void) wc_Sha384Free(&sha384); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384Final */ /* @@ -12789,12 +12749,11 @@ static int test_wc_Sha384Final(void) */ static int test_wc_Sha384GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA384) && defined(WOLFSSL_HASH_FLAGS) wc_Sha384 sha384; word32 flags = 0; - - printf(testingFmt, "wc_Sha384GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha384(&sha384); @@ -12807,13 +12766,11 @@ static int test_wc_Sha384GetFlags(void) } } - wc_Sha384Free(&sha384); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384GetFlags */ /* @@ -12821,7 +12778,7 @@ static int test_wc_Sha384GetFlags(void) */ static int test_wc_Sha384FinalRaw(void) { - int flag = 0; + int res = TEST_SKIPPED; #if (defined(WOLFSSL_SHA384) && !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3)))) && \ !defined(WOLFSSL_NO_HASH_RAW) @@ -12831,6 +12788,7 @@ static int test_wc_Sha384FinalRaw(void) byte hash2[2*WC_SHA384_DIGEST_SIZE]; byte hash3[5*WC_SHA384_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha384(&sha384); @@ -12847,8 +12805,6 @@ static int test_wc_Sha384FinalRaw(void) times = sizeof(hash_test) / sizeof(byte*); /* Good test args. */ - printf(testingFmt, "wc_Sha384FinalRaw()"); - for (i = 0; i < times; i++) { if (!flag) { ret = wc_Sha384FinalRaw(&sha384, hash_test[i]); @@ -12882,9 +12838,9 @@ static int test_wc_Sha384FinalRaw(void) wc_Sha384Free(&sha384); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384FinalRaw */ /* @@ -12892,15 +12848,13 @@ static int test_wc_Sha384FinalRaw(void) */ static int test_wc_Sha384Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 - printf(testingFmt, "wc_Sha384Free()"); wc_Sha384Free(NULL); - - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(1); #endif - return flag; + return res; } /* END test_wc_Sha384Free */ /* @@ -12908,12 +12862,11 @@ static int test_wc_Sha384Free(void) */ static int test_wc_Sha384GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 wc_Sha384 sha384; byte hash1[WC_SHA384_DIGEST_SIZE]; - - printf(testingFmt, "wc_Sha384GetHash()"); + int flag = 0; /* Initialize */ flag = wc_InitSha384(&sha384); @@ -12943,9 +12896,9 @@ static int test_wc_Sha384GetHash(void) wc_Sha384Free(&sha384); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384GetHash */ /* @@ -12953,12 +12906,11 @@ static int test_wc_Sha384GetHash(void) */ static int test_wc_Sha384Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA384 wc_Sha384 sha384; wc_Sha384 temp; - - printf(testingFmt, "wc_Sha384Copy()"); + int flag = 0; /* Initialize */ flag = wc_InitSha384(&sha384); @@ -12991,9 +12943,9 @@ static int test_wc_Sha384Copy(void) wc_Sha384Free(&sha384); wc_Sha384Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384Copy */ @@ -13002,12 +12954,11 @@ static int test_wc_Sha384Copy(void) */ static int test_wc_InitSha224(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 wc_Sha224 sha224; int ret; - - printf(testingFmt, "wc_InitSha224()"); + int flag = 0; /* Test good arg. */ ret = wc_InitSha224(&sha224); @@ -13024,10 +12975,10 @@ static int test_wc_InitSha224(void) } wc_Sha224Free(&sha224); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitSha224 */ /* @@ -13035,20 +12986,19 @@ static int test_wc_InitSha224(void) */ static int test_wc_Sha224Update(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 wc_Sha224 sha224; byte hash[WC_SHA224_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitSha224(&sha224); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_Sha224Update()"); - /* Input. */ if (!flag) { a.input = "a"; @@ -13134,10 +13084,9 @@ static int test_wc_Sha224Update(void) wc_Sha224Free(&sha224); - /* If not returned then the unit test passed test vectors. */ - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224Update */ @@ -13146,7 +13095,7 @@ static int test_wc_Sha224Update(void) */ static int test_wc_Sha224Final(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 wc_Sha224 sha224; byte* hash_test[3]; @@ -13154,6 +13103,7 @@ static int test_wc_Sha224Final(void) byte hash2[2*WC_SHA224_DIGEST_SIZE]; byte hash3[5*WC_SHA224_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitSha224(&sha224); @@ -13170,7 +13120,6 @@ static int test_wc_Sha224Final(void) times = sizeof(hash_test) / sizeof(byte*); /* Good test args. */ - printf(testingFmt, "wc_sha224Final()"); /* Testing oversized buffers. */ for (i = 0; i < times; i++) { if (!flag) { @@ -13205,9 +13154,9 @@ static int test_wc_Sha224Final(void) wc_Sha224Free(&sha224); - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224Final */ /* @@ -13215,12 +13164,11 @@ static int test_wc_Sha224Final(void) */ static int test_wc_Sha224SetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA224) && defined(WOLFSSL_HASH_FLAGS) wc_Sha224 sha224; word32 flags = 0; - - printf(testingFmt, "wc_Sha224SetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha224(&sha224); @@ -13235,11 +13183,9 @@ static int test_wc_Sha224SetFlags(void) wc_Sha224Free(&sha224); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha224SetFlags */ /* @@ -13247,12 +13193,11 @@ static int test_wc_Sha224SetFlags(void) */ static int test_wc_Sha224GetFlags(void) { - int flag = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA224) && defined(WOLFSSL_HASH_FLAGS) wc_Sha224 sha224; word32 flags = 0; - - printf(testingFmt, "wc_Sha224GetFlags()"); + int flag = 0; /* Initialize */ flag = wc_InitSha224(&sha224); @@ -13265,13 +13210,11 @@ static int test_wc_Sha224GetFlags(void) } } - wc_Sha224Free(&sha224); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224GetFlags */ /* @@ -13279,15 +13222,13 @@ static int test_wc_Sha224GetFlags(void) */ static int test_wc_Sha224Free(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 - printf(testingFmt, "wc_Sha224Free()"); wc_Sha224Free(NULL); - - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(1); #endif - return flag; + return res; } /* END test_wc_Sha224Free */ @@ -13296,12 +13237,11 @@ static int test_wc_Sha224Free(void) */ static int test_wc_Sha224GetHash(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 wc_Sha224 sha224; byte hash1[WC_SHA224_DIGEST_SIZE]; - - printf(testingFmt, "wc_Sha224GetHash()"); + int flag = 0; /* Initialize */ flag = wc_InitSha224(&sha224); @@ -13331,11 +13271,9 @@ static int test_wc_Sha224GetHash(void) wc_Sha224Free(&sha224); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha224GetHash */ /* @@ -13343,12 +13281,11 @@ static int test_wc_Sha224GetHash(void) */ static int test_wc_Sha224Copy(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHA224 wc_Sha224 sha224; wc_Sha224 temp; - - printf(testingFmt, "wc_Sha224Copy()"); + int flag = 0; /* Initialize */ flag = wc_InitSha224(&sha224); @@ -13382,11 +13319,9 @@ static int test_wc_Sha224Copy(void) wc_Sha224Free(&sha224); wc_Sha224Free(&temp); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; - + return res; } /* END test_wc_Sha224Copy */ @@ -13395,12 +13330,11 @@ static int test_wc_Sha224Copy(void) */ static int test_wc_InitRipeMd(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; int ret; - - printf(testingFmt, "wc_InitRipeMd()"); + int flag = 0; /* Test good arg. */ ret = wc_InitRipeMd(&ripemd); @@ -13416,10 +13350,9 @@ static int test_wc_InitRipeMd(void) } } - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_InitRipeMd */ @@ -13428,21 +13361,19 @@ static int test_wc_InitRipeMd(void) */ static int test_wc_RipeMdUpdate(void) { - - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; byte hash[RIPEMD_DIGEST_SIZE]; testVector a, b, c; int ret; + int flag = 0; ret = wc_InitRipeMd(&ripemd); if (ret != 0) { flag = ret; } - printf(testingFmt, "wc_RipeMdUpdate()"); - /* Input */ if (!flag) { a.input = "a"; @@ -13516,10 +13447,9 @@ static int test_wc_RipeMdUpdate(void) } } - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_RipeMdUdpate */ @@ -13528,7 +13458,7 @@ static int test_wc_RipeMdUpdate(void) */ static int test_wc_RipeMdFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_RIPEMD RipeMd ripemd; byte* hash_test[3]; @@ -13536,6 +13466,7 @@ static int test_wc_RipeMdFinal(void) byte hash2[2*RIPEMD_DIGEST_SIZE]; byte hash3[5*RIPEMD_DIGEST_SIZE]; int times, i, ret; + int flag = 0; /* Initialize */ ret = wc_InitRipeMd(&ripemd); @@ -13551,8 +13482,6 @@ static int test_wc_RipeMdFinal(void) times = sizeof(hash_test) / sizeof(byte*); - /* Good test args. */ - printf(testingFmt, "wc_RipeMdFinal()"); /* Testing oversized buffers. */ for (i = 0; i < times; i++) { if (!flag) { @@ -13585,9 +13514,9 @@ static int test_wc_RipeMdFinal(void) } } - printf(resultFmt, flag == 0 ? passed : failed); + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_RipeMdFinal */ @@ -13597,15 +13526,14 @@ static int test_wc_RipeMdFinal(void) */ static int test_wc_InitSha3(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) - wc_Sha3 sha3; + wc_Sha3 sha3; + int ret = 0; (void)sha3; #if !defined(WOLFSSL_NOSHA3_224) - printf(testingFmt, "wc_InitSha3_224()"); - ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); /* Test bad args. */ @@ -13613,69 +13541,65 @@ static int test_wc_InitSha3(void) ret = wc_InitSha3_224(NULL, HEAP_HINT, testDevId); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_224_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); #endif /* NOSHA3_224 */ #if !defined(WOLFSSL_NOSHA3_256) if (ret == 0) { - printf(testingFmt, "wc_InitSha3_256()"); - ret = wc_InitSha3_256(&sha3, HEAP_HINT, testDevId); /* Test bad args. */ if (ret == 0) { ret = wc_InitSha3_256(NULL, HEAP_HINT, testDevId); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_256_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); } /* END sha3_256 */ #endif /* NOSHA3_256 */ #if !defined(WOLFSSL_NOSHA3_384) if (ret == 0) { - printf(testingFmt, "wc_InitSha3_384()"); - ret = wc_InitSha3_384(&sha3, HEAP_HINT, testDevId); /* Test bad args. */ if (ret == 0) { ret = wc_InitSha3_384(NULL, HEAP_HINT, testDevId); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_384_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); } /* END sha3_384 */ #endif /* NOSHA3_384 */ #if !defined(WOLFSSL_NOSHA3_512) if (ret == 0) { - printf(testingFmt, "wc_InitSha3_512()"); - ret = wc_InitSha3_512(&sha3, HEAP_HINT, testDevId); /* Test bad args. */ if (ret == 0) { ret = wc_InitSha3_512(NULL, HEAP_HINT, testDevId); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_512_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); } /* END sha3_512 */ #endif /* NOSHA3_512 */ + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_InitSha3 */ @@ -13685,28 +13609,26 @@ static int test_wc_InitSha3(void) */ static int testing_wc_Sha3_Update(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_XILINX_CRYPT) && \ !defined(WOLFSSL_AFALG_XILINX) - wc_Sha3 sha3; - byte msg[] = "Everybody's working for the weekend."; - byte msg2[] = "Everybody gets Friday off."; - byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20" - "\x77\x6f\x72\x6b\x69\x6e\x67\x20\x66\x6f\x72\x20\x74" - "\x68\x65\x20\x77\x65\x65\x6b\x65\x6e\x64\x2e\x45\x76" - "\x65\x72\x79\x62\x6f\x64\x79\x20\x67\x65\x74\x73\x20" - "\x46\x72\x69\x64\x61\x79\x20\x6f\x66\x66\x2e"; - word32 msglen = sizeof(msg) - 1; - word32 msg2len = sizeof(msg2); - word32 msgCmplen = sizeof(msgCmp); + wc_Sha3 sha3; + byte msg[] = "Everybody's working for the weekend."; + byte msg2[] = "Everybody gets Friday off."; + byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20" + "\x77\x6f\x72\x6b\x69\x6e\x67\x20\x66\x6f\x72\x20\x74" + "\x68\x65\x20\x77\x65\x65\x6b\x65\x6e\x64\x2e\x45\x76" + "\x65\x72\x79\x62\x6f\x64\x79\x20\x67\x65\x74\x73\x20" + "\x46\x72\x69\x64\x61\x79\x20\x6f\x66\x66\x2e"; + word32 msglen = sizeof(msg) - 1; + word32 msg2len = sizeof(msg2); + word32 msgCmplen = sizeof(msgCmp); + int ret = 0; #if !defined(WOLFSSL_NOSHA3_224) - printf(testingFmt, "wc_Sha3_224_Update()"); - ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_224_Update(&sha3, msg, msglen); @@ -13728,7 +13650,7 @@ static int testing_wc_Sha3_Update(void) if (ret == BAD_FUNC_ARG) { wc_Sha3_224_Free(&sha3); if (wc_InitSha3_224(&sha3, HEAP_HINT, testDevId)) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_224_Update(&sha3, NULL, 0); if (ret == 0) { @@ -13740,17 +13662,13 @@ static int testing_wc_Sha3_Update(void) } } wc_Sha3_224_Free(&sha3); - - printf(resultFmt, ret == 0 ? passed : failed); #endif /* SHA3_224 */ #if !defined(WOLFSSL_NOSHA3_256) if (ret == 0) { - printf(testingFmt, "wc_Sha3_256_Update()"); - ret = wc_InitSha3_256(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_256_Update(&sha3, msg, msglen); if (XMEMCMP(msg, sha3.t, msglen) || sha3.i != msglen) { @@ -13771,7 +13689,7 @@ static int testing_wc_Sha3_Update(void) if (ret == BAD_FUNC_ARG) { wc_Sha3_256_Free(&sha3); if (wc_InitSha3_256(&sha3, HEAP_HINT, testDevId)) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_256_Update(&sha3, NULL, 0); if (ret == 0) { @@ -13783,18 +13701,14 @@ static int testing_wc_Sha3_Update(void) } } wc_Sha3_256_Free(&sha3); - - printf(resultFmt, ret == 0 ? passed : failed); } #endif /* SHA3_256 */ #if !defined(WOLFSSL_NOSHA3_384) if (ret == 0) { - printf(testingFmt, "wc_Sha3_384_Update()"); - ret = wc_InitSha3_384(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_384_Update(&sha3, msg, msglen); if (XMEMCMP(msg, sha3.t, msglen) || sha3.i != msglen) { @@ -13815,7 +13729,7 @@ static int testing_wc_Sha3_Update(void) if (ret == BAD_FUNC_ARG) { wc_Sha3_384_Free(&sha3); if (wc_InitSha3_384(&sha3, HEAP_HINT, testDevId)) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_384_Update(&sha3, NULL, 0); if (ret == 0) { @@ -13827,18 +13741,14 @@ static int testing_wc_Sha3_Update(void) } } wc_Sha3_384_Free(&sha3); - - printf(resultFmt, ret == 0 ? passed : failed); } #endif /* SHA3_384 */ #if !defined(WOLFSSL_NOSHA3_512) if (ret == 0) { - printf(testingFmt, "wc_Sha3_512_Update()"); - ret = wc_InitSha3_512(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_512_Update(&sha3, msg, msglen); if (XMEMCMP(msg, sha3.t, msglen) || sha3.i != msglen) { @@ -13859,7 +13769,7 @@ static int testing_wc_Sha3_Update(void) if (ret == BAD_FUNC_ARG) { wc_Sha3_512_Free(&sha3); if (wc_InitSha3_512(&sha3, HEAP_HINT, testDevId)) { - return ret; + return TEST_FAIL; } ret = wc_Sha3_512_Update(&sha3, NULL, 0); if (ret == 0) { @@ -13871,11 +13781,12 @@ static int testing_wc_Sha3_Update(void) } } wc_Sha3_512_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); } #endif /* SHA3_512 */ + + res = TEST_RES_CHECK(ret == 0); #endif /* WOLFSSL_SHA3 */ - return ret; + return res; } /* END testing_wc_Sha3_Update */ @@ -13884,10 +13795,9 @@ static int testing_wc_Sha3_Update(void) */ static int test_wc_Sha3_224_Final(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224) - wc_Sha3 sha3; + wc_Sha3 sha3; const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom" "nopnopq"; const char* expOut = "\x8a\x24\x10\x8b\x15\x4a\xda\x21\xc9\xfd\x55" @@ -13895,15 +13805,14 @@ static int test_wc_Sha3_224_Final(void) "\x64\xea\xd0\xfc\xce\x33"; byte hash[WC_SHA3_224_DIGEST_SIZE]; byte hashRet[WC_SHA3_224_DIGEST_SIZE]; + int ret = 0; /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); - printf(testingFmt, "wc_Sha3_224_Final()"); - ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret= wc_Sha3_224_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)); @@ -13921,19 +13830,17 @@ static int test_wc_Sha3_224_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_224_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_Sha3_224_GetHash()"); - ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } /* Init stack variables. */ @@ -13959,17 +13866,18 @@ static int test_wc_Sha3_224_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); } wc_Sha3_224_Free(&sha3); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_224_Final */ @@ -13978,10 +13886,9 @@ static int test_wc_Sha3_224_Final(void) */ static int test_wc_Sha3_256_Final(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256) - wc_Sha3 sha3; + wc_Sha3 sha3; const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom" "nopnopq"; const char* expOut = "\x41\xc0\xdb\xa2\xa9\xd6\x24\x08\x49\x10\x03\x76\xa8" @@ -13989,15 +13896,14 @@ static int test_wc_Sha3_256_Final(void) "\xdd\x97\x49\x6d\x33\x76"; byte hash[WC_SHA3_256_DIGEST_SIZE]; byte hashRet[WC_SHA3_256_DIGEST_SIZE]; + int ret = 0; /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); - printf(testingFmt, "wc_Sha3_256_Final()"); - ret = wc_InitSha3_256(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret= wc_Sha3_256_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)); @@ -14015,19 +13921,17 @@ static int test_wc_Sha3_256_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_256_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_Sha3_256_GetHash()"); - ret = wc_InitSha3_256(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); @@ -14051,17 +13955,18 @@ static int test_wc_Sha3_256_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); } wc_Sha3_256_Free(&sha3); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_256_Final */ @@ -14070,8 +13975,7 @@ static int test_wc_Sha3_256_Final(void) */ static int test_wc_Sha3_384_Final(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384) wc_Sha3 sha3; const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom" @@ -14082,15 +13986,14 @@ static int test_wc_Sha3_384_Final(void) "\xa1\x9e\xef\x51\xac\xd0\x65\x7c\x22"; byte hash[WC_SHA3_384_DIGEST_SIZE]; byte hashRet[WC_SHA3_384_DIGEST_SIZE]; + int ret = 0; /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); - printf(testingFmt, "wc_Sha3_384_Final()"); - ret = wc_InitSha3_384(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret= wc_Sha3_384_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)); @@ -14108,19 +14011,17 @@ static int test_wc_Sha3_384_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_384_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_Sha3_384_GetHash()"); - ret = wc_InitSha3_384(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); @@ -14144,17 +14045,18 @@ static int test_wc_Sha3_384_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); } wc_Sha3_384_Free(&sha3); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_384_Final */ @@ -14164,11 +14066,10 @@ static int test_wc_Sha3_384_Final(void) */ static int test_wc_Sha3_512_Final(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512) && \ !defined(WOLFSSL_NOSHA3_384) - wc_Sha3 sha3; + wc_Sha3 sha3; const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom" "nopnopq"; const char* expOut = "\x04\xa3\x71\xe8\x4e\xcf\xb5\xb8\xb7\x7c\xb4\x86\x10" @@ -14178,15 +14079,14 @@ static int test_wc_Sha3_512_Final(void) "\x9c\x03\x0d\x99\xa2\x7d\xaf\x11\x39\xd6\xe7\x5e"; byte hash[WC_SHA3_512_DIGEST_SIZE]; byte hashRet[WC_SHA3_512_DIGEST_SIZE]; + int ret = 0; /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); - printf(testingFmt, "wc_Sha3_512_Final()"); - ret = wc_InitSha3_512(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret= wc_Sha3_512_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)); @@ -14204,19 +14104,17 @@ static int test_wc_Sha3_512_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Sha3_512_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_Sha3_512_GetHash()"); - ret = wc_InitSha3_512(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); @@ -14240,17 +14138,18 @@ static int test_wc_Sha3_512_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); } wc_Sha3_512_Free(&sha3); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_512_Final */ @@ -14259,28 +14158,27 @@ static int test_wc_Sha3_512_Final(void) */ static int test_wc_Sha3_224_Copy(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224) - wc_Sha3 sha3, sha3Cpy; + wc_Sha3 sha3, sha3Cpy; const char* msg = TEST_STRING; word32 msglen = (word32)TEST_STRING_SZ; byte hash[WC_SHA3_224_DIGEST_SIZE]; byte hashCpy[WC_SHA3_224_DIGEST_SIZE]; + int ret = 0; XMEMSET(hash, 0, sizeof(hash)); XMEMSET(hashCpy, 0, sizeof(hashCpy)); - printf(testingFmt, "wc_Sha3_224_Copy()"); - ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_InitSha3_224(&sha3Cpy, HEAP_HINT, testDevId); if (ret != 0) { - wc_Sha3_224_Free(&sha3); - return ret; + wc_Sha3_224_Free(&sha3); + return TEST_FAIL; } ret = wc_Sha3_224_Update(&sha3, (byte*)msg, msglen); @@ -14305,15 +14203,15 @@ static int test_wc_Sha3_224_Copy(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_224_Copy */ @@ -14324,28 +14222,27 @@ static int test_wc_Sha3_224_Copy(void) */ static int test_wc_Sha3_256_Copy(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256) - wc_Sha3 sha3, sha3Cpy; + wc_Sha3 sha3, sha3Cpy; const char* msg = TEST_STRING; word32 msglen = (word32)TEST_STRING_SZ; byte hash[WC_SHA3_256_DIGEST_SIZE]; byte hashCpy[WC_SHA3_256_DIGEST_SIZE]; + int ret = 0; XMEMSET(hash, 0, sizeof(hash)); XMEMSET(hashCpy, 0, sizeof(hashCpy)); - printf(testingFmt, "wc_Sha3_256_Copy()"); - ret = wc_InitSha3_256(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_InitSha3_256(&sha3Cpy, HEAP_HINT, testDevId); if (ret != 0) { - wc_Sha3_256_Free(&sha3); - return ret; + wc_Sha3_256_Free(&sha3); + return TEST_FAIL; } ret = wc_Sha3_256_Update(&sha3, (byte*)msg, msglen); @@ -14370,15 +14267,15 @@ static int test_wc_Sha3_256_Copy(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_256_Copy */ @@ -14389,28 +14286,27 @@ static int test_wc_Sha3_256_Copy(void) */ static int test_wc_Sha3_384_Copy(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384) - wc_Sha3 sha3, sha3Cpy; + wc_Sha3 sha3, sha3Cpy; const char* msg = TEST_STRING; word32 msglen = (word32)TEST_STRING_SZ; byte hash[WC_SHA3_384_DIGEST_SIZE]; byte hashCpy[WC_SHA3_384_DIGEST_SIZE]; + int ret = 0; XMEMSET(hash, 0, sizeof(hash)); XMEMSET(hashCpy, 0, sizeof(hashCpy)); - printf(testingFmt, "wc_Sha3_384_Copy()"); - ret = wc_InitSha3_384(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_InitSha3_384(&sha3Cpy, HEAP_HINT, testDevId); if (ret != 0) { - wc_Sha3_384_Free(&sha3); - return ret; + wc_Sha3_384_Free(&sha3); + return TEST_FAIL; } ret = wc_Sha3_384_Update(&sha3, (byte*)msg, msglen); @@ -14435,15 +14331,15 @@ static int test_wc_Sha3_384_Copy(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_384_Copy */ @@ -14453,30 +14349,27 @@ static int test_wc_Sha3_384_Copy(void) */ static int test_wc_Sha3_512_Copy(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512) - wc_Sha3 sha3, sha3Cpy; + wc_Sha3 sha3, sha3Cpy; const char* msg = TEST_STRING; word32 msglen = (word32)TEST_STRING_SZ; byte hash[WC_SHA3_512_DIGEST_SIZE]; byte hashCpy[WC_SHA3_512_DIGEST_SIZE]; + int ret = 0; XMEMSET(hash, 0, sizeof(hash)); XMEMSET(hashCpy, 0, sizeof(hashCpy)); - - printf(testingFmt, "wc_Sha3_512_Copy()"); - ret = wc_InitSha3_512(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_InitSha3_512(&sha3Cpy, HEAP_HINT, testDevId); if (ret != 0) { wc_Sha3_512_Free(&sha3); - return ret; + return TEST_FAIL; } ret = wc_Sha3_512_Update(&sha3, (byte*)msg, msglen); @@ -14501,15 +14394,15 @@ static int test_wc_Sha3_512_Copy(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_512_Copy */ /* @@ -14517,18 +14410,16 @@ static int test_wc_Sha3_512_Copy(void) */ static int test_wc_Sha3_GetFlags(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_SHA3) && defined(WOLFSSL_HASH_FLAGS) - wc_Sha3 sha3; - word32 flags = 0; - - - printf(testingFmt, "wc_Sha3_GetFlags()"); + wc_Sha3 sha3; + word32 flags = 0; + int ret = 0; /* Initialize */ ret = wc_InitSha3_224(&sha3, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } if (ret == 0) { ret = wc_Sha3_GetFlags(&sha3, &flags); @@ -14539,23 +14430,20 @@ static int test_wc_Sha3_GetFlags(void) } } wc_Sha3_224_Free(&sha3); - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Sha3_GetFlags */ - - static int test_wc_InitShake256(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHAKE256 - wc_Shake shake; - - printf(testingFmt, "wc_InitShake256()"); + wc_Shake shake; + int ret = 0; ret = wc_InitShake256(&shake, HEAP_HINT, testDevId); /* Test bad args. */ @@ -14563,40 +14451,40 @@ static int test_wc_InitShake256(void) ret = wc_InitShake256(NULL, HEAP_HINT, testDevId); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Shake256_Free(&shake); - printf(resultFmt, ret == 0 ? passed : failed); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_InitSha3 */ static int testing_wc_Shake256_Update(void) { - int ret = 0; - + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHAKE256 - wc_Shake shake; - byte msg[] = "Everybody's working for the weekend."; - byte msg2[] = "Everybody gets Friday off."; - byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20" + wc_Shake shake; + byte msg[] = "Everybody's working for the weekend."; + byte msg2[] = "Everybody gets Friday off."; + byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20" "\x77\x6f\x72\x6b\x69\x6e\x67\x20\x66\x6f\x72\x20\x74" "\x68\x65\x20\x77\x65\x65\x6b\x65\x6e\x64\x2e\x45\x76" "\x65\x72\x79\x62\x6f\x64\x79\x20\x67\x65\x74\x73\x20" "\x46\x72\x69\x64\x61\x79\x20\x6f\x66\x66\x2e"; - word32 msglen = sizeof(msg) - 1; - word32 msg2len = sizeof(msg2); - word32 msgCmplen = sizeof(msgCmp); - - printf(testingFmt, "wc_Shake256_Update()"); + word32 msglen = sizeof(msg) - 1; + word32 msg2len = sizeof(msg2); + word32 msgCmplen = sizeof(msgCmp); + int ret = 0; ret = wc_InitShake256(&shake, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_Shake256_Update(&shake, msg, msglen); if (XMEMCMP(msg, shake.t, msglen) || shake.i != msglen) { @@ -14617,7 +14505,7 @@ static int testing_wc_Shake256_Update(void) if (ret == BAD_FUNC_ARG) { wc_Shake256_Free(&shake); if (wc_InitShake256(&shake, HEAP_HINT, testDevId)) { - return ret; + return TEST_FAIL; } ret = wc_Shake256_Update(&shake, NULL, 0); if (ret == 0) { @@ -14630,17 +14518,14 @@ static int testing_wc_Shake256_Update(void) } wc_Shake256_Free(&shake); - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif /* WOLFSSL_SHAKE256 */ - - return ret; - + return res; } static int test_wc_Shake256_Final(void) { - int ret = 0; - + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHAKE256 wc_Shake shake; const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom" @@ -14655,15 +14540,14 @@ static int test_wc_Shake256_Final(void) "\x08\xba\xf1\x9b\xe2\x12\x33\xf3\xde\xbe\x78\xd0\x67" "\x60\xcf\xa5\x51\xee\x1e\x07\x91\x41\xd4"; byte hash[114]; + int ret = 0; /* Init stack variables. */ XMEMSET(hash, 0, sizeof(hash)); - printf(testingFmt, "wc_Shake256_Final()"); - ret = wc_InitShake256(&shake, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret= wc_Shake256_Update(&shake, (byte*)msg, (word32)XSTRLEN(msg)); @@ -14681,21 +14565,23 @@ static int test_wc_Shake256_Final(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Shake256_Free(&shake); - printf(resultFmt, ret == 0 ? passed : failed); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* * Testing wc_Shake256_Copy() */ static int test_wc_Shake256_Copy(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHAKE256 wc_Shake shake, shakeCpy; const char* msg = TEST_STRING; @@ -14704,21 +14590,20 @@ static int test_wc_Shake256_Copy(void) byte hashCpy[144]; word32 hashLen = sizeof(hash); word32 hashLenCpy = sizeof(hashCpy); + int ret; XMEMSET(hash, 0, sizeof(hash)); XMEMSET(hashCpy, 0, sizeof(hashCpy)); - printf(testingFmt, "wc_Shake256_Copy()"); - ret = wc_InitShake256(&shake, HEAP_HINT, testDevId); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_InitShake256(&shakeCpy, HEAP_HINT, testDevId); if (ret != 0) { wc_Shake256_Free(&shake); - return ret; + return TEST_FAIL; } ret = wc_Shake256_Update(&shake, (byte*)msg, msglen); @@ -14743,40 +14628,38 @@ static int test_wc_Shake256_Copy(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } wc_Shake256_Free(&shake); - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Shake256_Copy */ /* * Unit test function for wc_Shake256Hash() */ static int test_wc_Shake256Hash(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_SHAKE256 - const byte data[] = { /* Hello World */ 0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f, 0x72,0x6c,0x64 }; - word32 len = sizeof(data); - byte hash[144]; - word32 hashLen = sizeof(hash); - - printf(testingFmt, "wc_Shake256Hash()"); + word32 len = sizeof(data); + byte hash[144]; + word32 hashLen = sizeof(hash); + int ret; ret = wc_Shake256Hash(data, len, hash, hashLen); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Shake256Hash */ /* @@ -14784,10 +14667,11 @@ static int test_wc_Shake256Hash(void) */ static int test_wc_Md5HmacSetKey(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_MD5) Hmac hmac; - int ret, times, itr; + int ret, times, itr; + int flag = 0; const char* keys[]= { @@ -14801,21 +14685,20 @@ static int test_wc_Md5HmacSetKey(void) times = sizeof(keys) / sizeof(char*); flag = 0; - printf(testingFmt, "wc_HmacSetKey() with MD5"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) - return ret; + return TEST_FAIL; for (itr = 0; itr < times; itr++) { ret = wc_HmacSetKey(&hmac, WC_MD5, (byte*)keys[itr], (word32)XSTRLEN(keys[itr])); #if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 5) wc_HmacFree(&hmac); - if (ret == BAD_FUNC_ARG) - return 0; + if (ret == BAD_FUNC_ARG) { + return TEST_SUCCESS; + } else { - return WOLFSSL_FATAL_ERROR; + return TEST_FAIL; } #else if (ret != 0) { @@ -14863,10 +14746,9 @@ static int test_wc_Md5HmacSetKey(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Md5HmacSetKey */ @@ -14875,11 +14757,11 @@ static int test_wc_Md5HmacSetKey(void) */ static int test_wc_ShaHmacSetKey(void) { - - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; int ret, times, itr; + int flag = 0; const char* keys[]= { @@ -14895,8 +14777,6 @@ static int test_wc_ShaHmacSetKey(void) times = sizeof(keys) / sizeof(char*); flag = 0; - printf(testingFmt, "wc_HmacSetKey() with SHA"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -14948,10 +14828,9 @@ static int test_wc_ShaHmacSetKey(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_ShaHmacSetKey() */ /* @@ -14959,11 +14838,11 @@ static int test_wc_ShaHmacSetKey(void) */ static int test_wc_Sha224HmacSetKey(void) { - - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; int ret, times, itr; + int flag = 0; const char* keys[]= { @@ -14979,8 +14858,6 @@ static int test_wc_Sha224HmacSetKey(void) times = sizeof(keys) / sizeof(char*); flag = 0; - printf(testingFmt, "wc_HmacSetKey() with SHA 224"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15032,10 +14909,9 @@ static int test_wc_Sha224HmacSetKey(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224HmacSetKey() */ /* @@ -15043,11 +14919,11 @@ static int test_wc_Sha224HmacSetKey(void) */ static int test_wc_Sha256HmacSetKey(void) { - - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; int ret, times, itr; + int flag = 0; const char* keys[]= { @@ -15063,8 +14939,6 @@ static int test_wc_Sha256HmacSetKey(void) times = sizeof(keys) / sizeof(char*); flag = 0; - printf(testingFmt, "wc_HmacSetKey() with SHA256"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15116,10 +14990,9 @@ static int test_wc_Sha256HmacSetKey(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256HmacSetKey() */ @@ -15128,10 +15001,11 @@ static int test_wc_Sha256HmacSetKey(void) */ static int test_wc_Sha384HmacSetKey(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; int ret, times, itr; + int flag = 0; const char* keys[]= { @@ -15147,8 +15021,6 @@ static int test_wc_Sha384HmacSetKey(void) times = sizeof(keys) / sizeof(char*); flag = 0; - printf(testingFmt, "wc_HmacSetKey() with SHA384"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15200,10 +15072,9 @@ static int test_wc_Sha384HmacSetKey(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384HmacSetKey() */ @@ -15212,11 +15083,12 @@ static int test_wc_Sha384HmacSetKey(void) */ static int test_wc_Md5HmacUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_MD5) && !(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 5)) Hmac hmac; testVector a, b; int ret; + int flag = 0; #ifdef HAVE_FIPS const char* keys = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -15232,8 +15104,6 @@ static int test_wc_Md5HmacUpdate(void) flag = 0; - printf(testingFmt, "wc_HmacUpdate() with MD5"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15281,10 +15151,9 @@ static int test_wc_Md5HmacUpdate(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Md5HmacUpdate */ /* @@ -15292,11 +15161,12 @@ static int test_wc_Md5HmacUpdate(void) */ static int test_wc_ShaHmacUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; testVector a, b; int ret; + int flag = 0; #ifdef HAVE_FIPS const char* keys = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -15312,8 +15182,6 @@ static int test_wc_ShaHmacUpdate(void) flag = 0; - printf(testingFmt, "wc_HmacUpdate() with SHA"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15361,10 +15229,9 @@ static int test_wc_ShaHmacUpdate(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_ShaHmacUpdate */ /* @@ -15372,11 +15239,12 @@ static int test_wc_ShaHmacUpdate(void) */ static int test_wc_Sha224HmacUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; testVector a, b; int ret; + int flag = 0; #ifdef HAVE_FIPS const char* keys = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -15392,8 +15260,6 @@ static int test_wc_Sha224HmacUpdate(void) flag = 0; - printf(testingFmt, "wc_HmacUpdate() with SHA224"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15441,10 +15307,9 @@ static int test_wc_Sha224HmacUpdate(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224HmacUpdate */ /* @@ -15452,11 +15317,12 @@ static int test_wc_Sha224HmacUpdate(void) */ static int test_wc_Sha256HmacUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; testVector a, b; int ret; + int flag = 0; #ifdef HAVE_FIPS const char* keys = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -15472,8 +15338,6 @@ static int test_wc_Sha256HmacUpdate(void) flag = 0; - printf(testingFmt, "wc_HmacUpdate() with WC_SHA256"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15521,10 +15385,9 @@ static int test_wc_Sha256HmacUpdate(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256HmacUpdate */ /* @@ -15532,11 +15395,12 @@ static int test_wc_Sha256HmacUpdate(void) */ static int test_wc_Sha384HmacUpdate(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; testVector a, b; int ret; + int flag = 0; #ifdef HAVE_FIPS const char* keys = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; @@ -15552,8 +15416,6 @@ static int test_wc_Sha384HmacUpdate(void) flag = 0; - printf(testingFmt, "wc_HmacUpdate() with SHA384"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15601,10 +15463,9 @@ static int test_wc_Sha384HmacUpdate(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384HmacUpdate */ /* @@ -15613,13 +15474,14 @@ static int test_wc_Sha384HmacUpdate(void) static int test_wc_Md5HmacFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_MD5) && !(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 5)) Hmac hmac; byte hash[WC_MD5_DIGEST_SIZE]; testVector a; int ret; const char* key; + int flag = 0; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; a.input = "Hi There"; @@ -15630,8 +15492,6 @@ static int test_wc_Md5HmacFinal(void) flag = 0; - printf(testingFmt, "wc_HmacFinal() with MD5"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15680,10 +15540,9 @@ static int test_wc_Md5HmacFinal(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Md5HmacFinal */ @@ -15692,12 +15551,13 @@ static int test_wc_Md5HmacFinal(void) */ static int test_wc_ShaHmacFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA) Hmac hmac; byte hash[WC_SHA_DIGEST_SIZE]; testVector a; int ret; + int flag = 0; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -15710,8 +15570,6 @@ static int test_wc_ShaHmacFinal(void) flag = 0; - printf(testingFmt, "wc_HmacFinal() with SHA"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15760,10 +15618,9 @@ static int test_wc_ShaHmacFinal(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_ShaHmacFinal */ @@ -15773,12 +15630,13 @@ static int test_wc_ShaHmacFinal(void) */ static int test_wc_Sha224HmacFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA224) Hmac hmac; byte hash[WC_SHA224_DIGEST_SIZE]; testVector a; int ret; + int flag = 0; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -15791,8 +15649,6 @@ static int test_wc_Sha224HmacFinal(void) flag = 0; - printf(testingFmt, "wc_HmacFinal() with SHA224"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -15841,10 +15697,9 @@ static int test_wc_Sha224HmacFinal(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha224HmacFinal */ /* @@ -15852,12 +15707,13 @@ static int test_wc_Sha224HmacFinal(void) */ static int test_wc_Sha256HmacFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && !defined(NO_SHA256) Hmac hmac; byte hash[WC_SHA256_DIGEST_SIZE]; testVector a; int ret; + int flag = 0; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -15871,11 +15727,9 @@ static int test_wc_Sha256HmacFinal(void) flag = 0; - printf(testingFmt, "wc_HmacFinal() with WC_SHA256"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) - return ret; + return TEST_FAIL; ret = wc_HmacSetKey(&hmac, WC_SHA256, (byte*)key, (word32)XSTRLEN(key)); if (ret != 0) { @@ -15921,10 +15775,9 @@ static int test_wc_Sha256HmacFinal(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha256HmacFinal */ /* @@ -15932,12 +15785,13 @@ static int test_wc_Sha256HmacFinal(void) */ static int test_wc_Sha384HmacFinal(void) { - int flag = 0; + int res = TEST_SKIPPED; #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) Hmac hmac; byte hash[WC_SHA384_DIGEST_SIZE]; testVector a; int ret; + int flag = 0; const char* key; key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -15952,8 +15806,6 @@ static int test_wc_Sha384HmacFinal(void) flag = 0; - printf(testingFmt, "wc_HmacFinal() with SHA384"); - ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -16001,10 +15853,9 @@ static int test_wc_Sha384HmacFinal(void) wc_HmacFree(&hmac); - printf(resultFmt, flag == 0 ? passed : failed); - + res = TEST_RES_CHECK(flag == 0); #endif - return flag; + return res; } /* END test_wc_Sha384HmacFinal */ @@ -16014,8 +15865,7 @@ static int test_wc_Sha384HmacFinal(void) */ static int test_wc_InitCmac(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_CMAC) && !defined(NO_AES) Cmac cmac1, cmac2, cmac3; /* AES 128 key. */ @@ -16036,8 +15886,7 @@ static int test_wc_InitCmac(void) word32 key2Sz = (word32)sizeof(key2) - 1; word32 key3Sz = (word32)sizeof(key3) - 1; int type = WC_CMAC_AES; - - printf(testingFmt, "wc_InitCmac()"); + int ret = 0; #ifdef WOLFSSL_AES_128 ret = wc_InitCmac(&cmac1, key1, key1Sz, type, NULL); @@ -16070,7 +15919,8 @@ static int test_wc_InitCmac(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -16082,10 +15932,9 @@ static int test_wc_InitCmac(void) (void)cmac1; (void)cmac2; - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_InitCmac */ @@ -16095,8 +15944,7 @@ static int test_wc_InitCmac(void) */ static int test_wc_CmacUpdate(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) Cmac cmac; byte key[] = @@ -16113,14 +15961,13 @@ static int test_wc_CmacUpdate(void) word32 inSz = (word32)sizeof(in) - 1; word32 keySz = (word32)sizeof(key); int type = WC_CMAC_AES; + int ret = 0; ret = wc_InitCmac(&cmac, key, keySz, type, NULL); if (ret != 0) { return ret; } - printf(testingFmt, "wc_CmacUpdate()"); - ret = wc_CmacUpdate(&cmac, in, inSz); /* Test bad args. */ @@ -16131,16 +15978,16 @@ static int test_wc_CmacUpdate(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_AesFree(&cmac.aes); } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_CmacUpdate */ @@ -16150,8 +15997,7 @@ static int test_wc_CmacUpdate(void) */ static int test_wc_CmacFinal(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) Cmac cmac; byte key[] = @@ -16183,6 +16029,7 @@ static int test_wc_CmacFinal(void) word32 badMacSz = 17; int expMacSz = sizeof(expMac); int type = WC_CMAC_AES; + int ret = 0; XMEMSET(mac, 0, macSz); @@ -16192,7 +16039,6 @@ static int test_wc_CmacFinal(void) } ret = wc_CmacUpdate(&cmac, msg, msgSz); - printf(testingFmt, "wc_CmacFinal()"); if (ret == 0) { ret = wc_CmacFinal(&cmac, mac, &macSz); if (ret == 0 && XMEMCMP(mac, expMac, expMacSz) != 0) { @@ -16209,15 +16055,16 @@ static int test_wc_CmacFinal(void) if (ret == BUFFER_E) { ret = 0; } - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_CmacFinal */ @@ -16227,7 +16074,7 @@ static int test_wc_CmacFinal(void) */ static int test_wc_AesCmacGenerate(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) Cmac cmac; byte key[] = @@ -16245,6 +16092,7 @@ static int test_wc_AesCmacGenerate(void) word32 msgSz = sizeof(msg) - 1; word32 expMacSz = sizeof(expMac) - 1; int type = WC_CMAC_AES; + int ret = 0; XMEMSET(mac, 0, macSz); @@ -16256,12 +16104,11 @@ static int test_wc_AesCmacGenerate(void) ret = wc_CmacUpdate(&cmac, msg, msgSz); if (ret != 0) { return ret; - } else { + } + else { wc_AesFree(&cmac.aes); } - printf(testingFmt, "wc_AesCmacGenerate()"); - ret = wc_AesCmacGenerate(mac, &macSz, msg, msgSz, key, keySz); if (ret == 0 && XMEMCMP(mac, expMac, expMacSz) != 0) { ret = WOLFSSL_FATAL_ERROR; @@ -16280,15 +16127,13 @@ static int test_wc_AesCmacGenerate(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_AesCmacVerify()"); - ret = wc_AesCmacVerify(mac, macSz, msg, msgSz, key, keySz); /* Test bad args. */ if (ret == 0) { @@ -16307,16 +16152,16 @@ static int test_wc_AesCmacGenerate(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); } + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesCmacGenerate */ @@ -16326,10 +16171,10 @@ static int test_wc_AesCmacGenerate(void) */ static int test_wc_AesGcmStream(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(WOLFSSL_AES_128) && defined(HAVE_AESGCM) && \ defined(WOLFSSL_AESGCM_STREAM) - + int ret = 0; int i; WC_RNG rng[1]; Aes aesEnc[1]; @@ -16523,8 +16368,9 @@ static int test_wc_AesGcmStream(void) wc_AesFree(aesDec); wc_FreeRng(rng); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesGcmStream */ @@ -16534,9 +16380,10 @@ static int test_wc_AesGcmStream(void) */ static int test_wc_Des3_SetIV(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_DES3 Des3 des; + int ret = 0; const byte key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, @@ -16551,8 +16398,6 @@ static int test_wc_Des3_SetIV(void) 0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81 }; - printf(testingFmt, "wc_Des3_SetIV()"); - ret = wc_Des3Init(&des, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -16572,7 +16417,8 @@ static int test_wc_Des3_SetIV(void) ret = wc_Des3_SetIV(NULL, iv); if (ret == BAD_FUNC_ARG) { ret = wc_Des3_SetIV(&des, NULL); - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } @@ -16580,10 +16426,9 @@ static int test_wc_Des3_SetIV(void) wc_Des3Free(&des); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Des3_SetIV */ @@ -16592,9 +16437,10 @@ static int test_wc_Des3_SetIV(void) */ static int test_wc_Des3_SetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_DES3 Des3 des; + int ret = 0; const byte key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, @@ -16609,8 +16455,6 @@ static int test_wc_Des3_SetKey(void) 0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81 }; - printf(testingFmt, "wc_Des3_SetKey()"); - ret = wc_Des3Init(&des, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -16640,10 +16484,9 @@ static int test_wc_Des3_SetKey(void) wc_Des3Free(&des); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Des3_SetKey */ @@ -16653,9 +16496,10 @@ static int test_wc_Des3_SetKey(void) */ static int test_wc_Des3_CbcEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_DES3 Des3 des; + int ret = 0; byte cipher[24]; byte plain[24]; @@ -16679,8 +16523,6 @@ static int test_wc_Des3_CbcEncryptDecrypt(void) 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20 }; - printf(testingFmt, "wc_Des3_CbcEncrypt()"); - ret = wc_Des3Init(&des, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -16715,7 +16557,8 @@ static int test_wc_Des3_CbcEncryptDecrypt(void) } if (ret != BAD_FUNC_ARG) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -16730,17 +16573,17 @@ static int test_wc_Des3_CbcEncryptDecrypt(void) } if (ret != BAD_FUNC_ARG) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } wc_Des3Free(&des); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END wc_Des3_CbcEncrypt */ @@ -16749,9 +16592,9 @@ static int test_wc_Des3_CbcEncryptDecrypt(void) */ static int test_wc_Des3_CbcEncryptDecryptWithKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_DES3 - + int ret = 0; word32 vectorSz, cipherSz; byte cipher[24]; byte plain[24]; @@ -16781,8 +16624,6 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey(void) vectorSz = sizeof(byte) * 24; cipherSz = sizeof(byte) * 24; - printf(testingFmt, "wc_Des3_CbcEncryptWithKey()"); - ret = wc_Des3_CbcEncryptWithKey(cipher, vector, vectorSz, key, iv); if (ret == 0) { ret = wc_Des3_CbcDecryptWithKey(plain, cipher, cipherSz, key, iv); @@ -16805,7 +16646,8 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey(void) if (ret == BAD_FUNC_ARG) { ret = wc_Des3_CbcEncryptWithKey(cipher, vector, vectorSz, key, NULL); - } else { + } + else { /* Return code catch. */ ret = WOLFSSL_FAILURE; } @@ -16821,25 +16663,25 @@ static int test_wc_Des3_CbcEncryptDecryptWithKey(void) } if (ret == BAD_FUNC_ARG) { ret = wc_Des3_CbcDecryptWithKey(plain, cipher, cipherSz, key, NULL); - } else { + } + else { ret = WOLFSSL_FAILURE; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Des3_CbcEncryptDecryptWithKey */ /* * Unit test for wc_Des3_EcbEncrypt */ static int test_wc_Des3_EcbEncrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_DES3) && defined(WOLFSSL_DES_ECB) - Des3 des; + int ret = 0; byte cipher[24]; word32 cipherSz = sizeof(cipher); @@ -16863,8 +16705,6 @@ static int test_wc_Des3_EcbEncrypt(void) 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20 }; - printf(testingFmt, "wc_Des3_EcbEncrypt()"); - ret = wc_Des3Init(&des, NULL, INVALID_DEVID); if (ret != 0) { return ret; @@ -16909,10 +16749,9 @@ static int test_wc_Des3_EcbEncrypt(void) } wc_Des3Free(&des); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Des3_EcbEncrypt */ /* @@ -16920,7 +16759,7 @@ static int test_wc_Des3_EcbEncrypt(void) */ static int test_wc_Chacha_SetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CHACHA ChaCha ctx; const byte key[] = @@ -16931,8 +16770,7 @@ static int test_wc_Chacha_SetKey(void) 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01 }; byte cipher[128]; - - printf(testingFmt, "wc_Chacha_SetKey()"); + int ret = 0; ret = wc_Chacha_SetKey(&ctx, key, (word32)(sizeof(key)/sizeof(byte))); /* Test bad args. */ @@ -16943,30 +16781,29 @@ static int test_wc_Chacha_SetKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - if (ret != 0) { - return ret; - } - printf(testingFmt, "wc_Chacha_SetIV"); - ret = wc_Chacha_SetIV(&ctx, cipher, 0); if (ret == 0) { - /* Test bad args. */ + ret = wc_Chacha_SetIV(&ctx, cipher, 0); + } + if (ret == 0) { + /* Test bad args. */ ret = wc_Chacha_SetIV(NULL, cipher, 0); if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FAILURE; } } - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Chacha_SetKey */ /* @@ -16974,8 +16811,7 @@ static int test_wc_Chacha_SetKey(void) */ static int test_wc_Poly1305SetKey(void) { - int ret = 0; - + int res = TEST_SKIPPED; #ifdef HAVE_POLY1305 Poly1305 ctx; const byte key[] = @@ -16985,14 +16821,13 @@ static int test_wc_Poly1305SetKey(void) 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01 }; - - printf(testingFmt, "wc_Poly1305_SetKey()"); + int ret = 0; ret = wc_Poly1305SetKey(&ctx, key, (word32)(sizeof(key)/sizeof(byte))); /* Test bad args. */ if (ret == 0) { ret = wc_Poly1305SetKey(NULL, key, (word32)(sizeof(key)/sizeof(byte))); - if(ret == BAD_FUNC_ARG) { + if (ret == BAD_FUNC_ARG) { ret = wc_Poly1305SetKey(&ctx, NULL, (word32)(sizeof(key)/sizeof(byte))); } if (ret == BAD_FUNC_ARG) { @@ -17000,15 +16835,15 @@ static int test_wc_Poly1305SetKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Poly1305_SetKey() */ /* @@ -17016,7 +16851,7 @@ static int test_wc_Poly1305SetKey(void) */ static int test_wc_Chacha_Process(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CHACHA ChaCha enc, dec; byte cipher[128]; @@ -17031,13 +16866,12 @@ static int test_wc_Chacha_Process(void) const char* input = "Everybody gets Friday off."; word32 keySz = sizeof(key)/sizeof(byte); unsigned long int inlen = XSTRLEN(input); + int ret = 0; /*Initialize stack varialbes.*/ XMEMSET(cipher, 0, 128); XMEMSET(plain, 0, 128); - printf(testingFmt, "wc_Chacha_Process()"); - ret = wc_Chacha_SetKey(&enc, key, keySz); AssertIntEQ(ret, 0); ret = wc_Chacha_SetKey(&dec, key, keySz); @@ -17150,10 +16984,9 @@ static int test_wc_Chacha_Process(void) ret = 0; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Chacha_Process */ /* @@ -17161,7 +16994,7 @@ static int test_wc_Chacha_Process(void) */ static int test_wc_ChaCha20Poly1305_aead(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) const byte key[] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, @@ -17221,14 +17054,13 @@ static int test_wc_ChaCha20Poly1305_aead(void) byte generatedCiphertext[272]; byte generatedPlaintext[272]; byte generatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]; + int ret = 0; /* Initialize stack variables. */ XMEMSET(generatedCiphertext, 0, 272); XMEMSET(generatedPlaintext, 0, 272); /* Test Encrypt */ - printf(testingFmt, "wc_ChaCha20Poly1305_Encrypt()"); - ret = wc_ChaCha20Poly1305_Encrypt(key, iv, aad, sizeof(aad), plaintext, sizeof(plaintext), generatedCiphertext, generatedAuthTag); AssertIntEQ(ret, 0); @@ -17257,12 +17089,7 @@ static int test_wc_ChaCha20Poly1305_aead(void) if (ret == BAD_FUNC_ARG) { ret = 0; } - printf(resultFmt, ret == 0 ? passed : failed); - if (ret != 0) { - return ret; - } - printf(testingFmt, "wc_ChaCha20Poly1305_Decrypt()"); ret = wc_ChaCha20Poly1305_Decrypt(key, iv, aad, sizeof(aad), cipher, sizeof(cipher), authTag, generatedPlaintext); AssertIntEQ(ret, 0); @@ -17293,10 +17120,9 @@ static int test_wc_ChaCha20Poly1305_aead(void) ret = 0; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test-wc_ChaCha20Poly1305_EncryptDecrypt */ @@ -17306,13 +17132,12 @@ static int test_wc_ChaCha20Poly1305_aead(void) */ static int test_wc_Rc2SetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WC_RC2 Rc2 rc2; byte key40[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; - - printf(testingFmt, "wc_Rc2SetKey()"); + int ret = 0; /* valid key and IV */ ret = wc_Rc2SetKey(&rc2, key40, (word32) sizeof(key40) / sizeof(byte), @@ -17376,10 +17201,9 @@ static int test_wc_Rc2SetKey(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Rc2SetKey */ /* @@ -17387,12 +17211,11 @@ static int test_wc_Rc2SetKey(void) */ static int test_wc_Rc2SetIV(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WC_RC2 Rc2 rc2; byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; - - printf(testingFmt, "wc_Rc2SetIV()"); + int ret = 0; /* valid IV */ ret = wc_Rc2SetIV(&rc2, iv); @@ -17409,10 +17232,9 @@ static int test_wc_Rc2SetIV(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Rc2SetKey */ /* @@ -17420,9 +17242,10 @@ static int test_wc_Rc2SetIV(void) */ static int test_wc_Rc2EcbEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WC_RC2 Rc2 rc2; + int ret = 0; int effectiveKeyBits = 63; byte cipher[RC2_BLOCK_SIZE]; @@ -17432,8 +17255,6 @@ static int test_wc_Rc2EcbEncryptDecrypt(void) byte input[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte output[] = { 0xeb, 0xb7, 0x73, 0xf9, 0x93, 0x27, 0x8e, 0xff }; - printf(testingFmt, "wc_Rc2EcbEncryptDecrypt()"); - XMEMSET(cipher, 0, sizeof(cipher)); XMEMSET(plain, 0, sizeof(plain)); @@ -17519,10 +17340,9 @@ static int test_wc_Rc2EcbEncryptDecrypt(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Rc2SetKey */ /* @@ -17530,9 +17350,10 @@ static int test_wc_Rc2EcbEncryptDecrypt(void) */ static int test_wc_Rc2CbcEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WC_RC2 Rc2 rc2; + int ret = 0; int effectiveKeyBits = 63; byte cipher[RC2_BLOCK_SIZE*2]; @@ -17554,8 +17375,6 @@ static int test_wc_Rc2CbcEncryptDecrypt(void) 0xf0, 0x51, 0x77, 0x8b, 0x65, 0xdb, 0x13, 0x57 }; - printf(testingFmt, "wc_Rc2CbcEncryptDecrypt()"); - XMEMSET(cipher, 0, sizeof(cipher)); XMEMSET(plain, 0, sizeof(plain)); @@ -17565,7 +17384,8 @@ static int test_wc_Rc2CbcEncryptDecrypt(void) ret = wc_Rc2CbcEncrypt(&rc2, cipher, input, sizeof(input)); if (ret != 0 || XMEMCMP(cipher, output, sizeof(output)) != 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { /* reset IV for decrypt */ ret = wc_Rc2SetIV(&rc2, iv); } @@ -17636,10 +17456,9 @@ static int test_wc_Rc2CbcEncryptDecrypt(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Rc2SetKey */ @@ -17648,9 +17467,10 @@ static int test_wc_Rc2CbcEncryptDecrypt(void) */ static int test_wc_AesSetIV(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(WOLFSSL_AES_128) Aes aes; + int ret = 0; byte key16[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, @@ -17659,34 +17479,32 @@ static int test_wc_AesSetIV(void) byte iv1[] = "1234567890abcdef"; byte iv2[] = "0987654321fedcba"; - printf(testingFmt, "wc_AesSetIV()"); - ret = wc_AesInit(&aes, NULL, INVALID_DEVID); if (ret != 0) return ret; ret = wc_AesSetKey(&aes, key16, (word32) sizeof(key16) / sizeof(byte), iv1, AES_ENCRYPTION); - if(ret == 0) { + if (ret == 0) { ret = wc_AesSetIV(&aes, iv2); } /* Test bad args. */ - if(ret == 0) { + if (ret == 0) { ret = wc_AesSetIV(NULL, iv1); - if(ret == BAD_FUNC_ARG) { + if (ret == BAD_FUNC_ARG) { /* NULL iv should return 0. */ ret = wc_AesSetIV(&aes, NULL); - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* test_wc_AesSetIV */ @@ -17695,9 +17513,10 @@ static int test_wc_AesSetIV(void) */ static int test_wc_AesSetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_AES Aes aes; + int ret = 0; byte key16[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, @@ -17727,8 +17546,6 @@ static int test_wc_AesSetKey(void) }; byte iv[] = "1234567890abcdef"; - printf(testingFmt, "wc_AesSetKey()"); - ret = wc_AesInit(&aes, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -17761,17 +17578,17 @@ static int test_wc_AesSetKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesSetKey */ @@ -17782,10 +17599,11 @@ static int test_wc_AesSetKey(void) */ static int test_wc_AesCbcEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AES_CBC) && defined(HAVE_AES_DECRYPT)&& \ defined(WOLFSSL_AES_256) Aes aes; + int ret = 0; byte key32[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, @@ -17831,7 +17649,8 @@ static int test_wc_AesCbcEncryptDecrypt(void) ret = wc_AesCbcDecrypt(&aes, dec, enc, sizeof(vector)); if (ret != 0 || XMEMCMP(vector, dec, sizeof(vector)) != 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { /* Set flag. */ cbcD = 0; } @@ -17846,7 +17665,6 @@ static int test_wc_AesCbcEncryptDecrypt(void) } } - printf(testingFmt, "wc_AesCbcEncrypt()"); /* Pass in bad args */ if (cbcE == 0) { cbcE = wc_AesCbcEncrypt(NULL, enc, vector, sizeof(vector)); @@ -17858,7 +17676,8 @@ static int test_wc_AesCbcEncryptDecrypt(void) } if (cbcE == BAD_FUNC_ARG) { cbcE = 0; - } else { + } + else { cbcE = WOLFSSL_FATAL_ERROR; } #ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS @@ -17867,7 +17686,8 @@ static int test_wc_AesCbcEncryptDecrypt(void) } if (cbcE == BAD_LENGTH_E) { cbcE = 0; - } else { + } + else { cbcE = WOLFSSL_FATAL_ERROR; } #endif @@ -17875,8 +17695,8 @@ static int test_wc_AesCbcEncryptDecrypt(void) if (cbcE == 0) { #if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && \ (HAVE_FIPS_VERSION == 2) && defined(WOLFSSL_AESNI) - printf("Zero length inputs not supported with AESNI in FIPS mode (v2)," - " skip test"); + fprintf(stderr, "Zero length inputs not supported with AESNI in FIPS " + "mode (v2), skip test"); #else /* Test passing in size of 0 */ XMEMSET(enc, 0, sizeof(enc)); @@ -17889,13 +17709,11 @@ static int test_wc_AesCbcEncryptDecrypt(void) } #endif } - printf(resultFmt, cbcE == 0 ? passed : failed); if (cbcE != 0) { wc_AesFree(&aes); - return cbcE; + return TEST_FAIL; } - printf(testingFmt, "wc_AesCbcDecrypt()"); if (cbcD == 0) { cbcD = wc_AesCbcDecrypt(NULL, dec, enc, AES_BLOCK_SIZE); if (cbcD == BAD_FUNC_ARG) { @@ -17910,13 +17728,15 @@ static int test_wc_AesCbcEncryptDecrypt(void) #ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS if (cbcD == BAD_LENGTH_E) { cbcD = 0; - } else { + } + else { cbcD = WOLFSSL_FATAL_ERROR; } #else if (cbcD == BAD_FUNC_ARG) { cbcD = 0; - } else { + } + else { cbcD = WOLFSSL_FATAL_ERROR; } #endif @@ -17932,13 +17752,11 @@ static int test_wc_AesCbcEncryptDecrypt(void) cbcD |= dec[i]; } } - printf(resultFmt, cbcD == 0 ? passed : failed); if (cbcD != 0) { wc_AesFree(&aes); - return cbcD; + return TEST_FAIL; } - printf(testingFmt, "wc_AesCbcDecryptWithKey()"); if (cbcDWK == 0) { cbcDWK = wc_AesCbcDecryptWithKey(NULL, enc, AES_BLOCK_SIZE, key32, sizeof(key32)/sizeof(byte), iv); @@ -17956,20 +17774,17 @@ static int test_wc_AesCbcEncryptDecrypt(void) } if (cbcDWK == BAD_FUNC_ARG) { cbcDWK = 0; - } else { + } + else { cbcDWK = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&aes); - printf(resultFmt, cbcDWK == 0 ? passed : failed); - - if (cbcDWK != 0) { - return cbcDWK; - } + res = TEST_RES_CHECK(cbcDWK == 0); #endif - return ret; + return res; } /* END test_wc_AesCbcEncryptDecrypt */ /* @@ -17977,9 +17792,10 @@ static int test_wc_AesCbcEncryptDecrypt(void) */ static int test_wc_AesCtrEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER) && defined(WOLFSSL_AES_256) Aes aesEnc, aesDec; + int ret = 0; byte key32[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, @@ -18001,8 +17817,6 @@ static int test_wc_AesCtrEncryptDecrypt(void) XMEMSET(enc, 0, AES_BLOCK_SIZE * 2); XMEMSET(dec, 0, AES_BLOCK_SIZE * 2); - printf(testingFmt, "wc_AesCtrEncrypt()"); - ret = wc_AesInit(&aesEnc, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -18041,7 +17855,8 @@ static int test_wc_AesCtrEncryptDecrypt(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -18049,10 +17864,9 @@ static int test_wc_AesCtrEncryptDecrypt(void) wc_AesFree(&aesEnc); wc_AesFree(&aesDec); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesCtrEncryptDecrypt */ @@ -18061,10 +17875,10 @@ static int test_wc_AesCtrEncryptDecrypt(void) */ static int test_wc_AesGcmSetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AESGCM) - Aes aes; + int ret = 0; #ifdef WOLFSSL_AES_128 byte key16[] = { @@ -18108,8 +17922,6 @@ static int test_wc_AesGcmSetKey(void) 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65 }; - printf(testingFmt, "wc_AesGcmSetKey()"); - ret = wc_AesInit(&aes, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -18139,17 +17951,17 @@ static int test_wc_AesGcmSetKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesGcmSetKey */ /* @@ -18157,7 +17969,7 @@ static int test_wc_AesGcmSetKey(void) */ static int test_wc_AesGcmEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; /* WOLFSSL_AFALG requires 12 byte IV */ #if !defined(NO_AES) && defined(HAVE_AESGCM) && defined(WOLFSSL_AES_256) && \ !defined(WOLFSSL_AFALG) && !defined(WOLFSSL_DEVCRYPTO_AES) @@ -18189,6 +18001,7 @@ static int test_wc_AesGcmEncryptDecrypt(void) byte dec[sizeof(vector)]; int gcmD = WOLFSSL_FATAL_ERROR; int gcmE = WOLFSSL_FATAL_ERROR; + int ret = 0; /* Init stack variables. */ XMEMSET(enc, 0, sizeof(vector)); @@ -18209,11 +18022,10 @@ static int test_wc_AesGcmEncryptDecrypt(void) gcmD = wc_AesGcmDecrypt(&aes, dec, enc, sizeof(vector), iv, sizeof(iv)/sizeof(byte), resultT, sizeof(resultT), a, sizeof(a)); - if(gcmD == 0 && (XMEMCMP(vector, dec, sizeof(vector)) != 0)) { + if (gcmD == 0 && (XMEMCMP(vector, dec, sizeof(vector)) != 0)) { gcmD = WOLFSSL_FATAL_ERROR; } } - printf(testingFmt, "wc_AesGcmEncrypt()"); /*Test bad args for wc_AesGcmEncrypt and wc_AesGcmDecrypt */ if (gcmE == 0) { gcmE = wc_AesGcmEncrypt(NULL, enc, vector, sizeof(vector), @@ -18243,7 +18055,8 @@ static int test_wc_AesGcmEncryptDecrypt(void) #endif if (gcmE == BAD_FUNC_ARG) { gcmE = 0; - } else { + } + else { gcmE = WOLFSSL_FATAL_ERROR; } } @@ -18264,15 +18077,12 @@ static int test_wc_AesGcmEncryptDecrypt(void) #endif /* Old FIPS */ /* END wc_AesGcmEncrypt */ - printf(resultFmt, gcmE == 0 ? passed : failed); if (gcmE != 0) { wc_AesFree(&aes); - return gcmE; + return TEST_FAIL; } #ifdef HAVE_AES_DECRYPT - printf(testingFmt, "wc_AesGcmDecrypt()"); - if (gcmD == 0) { gcmD = wc_AesGcmDecrypt(NULL, dec, enc, sizeof(enc)/sizeof(byte), iv, sizeof(iv)/sizeof(byte), resultT, @@ -18315,18 +18125,18 @@ static int test_wc_AesGcmEncryptDecrypt(void) #endif if (gcmD == BAD_FUNC_ARG) { gcmD = 0; - } else { + } + else { gcmD = WOLFSSL_FATAL_ERROR; } - } /* END wc_AesGcmDecrypt */ - printf(resultFmt, gcmD == 0 ? passed : failed); + res = TEST_RES_CHECK(gcmD == 0); + } /* END wc_AesGcmDecrypt */ #endif /* HAVE_AES_DECRYPT */ wc_AesFree(&aes); #endif - - return ret; + return res; } /* END test_wc_AesGcmEncryptDecrypt */ @@ -18335,7 +18145,7 @@ static int test_wc_AesGcmEncryptDecrypt(void) */ static int test_wc_GmacSetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AESGCM) Gmac gmac; byte key16[] = @@ -18378,8 +18188,7 @@ static int test_wc_GmacSetKey(void) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 }; - - printf(testingFmt, "wc_GmacSetKey()"); + int ret = 0; ret = wc_AesInit(&gmac.aes, NULL, INVALID_DEVID); if (ret != 0) @@ -18416,17 +18225,17 @@ static int test_wc_GmacSetKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&gmac.aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_GmacSetKey */ @@ -18435,7 +18244,7 @@ static int test_wc_GmacSetKey(void) */ static int test_wc_GmacUpdate(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AESGCM) Gmac gmac; #ifdef WOLFSSL_AES_128 @@ -18522,14 +18331,13 @@ static int test_wc_GmacUpdate(void) byte tagOut[16]; byte tagOut2[24]; byte tagOut3[32]; + int ret = 0; /* Init stack variables. */ XMEMSET(tagOut, 0, sizeof(tagOut)); XMEMSET(tagOut2, 0, sizeof(tagOut2)); XMEMSET(tagOut3, 0, sizeof(tagOut3)); - printf(testingFmt, "wc_GmacUpdate()"); - ret = wc_AesInit(&gmac.aes, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -18590,17 +18398,17 @@ static int test_wc_GmacUpdate(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } wc_AesFree(&gmac.aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_GmacUpdate */ @@ -18610,7 +18418,7 @@ static int test_wc_GmacUpdate(void) */ static int test_wc_CamelliaSetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CAMELLIA Camellia camellia; /*128-bit key*/ @@ -18639,8 +18447,7 @@ static int test_wc_CamelliaSetKey(void) 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - - printf(testingFmt, "wc_CamelliaSetKey()"); + int ret = 0; ret = wc_CamelliaSetKey(&camellia, key16, (word32)sizeof(key16), iv); if (ret == 0) { @@ -18668,14 +18475,15 @@ static int test_wc_CamelliaSetKey(void) ret = wc_CamelliaSetKey(NULL, key32, (word32)sizeof(key32), iv); if (ret != BAD_FUNC_ARG) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } /* END bad args. */ - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_CammeliaSetKey */ @@ -18684,7 +18492,7 @@ static int test_wc_CamelliaSetKey(void) */ static int test_wc_CamelliaSetIV(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte iv[] = @@ -18692,8 +18500,7 @@ static int test_wc_CamelliaSetIV(void) 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - - printf(testingFmt, "wc_CamelliaSetIV()"); + int ret = 0; ret = wc_CamelliaSetIV(&camellia, iv); if (ret == 0) { @@ -18704,15 +18511,15 @@ static int test_wc_CamelliaSetIV(void) ret = wc_CamelliaSetIV(NULL, NULL); if (ret != BAD_FUNC_ARG) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_CamelliaSetIV*/ /* @@ -18720,7 +18527,7 @@ static int test_wc_CamelliaSetIV(void) */ static int test_wc_CamelliaEncryptDecryptDirect(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte key24[] = @@ -18743,6 +18550,7 @@ static int test_wc_CamelliaEncryptDecryptDirect(void) byte dec[sizeof(enc)]; int camE = WOLFSSL_FATAL_ERROR; int camD = WOLFSSL_FATAL_ERROR; + int ret = 0; /*Init stack variables.*/ XMEMSET(enc, 0, 16); @@ -18758,7 +18566,6 @@ static int test_wc_CamelliaEncryptDecryptDirect(void) } } } - printf(testingFmt, "wc_CamelliaEncryptDirect()"); /* Pass bad args. */ if (ret == 0) { camE = wc_CamelliaEncryptDirect(NULL, enc, plainT); @@ -18770,18 +18577,16 @@ static int test_wc_CamelliaEncryptDecryptDirect(void) } if (camE == BAD_FUNC_ARG) { camE = 0; - } else { + } + else { camE = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, camE == 0 ? passed : failed); if (camE != 0) { - return camE; + return TEST_FAIL; } - printf(testingFmt, "wc_CamelliaDecryptDirect()"); - if (ret == 0) { camD = wc_CamelliaDecryptDirect(NULL, dec, enc); if (camD == BAD_FUNC_ARG) { @@ -18792,18 +18597,15 @@ static int test_wc_CamelliaEncryptDecryptDirect(void) } if (camD == BAD_FUNC_ARG) { camD = 0; - } else { + } + else { camD = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, camD == 0 ? passed : failed); - if (camD != 0) { - return camD; - } - + res = TEST_RES_CHECK(camD == 0); #endif - return ret; + return res; } /* END test-wc_CamelliaEncryptDecryptDirect */ @@ -18812,7 +18614,7 @@ static int test_wc_CamelliaEncryptDecryptDirect(void) */ static int test_wc_CamelliaCbcEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CAMELLIA Camellia camellia; static const byte key24[] = @@ -18830,6 +18632,7 @@ static int test_wc_CamelliaCbcEncryptDecrypt(void) byte dec[CAMELLIA_BLOCK_SIZE]; int camCbcE = WOLFSSL_FATAL_ERROR; int camCbcD = WOLFSSL_FATAL_ERROR; + int ret = 0; /* Init stack variables. */ XMEMSET(enc, 0, CAMELLIA_BLOCK_SIZE); @@ -18852,7 +18655,6 @@ static int test_wc_CamelliaCbcEncryptDecrypt(void) } } - printf(testingFmt, "wc_CamelliaCbcEncrypt"); /* Pass in bad args. */ if (ret == 0) { camCbcE = wc_CamelliaCbcEncrypt(NULL, enc, plainT, CAMELLIA_BLOCK_SIZE); @@ -18866,18 +18668,16 @@ static int test_wc_CamelliaCbcEncryptDecrypt(void) } if (camCbcE == BAD_FUNC_ARG) { camCbcE = 0; - } else { + } + else { camCbcE = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, camCbcE == 0 ? passed : failed); if (camCbcE != 0) { - return camCbcE; + return TEST_FAIL; } - printf(testingFmt, "wc_CamelliaCbcDecrypt()"); - if (ret == 0) { camCbcD = wc_CamelliaCbcDecrypt(NULL, dec, enc, CAMELLIA_BLOCK_SIZE); if (camCbcD == BAD_FUNC_ARG) { @@ -18890,18 +18690,15 @@ static int test_wc_CamelliaCbcEncryptDecrypt(void) } if (camCbcD == BAD_FUNC_ARG) { camCbcD = 0; - } else { + } + else { camCbcD = WOLFSSL_FATAL_ERROR; } } /* END bad args. */ - printf(resultFmt, camCbcD == 0 ? passed : failed); - if (camCbcD != 0) { - return camCbcD; - } - + res = TEST_RES_CHECK(camCbcD == 0); #endif - return ret; + return res; } /* END test_wc_CamelliaCbcEncryptDecrypt */ @@ -18911,13 +18708,12 @@ static int test_wc_CamelliaCbcEncryptDecrypt(void) */ static int test_wc_Arc4SetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_RC4 Arc4 arc; const char* key = "\x01\x23\x45\x67\x89\xab\xcd\xef"; int keyLen = 8; - - printf(testingFmt, "wc_Arch4SetKey()"); + int ret = 0; ret = wc_Arc4SetKey(&arc, (byte*)key, keyLen); /* Test bad args. */ @@ -18933,10 +18729,9 @@ static int test_wc_Arc4SetKey(void) ret = WOLFSSL_FATAL_ERROR; } /* END test bad args. */ - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_Arc4SetKey */ @@ -18945,7 +18740,7 @@ static int test_wc_Arc4SetKey(void) */ static int test_wc_Arc4Process(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_RC4 Arc4 enc, dec; const char* key = "\x01\x23\x45\x67\x89\xab\xcd\xef"; @@ -18953,6 +18748,7 @@ static int test_wc_Arc4Process(void) 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)); @@ -18964,8 +18760,6 @@ static int test_wc_Arc4Process(void) ret = wc_Arc4Init(&dec, NULL, INVALID_DEVID); } - printf(testingFmt, "wc_Arc4Process()"); - if (ret == 0) { ret = wc_Arc4SetKey(&enc, (byte*)key, keyLen); } @@ -18979,7 +18773,8 @@ static int test_wc_Arc4Process(void) ret = wc_Arc4Process(&dec, plain, cipher, keyLen); if (ret != 0 || XMEMCMP(plain, input, keyLen)) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } @@ -18995,18 +18790,18 @@ static int test_wc_Arc4Process(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - wc_Arc4Free(&enc); wc_Arc4Free(&dec); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* END test_wc_Arc4Process */ @@ -19016,11 +18811,10 @@ static int test_wc_Arc4Process(void) */ static int test_wc_InitRsaKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_RSA RsaKey key; - - printf(testingFmt, "wc_InitRsaKey()"); + int ret = 0; ret = wc_InitRsaKey(&key, HEAP_HINT); @@ -19030,11 +18824,13 @@ static int test_wc_InitRsaKey(void) #ifndef HAVE_USER_RSA if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { #else if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { #endif ret = WOLFSSL_FATAL_ERROR; } @@ -19044,10 +18840,9 @@ static int test_wc_InitRsaKey(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_InitRsaKey */ @@ -19056,15 +18851,14 @@ static int test_wc_InitRsaKey(void) */ static int test_wc_RsaPrivateKeyDecode(void) { - int ret = 0; + int res = TEST_SKIPPED; #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 bytes = 0; - - printf(testingFmt, "wc_RsaPrivateKeyDecode()"); + int ret = 0; tmp = (byte*)XMALLOC(FOURK_BUF, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) { @@ -19096,7 +18890,8 @@ static int test_wc_RsaPrivateKeyDecode(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19112,7 +18907,8 @@ static int test_wc_RsaPrivateKeyDecode(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19125,10 +18921,9 @@ static int test_wc_RsaPrivateKeyDecode(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaPrivateKeyDecode */ @@ -19137,7 +18932,7 @@ static int test_wc_RsaPrivateKeyDecode(void) */ static int test_wc_RsaPublicKeyDecode(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && (defined(USE_CERT_BUFFERS_1024)\ || defined(USE_CERT_BUFFERS_2048)) && !defined(HAVE_FIPS) RsaKey keyPub; @@ -19146,6 +18941,7 @@ static int test_wc_RsaPublicKeyDecode(void) int bytes = 0; word32 keySz = 0; word32 tstKeySz = 0; + int ret = 0; #if defined(WC_RSA_PSS) && !defined(NO_FILESYSTEM) XFILE f; const char* rsaPssPubKey = "./certs/rsapss/ca-rsapss-key.der"; @@ -19171,8 +18967,6 @@ static int test_wc_RsaPublicKeyDecode(void) keySz = 2048; #endif - printf(testingFmt, "wc_RsaPublicKeyDecode()"); - ret = wc_RsaPublicKeyDecode(tmp, &idx, &keyPub, (word32)bytes); } #ifndef HAVE_USER_RSA @@ -19187,7 +18981,8 @@ static int test_wc_RsaPublicKeyDecode(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19203,7 +18998,8 @@ static int test_wc_RsaPublicKeyDecode(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19242,12 +19038,9 @@ static int test_wc_RsaPublicKeyDecode(void) XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - printf(resultFmt, ret == 0 ? passed : failed); - - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_RsaPublicKeyDecode */ /* @@ -19255,15 +19048,14 @@ static int test_wc_RsaPublicKeyDecode(void) */ static int test_wc_RsaPublicKeyDecodeRaw(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) RsaKey key; const byte n = 0x23; const byte e = 0x03; int nSz = sizeof(n); int eSz = sizeof(e); - - printf(testingFmt, "wc_RsaPublicKeyDecodeRaw()"); + int ret; ret = wc_InitRsaKey(&key, HEAP_HINT); if (ret == 0) { @@ -19281,7 +19073,8 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19297,7 +19090,8 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19307,10 +19101,9 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaPublicKeyDecodeRaw */ @@ -19327,7 +19120,8 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) for (;;) { ret = wc_MakeRsaKey(key, size, e, rng); if (ret != PRIME_GEN_E) break; - printf("MakeRsaKey couldn't find prime; trying again.\n"); + fprintf(stderr, "MakeRsaKey couldn't find prime; " + "trying again.\n"); } return ret; @@ -19344,7 +19138,7 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) */ static int test_wc_MakeRsaKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey genKey; @@ -19355,8 +19149,7 @@ static int test_wc_MakeRsaKey(void) #else int bits = 2048; #endif - - printf(testingFmt, "wc_MakeRsaKey()"); + int ret = 0; ret = wc_InitRsaKey(&genKey, HEAP_HINT); if (ret == 0) { @@ -19385,7 +19178,8 @@ static int test_wc_MakeRsaKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19406,7 +19200,8 @@ static int test_wc_MakeRsaKey(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -19416,10 +19211,9 @@ static int test_wc_MakeRsaKey(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_MakeRsaKey */ @@ -19434,18 +19228,18 @@ static int test_wc_MakeRsaKey(void) */ static int test_RsaDecryptBoundsCheck(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WC_RSA_NO_PADDING) && \ (defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048)) && \ defined(WOLFSSL_PUBLIC_MP) && !defined(NO_RSA_BOUNDS_CHECK) + WC_RNG rng; RsaKey key; byte flatC[256]; word32 flatCSz; byte out[256]; word32 outSz = sizeof(out); - WC_RNG rng; + int ret; - printf(testingFmt, "RSA decrypt bounds check"); XMEMSET(&rng, 0, sizeof(rng)); ret = wc_InitRng(&rng); @@ -19496,12 +19290,9 @@ static int test_RsaDecryptBoundsCheck(void) if (wc_FreeRsaKey(&key) || wc_FreeRng(&rng) || ret != 0) ret = WOLFSSL_FATAL_ERROR; - printf(resultFmt, ret == 0 ? passed : failed); - - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_RsaDecryptBoundsCheck */ /* @@ -19509,13 +19300,13 @@ static int test_RsaDecryptBoundsCheck(void) */ static int test_wc_SetKeyUsage(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN) && !defined(HAVE_FIPS) Cert myCert; + int ret = 0; ret = wc_InitCert(&myCert); - printf(testingFmt, "wc_SetKeyUsage()"); if (ret == 0) { ret = wc_SetKeyUsage(&myCert, "keyEncipherment,keyAgreement"); if (ret == 0) { @@ -19548,15 +19339,15 @@ static int test_wc_SetKeyUsage(void) } if (ret == KEYUSAGE_E) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_SetKeyUsage */ /* @@ -19564,33 +19355,30 @@ static int test_wc_SetKeyUsage(void) */ static int test_wc_CheckProbablePrime(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING) #define CHECK_PROBABLE_PRIME_KEY_BITS 2048 - RsaKey key; - WC_RNG rng; - byte e[3]; - word32 eSz = (word32)sizeof(e); - byte n[CHECK_PROBABLE_PRIME_KEY_BITS / 8]; - word32 nSz = (word32)sizeof(n); - byte d[CHECK_PROBABLE_PRIME_KEY_BITS / 8]; - word32 dSz = (word32)sizeof(d); - byte p[CHECK_PROBABLE_PRIME_KEY_BITS / 8 / 2]; - word32 pSz = (word32)sizeof(p); - byte q[CHECK_PROBABLE_PRIME_KEY_BITS / 8 / 2]; - word32 qSz = (word32)sizeof(q); - int nlen = CHECK_PROBABLE_PRIME_KEY_BITS; - int* isPrime; - int test[5]; + RsaKey key; + WC_RNG rng; + byte e[3]; + word32 eSz = (word32)sizeof(e); + byte n[CHECK_PROBABLE_PRIME_KEY_BITS / 8]; + word32 nSz = (word32)sizeof(n); + byte d[CHECK_PROBABLE_PRIME_KEY_BITS / 8]; + word32 dSz = (word32)sizeof(d); + byte p[CHECK_PROBABLE_PRIME_KEY_BITS / 8 / 2]; + word32 pSz = (word32)sizeof(p); + byte q[CHECK_PROBABLE_PRIME_KEY_BITS / 8 / 2]; + word32 qSz = (word32)sizeof(q); + int nlen = CHECK_PROBABLE_PRIME_KEY_BITS; + int ret = 0; + int* isPrime; + int test[5]; isPrime = test; - - printf(testingFmt, "wc_CheckProbablePrime()"); - - ret = wc_InitRsaKey(&key, HEAP_HINT); if (ret == 0) { ret = wc_InitRng(&rng); @@ -19666,34 +19454,31 @@ static int test_wc_CheckProbablePrime(void) wc_FreeRsaKey(&key); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - #undef CHECK_PROBABLE_PRIME_KEY_BITS + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; + return res; } /* END test_wc_CheckProbablePrime */ /* * Testing wc_RsaPSS_Verify() */ static int test_wc_RsaPSS_Verify(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING) && defined(WC_RSA_PSS) - RsaKey key; - WC_RNG rng; - int sz = 256; - byte* pt; - const char* szMessage = "This is the string to be signed"; - unsigned char pSignature[2048/8]; /* 2048 is RSA_KEY_SIZE */ - unsigned char pDecrypted[2048/8]; - word32 outLen = sizeof(pDecrypted); + RsaKey key; + WC_RNG rng; + int sz = 256; + byte* pt; + const char* szMessage = "This is the string to be signed"; + unsigned char pSignature[2048/8]; /* 2048 is RSA_KEY_SIZE */ + unsigned char pDecrypted[2048/8]; + word32 outLen = sizeof(pDecrypted); + int ret = 0; pt = pDecrypted; - printf(testingFmt, "wc_RsaPSS_Verify()"); - ret = wc_InitRsaKey(&key, HEAP_HINT); if (ret == 0) { @@ -19710,7 +19495,7 @@ static int test_wc_RsaPSS_Verify(void) ret = wc_RsaPSS_Sign((byte*)szMessage, (word32)XSTRLEN(szMessage)+1, pSignature, sizeof(pSignature), WC_HASH_TYPE_SHA256, WC_MGF1SHA256, &key, &rng); - if (ret > 0 ){ + if (ret > 0) { sz = ret; ret = 0; } @@ -19754,33 +19539,32 @@ static int test_wc_RsaPSS_Verify(void) } wc_FreeRsaKey(&key); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_RsaPSS_Verify */ /* * Testing wc_RsaPSS_VerifyCheck() */ static int test_wc_RsaPSS_VerifyCheck(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING) && defined(WC_RSA_PSS) - RsaKey key; - WC_RNG rng; - int sz = 256; /* 2048/8 */ - byte* pt; - byte digest[32]; - word32 digestSz = sizeof(digest); - unsigned char pSignature[2048/8]; /* 2048 is RSA_KEY_SIZE */ - word32 pSignatureSz = sizeof(pSignature); - unsigned char pDecrypted[2048/8]; - word32 outLen = sizeof(pDecrypted); + RsaKey key; + WC_RNG rng; + int sz = 256; /* 2048/8 */ + byte* pt; + byte digest[32]; + word32 digestSz = sizeof(digest); + unsigned char pSignature[2048/8]; /* 2048 is RSA_KEY_SIZE */ + word32 pSignatureSz = sizeof(pSignature); + unsigned char pDecrypted[2048/8]; + word32 outLen = sizeof(pDecrypted); + int ret = 0; pt = pDecrypted; - printf(testingFmt, "wc_RsaPSS_VerifyCheck()"); - XMEMSET(digest, 0, sizeof(digest)); XMEMSET(pSignature, 0, sizeof(pSignature)); @@ -19804,7 +19588,7 @@ static int test_wc_RsaPSS_VerifyCheck(void) if (ret == 0) { ret = wc_RsaPSS_Sign(digest, digestSz, pSignature, pSignatureSz, WC_HASH_TYPE_SHA256, WC_MGF1SHA256, &key, &rng); - if (ret > 0 ){ + if (ret > 0) { sz = ret; ret = 0; } @@ -19849,17 +19633,17 @@ static int test_wc_RsaPSS_VerifyCheck(void) } wc_FreeRsaKey(&key); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_RsaPSS_VerifyCheck */ /* * Testing wc_RsaPSS_VerifyCheckInline() */ static int test_wc_RsaPSS_VerifyCheckInline(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING) && defined(WC_RSA_PSS) RsaKey key; @@ -19870,11 +19654,9 @@ static int test_wc_RsaPSS_VerifyCheckInline(void) word32 digestSz = sizeof(digest); unsigned char pSignature[2048/8]; /* 2048 is RSA_KEY_SIZE */ unsigned char pDecrypted[2048/8]; + int ret; pt = pDecrypted; - - printf(testingFmt, "wc_RsaPSS_VerifyCheckInline()"); - ret = wc_InitRsaKey(&key, HEAP_HINT); XMEMSET(digest, 0, sizeof(digest)); @@ -19898,7 +19680,7 @@ static int test_wc_RsaPSS_VerifyCheckInline(void) if (ret == 0) { ret = wc_RsaPSS_Sign(digest, digestSz, pSignature, sizeof(pSignature), WC_HASH_TYPE_SHA256, WC_MGF1SHA256, &key, &rng); - if (ret > 0 ){ + if (ret > 0) { sz = ret; ret = 0; } @@ -19942,10 +19724,10 @@ static int test_wc_RsaPSS_VerifyCheckInline(void) } wc_FreeRsaKey(&key); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_RsaPSS_VerifyCheckInline */ #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) @@ -19962,21 +19744,20 @@ static void sample_mutex_cb (int flag, int type, const char* file, int line) */ static int test_wc_LockMutex_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) + int ret = 0; int flag = CRYPTO_LOCK; int type = 0; const char* file = "./test-LockMutex_ex.txt"; int line = 0; - printf(testingFmt, "wc_LockMutex_ex()"); - - /*without SetMutexCb*/ + /* without SetMutexCb */ ret = wc_LockMutex_ex(flag, type, file, line); if (ret == BAD_STATE_E) { ret = 0; } - /*with SetMutexCb*/ + /* with SetMutexCb */ if (ret == 0) { ret = wc_SetMutexCb(sample_mutex_cb); if (ret == 0) { @@ -19984,26 +19765,22 @@ static int test_wc_LockMutex_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/*End test_wc_LockMutex_ex*/ /* * Testing wc_SetMutexCb */ static int test_wc_SetMutexCb(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) + int ret = wc_SetMutexCb(sample_mutex_cb); - printf(testingFmt, "wc_SetMutexCb()"); - - ret = wc_SetMutexCb(sample_mutex_cb); - - printf(resultFmt, ret == 0 ? passed : failed); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/*End test_wc_SetMutexCb*/ /* @@ -20011,11 +19788,12 @@ static int test_wc_SetMutexCb(void) */ static int test_wc_RsaKeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey genKey; WC_RNG rng; byte* der; + int ret = 0; #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) int bits = 1024; @@ -20050,13 +19828,12 @@ static int test_wc_RsaKeyToDer(void) } } - printf(testingFmt, "wc_RsaKeyToDer()"); - if (ret == 0) { ret = wc_RsaKeyToDer(&genKey, der, derSz); if (ret > 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20079,7 +19856,8 @@ static int test_wc_RsaKeyToDer(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20102,7 +19880,8 @@ static int test_wc_RsaKeyToDer(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20118,10 +19897,9 @@ static int test_wc_RsaKeyToDer(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaKeyToDer */ /* @@ -20129,11 +19907,12 @@ static int test_wc_RsaKeyToDer(void) */ static int test_wc_RsaKeyToPublicDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; byte* der; + int ret = 0; #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) int bits = 1024; @@ -20160,8 +19939,6 @@ static int test_wc_RsaKeyToPublicDer(void) ret = MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng); } - printf(testingFmt, "wc_RsaKeyToPublicDer()"); - if (ret == 0) { /* test getting size only */ ret = wc_RsaKeyToPublicDer(&key, NULL, derLen); @@ -20172,7 +19949,8 @@ static int test_wc_RsaKeyToPublicDer(void) ret = wc_RsaKeyToPublicDer(&key, der, derLen); if (ret >= 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20187,7 +19965,8 @@ static int test_wc_RsaKeyToPublicDer(void) ret = wc_RsaKeyToPublicDer_ex(&key, der, derLen, 0); if (ret >= 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20201,7 +19980,8 @@ static int test_wc_RsaKeyToPublicDer(void) } if (ret == BUFFER_E || ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20214,7 +19994,8 @@ static int test_wc_RsaKeyToPublicDer(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20230,10 +20011,9 @@ static int test_wc_RsaKeyToPublicDer(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaKeyToPublicDer */ @@ -20242,10 +20022,11 @@ static int test_wc_RsaKeyToPublicDer(void) */ static int test_wc_RsaPublicEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; + int ret = 0; const char inStr[] = TEST_STRING; const word32 plainLen = (word32)TEST_STRING_SZ; const word32 inLen = (word32)TEST_STRING_SZ; @@ -20259,7 +20040,7 @@ static int test_wc_RsaPublicEncryptDecrypt(void) #ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC if (in == NULL || plain == NULL || cipher == NULL) { - printf("test_wc_RsaPublicEncryptDecrypt malloc failed\n"); + fprintf(stderr, "test_wc_RsaPublicEncryptDecrypt malloc failed\n"); return MEMORY_E; } #endif @@ -20273,27 +20054,25 @@ static int test_wc_RsaPublicEncryptDecrypt(void) ret = MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng); } /* Encrypt. */ - printf(testingFmt, "wc_RsaPublicEncrypt()"); if (ret == 0) { ret = wc_RsaPublicEncrypt(in, inLen, cipher, cipherLen, &key, &rng); if (ret >= 0) { cipherLenResult = ret; ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } /* Pass bad args. */ - /* Tests PsaPublicEncryptEx() which, is tested by another fn. No need dup.*/ - printf(resultFmt, ret == 0 ? passed : failed); + /* Tests PsaPublicEncryptEx() which, is tested by another fn. No need dup.*/ if (ret != 0) { - return ret; + return TEST_FAIL; } /* Decrypt */ - printf(testingFmt, "wc_RsaPrivateDecrypt()"); #if defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS) /* Bind rng */ if (ret == 0) { @@ -20320,10 +20099,9 @@ static int test_wc_RsaPublicEncryptDecrypt(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaPublicEncryptDecrypt */ @@ -20332,12 +20110,13 @@ static int test_wc_RsaPublicEncryptDecrypt(void) */ static int test_wc_RsaPublicEncryptDecrypt_ex(void) { - int ret = 0; + int result = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_FIPS)\ && !defined(WC_NO_RSA_OAEP) && !defined(HAVE_USER_RSA)\ && !defined(NO_SHA) RsaKey key; WC_RNG rng; + int ret; const char inStr[] = TEST_STRING; const word32 inLen = (word32)TEST_STRING_SZ; const word32 plainSz = (word32)TEST_STRING_SZ; @@ -20352,8 +20131,8 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) #ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC if (in == NULL || plain == NULL || cipher == NULL) { - printf("test_wc_RsaPublicEncryptDecrypt_exmalloc failed\n"); - return MEMORY_E; + fprintf(stderr, "test_wc_RsaPublicEncryptDecrypt_exmalloc failed\n"); + return TEST_FAIL; } #endif XMEMCPY(in, inStr, inLen); @@ -20370,28 +20149,26 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) ret = MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng); } /* Encrypt */ - printf(testingFmt, "wc_RsaPublicEncrypt_ex()"); if (ret == 0) { ret = wc_RsaPublicEncrypt_ex(in, inLen, cipher, cipherSz, &key, &rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); if (ret >= 0) { idx = ret; ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - /*Pass bad args.*/ - /* Tests RsaPublicEncryptEx again. No need duplicate. */ - printf(resultFmt, ret == 0 ? passed : failed); + /* Pass bad args. */ + /* Tests RsaPublicEncryptEx again. No need duplicate. */ if (ret != 0) { - return ret; + return TEST_FAIL; } #ifndef WOLFSSL_RSA_PUBLIC_ONLY /* Decrypt */ - printf(testingFmt, "wc_RsaPrivateDecrypt_ex()"); #if defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS) if (ret == 0) { ret = wc_RsaSetRNG(&key, &rng); @@ -20405,19 +20182,18 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) if (ret >= 0) { if (!XMEMCMP(plain, inStr, plainSz)) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } /*Pass bad args.*/ /* Tests RsaPrivateDecryptEx() again. No need duplicate. */ - printf(resultFmt, ret == 0 ? passed : failed); if (ret != 0) { - return ret; + return TEST_FAIL; } - printf(testingFmt, "wc_RsaPrivateDecryptInline_ex()"); if (ret == 0) { ret = wc_RsaPrivateDecryptInline_ex(cipher, (word32)idx, &res, &key, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, @@ -20426,7 +20202,8 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) if (ret >= 0) { if (!XMEMCMP(inStr, res, plainSz)) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20443,10 +20220,9 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + result = TEST_RES_CHECK(ret == 0); #endif - return ret; + return result; } /* END test_wc_RsaPublicEncryptDecrypt_ex */ @@ -20455,10 +20231,11 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void) */ static int test_wc_RsaSSL_SignVerify(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; + int ret = 0; const char inStr[] = TEST_STRING; const word32 plainSz = (word32)TEST_STRING_SZ; const word32 inLen = (word32)TEST_STRING_SZ; @@ -20472,8 +20249,8 @@ static int test_wc_RsaSSL_SignVerify(void) #ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC if (in == NULL || out == NULL || plain == NULL) { - printf("test_wc_RsaSSL_SignVerify failed\n"); - return MEMORY_E; + fprintf(stderr, "test_wc_RsaSSL_SignVerify failed\n"); + return TEST_FAIL; } #endif XMEMCPY(in, inStr, inLen); @@ -20488,14 +20265,14 @@ static int test_wc_RsaSSL_SignVerify(void) ret = MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng); } /* Sign. */ - printf(testingFmt, "wc_RsaSSL_Sign()"); if (ret == 0) { ret = wc_RsaSSL_Sign(in, inLen, out, outSz, &key, &rng); if (ret == (int)outSz) { idx = ret; ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20514,7 +20291,8 @@ static int test_wc_RsaSSL_SignVerify(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20533,26 +20311,23 @@ static int test_wc_RsaSSL_SignVerify(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } #endif - printf(resultFmt, ret == 0 ? passed : failed); if (ret != 0) { - return ret; + return TEST_FAIL; } /* Verify. */ - printf(testingFmt, "wc_RsaSSL_Verify()"); - - if (ret == 0) { - ret = wc_RsaSSL_Verify(out, idx, plain, plainSz, &key); - if (ret == (int)inLen) { - ret = 0; - } else { - ret = WOLFSSL_FATAL_ERROR; - } + ret = wc_RsaSSL_Verify(out, idx, plain, plainSz, &key); + if (ret == (int)inLen) { + ret = 0; + } + else { + ret = WOLFSSL_FATAL_ERROR; } #ifndef HAVE_USER_RSA /* Pass bad args. */ @@ -20569,7 +20344,8 @@ static int test_wc_RsaSSL_SignVerify(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20588,7 +20364,8 @@ static int test_wc_RsaSSL_SignVerify(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20604,10 +20381,9 @@ static int test_wc_RsaSSL_SignVerify(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaSSL_SignVerify */ @@ -20616,10 +20392,11 @@ static int test_wc_RsaSSL_SignVerify(void) */ static int test_wc_RsaEncryptSize(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; + int ret; ret = wc_InitRsaKey(&key, HEAP_HINT); @@ -20627,7 +20404,6 @@ static int test_wc_RsaEncryptSize(void) ret = wc_InitRng(&rng); } - printf(testingFmt, "wc_RsaEncryptSize()"); #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) if (ret == 0) { @@ -20637,13 +20413,15 @@ static int test_wc_RsaEncryptSize(void) } if (ret == 128) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } if (wc_FreeRsaKey(&key) || ret != 0) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } #endif @@ -20655,7 +20433,8 @@ static int test_wc_RsaEncryptSize(void) } if (ret == 256) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20666,7 +20445,8 @@ static int test_wc_RsaEncryptSize(void) #ifndef HAVE_USER_RSA if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } #endif @@ -20679,10 +20459,9 @@ static int test_wc_RsaEncryptSize(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaEncryptSize*/ @@ -20691,10 +20470,11 @@ static int test_wc_RsaEncryptSize(void) */ static int test_wc_RsaFlattenPublicKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) RsaKey key; WC_RNG rng; + int ret = 0; byte e[256]; byte n[256]; word32 eSz = sizeof(e); @@ -20715,13 +20495,12 @@ static int test_wc_RsaFlattenPublicKey(void) ret = MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng); if (ret >= 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(testingFmt, "wc_RsaFlattenPublicKey()"); - if (ret == 0) { ret = wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz); } @@ -20743,7 +20522,8 @@ static int test_wc_RsaFlattenPublicKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20765,7 +20545,8 @@ static int test_wc_RsaFlattenPublicKey(void) } if (ret == USER_CRYPTO_ERROR) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -20777,10 +20558,9 @@ static int test_wc_RsaFlattenPublicKey(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_RsaFlattenPublicKey */ @@ -20791,9 +20571,10 @@ static int test_wc_RsaFlattenPublicKey(void) */ static int test_wc_AesCcmSetKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_AESCCM Aes aes; + int ret = 0; const byte key16[] = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, @@ -20813,8 +20594,6 @@ static int test_wc_AesCcmSetKey(void) 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 }; - printf(testingFmt, "wc_AesCcmSetKey()"); - ret = wc_AesInit(&aes, NULL, INVALID_DEVID); if (ret != 0) return ret; @@ -20844,17 +20623,17 @@ static int test_wc_AesCcmSetKey(void) } if (ret != BAD_FUNC_ARG) { ret = WOLFSSL_FATAL_ERROR; - } else { + } + else { ret = 0; } } wc_AesFree(&aes); - printf(resultFmt, ret == 0 ? passed : failed); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_AesCcmSetKey */ @@ -20863,9 +20642,10 @@ static int test_wc_AesCcmSetKey(void) */ static int test_wc_AesCcmEncryptDecrypt(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_AESCCM) && defined(WOLFSSL_AES_128) Aes aes; + int ret = 0; const byte key16[] = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, @@ -20933,8 +20713,6 @@ static int test_wc_AesCcmEncryptDecrypt(void) #endif } - printf(testingFmt, "wc_AesCcmEncrypt()"); - /* Pass in bad args. Encrypt*/ if (ret == 0 && ccmE == 0) { ccmE = wc_AesCcmEncrypt(NULL, cipherOut, plainT, sizeof(cipherOut), @@ -20973,19 +20751,17 @@ static int test_wc_AesCcmEncryptDecrypt(void) if (ccmE != BAD_FUNC_ARG) { ccmE = WOLFSSL_FATAL_ERROR; - } else { + } + else { ccmE = 0; } } /* End Encrypt */ - printf(resultFmt, ccmE == 0 ? passed : failed); if (ccmE != 0) { wc_AesFree(&aes); - return ccmE; + return TEST_FAIL; } #ifdef HAVE_AES_DECRYPT - printf(testingFmt, "wc_AesCcmDecrypt()"); - /* Pass in bad args. Decrypt*/ if (ret == 0 && ccmD == 0) { ccmD = wc_AesCcmDecrypt(NULL, plainOut, cipherOut, sizeof(plainOut), @@ -21026,23 +20802,18 @@ static int test_wc_AesCcmEncryptDecrypt(void) } if (ccmD != BAD_FUNC_ARG) { ccmD = WOLFSSL_FATAL_ERROR; - } else { + } + else { ccmD = 0; } } /* END Decrypt */ - printf(resultFmt, ccmD == 0 ? passed : failed); - if (ccmD != 0) { - return ccmD; - } + res = TEST_RES_CHECK(ccmD == 0); #endif wc_AesFree(&aes); - #endif /* HAVE_AESCCM */ - - return ret; - + return res; } /* END test_wc_AesCcmEncryptDecrypt */ @@ -21051,12 +20822,10 @@ static int test_wc_AesCcmEncryptDecrypt(void) */ static int test_wc_InitDsaKey(void) { - int ret = 0; - + int res = TEST_SKIPPED; #ifndef NO_DSA DsaKey key; - - printf(testingFmt, "wc_InitDsaKey()"); + int ret = 0; ret = wc_InitDsaKey(&key); @@ -21065,17 +20834,17 @@ static int test_wc_InitDsaKey(void) ret = wc_InitDsaKey(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_InitDsaKey */ @@ -21084,11 +20853,12 @@ static int test_wc_InitDsaKey(void) */ static int test_wc_DsaSignVerify(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_DSA) DsaKey key; WC_RNG rng; wc_Sha sha; + int ret = 0; byte signature[DSA_SIG_SIZE]; byte hash[WC_SHA_DIGEST_SIZE]; word32 idx = 0; @@ -21132,7 +20902,6 @@ static int test_wc_DsaSignVerify(void) } } - printf(testingFmt, "wc_DsaSign()"); /* Sign. */ if (ret == 0) { ret = wc_DsaSign(hash, signature, &key, &rng); @@ -21152,25 +20921,21 @@ static int test_wc_DsaSignVerify(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - - if (ret != 0) { - return ret; - } - - /* Verify. */ - printf(testingFmt, "wc_DsaVerify()"); - - ret = wc_DsaVerify(hash, signature, &key, &answer); - if (ret != 0 || answer != 1) { - ret = WOLFSSL_FATAL_ERROR; - } else { - ret = 0; + if (ret == 0) { + /* Verify. */ + ret = wc_DsaVerify(hash, signature, &key, &answer); + if (ret != 0 || answer != 1) { + ret = WOLFSSL_FATAL_ERROR; + } + else { + ret = 0; + } } /* Pass in bad args. */ @@ -21187,7 +20952,8 @@ static int test_wc_DsaSignVerify(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21206,13 +20972,12 @@ static int test_wc_DsaSignVerify(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); wc_ShaFree(&sha); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_DsaSign */ @@ -21221,14 +20986,14 @@ static int test_wc_DsaSignVerify(void) */ static int test_wc_DsaPublicPrivateKeyDecode(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) DsaKey key; word32 bytes; word32 idx = 0; int priv = WOLFSSL_FATAL_ERROR; int pub = WOLFSSL_FATAL_ERROR; + int ret = 0; #ifdef USE_CERT_BUFFERS_1024 byte tmp[ONEK_BUF]; @@ -21252,7 +21017,6 @@ static int test_wc_DsaPublicPrivateKeyDecode(void) ret = wc_InitDsaKey(&key); - printf(testingFmt, "wc_DsaPrivateKeyDecode()"); if (ret == 0) { priv = wc_DsaPrivateKeyDecode(tmp, &idx, &key, bytes); @@ -21270,7 +21034,8 @@ static int test_wc_DsaPublicPrivateKeyDecode(void) } if (priv == ASN_PARSE_E) { priv = 0; - } else { + } + else { priv = WOLFSSL_FATAL_ERROR; } } @@ -21279,9 +21044,6 @@ static int test_wc_DsaPublicPrivateKeyDecode(void) ret = wc_InitDsaKey(&key); } - printf(resultFmt, priv == 0 ? passed : failed); - - printf(testingFmt, "wc_DsaPublicKeyDecode()"); if (ret == 0) { idx = 0; /* Reset */ pub = wc_DsaPublicKeyDecode(tmp, &idx, &key, bytes); @@ -21299,19 +21061,19 @@ static int test_wc_DsaPublicPrivateKeyDecode(void) } if (pub == ASN_PARSE_E) { pub = 0; - } else { + } + else { pub = WOLFSSL_FATAL_ERROR; } } } /* END Public Key */ - printf(resultFmt, pub == 0 ? passed : failed); - wc_FreeDsaKey(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_DsaPublicPrivateKeyDecode */ @@ -21321,11 +21083,12 @@ static int test_wc_DsaPublicPrivateKeyDecode(void) */ static int test_wc_MakeDsaKey(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) && defined(WOLFSSL_KEY_GEN) DsaKey genKey; WC_RNG rng; + int ret = 0; + XMEMSET(&rng, 0, sizeof(rng)); XMEMSET(&genKey, 0, sizeof(genKey)); @@ -21334,7 +21097,6 @@ static int test_wc_MakeDsaKey(void) ret = wc_InitDsaKey(&genKey); } - printf(testingFmt, "wc_MakeDsaParameters()"); if (ret == 0) { ret = wc_MakeDsaParameters(&rng, ONEK_BUF, &genKey); } @@ -21349,15 +21111,12 @@ static int test_wc_MakeDsaKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - - printf(testingFmt, "wc_MakeDsaKey()"); - if (ret == 0) { ret = wc_MakeDsaKey(&rng, &genKey); } @@ -21370,7 +21129,8 @@ static int test_wc_MakeDsaKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21379,11 +21139,11 @@ static int test_wc_MakeDsaKey(void) ret = WOLFSSL_FAILURE; } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&genKey); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_MakeDsaKey */ /* @@ -21391,14 +21151,13 @@ static int test_wc_MakeDsaKey(void) */ static int test_wc_DsaKeyToDer(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) && defined(WOLFSSL_KEY_GEN) DsaKey genKey; WC_RNG rng; word32 bytes; word32 idx = 0; - + int ret = 0; #ifdef USE_CERT_BUFFERS_1024 byte tmp[ONEK_BUF]; byte der[ONEK_BUF]; @@ -21444,8 +21203,6 @@ static int test_wc_DsaKeyToDer(void) ret = wc_DsaPrivateKeyDecode(tmp, &idx, &genKey, bytes); } - printf(testingFmt, "wc_DsaKeyToDer()"); - if (ret == 0) { ret = wc_DsaKeyToDer(&genKey, der, bytes); if ( ret >= 0 && ( ret = XMEMCMP(der, tmp, bytes) ) == 0 ) { @@ -21461,7 +21218,8 @@ static int test_wc_DsaKeyToDer(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21470,13 +21228,11 @@ static int test_wc_DsaKeyToDer(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&genKey); + res = TEST_RES_CHECK(ret == 0); #endif /* !NO_DSA && WOLFSSL_KEY_GEN */ - - return ret; + return res; } /* END test_wc_DsaKeyToDer */ @@ -21486,15 +21242,14 @@ static int test_wc_DsaKeyToDer(void) */ static int test_wc_DsaKeyToPublicDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef HAVE_SELFTEST #if !defined(NO_DSA) && defined(WOLFSSL_KEY_GEN) DsaKey genKey; WC_RNG rng; byte* der; word32 sz; - - printf(testingFmt, "wc_DsaKeyToPublicDer()"); + int ret = 0; der = (byte*)XMALLOC(ONEK_BUF, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (der == NULL) { @@ -21518,7 +21273,8 @@ static int test_wc_DsaKeyToPublicDer(void) if (ret >= 0) { sz = ret; ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21533,7 +21289,8 @@ static int test_wc_DsaKeyToPublicDer(void) if (ret >= 0) { sz = ret; ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21551,7 +21308,8 @@ static int test_wc_DsaKeyToPublicDer(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -21560,13 +21318,13 @@ static int test_wc_DsaKeyToPublicDer(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - XFREE(der,NULL,DYNAMIC_TYPE_TMP_BUFFER); wc_FreeDsaKey(&genKey); + + res = TEST_RES_CHECK(ret == 0); #endif /* !defined(NO_DSA) && defined(WOLFSSL_KEY_GEN) */ #endif /* HAVE_SELFTEST */ - return ret; + return res; } /* END test_wc_DsaKeyToPublicDer */ @@ -21575,10 +21333,10 @@ static int test_wc_DsaKeyToPublicDer(void) */ static int test_wc_DsaImportParamsRaw(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) DsaKey key; + int ret = 0; /* [mod = L=1024, N=160], from CAVP KeyPair */ const char* p = "d38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d" @@ -21599,8 +21357,6 @@ static int test_wc_DsaImportParamsRaw(void) const char* invalidP = "d38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d"; const char* invalidQ = "96c5390a"; - printf(testingFmt, "wc_DsaImportParamsRaw()"); - ret = wc_InitDsaKey(&key); if (ret == 0) { ret = wc_DsaImportParamsRaw(&key, p, q, g); @@ -21629,13 +21385,11 @@ static int test_wc_DsaImportParamsRaw(void) } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; + return res; } /* END test_wc_DsaImportParamsRaw */ @@ -21644,10 +21398,10 @@ static int test_wc_DsaImportParamsRaw(void) */ static int test_wc_DsaImportParamsRawCheck(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) DsaKey key; + int ret = 0; int trusted = 0; /* [mod = L=1024, N=160], from CAVP KeyPair */ const char* p = "d38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d" @@ -21668,8 +21422,6 @@ static int test_wc_DsaImportParamsRawCheck(void) const char* invalidP = "d38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d"; const char* invalidQ = "96c5390a"; - printf(testingFmt, "wc_DsaImportParamsRawCheck()"); - ret = wc_InitDsaKey(&key); if (ret == 0) { ret = wc_DsaImportParamsRawCheck(&key, p, q, g, trusted, NULL); @@ -21698,14 +21450,11 @@ static int test_wc_DsaImportParamsRawCheck(void) } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_DsaImportParamsRawCheck */ /* @@ -21713,10 +21462,10 @@ static int test_wc_DsaImportParamsRawCheck(void) */ static int test_wc_DsaExportParamsRaw(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) DsaKey key; + int ret = 0; /* [mod = L=1024, N=160], from CAVP KeyPair */ const char* p = "d38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d" @@ -21763,8 +21512,6 @@ static int test_wc_DsaExportParamsRaw(void) byte gOut[MAX_DSA_PARAM_SIZE]; word32 pOutSz, qOutSz, gOutSz; - printf(testingFmt, "wc_DsaExportParamsRaw()"); - ret = wc_InitDsaKey(&key); if (ret == 0) { /* first test using imported raw parameters, for expected */ @@ -21832,14 +21579,11 @@ static int test_wc_DsaExportParamsRaw(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_DsaExportParamsRaw */ /* @@ -21847,17 +21591,16 @@ static int test_wc_DsaExportParamsRaw(void) */ static int test_wc_DsaExportKeyRaw(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if !defined(NO_DSA) && defined(WOLFSSL_KEY_GEN) DsaKey key; WC_RNG rng; + int ret = 0; byte xOut[MAX_DSA_PARAM_SIZE]; byte yOut[MAX_DSA_PARAM_SIZE]; word32 xOutSz, yOutSz; - printf(testingFmt, "wc_DsaExportKeyRaw()"); XMEMSET(&rng, 0, sizeof(rng)); XMEMSET(&key, 0, sizeof(key)); @@ -21913,15 +21656,12 @@ static int test_wc_DsaExportKeyRaw(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - wc_FreeDsaKey(&key); wc_FreeRng(&rng); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_DsaExportParamsRaw */ @@ -21930,12 +21670,12 @@ static int test_wc_DsaExportKeyRaw(void) */ static int test_wc_ed25519_make_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) ed25519_key key; WC_RNG rng; unsigned char pubkey[ED25519_PUB_KEY_SIZE]; + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -21950,7 +21690,6 @@ static int test_wc_ed25519_make_key(void) ret = -1; } } - printf(testingFmt, "wc_ed25519_make_key()"); if (ret == 0) { ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key); } @@ -21968,22 +21707,21 @@ static int test_wc_ed25519_make_key(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_make_key */ @@ -21992,13 +21730,10 @@ static int test_wc_ed25519_make_key(void) */ static int test_wc_ed25519_init(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) - ed25519_key key; - - printf(testingFmt, "wc_ed25519_init()"); + int ret = 0; ret = wc_ed25519_init(&key); @@ -22007,18 +21742,17 @@ static int test_wc_ed25519_init(void) ret = wc_ed25519_init(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_init */ /* @@ -22026,11 +21760,11 @@ static int test_wc_ed25519_init(void) */ static int test_wc_ed25519_sign_msg(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_SIGN) WC_RNG rng; ed25519_key key; + int ret = 0; byte msg[] = "Everybody gets Friday off.\n"; byte sig[ED25519_SIG_SIZE]; word32 msglen = sizeof(msg); @@ -22052,8 +21786,6 @@ static int test_wc_ed25519_sign_msg(void) } } - printf(testingFmt, "wc_ed25519_sign_msg()"); - if (ret == 0) { ret = wc_ed25519_sign_msg(msg, msglen, sig, &siglen, &key); } @@ -22075,70 +21807,69 @@ static int test_wc_ed25519_sign_msg(void) if (ret == BUFFER_E && badSigLen == ED25519_SIG_SIZE) { badSigLen -= 1; ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } /* END sign */ - printf(resultFmt, ret == 0 ? passed : failed); - #ifdef HAVE_ED25519_VERIFY - printf(testingFmt, "wc_ed25519_verify_msg()"); +#ifdef HAVE_ED25519_VERIFY + if (ret == 0) { + ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, &verify_ok, &key); + if (ret == 0 && verify_ok == 1) { + ret = 0; + } + else if (ret == 0) { + ret = WOLFSSL_FATAL_ERROR; + } + + /* Test bad args. */ if (ret == 0) { + AssertIntEQ(wc_ed25519_verify_msg(sig, siglen - 1, msg, + msglen, &verify_ok, &key), + BAD_FUNC_ARG); + AssertIntEQ(wc_ed25519_verify_msg(sig, siglen + 1, msg, + msglen, &verify_ok, &key), + BAD_FUNC_ARG); - ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, &verify_ok, &key); - if (ret == 0 && verify_ok == 1) { + ret = wc_ed25519_verify_msg(NULL, siglen, msg, msglen, &verify_ok, + &key); + if (ret == BAD_FUNC_ARG) { + ret = wc_ed25519_verify_msg(sig, siglen, NULL, msglen, + &verify_ok, &key); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, + NULL, &key); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, + &verify_ok, NULL); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed25519_verify_msg(sig, badSigLen, msg, msglen, + &verify_ok, &key); + } + if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } + } - /* Test bad args. */ - if (ret == 0) { - AssertIntEQ(wc_ed25519_verify_msg(sig, siglen - 1, msg, - msglen, &verify_ok, &key), - BAD_FUNC_ARG); - AssertIntEQ(wc_ed25519_verify_msg(sig, siglen + 1, msg, - msglen, &verify_ok, &key), - BAD_FUNC_ARG); - - ret = wc_ed25519_verify_msg(NULL, siglen, msg, msglen, &verify_ok, - &key); - if (ret == BAD_FUNC_ARG) { - ret = wc_ed25519_verify_msg(sig, siglen, NULL, msglen, - &verify_ok, &key); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, - NULL, &key); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed25519_verify_msg(sig, siglen, msg, msglen, - &verify_ok, NULL); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed25519_verify_msg(sig, badSigLen, msg, msglen, - &verify_ok, &key); - } - if (ret == BAD_FUNC_ARG) { - ret = 0; - } else if (ret == 0) { - ret = WOLFSSL_FATAL_ERROR; - } - } - - } /* END verify. */ - - printf(resultFmt, ret == 0 ? passed : failed); - #endif /* Verify. */ + } /* END verify. */ +#endif /* Verify. */ if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ed25519_sign_msg */ @@ -22147,14 +21878,13 @@ static int test_wc_ed25519_sign_msg(void) */ static int test_wc_ed25519_import_public(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_IMPORT) WC_RNG rng; ed25519_key pubKey; const byte in[] = "Ed25519PublicKeyUnitTest......\n"; word32 inlen = sizeof(in); - + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -22163,14 +21893,14 @@ static int test_wc_ed25519_import_public(void) ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &pubKey); } } - printf(testingFmt, "wc_ed25519_import_public()"); if (ret == 0) { ret = wc_ed25519_import_public_ex(in, inlen, &pubKey, 1); if (ret == 0 && XMEMCMP(in, pubKey.p, inlen) == 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } @@ -22185,22 +21915,21 @@ static int test_wc_ed25519_import_public(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed25519_free(&pubKey); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END wc_ed25519_import_public */ /* @@ -22208,11 +21937,11 @@ static int test_wc_ed25519_import_public(void) */ static int test_wc_ed25519_import_private_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_IMPORT) WC_RNG rng; ed25519_key key; + int ret; const byte privKey[] = "Ed25519PrivateKeyUnitTest.....\n"; const byte pubKey[] = "Ed25519PublicKeyUnitTest......\n"; word32 privKeySz = sizeof(privKey); @@ -22233,8 +21962,6 @@ static int test_wc_ed25519_import_private_key(void) } ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key); - printf(testingFmt, "wc_ed25519_import_private_key()"); - if (ret == 0) { ret = wc_ed25519_import_private_key_ex(privKey, privKeySz, pubKey, pubKeySz, &key, 1); @@ -22284,21 +22011,20 @@ static int test_wc_ed25519_import_private_key(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_import_private_key */ /* @@ -22306,11 +22032,11 @@ static int test_wc_ed25519_import_private_key(void) */ static int test_wc_ed25519_export(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) WC_RNG rng; ed25519_key key; + int ret = 0; byte priv[ED25519_PRV_KEY_SIZE]; byte pub[ED25519_PUB_KEY_SIZE]; word32 privSz = sizeof(priv); @@ -22331,8 +22057,6 @@ static int test_wc_ed25519_export(void) ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key); } - printf(testingFmt, "wc_ed25519_export_public()"); - if (ret == 0) { ret = wc_ed25519_export_public(&key, pub, &pubSz); if (ret == 0 && (pubSz != ED25519_KEY_SIZE @@ -22349,15 +22073,13 @@ static int test_wc_ed25519_export(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - printf(testingFmt, "wc_ed25519_export_private_only()"); - if (ret == 0) { ret = wc_ed25519_export_private_only(&key, priv, &privSz); if (ret == 0 && (privSz != ED25519_KEY_SIZE @@ -22374,22 +22096,21 @@ static int test_wc_ed25519_export(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_export */ /* @@ -22397,10 +22118,11 @@ static int test_wc_ed25519_export(void) */ static int test_wc_ed25519_size(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) WC_RNG rng; ed25519_key key; + int ret; ret = wc_InitRng(&rng); if (ret != 0) { @@ -22419,7 +22141,6 @@ static int test_wc_ed25519_size(void) return ret; } - printf(testingFmt, "wc_ed25519_size()"); ret = wc_ed25519_size(&key); /* Test bad args. */ if (ret == ED25519_KEY_SIZE) { @@ -22428,11 +22149,8 @@ static int test_wc_ed25519_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); if (ret == 0) { - printf(testingFmt, "wc_ed25519_sig_size()"); - ret = wc_ed25519_sig_size(&key); if (ret == ED25519_SIG_SIZE) { ret = 0; @@ -22444,12 +22162,9 @@ static int test_wc_ed25519_size(void) ret = 0; } } - - printf(resultFmt, ret == 0 ? passed : failed); } /* END wc_ed25519_sig_size() */ if (ret == 0) { - printf(testingFmt, "wc_ed25519_pub_size"); ret = wc_ed25519_pub_size(&key); if (ret == ED25519_PUB_KEY_SIZE) { ret = 0; @@ -22460,11 +22175,9 @@ static int test_wc_ed25519_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); } /* END wc_ed25519_pub_size */ if (ret == 0) { - printf(testingFmt, "wc_ed25519_priv_size"); ret = wc_ed25519_priv_size(&key); if (ret == ED25519_PRV_KEY_SIZE) { ret = 0; @@ -22475,7 +22188,6 @@ static int test_wc_ed25519_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); } /* END wc_ed25519_pub_size */ if (wc_FreeRng(&rng) && ret == 0) { @@ -22483,9 +22195,9 @@ static int test_wc_ed25519_size(void) } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_size */ /* @@ -22493,10 +22205,11 @@ static int test_wc_ed25519_size(void) */ static int test_wc_ed25519_exportKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) WC_RNG rng; ed25519_key key; + int ret = 0; byte priv[ED25519_PRV_KEY_SIZE]; byte pub[ED25519_PUB_KEY_SIZE]; byte privOnly[ED25519_PRV_KEY_SIZE]; @@ -22506,23 +22219,21 @@ static int test_wc_ed25519_exportKey(void) ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed25519_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key); if (ret != 0) { wc_FreeRng(&rng); wc_ed25519_free(&key); - return ret; + return TEST_FAIL; } - printf(testingFmt, "wc_ed25519_export_private()"); - ret = wc_ed25519_export_private(&key, privOnly, &privOnlySz); if (ret == 0) { ret = wc_ed25519_export_private(NULL, privOnly, &privOnlySz); @@ -22534,16 +22245,13 @@ static int test_wc_ed25519_exportKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - if (ret == 0) { - printf(testingFmt, "wc_ed25519_export_key()"); - ret = wc_ed25519_export_key(&key, priv, &privSz, pub, &pubSz); if (ret == 0) { ret = wc_ed25519_export_key(NULL, priv, &privSz, pub, &pubSz); @@ -22561,11 +22269,11 @@ static int test_wc_ed25519_exportKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); } /* END wc_ed25519_export_key() */ /* Cross check output. */ @@ -22578,9 +22286,9 @@ static int test_wc_ed25519_exportKey(void) } wc_ed25519_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed25519_exportKey */ /* @@ -22588,15 +22296,13 @@ static int test_wc_ed25519_exportKey(void) */ static int test_wc_Ed25519PublicKeyToDer(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) int tmp; ed25519_key key; byte derBuf[1024]; - - printf(testingFmt, "wc_Ed25519PublicKeyToDer()"); + int ret = 0; /* Test bad args */ tmp = wc_Ed25519PublicKeyToDer(NULL, NULL, 0, 0); @@ -22618,19 +22324,19 @@ static int test_wc_Ed25519PublicKeyToDer(void) WC_RNG rng; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed25519_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key); if (ret != 0) { wc_FreeRng(&rng); wc_ed25519_free(&key); - return ret; + return TEST_FAIL; } tmp = wc_Ed25519PublicKeyToDer(&key, derBuf, 1024, 1); @@ -22641,10 +22347,10 @@ static int test_wc_Ed25519PublicKeyToDer(void) wc_FreeRng(&rng); wc_ed25519_free(&key); } - printf(resultFmt, ret == 0 ? passed : failed); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END testing wc_Ed25519PublicKeyToDer */ /* @@ -22652,47 +22358,41 @@ static int test_wc_Ed25519PublicKeyToDer(void) */ static int test_wc_curve25519_init(void) { + int res = TEST_SKIPPED; +#if defined(HAVE_CURVE25519) + curve25519_key key; int ret = 0; -#if defined(HAVE_CURVE25519) - - curve25519_key key; - - printf(testingFmt, "wc_curve25519_init()"); ret = wc_curve25519_init(&key); - /* Test bad args for wc_curve25519_init */ if (ret == 0) { ret = wc_curve25519_init(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); /* Test good args for wc_curve_25519_free */ wc_curve25519_free(&key); wc_curve25519_free(NULL); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_curve25519_init and wc_curve_25519_free*/ /* * Testing test_wc_curve25519_size. */ static int test_wc_curve25519_size(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) - curve25519_key key; - - printf(testingFmt, "wc_curve25519_size()"); + int ret = 0; ret = wc_curve25519_init(&key); @@ -22706,11 +22406,11 @@ static int test_wc_curve25519_size(void) ret = wc_curve25519_size(NULL); } - printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&key); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_curve25519_size*/ /* @@ -22718,11 +22418,11 @@ static int test_wc_curve25519_size(void) */ static int test_wc_curve25519_export_key_raw(void) { - + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) && defined(HAVE_CURVE25519_KEY_EXPORT) - curve25519_key key; WC_RNG rng; + int ret = 0; byte privateKey[CURVE25519_KEYSIZE]; byte publicKey[CURVE25519_KEYSIZE]; @@ -22734,182 +22434,104 @@ static int test_wc_curve25519_export_key_raw(void) word32 prksz; word32 pbksz; - printf(testingFmt, "wc_curve25519_export_key_raw()"); - - - if(0 != wc_InitRng(&rng)){ - printf(testingFmt, "failed due to wc_InitRng"); - fflush(stdout); - return 1; + if (0 != wc_InitRng(&rng)) { + return TEST_FAIL; } - - if(0 != wc_curve25519_init(&key)){ - printf(testingFmt, "failed due to wc_curve25519_init"); - fflush(stdout); + if (0 != wc_curve25519_init(&key)) { wc_FreeRng(&rng); - return 1; + return TEST_FAIL; } - 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; - } + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); /* bad-argument-test cases target function sould return BAD_FUNC_ARG - */ - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( - NULL , privateKey, &prvkSz, publicKey, &pubkSz)){ - - printf(testingFmt,"failed at bad-arg-case-1."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + */ + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw( + NULL, privateKey, &prvkSz, publicKey, &pubkSz)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( - &key , NULL, &prvkSz, publicKey, &pubkSz)){ - - printf(testingFmt,"failed at bad-arg-case-2."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw( + &key, NULL, &prvkSz, publicKey, &pubkSz)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( - &key , privateKey, NULL, publicKey, &pubkSz)){ - - printf(testingFmt,"failed at bad-arg-case-3."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw( + &key, privateKey, NULL, publicKey, &pubkSz)) { + ret = -1; + } } - /* prvkSz = CURVE25519_KEYSIZE; */ - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( - &key , privateKey, &prvkSz, NULL, &pubkSz)){ - - printf(testingFmt,"failed at bad-arg-case-4."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + /* prvkSz = CURVE25519_KEYSIZE; */ + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw( + &key, privateKey, &prvkSz, NULL, &pubkSz)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw( - &key , privateKey, &prvkSz, publicKey, NULL )){ - - printf(testingFmt,"failed at bad-arg-case-5."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw( + &key, privateKey, &prvkSz, publicKey, NULL )) { + ret = -1; + } } /* cross-testing */ - prksz = CURVE25519_KEYSIZE; - - if( 0 != wc_curve25519_export_private_raw(&key, prik, &prksz)){ - - printf(testingFmt,"failed due to wc_curve25519_export_private_raw"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + prksz = CURVE25519_KEYSIZE; + ret = wc_curve25519_export_private_raw(&key, prik, &prksz); } - pbksz = CURVE25519_KEYSIZE; - - if(0 != wc_curve25519_export_public(&key, pubk, &pbksz)){ - - printf(testingFmt,"failed due to wc_curve25519_export_public"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + pbksz = CURVE25519_KEYSIZE; + ret = wc_curve25519_export_public(&key, pubk, &pbksz); } - prvkSz = CURVE25519_KEYSIZE; - /* pubkSz = CURVE25519_KEYSIZE; */ - - 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; - + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + /* pubkSz = CURVE25519_KEYSIZE; */ + ret = wc_curve25519_export_key_raw(&key, privateKey, &prvkSz, + publicKey, &pubkSz); } - if((prksz == CURVE25519_KEYSIZE) && - (pbksz == CURVE25519_KEYSIZE) && - (prvkSz == CURVE25519_KEYSIZE) && - (pubkSz == CURVE25519_KEYSIZE)){ + if (ret == 0) { + if ((prksz == CURVE25519_KEYSIZE) && + (pbksz == CURVE25519_KEYSIZE) && + (prvkSz == CURVE25519_KEYSIZE) && + (pubkSz == CURVE25519_KEYSIZE)) { - if( 0 == XMEMCMP(privateKey, prik, CURVE25519_KEYSIZE) && - 0 == XMEMCMP(publicKey, pubk, CURVE25519_KEYSIZE)){ - - printf(resultFmt,passed); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 0; - - } - else{ - - printf(testingFmt,"failed due to key-contents-inconsistency."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (0 != XMEMCMP(privateKey, prik, CURVE25519_KEYSIZE) || + 0 != XMEMCMP(publicKey, pubk, CURVE25519_KEYSIZE)) { + ret = -1; + } } } - else{ - printf(testingFmt,"failed due to bad-key-size."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - } + wc_curve25519_free(&key); + wc_FreeRng(&rng); + res = TEST_RES_CHECK(ret == 0); #endif - fflush(stdout); - - return 0; + return res; } /* end of test_wc_curve25519_export_key_raw */ /* @@ -22917,11 +22539,11 @@ static int test_wc_curve25519_export_key_raw(void) */ static int test_wc_curve25519_export_key_raw_ex(void) { - + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) && defined(HAVE_CURVE25519_KEY_EXPORT) - curve25519_key key; WC_RNG rng; + int ret; byte privateKey[CURVE25519_KEYSIZE]; byte publicKey[CURVE25519_KEYSIZE]; @@ -22933,329 +22555,195 @@ static int test_wc_curve25519_export_key_raw_ex(void) word32 prksz; word32 pbksz; - printf(testingFmt, "wc_curve25519_export_key_raw_ex()"); - - if(0 != wc_InitRng(&rng)){ - printf(testingFmt, "failed due to wc_InitRng"); - fflush(stdout); - return 1; + if (0 != wc_InitRng(&rng)) { + return TEST_FAIL; } - - if(0 != wc_curve25519_init(&key)){ - printf(testingFmt, "failed due to wc_curve25519_init"); - fflush(stdout); + if (0 != wc_curve25519_init(&key)) { wc_FreeRng(&rng); - return 1; + return TEST_FAIL; } - 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; - } + ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key); /* bad-argument-test cases 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, - &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-1."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL , privateKey, + &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - 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."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key , NULL, + &prvkSz, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)) { + ret = -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; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key,privateKey, + NULL, publicKey, &pubkSz, EC25519_LITTLE_ENDIAN)) { + ret = -1; + } } - /* prvkSz = CURVE25519_KEYSIZE; */ - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, - &prvkSz, NULL, &pubkSz, EC25519_LITTLE_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-4."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + /* prvkSz = CURVE25519_KEYSIZE; */ + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + &prvkSz, NULL, &pubkSz, EC25519_LITTLE_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, - &prvkSz, publicKey, NULL, EC25519_LITTLE_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-5."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + &prvkSz, publicKey, NULL, EC25519_LITTLE_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - /* pubkSz = CURVE25519_KEYSIZE; */ - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL, privateKey, - &prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-6."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + /* pubkSz = CURVE25519_KEYSIZE; */ + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL, privateKey, + &prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, NULL, &prvkSz, - publicKey, &pubkSz, EC25519_BIG_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-7."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, NULL, + &prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, - NULL, publicKey, &pubkSz, EC25519_BIG_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-8."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + NULL, publicKey, &pubkSz, EC25519_BIG_ENDIAN)) { + ret = -1; + } } - /* prvkSz = CURVE25519_KEYSIZE; */ - pubkSz = CURVE25519_KEYSIZE; - - 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."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + /* prvkSz = CURVE25519_KEYSIZE; */ + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + &prvkSz, NULL, &pubkSz, EC25519_BIG_ENDIAN)) { + ret = -1; + } } - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, - &prvkSz, publicKey, NULL, EC25519_BIG_ENDIAN)){ - - printf(testingFmt,"failed at bad-arg-case-10."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, + &prvkSz, publicKey, NULL, EC25519_BIG_ENDIAN)) { + ret = -1; + } } /* illegal value for endien */ - prvkSz = CURVE25519_KEYSIZE; - /* pubkSz = CURVE25519_KEYSIZE; */ - - if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey, - &prvkSz, publicKey, NULL, EC25519_BIG_ENDIAN + 10 )){ - - printf(testingFmt,"failed at bad-arg-case-11."); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + /* pubkSz = CURVE25519_KEYSIZE; */ + if (BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex(&key, privateKey, + &prvkSz, publicKey, NULL, EC25519_BIG_ENDIAN + 10)) { + ret = -1; + } } /* cross-testing */ - prksz = CURVE25519_KEYSIZE; - - if(0 != wc_curve25519_export_private_raw( &key, prik, &prksz )){ - - printf(testingFmt,"failed due to wc_curve25519_export_private_raw"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prksz = CURVE25519_KEYSIZE; + ret = wc_curve25519_export_private_raw( &key, prik, &prksz); } - pbksz = CURVE25519_KEYSIZE; - - if(0 != wc_curve25519_export_public( &key, pubk, &pbksz )){ - - printf(testingFmt,"failed due to wc_curve25519_export_public"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - + if (ret == 0) { + pbksz = CURVE25519_KEYSIZE; + ret = wc_curve25519_export_public( &key, pubk, &pbksz); } - prvkSz = CURVE25519_KEYSIZE; - /* pubkSz = CURVE25519_KEYSIZE; */ - - if(0 != wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, - publicKey, &pubkSz, EC25519_BIG_ENDIAN)) { - - printf(testingFmt,"failed due to wc_curve25519_export_key_raw_ex"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + /* pubkSz = CURVE25519_KEYSIZE; */ + ret = wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, + publicKey, &pubkSz, EC25519_BIG_ENDIAN); } - if( prksz == CURVE25519_KEYSIZE && - pbksz == CURVE25519_KEYSIZE && - prvkSz == CURVE25519_KEYSIZE && - pubkSz == 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 && - pubkSz == CURVE25519_KEYSIZE ){ - - ; /* proceed to the next test */ - } - else{ - - printf(testingFmt,"failed due to key-size-inconsistency"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - } - } - else{ - - printf(testingFmt, - "failed due to wc_curve25519_export_key_raw_ex"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - - } - } - else{ - - printf(testingFmt,"failed due to key-contents-inconsistency"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - - } + if (ret == 0 && (prksz != CURVE25519_KEYSIZE || + pbksz != CURVE25519_KEYSIZE || + prvkSz != CURVE25519_KEYSIZE || + pubkSz != CURVE25519_KEYSIZE)) { + ret = -1; } - else{ - printf(testingFmt,"failed due to bad-key-size"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0 && (0 != XMEMCMP(privateKey, prik, CURVE25519_KEYSIZE) || + 0 != XMEMCMP(publicKey, pubk, CURVE25519_KEYSIZE))) { + ret = -1; + } + + if (ret == 0) { + ret = wc_curve25519_export_key_raw_ex(&key, privateKey, &prvkSz, + publicKey, &pubkSz, EC25519_LITTLE_ENDIAN); + } + if (ret == 0 && (prvkSz != CURVE25519_KEYSIZE || + pubkSz != CURVE25519_KEYSIZE)) { + ret = -1; } /* try once with another endian */ - - prvkSz = CURVE25519_KEYSIZE; - pubkSz = CURVE25519_KEYSIZE; - - if( 0 == wc_curve25519_export_key_raw_ex( &key, privateKey, - &prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)){ - - if( prvkSz == CURVE25519_KEYSIZE && - pubkSz == CURVE25519_KEYSIZE ){ - - /* no more test*/ - printf(resultFmt, passed ); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 0; - } - else{ - - printf(testingFmt,"failed due to key-size-inconsistency"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; - } + if (ret == 0) { + prvkSz = CURVE25519_KEYSIZE; + pubkSz = CURVE25519_KEYSIZE; + ret = wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz, + publicKey, &pubkSz, EC25519_BIG_ENDIAN); } - else{ - - printf(testingFmt, - "failed due to wc_curve25519_export_key_raw_ex(BIGENDIAN)"); - fflush(stdout); - wc_curve25519_free(&key); - wc_FreeRng(&rng); - return 1; + if (ret == 0 && (prvkSz != CURVE25519_KEYSIZE || + pubkSz != CURVE25519_KEYSIZE)) { + ret = -1; } -#else - return 0; + wc_curve25519_free(&key); + wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif + return res; } /* end of test_wc_curve25519_export_key_raw_ex */ + /* * Testing wc_curve25519_make_key */ static int test_wc_curve25519_make_key(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) WC_RNG rng; curve25519_key key; int keysize; - - - printf(testingFmt, "wc_curve25519_make_key()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23299,26 +22787,26 @@ static int test_wc_curve25519_make_key(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); wc_curve25519_free(&key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve25519_make_key*/ /* * Testing wc_curve25519_shared_secret_ex */ static int test_wc_curve25519_shared_secret_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) WC_RNG rng; curve25519_key private_key, public_key; byte out[CURVE25519_KEYSIZE]; word32 outLen = sizeof(out); int endian = EC25519_BIG_ENDIAN; - - printf(testingFmt, "wc_curve25519_shared_secret_ex()"); + int ret; ret = wc_curve25519_init(&private_key); if (ret == 0) { @@ -23415,27 +22903,25 @@ static int test_wc_curve25519_shared_secret_ex(void) } } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve25519_free(&private_key); wc_curve25519_free(&public_key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve25519_shared_secret_ex*/ /* * Testing wc_curve25519_make_pub */ static int test_wc_curve25519_make_pub(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef HAVE_CURVE25519 WC_RNG rng; curve25519_key key; byte out[CURVE25519_KEYSIZE]; - - printf(testingFmt, "wc_curve25519_make_pub()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23486,28 +22972,26 @@ static int test_wc_curve25519_make_pub(void) ret = wc_curve25519_make_pub((int)sizeof out, out, (int)sizeof(key.k), key.k); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve25519_free(&key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve25519_make_pub */ /* * Testing test_wc_curve25519_export_public_ex */ static int test_wc_curve25519_export_public_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #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()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23556,12 +23040,12 @@ static int test_wc_curve25519_export_public_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve25519_free(&key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve25519_export_public_ex*/ /* @@ -23569,7 +23053,7 @@ static int test_wc_curve25519_export_public_ex(void) */ static int test_wc_curve25519_import_private_raw_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) WC_RNG rng; curve25519_key key; @@ -23578,9 +23062,7 @@ static int test_wc_curve25519_import_private_raw_ex(void) word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); int endian = EC25519_BIG_ENDIAN; - - - printf(testingFmt, "wc_curve25519_import_private_raw_ex()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23649,28 +23131,26 @@ static int test_wc_curve25519_import_private_raw_ex(void) } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve25519_free(&key); wc_FreeRng(&rng); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve25519_import_private_raw_ex*/ + /* * Testing test_wc_curve25519_import_private */ static int test_wc_curve25519_import_private(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) - curve25519_key key; WC_RNG rng; byte priv[CURVE25519_KEYSIZE]; word32 privSz = sizeof(priv); - - printf(testingFmt, "wc_curve25519_import_private()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23686,28 +23166,26 @@ 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); - fflush(stdout); wc_curve25519_free(&key); wc_FreeRng(&rng); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /*END test_wc_curve25519_import*/ + /* * Testing test_wc_curve25519_export_private_raw_ex */ static int test_wc_curve25519_export_private_raw_ex(void) { - - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE25519) curve25519_key key; byte out[CURVE25519_KEYSIZE]; word32 outLen = sizeof(out); int endian = EC25519_BIG_ENDIAN; - - printf(testingFmt, "wc_curve25519_export_private_raw_ex()"); + int ret; ret = wc_curve25519_init(&key); if (ret == 0) { @@ -23750,12 +23228,11 @@ static int test_wc_curve25519_export_private_raw_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve25519_free(&key); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; }/*END test_wc_curve25519_export_private_raw_ex*/ /* @@ -23763,12 +23240,12 @@ static int test_wc_curve25519_export_private_raw_ex(void) */ static int test_wc_ed448_make_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) ed448_key key; WC_RNG rng; unsigned char pubkey[ED448_PUB_KEY_SIZE]; + int ret; ret = wc_InitRng(&rng); if (ret == 0) { @@ -23783,7 +23260,6 @@ static int test_wc_ed448_make_key(void) ret = -1; } } - printf(testingFmt, "wc_ed448_make_key()"); if (ret == 0) { ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); } @@ -23801,23 +23277,20 @@ static int test_wc_ed448_make_key(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_make_key */ @@ -23826,13 +23299,10 @@ static int test_wc_ed448_make_key(void) */ static int test_wc_ed448_init(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) - ed448_key key; - - printf(testingFmt, "wc_ed448_init()"); + int ret; ret = wc_ed448_init(&key); @@ -23841,19 +23311,17 @@ static int test_wc_ed448_init(void) ret = wc_ed448_init(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_init */ /* @@ -23861,8 +23329,7 @@ static int test_wc_ed448_init(void) */ static int test_wc_ed448_sign_msg(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_SIGN) WC_RNG rng; ed448_key key; @@ -23874,6 +23341,7 @@ static int test_wc_ed448_sign_msg(void) #ifdef HAVE_ED448_VERIFY int verify_ok = 0; /*1 = Verify success.*/ #endif + int ret; /* Initialize stack variables. */ XMEMSET(sig, 0, siglen); @@ -23887,8 +23355,6 @@ static int test_wc_ed448_sign_msg(void) } } - printf(testingFmt, "wc_ed448_sign_msg()"); - if (ret == 0) { ret = wc_ed448_sign_msg(msg, msglen, sig, &siglen, &key, NULL, 0); } @@ -23911,76 +23377,68 @@ static int test_wc_ed448_sign_msg(void) if (ret == BUFFER_E && badSigLen == ED448_SIG_SIZE) { badSigLen -= 1; ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } /* END sign */ - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - #ifdef HAVE_ED448_VERIFY - printf(testingFmt, "wc_ed448_verify_msg()"); +#ifdef HAVE_ED448_VERIFY + if (ret == 0) { + ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, &verify_ok, + &key, NULL, 0); + if (ret == 0 && verify_ok == 1) { + ret = 0; + } + else if (ret == 0) { + ret = WOLFSSL_FATAL_ERROR; + } + + /* Test bad args. */ if (ret == 0) { + AssertIntEQ(wc_ed448_verify_msg(sig, siglen - 1, msg, + msglen, &verify_ok, &key, NULL, 0), BAD_FUNC_ARG); + AssertIntEQ(wc_ed448_verify_msg(sig, siglen + 1, msg, + msglen, &verify_ok, &key, NULL, 0), BAD_FUNC_ARG); - ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, &verify_ok, + ret = wc_ed448_verify_msg(NULL, siglen, msg, msglen, &verify_ok, &key, NULL, 0); - if (ret == 0 && verify_ok == 1) { + if (ret == BAD_FUNC_ARG) { + ret = wc_ed448_verify_msg(sig, siglen, NULL, msglen, + &verify_ok, &key, NULL, 0); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, + NULL, &key, NULL, 0); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, + &verify_ok, NULL, NULL, 0); + } + if (ret == BAD_FUNC_ARG) { + ret = wc_ed448_verify_msg(sig, badSigLen, msg, msglen, + &verify_ok, &key, NULL, 0); + } + if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } + } - /* Test bad args. */ - if (ret == 0) { - AssertIntEQ(wc_ed448_verify_msg(sig, siglen - 1, msg, - msglen, &verify_ok, &key, - NULL, 0), - BAD_FUNC_ARG); - AssertIntEQ(wc_ed448_verify_msg(sig, siglen + 1, msg, - msglen, &verify_ok, &key, - NULL, 0), - BAD_FUNC_ARG); - - ret = wc_ed448_verify_msg(NULL, siglen, msg, msglen, &verify_ok, - &key, NULL, 0); - if (ret == BAD_FUNC_ARG) { - ret = wc_ed448_verify_msg(sig, siglen, NULL, msglen, - &verify_ok, &key, NULL, 0); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, - NULL, &key, NULL, 0); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed448_verify_msg(sig, siglen, msg, msglen, - &verify_ok, NULL, NULL, 0); - } - if (ret == BAD_FUNC_ARG) { - ret = wc_ed448_verify_msg(sig, badSigLen, msg, msglen, - &verify_ok, &key, NULL, 0); - } - if (ret == BAD_FUNC_ARG) { - ret = 0; - } else if (ret == 0) { - ret = WOLFSSL_FATAL_ERROR; - } - } - - } /* END verify. */ - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - #endif /* Verify. */ + } /* END verify. */ +#endif /* Verify. */ if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_sign_msg */ /* @@ -23988,15 +23446,14 @@ static int test_wc_ed448_sign_msg(void) */ static int test_wc_ed448_import_public(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_IMPORT) WC_RNG rng; ed448_key pubKey; const byte in[] = "Ed448PublicKeyUnitTest.................................\n"; word32 inlen = sizeof(in); - + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -24005,14 +23462,14 @@ static int test_wc_ed448_import_public(void) ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &pubKey); } } - printf(testingFmt, "wc_ed448_import_public()"); if (ret == 0) { ret = wc_ed448_import_public_ex(in, inlen, &pubKey, 1); if (ret == 0 && XMEMCMP(in, pubKey.p, inlen) == 0) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } @@ -24027,23 +23484,21 @@ static int test_wc_ed448_import_public(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed448_free(&pubKey); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END wc_ed448_import_public */ /* @@ -24051,8 +23506,7 @@ static int test_wc_ed448_import_public(void) */ static int test_wc_ed448_import_private_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_IMPORT) WC_RNG rng; ed448_key key; @@ -24066,20 +23520,19 @@ static int test_wc_ed448_import_private_key(void) byte bothKeys[sizeof(privKey) + sizeof(pubKey)]; word32 bothKeysSz = sizeof(bothKeys); #endif + int ret; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed448_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); - printf(testingFmt, "wc_ed448_import_private_key()"); - if (ret == 0) { ret = wc_ed448_import_private_key_ex(privKey, privKeySz, pubKey, pubKeySz, &key, 1); @@ -24130,22 +23583,20 @@ static int test_wc_ed448_import_private_key(void) if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_import_private_key */ /* @@ -24153,8 +23604,7 @@ static int test_wc_ed448_import_private_key(void) */ static int test_wc_ed448_export(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) WC_RNG rng; ed448_key key; @@ -24162,24 +23612,23 @@ static int test_wc_ed448_export(void) byte pub[ED448_PUB_KEY_SIZE]; word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); + int ret; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed448_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } if (ret == 0) { ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); } - printf(testingFmt, "wc_ed448_export_public()"); - if (ret == 0) { ret = wc_ed448_export_public(&key, pub, &pubSz); if (ret == 0 && (pubSz != ED448_KEY_SIZE || @@ -24196,16 +23645,13 @@ static int test_wc_ed448_export(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wc_ed448_export_private_only()"); - if (ret == 0) { ret = wc_ed448_export_private_only(&key, priv, &privSz); if (ret == 0 && (privSz != ED448_KEY_SIZE || @@ -24222,22 +23668,21 @@ static int test_wc_ed448_export(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ed448_export */ @@ -24246,29 +23691,29 @@ static int test_wc_ed448_export(void) */ static int test_wc_ed448_size(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED448) WC_RNG rng; ed448_key key; + int ret = 0; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed448_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); if (ret != 0) { wc_FreeRng(&rng); wc_ed448_free(&key); - return ret; + return TEST_FAIL; } - printf(testingFmt, "wc_ed448_size()"); ret = wc_ed448_size(&key); /* Test bad args. */ if (ret == ED448_KEY_SIZE) { @@ -24277,12 +23722,8 @@ static int test_wc_ed448_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); if (ret == 0) { - printf(testingFmt, "wc_ed448_sig_size()"); - ret = wc_ed448_sig_size(&key); if (ret == ED448_SIG_SIZE) { ret = 0; @@ -24294,13 +23735,9 @@ static int test_wc_ed448_size(void) ret = 0; } } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); } /* END wc_ed448_sig_size() */ if (ret == 0) { - printf(testingFmt, "wc_ed448_pub_size"); ret = wc_ed448_pub_size(&key); if (ret == ED448_PUB_KEY_SIZE) { ret = 0; @@ -24311,12 +23748,9 @@ static int test_wc_ed448_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); } /* END wc_ed448_pub_size */ if (ret == 0) { - printf(testingFmt, "wc_ed448_priv_size"); ret = wc_ed448_priv_size(&key); if (ret == ED448_PRV_KEY_SIZE) { ret = 0; @@ -24327,8 +23761,6 @@ static int test_wc_ed448_size(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); } /* END wc_ed448_pub_size */ if (wc_FreeRng(&rng) && ret == 0) { @@ -24336,9 +23768,9 @@ static int test_wc_ed448_size(void) } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_size */ /* @@ -24346,7 +23778,7 @@ static int test_wc_ed448_size(void) */ static int test_wc_ed448_exportKey(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) WC_RNG rng; ed448_key key; @@ -24356,26 +23788,25 @@ static int test_wc_ed448_exportKey(void) word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); word32 privOnlySz = sizeof(privOnly); + int ret; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed448_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); if (ret != 0) { wc_FreeRng(&rng); wc_ed448_free(&key); - return ret; + return TEST_FAIL; } - printf(testingFmt, "wc_ed448_export_private()"); - ret = wc_ed448_export_private(&key, privOnly, &privOnlySz); if (ret == 0) { ret = wc_ed448_export_private(NULL, privOnly, &privOnlySz); @@ -24387,17 +23818,13 @@ static int test_wc_ed448_exportKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (ret == 0) { - printf(testingFmt, "wc_ed448_export_key()"); - ret = wc_ed448_export_key(&key, priv, &privSz, pub, &pubSz); if (ret == 0) { ret = wc_ed448_export_key(NULL, priv, &privSz, pub, &pubSz); @@ -24415,12 +23842,11 @@ static int test_wc_ed448_exportKey(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); } /* END wc_ed448_export_key() */ /* Cross check output. */ @@ -24433,9 +23859,9 @@ static int test_wc_ed448_exportKey(void) } wc_ed448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ed448_exportKey */ /* @@ -24443,15 +23869,13 @@ static int test_wc_ed448_exportKey(void) */ static int test_wc_Ed448PublicKeyToDer(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) int tmp; ed448_key key; byte derBuf[1024]; - - printf(testingFmt, "wc_Ed448PublicKeyToDer()"); + int ret = 0; /* Test bad args */ tmp = wc_Ed448PublicKeyToDer(NULL, NULL, 0, 0); @@ -24473,19 +23897,19 @@ static int test_wc_Ed448PublicKeyToDer(void) WC_RNG rng; ret = wc_InitRng(&rng); if (ret != 0) { - return ret; + return TEST_FAIL; } ret = wc_ed448_init(&key); if (ret != 0) { wc_FreeRng(&rng); - return ret; + return TEST_FAIL; } ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key); if (ret != 0) { wc_FreeRng(&rng); wc_ed448_free(&key); - return ret; + return TEST_FAIL; } tmp = wc_Ed448PublicKeyToDer(&key, derBuf, 1024, 1); @@ -24496,11 +23920,10 @@ static int test_wc_Ed448PublicKeyToDer(void) wc_FreeRng(&rng); wc_ed448_free(&key); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END testing wc_Ed448PublicKeyToDer */ /* @@ -24508,13 +23931,11 @@ static int test_wc_Ed448PublicKeyToDer(void) */ static int test_wc_curve448_init(void) { + int res = TEST_SKIPPED; +#if defined(HAVE_CURVE448) + curve448_key key; int ret = 0; -#if defined(HAVE_CURVE448) - - curve448_key key; - - printf(testingFmt, "wc_curve448_init()"); ret = wc_curve448_init(&key); /* Test bad args for wc_curve448_init */ @@ -24522,21 +23943,20 @@ static int test_wc_curve448_init(void) ret = wc_curve448_init(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); /* Test good args for wc_curve_448_free */ wc_curve448_free(&key); wc_curve448_free(NULL); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_curve448_init and wc_curve_448_free*/ /* @@ -24544,14 +23964,12 @@ static int test_wc_curve448_init(void) */ static int test_wc_curve448_make_key(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) - WC_RNG rng; + WC_RNG rng; curve448_key key; int keysize; - - - printf(testingFmt, "wc_curve448_make_key()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24570,7 +23988,7 @@ static int test_wc_curve448_make_key(void) ret = wc_curve448_make_key(&rng, keysize, &key); } } - /*test bad cases*/ + /* test bad cases */ if (ret == 0) { ret = wc_curve448_make_key(NULL, 0, NULL); if (ret == BAD_FUNC_ARG) { @@ -24600,26 +24018,25 @@ static int test_wc_curve448_make_key(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve448_make_key*/ /* * Testing test_wc_curve448_shared_secret_ex */ static int test_wc_curve448_shared_secret_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #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()"); + int ret; ret = wc_curve448_init(&private_key); if (ret == 0) { @@ -24641,10 +24058,9 @@ static int test_wc_curve448_shared_secret_ex(void) 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); + ret = wc_curve448_shared_secret_ex(NULL, NULL, NULL, 0, endian); if (ret == BAD_FUNC_ARG) { ret = 0; } @@ -24670,7 +24086,7 @@ static int test_wc_curve448_shared_secret_ex(void) ret = 0; } } - if (ret == 0) { + if (ret == 0) { ret = wc_curve448_shared_secret_ex(&private_key, &public_key, out, NULL, endian); if (ret == BAD_FUNC_ARG) { @@ -24686,29 +24102,28 @@ static int test_wc_curve448_shared_secret_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&private_key); wc_curve448_free(&public_key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve448_shared_secret_ex*/ + /* * Testing test_wc_curve448_export_public_ex */ static int test_wc_curve448_export_public_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #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()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24717,7 +24132,7 @@ static int test_wc_curve448_export_public_ex(void) if (ret == 0) { ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); - if (ret == 0){ + if (ret == 0) { ret = wc_curve448_export_public(&key, out, &outLen); } if (ret == 0) { @@ -24757,28 +24172,27 @@ static int test_wc_curve448_export_public_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*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) { - - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) 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()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24821,19 +24235,19 @@ static int test_wc_curve448_export_private_raw_ex(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; }/*END test_wc_curve448_export_private_raw_ex*/ + /* * Testing test_wc_curve448_import_private_raw_ex */ static int test_wc_curve448_import_private_raw_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) WC_RNG rng; curve448_key key; @@ -24842,8 +24256,7 @@ static int test_wc_curve448_import_private_raw_ex(void) word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); int endian = EC448_BIG_ENDIAN; - - printf(testingFmt, "wc_curve448_import_private_raw_ex()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24852,10 +24265,10 @@ static int test_wc_curve448_import_private_raw_ex(void) if (ret == 0) { ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key); - if (ret == 0){ + if (ret == 0) { ret = wc_curve448_export_private_raw(&key, priv, &privSz); } - if (ret == 0){ + if (ret == 0) { ret = wc_curve448_export_public(&key, pub, &pubSz); } if (ret == 0) { @@ -24863,7 +24276,7 @@ static int test_wc_curve448_import_private_raw_ex(void) &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) { @@ -24915,19 +24328,18 @@ static int test_wc_curve448_import_private_raw_ex(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /*END test_wc_curve448_import_private_raw_ex*/ /* * Testing test_curve448_export_key_raw */ static int test_wc_curve448_export_key_raw(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) WC_RNG rng; curve448_key key; @@ -24935,8 +24347,7 @@ static int test_wc_curve448_export_key_raw(void) byte pub[CURVE448_KEY_SIZE]; word32 privSz = sizeof(priv); word32 pubSz = sizeof(pub); - - printf(testingFmt, "wc_curve448_export_key_raw()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24956,13 +24367,12 @@ static int test_wc_curve448_export_key_raw(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); wc_FreeRng(&rng); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; }/*END test_wc_curve448_import_private_raw_ex*/ @@ -24971,15 +24381,13 @@ static int test_wc_curve448_export_key_raw(void) */ static int test_wc_curve448_import_private(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) - curve448_key key; WC_RNG rng; byte priv[CURVE448_KEY_SIZE]; word32 privSz = sizeof(priv); - - printf(testingFmt, "wc_curve448_import_private()"); + int ret; ret = wc_curve448_init(&key); if (ret == 0) { @@ -24995,26 +24403,22 @@ 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); - fflush(stdout); wc_curve448_free(&key); wc_FreeRng(&rng); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /*END test_wc_curve448_import*/ /* * Testing test_wc_curve448_size. */ static int test_wc_curve448_size(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_CURVE448) - curve448_key key; - - printf(testingFmt, "wc_curve448_size()"); + int ret = 0; ret = wc_curve448_init(&key); @@ -25028,12 +24432,11 @@ static int test_wc_curve448_size(void) ret = wc_curve448_size(NULL); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_curve448_free(&key); -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_curve448_size*/ /* @@ -25041,17 +24444,15 @@ static int test_wc_curve448_size(void) */ static int test_wc_ecc_make_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) - WC_RNG rng; + WC_RNG rng; ecc_key key; - - printf(testingFmt, "wc_ecc_make_key()"); + int ret; ret = wc_InitRng(&rng); if (ret != 0) - return ret; + return TEST_FAIL; ret = wc_ecc_init(&key); if (ret == 0) { @@ -25068,7 +24469,8 @@ static int test_wc_ecc_make_key(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } @@ -25083,12 +24485,9 @@ static int test_wc_ecc_make_key(void) wc_ecc_fp_free(); #endif - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_ecc_make_key */ @@ -25097,12 +24496,10 @@ static int test_wc_ecc_make_key(void) */ static int test_wc_ecc_init(void) { - int ret = 0; - + int res = TEST_SKIPPED; #ifdef HAVE_ECC ecc_key key; - - printf(testingFmt, "wc_ecc_init()"); + int ret; ret = wc_ecc_init(&key); /* Pass in bad args. */ @@ -25110,19 +24507,17 @@ static int test_wc_ecc_init(void) ret = wc_ecc_init(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_init */ /* @@ -25130,11 +24525,11 @@ static int test_wc_ecc_init(void) */ static int test_wc_ecc_check_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) WC_RNG rng; ecc_key key; + int ret; XMEMSET(&rng, 0, sizeof(rng)); XMEMSET(&key, 0, sizeof(key)); @@ -25150,8 +24545,6 @@ static int test_wc_ecc_check_key(void) } } - printf(testingFmt, "wc_ecc_check_key()"); - if (ret == 0) { ret = wc_ecc_check_key(&key); } @@ -25161,14 +24554,12 @@ static int test_wc_ecc_check_key(void) ret = wc_ecc_check_key(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25178,9 +24569,9 @@ static int test_wc_ecc_check_key(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_check_key */ /* @@ -25188,20 +24579,17 @@ static int test_wc_ecc_check_key(void) */ static int test_wc_ecc_get_generator(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) && defined(OPENSSL_EXTRA) ecc_point* pt; - - printf(testingFmt, "wc_ecc_new_point()"); + int ret = 0; pt = wc_ecc_new_point(); if (!pt) { ret = WOLFSSL_FATAL_ERROR; } - printf(testingFmt, "wc_ecc_get_generator()"); - if (ret == 0) { ret = wc_ecc_get_generator(pt, wc_ecc_get_curve_idx(ECC_SECP256R1)); } @@ -25217,15 +24605,14 @@ static int test_wc_ecc_get_generator(void) * increase this number */ if (ret != MP_OKAY) wc_ecc_get_generator(NULL, -1); - ret = ret == MP_OKAY ? WOLFSSL_FATAL_ERROR : 0; + ret = (ret == MP_OKAY) ? WOLFSSL_FATAL_ERROR : 0; } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_del_point(pt); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ecc_get_generator */ /* @@ -25233,11 +24620,11 @@ static int test_wc_ecc_get_generator(void) */ static int test_wc_ecc_size(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) WC_RNG rng; ecc_key key; + int ret; XMEMSET(&rng, 0, sizeof(rng)); XMEMSET(&key, 0, sizeof(key)); @@ -25253,13 +24640,12 @@ static int test_wc_ecc_size(void) } } - printf(testingFmt, "wc_ecc_size()"); - if (ret == 0) { ret = wc_ecc_size(&key); if (ret == KEY14) { ret = 0; - } else if (ret == 0){ + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } @@ -25269,20 +24655,19 @@ static int test_wc_ecc_size(void) ret = wc_ecc_size(NULL); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ecc_size */ static int test_wc_ecc_params(void) { + int res = TEST_SKIPPED; /* FIPS/CAVP self-test modules do not have `wc_ecc_get_curve_params`. It was added after certifications */ #if defined(HAVE_ECC) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) @@ -25300,9 +24685,10 @@ static int test_wc_ecc_params(void) /* Test that we get curve params for index 0 */ ecc_set = wc_ecc_get_curve_params(0); AssertNotNull(ecc_set); -#endif /* HAVE_ECC && !HAVE_FIPS && !HAVE_SELFTEST */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_ECC && !HAVE_FIPS && !HAVE_SELFTEST */ + return res; } /* @@ -25310,11 +24696,11 @@ static int test_wc_ecc_params(void) */ static int test_wc_ecc_signVerify_hash(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN) && !defined(NO_ASN) && !defined(WC_NO_RNG) WC_RNG rng; ecc_key key; + int ret; int signH = WOLFSSL_FATAL_ERROR; #ifdef HAVE_ECC_VERIFY int verifyH = WOLFSSL_FATAL_ERROR; @@ -25343,8 +24729,6 @@ static int test_wc_ecc_signVerify_hash(void) } } - printf(testingFmt, "wc_ecc_sign_hash()"); - if (ret == 0) { ret = wc_ecc_sign_hash(digest, digestlen, sig, &siglen, &rng, &key); } @@ -25370,73 +24754,69 @@ static int test_wc_ecc_signVerify_hash(void) } if (signH == ECC_BAD_ARG_E) { signH = 0; - } else if (ret == 0) { + } + else if (ret == 0) { signH = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, signH == 0 ? passed : failed); +#ifdef HAVE_ECC_VERIFY + ret = wc_ecc_verify_hash(sig, siglen, digest, digestlen, &verify, &key); + if (verify != 1 && ret == 0) { + ret = WOLFSSL_FATAL_ERROR; + } - #ifdef HAVE_ECC_VERIFY - printf(testingFmt, "wc_ecc_verify_hash()"); - - ret = wc_ecc_verify_hash(sig, siglen, digest, digestlen, &verify, &key); - if (verify != 1 && ret == 0) { - ret = WOLFSSL_FATAL_ERROR; - } - - /* test check on length of signature passed in */ - XMEMCPY(adjustedSig, sig, siglen); - adjustedSig[1] = adjustedSig[1] + 1; /* add 1 to length for extra byte*/ + /* test check on length of signature passed in */ + XMEMCPY(adjustedSig, sig, siglen); + adjustedSig[1] = adjustedSig[1] + 1; /* add 1 to length for extra byte*/ #ifndef NO_STRICT_ECDSA_LEN - AssertIntNE(wc_ecc_verify_hash(adjustedSig, siglen+1, digest, digestlen, - &verify, &key), 0); + AssertIntNE(wc_ecc_verify_hash(adjustedSig, siglen+1, digest, digestlen, + &verify, &key), 0); #else - /* if NO_STRICT_ECDSA_LEN is set then extra bytes after the signature - * is allowed */ - AssertIntEQ(wc_ecc_verify_hash(adjustedSig, siglen+1, digest, digestlen, - &verify, &key), 0); + /* if NO_STRICT_ECDSA_LEN is set then extra bytes after the signature + * is allowed */ + AssertIntEQ(wc_ecc_verify_hash(adjustedSig, siglen+1, digest, digestlen, + &verify, &key), 0); #endif - /* Test bad args. */ - if (ret == 0) { - verifyH = wc_ecc_verify_hash(NULL, siglen, digest, digestlen, - &verify, &key); - if (verifyH == ECC_BAD_ARG_E) { - verifyH = wc_ecc_verify_hash(sig, siglen, NULL, digestlen, - &verify, &key); - } - if (verifyH == ECC_BAD_ARG_E) { - verifyH = wc_ecc_verify_hash(sig, siglen, digest, digestlen, - NULL, &key); - } - if (verifyH == ECC_BAD_ARG_E) { - verifyH = wc_ecc_verify_hash(sig, siglen, digest, digestlen, - &verify, NULL); - } - if (verifyH == ECC_BAD_ARG_E) { - verifyH = 0; - } else if (ret == 0) { - verifyH = WOLFSSL_FATAL_ERROR; - } + /* Test bad args. */ + if (ret == 0) { + verifyH = wc_ecc_verify_hash(NULL, siglen, digest, digestlen, + &verify, &key); + if (verifyH == ECC_BAD_ARG_E) { + verifyH = wc_ecc_verify_hash(sig, siglen, NULL, digestlen, + &verify, &key); } - - printf(resultFmt, verifyH == 0 ? passed : failed); - - #endif /* HAVE_ECC_VERIFY */ - - if (wc_FreeRng(&rng) && ret == 0) { - ret = WOLFSSL_FATAL_ERROR; + if (verifyH == ECC_BAD_ARG_E) { + verifyH = wc_ecc_verify_hash(sig, siglen, digest, digestlen, + NULL, &key); } - wc_ecc_free(&key); + if (verifyH == ECC_BAD_ARG_E) { + verifyH = wc_ecc_verify_hash(sig, siglen, digest, digestlen, + &verify, NULL); + } + if (verifyH == ECC_BAD_ARG_E) { + verifyH = 0; + } + else if (ret == 0) { + verifyH = WOLFSSL_FATAL_ERROR; + } + } - #ifdef FP_ECC - wc_ecc_fp_free(); - #endif +#endif /* HAVE_ECC_VERIFY */ + if (wc_FreeRng(&rng) && ret == 0) { + ret = WOLFSSL_FATAL_ERROR; + } + wc_ecc_free(&key); + +#ifdef FP_ECC + wc_ecc_fp_free(); #endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_ecc_sign_hash */ @@ -25445,11 +24825,11 @@ static int test_wc_ecc_signVerify_hash(void) */ static int test_wc_ecc_shared_secret(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_DHE) && !defined(WC_NO_RNG) ecc_key key, pubKey; WC_RNG rng; + int ret; byte out[KEY32]; int keySz = sizeof(out); word32 outlen = (word32)sizeof(out); @@ -25517,7 +24897,6 @@ static int test_wc_ecc_shared_secret(void) } #endif - printf(testingFmt, "wc_ecc_shared_secret()"); if (ret == 0) { ret = wc_ecc_shared_secret(&key, &pubKey, out, &outlen); @@ -25549,15 +24928,13 @@ static int test_wc_ecc_shared_secret(void) if (ret == BUFFER_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25566,14 +24943,13 @@ static int test_wc_ecc_shared_secret(void) #ifdef FP_ECC wc_ecc_fp_free(); -#endif - #endif PRIVATE_KEY_LOCK(); - return ret; - + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END tests_wc_ecc_shared_secret */ /* @@ -25581,13 +24957,13 @@ static int test_wc_ecc_shared_secret(void) */ static int test_wc_ecc_export_x963(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) ecc_key key; WC_RNG rng; byte out[ECC_ASN963_MAX_BUF_SZ]; word32 outlen = sizeof(out); + int ret = 0; PRIVATE_KEY_UNLOCK(); @@ -25606,8 +24982,6 @@ static int test_wc_ecc_export_x963(void) #endif } } - printf(testingFmt, "wc_ecc_export_x963()"); - if (ret == 0) { ret = wc_ecc_export_x963(&key, out, &outlen); } @@ -25627,14 +25001,12 @@ static int test_wc_ecc_export_x963(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25644,11 +25016,11 @@ static int test_wc_ecc_export_x963(void) wc_ecc_fp_free(); #endif -#endif PRIVATE_KEY_LOCK(); - return ret; - + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_ecc_export_x963 */ /* @@ -25657,11 +25029,11 @@ static int test_wc_ecc_export_x963(void) */ static int test_wc_ecc_export_x963_ex(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) ecc_key key; WC_RNG rng; + int ret = 0; byte out[ECC_ASN963_MAX_BUF_SZ]; word32 outlen = sizeof(out); #ifdef HAVE_COMP_KEY @@ -25684,8 +25056,6 @@ static int test_wc_ecc_export_x963_ex(void) } } - printf(testingFmt, "wc_ecc_export_x963_ex()"); - #ifdef HAVE_COMP_KEY if (ret == 0) { ret = wc_ecc_export_x963_ex(&key, out, &outlen, COMP); @@ -25720,7 +25090,8 @@ static int test_wc_ecc_export_x963_ex(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -25742,15 +25113,13 @@ static int test_wc_ecc_export_x963_ex(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } #endif - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25760,9 +25129,9 @@ static int test_wc_ecc_export_x963_ex(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_export_x963_ex */ /* @@ -25770,14 +25139,14 @@ static int test_wc_ecc_export_x963_ex(void) */ static int test_wc_ecc_import_x963(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_IMPORT) && \ defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) ecc_key pubKey, key; WC_RNG rng; byte x963[ECC_ASN963_MAX_BUF_SZ]; word32 x963Len = (word32)sizeof(x963); + int ret; /* Init stack variables. */ XMEMSET(x963, 0, x963Len); @@ -25804,7 +25173,6 @@ static int test_wc_ecc_import_x963(void) } } - printf(testingFmt, "wc_ecc_import_x963()"); if (ret == 0) { ret = wc_ecc_import_x963(x963, x963Len, &pubKey); } @@ -25820,14 +25188,12 @@ static int test_wc_ecc_import_x963(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25838,18 +25204,17 @@ static int test_wc_ecc_import_x963(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END wc_ecc_import_x963 */ /* * testing wc_ecc_import_private_key() */ -static int ecc_import_private_key (void) +static int ecc_import_private_key(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_IMPORT) && \ defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) ecc_key key, keyImp; @@ -25858,6 +25223,7 @@ static int ecc_import_private_key (void) byte x963Key[ECC_ASN963_MAX_BUF_SZ]; word32 privKeySz = (word32)sizeof(privKey); word32 x963KeySz = (word32)sizeof(x963Key); + int ret; /* Init stack variables. */ XMEMSET(privKey, 0, privKeySz); @@ -25888,8 +25254,6 @@ static int ecc_import_private_key (void) } } - printf(testingFmt, "wc_ecc_import_private_key()"); - if (ret == 0) { ret = wc_ecc_import_private_key(privKey, privKeySz, x963Key, x963KeySz, &keyImp); @@ -25904,14 +25268,12 @@ static int ecc_import_private_key (void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25922,9 +25284,9 @@ static int ecc_import_private_key (void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END wc_ecc_import_private_key */ @@ -25933,13 +25295,13 @@ static int ecc_import_private_key (void) */ static int test_wc_ecc_export_private_only(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) ecc_key key; WC_RNG rng; byte out[ECC_PRIV_KEY_BUF]; word32 outlen = sizeof(out); + int ret; /* Init stack variables. */ XMEMSET(out, 0, outlen); @@ -25956,8 +25318,6 @@ static int test_wc_ecc_export_private_only(void) #endif } } - printf(testingFmt, "wc_ecc_export_private_only()"); - if (ret == 0) { ret = wc_ecc_export_private_only(&key, out, &outlen); } @@ -25972,14 +25332,12 @@ static int test_wc_ecc_export_private_only(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -25989,9 +25347,9 @@ static int test_wc_ecc_export_private_only(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_export_private_only */ @@ -26000,9 +25358,7 @@ static int test_wc_ecc_export_private_only(void) */ static int test_wc_ecc_rs_to_sig(void) { - - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ASN) /* first [P-192,SHA-1] vector from FIPS 186-3 NIST vectors */ const char* R = "6994d962bdd0d793ffddf855ec5bf2f91a9698b46258a63e"; @@ -26016,14 +25372,13 @@ static int test_wc_ecc_rs_to_sig(void) byte s[KEY24]; word32 rlen = (word32)sizeof(r); word32 slen = (word32)sizeof(s); + int ret; /* Init stack variables. */ XMEMSET(sig, 0, ECC_MAX_SIG_SIZE); XMEMSET(r, 0, keySz); XMEMSET(s, 0, keySz); - printf(testingFmt, "wc_ecc_rs_to_sig()"); - ret = wc_ecc_rs_to_sig(R, S, sig, &siglen); /* Test bad args. */ if (ret == 0) { @@ -26045,14 +25400,12 @@ static int test_wc_ecc_rs_to_sig(void) } if (ret == MP_ZERO_E) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wc_ecc_sig_to_rs()"); if (ret == 0) { ret = wc_ecc_sig_to_rs(sig, siglen, r, &rlen, s, &slen); } @@ -26073,25 +25426,23 @@ static int test_wc_ecc_rs_to_sig(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_rs_to_sig */ static int test_wc_ecc_import_raw(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ECC256) ecc_key key; + int ret = 0; const char* qx = "bb33ac4c27504ac64aa504c33cde9f36db722dce94ea2bfacb2009392c16e861"; const char* qy = @@ -26105,8 +25456,6 @@ static int test_wc_ecc_import_raw(void) ret = wc_ecc_init(&key); - printf(testingFmt, "wc_ecc_import_raw()"); - if (ret == 0) { ret = wc_ecc_import_raw(&key, qx, qy, d, curveName); } @@ -26151,20 +25500,16 @@ static int test_wc_ecc_import_raw(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_ecc_import_raw */ static int test_wc_ecc_import_unsigned(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ECC256) && !defined(HAVE_SELFTEST) && \ (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) ecc_key key; @@ -26190,11 +25535,10 @@ static int test_wc_ecc_import_unsigned(void) const byte nullBytes[32] = {0}; #endif int curveId = ECC_SECP256R1; + int ret; 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, curveId); @@ -26226,15 +25570,11 @@ static int test_wc_ecc_import_unsigned(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - - return ret; - + return res; } /* END test_wc_ecc_import_unsigned */ @@ -26243,12 +25583,12 @@ static int test_wc_ecc_import_unsigned(void) */ static int test_wc_ecc_sig_size(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) ecc_key key; WC_RNG rng; int keySz = KEY16; + int ret = 0; XMEMSET(&rng, 0, sizeof(rng)); XMEMSET(&key, 0, sizeof(key)); @@ -26263,8 +25603,6 @@ static int test_wc_ecc_sig_size(void) } } - printf(testingFmt, "wc_ecc_sig_size()"); - if (ret == 0) { ret = wc_ecc_sig_size(&key); if (ret <= (2 * keySz + SIG_HEADER_SZ + ECC_MAX_PAD_SZ)) { @@ -26272,17 +25610,14 @@ static int test_wc_ecc_sig_size(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_free(&key); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_sig_size */ /* @@ -26290,16 +25625,15 @@ static int test_wc_ecc_sig_size(void) */ static int test_wc_ecc_ctx_new(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_ENCRYPT) && !defined(WC_NO_RNG) WC_RNG rng; + int ret = 0; ecEncCtx* cli = NULL; ecEncCtx* srv = NULL; ret = wc_InitRng(&rng); - printf(testingFmt, "wc_ecc_ctx_new()"); if (ret == 0) { cli = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng); srv = wc_ecc_ctx_new(REQ_RESP_SERVER, &rng); @@ -26324,17 +25658,14 @@ static int test_wc_ecc_ctx_new(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_ctx_free(cli); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_ctx_new */ /* @@ -26342,11 +25673,11 @@ static int test_wc_ecc_ctx_new(void) */ static int test_wc_ecc_ctx_reset(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_ENCRYPT) && !defined(WC_NO_RNG) ecEncCtx* ctx = NULL; WC_RNG rng; + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -26355,8 +25686,6 @@ static int test_wc_ecc_ctx_reset(void) } } - printf(testingFmt, "wc_ecc_ctx_reset()"); - if (ret == 0) { ret = wc_ecc_ctx_reset(ctx, &rng); } @@ -26369,22 +25698,20 @@ static int test_wc_ecc_ctx_reset(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_ctx_free(ctx); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_ctx_reset */ /* @@ -26392,14 +25719,14 @@ static int test_wc_ecc_ctx_reset(void) */ static int test_wc_ecc_ctx_set_peer_salt(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_ENCRYPT) && !defined(WC_NO_RNG) WC_RNG rng; ecEncCtx* cliCtx = NULL; ecEncCtx* servCtx = NULL; const byte* cliSalt = NULL; const byte* servSalt = NULL; + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -26409,8 +25736,6 @@ static int test_wc_ecc_ctx_set_peer_salt(void) } } - printf(testingFmt, "wc_ecc_ctx_get_own_salt()"); - /* Test bad args. */ if (ret == 0) { cliSalt = wc_ecc_ctx_get_own_salt(NULL); @@ -26427,10 +25752,6 @@ static int test_wc_ecc_ctx_set_peer_salt(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wc_ecc_ctx_set_peer_salt()"); - if (ret == 0) { ret = wc_ecc_ctx_set_peer_salt(cliCtx, servSalt); } @@ -26442,22 +25763,21 @@ static int test_wc_ecc_ctx_set_peer_salt(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_ctx_free(cliCtx); wc_ecc_ctx_free(servCtx); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ecc_ctx_set_peer_salt */ @@ -26466,11 +25786,11 @@ static int test_wc_ecc_ctx_set_peer_salt(void) */ static int test_wc_ecc_ctx_set_info(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_ENCRYPT) && !defined(WC_NO_RNG) ecEncCtx* ctx = NULL; WC_RNG rng; + int ret; const char* optInfo = "Optional Test Info."; int optInfoSz = (int)XSTRLEN(optInfo); const char* badOptInfo = NULL; @@ -26480,8 +25800,6 @@ static int test_wc_ecc_ctx_set_info(void) ret = WOLFSSL_FATAL_ERROR; } - printf(testingFmt, "wc_ecc_ctx_set_info()"); - if (ret == 0) { ret = wc_ecc_ctx_set_info(ctx, (byte*)optInfo, optInfoSz); } @@ -26496,22 +25814,20 @@ static int test_wc_ecc_ctx_set_info(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_ctx_free(ctx); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_ctx_set_info */ /* @@ -26519,12 +25835,12 @@ static int test_wc_ecc_ctx_set_info(void) */ static int test_wc_ecc_encryptDecrypt(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_ENCRYPT) && !defined(WC_NO_RNG) && \ defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128) ecc_key srvKey, cliKey, tmpKey; WC_RNG rng; + int ret; const char* msg = "EccBlock Size 16"; word32 msgSz = (word32)XSTRLEN("EccBlock Size 16"); #ifdef WOLFSSL_ECIES_OLD @@ -26581,8 +25897,6 @@ static int test_wc_ecc_encryptDecrypt(void) } #endif - printf(testingFmt, "wc_ecc_encrypt()"); - if (ret == 0) { ret = wc_ecc_encrypt(&cliKey, &srvKey, (byte*)msg, msgSz, out, &outSz, NULL); @@ -26608,15 +25922,12 @@ static int test_wc_ecc_encryptDecrypt(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wc_ecc_decrypt()"); - #ifdef WOLFSSL_ECIES_OLD if (ret == 0) { tmpKey.dp = cliKey.dp; @@ -26653,7 +25964,8 @@ static int test_wc_ecc_encryptDecrypt(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } @@ -26662,9 +25974,6 @@ static int test_wc_ecc_encryptDecrypt(void) ret = WOLFSSL_FATAL_ERROR; } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -26672,9 +25981,9 @@ static int test_wc_ecc_encryptDecrypt(void) wc_ecc_free(&cliKey); wc_ecc_free(&srvKey); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_encryptDecrypt */ /* @@ -26682,25 +25991,16 @@ static int test_wc_ecc_encryptDecrypt(void) */ static int test_wc_ecc_del_point(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) ecc_point* pt; - printf(testingFmt, "wc_ecc_new_point()"); - pt = wc_ecc_new_point(); - if (!pt) { - ret = WOLFSSL_FATAL_ERROR; - } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_del_point(pt); + res = TEST_RES_CHECK(pt != NULL); #endif - return ret; + return res; } /* END test_wc_ecc_del_point */ @@ -26711,13 +26011,13 @@ static int test_wc_ecc_del_point(void) */ static int test_wc_ecc_pointFns(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && \ !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) && \ !defined(WOLFSSL_ATECC608A) ecc_key key; WC_RNG rng; + int ret; ecc_point* point = NULL; ecc_point* cpypt = NULL; int idx = 0; @@ -26757,7 +26057,6 @@ static int test_wc_ecc_pointFns(void) } /* Export */ - printf(testingFmt, "wc_ecc_export_point_der()"); if (ret == 0) { ret = wc_ecc_export_point_der((idx = key.idx), &key.pubkey, NULL, &derlenChk); @@ -26779,17 +26078,13 @@ static int test_wc_ecc_pointFns(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - /* Import */ - printf(testingFmt, "wc_ecc_import_point_der()"); - if (ret == 0) { ret = wc_ecc_import_point_der(der, derSz, idx, point); /* Condition double checks wc_ecc_cmp_point(). */ @@ -26812,16 +26107,13 @@ static int test_wc_ecc_pointFns(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); /* Copy */ - printf(testingFmt, "wc_ecc_copy_point()"); - if (ret == 0) { ret = wc_ecc_copy_point(point, cpypt); } @@ -26833,15 +26125,12 @@ static int test_wc_ecc_pointFns(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - - printf(testingFmt, "wc_ecc_cmp_point()"); /* Compare point */ if (ret == 0) { ret = wc_ecc_cmp_point(point, cpypt); @@ -26854,14 +26143,12 @@ static int test_wc_ecc_pointFns(void) } if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wc_ecc_point_is_at_infinity()"); /* At infinity if return == 1, otherwise return == 0. */ if (ret == 0) { ret = wc_ecc_point_is_at_infinity(point); @@ -26871,17 +26158,14 @@ static int test_wc_ecc_pointFns(void) ret = wc_ecc_point_is_at_infinity(NULL); if (ret == BAD_FUNC_ARG) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) #ifdef USE_ECC_B_PARAM - printf(testingFmt, "wc_ecc_point_is_on_curve()"); /* On curve if ret == 0 */ if (ret == 0) { ret = wc_ecc_point_is_on_curve(point, idx); @@ -26894,12 +26178,11 @@ static int test_wc_ecc_pointFns(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); #endif /* USE_ECC_B_PARAM */ #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ @@ -26911,9 +26194,9 @@ static int test_wc_ecc_pointFns(void) ret = WOLFSSL_FATAL_ERROR; } + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_pointFns */ @@ -26922,13 +26205,13 @@ static int test_wc_ecc_pointFns(void) */ static int test_wc_ecc_shared_secret_ssh(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_DHE) && \ !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) && \ !defined(WOLFSSL_ATECC608A) ecc_key key, key2; WC_RNG rng; + int ret; int keySz = KEY32; int key2Sz = KEY24; byte secret[KEY32]; @@ -26966,8 +26249,6 @@ static int test_wc_ecc_shared_secret_ssh(void) } } - printf(testingFmt, "ecc_shared_secret_ssh()"); - #if defined(ECC_TIMING_RESISTANT) && (!defined(HAVE_FIPS) || \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION != 2))) && \ !defined(HAVE_SELFTEST) @@ -26996,17 +26277,16 @@ static int test_wc_ecc_shared_secret_ssh(void) ret = wc_ecc_shared_secret_ssh(&key, &key2.pubkey, secret, &secretLen); if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -27017,9 +26297,9 @@ static int test_wc_ecc_shared_secret_ssh(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; - + return res; } /* END test_wc_ecc_shared_secret_ssh */ /* @@ -27027,13 +26307,13 @@ static int test_wc_ecc_shared_secret_ssh(void) */ static int test_wc_ecc_verify_hash_ex(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN) && defined(WOLFSSL_PUBLIC_MP) \ && !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) && \ !defined(WOLFSSL_ATECC608A) && !defined(WOLFSSL_KCAPI_ECC) ecc_key key; WC_RNG rng; + int ret; mp_int r; mp_int s; mp_int z; @@ -27091,7 +26371,6 @@ static int test_wc_ecc_verify_hash_ex(void) } } - printf(testingFmt, "wc_ecc_sign_hash_ex()"); /* Test bad args. */ if (ret == 0) { if (wc_ecc_sign_hash_ex(NULL, hashlen, &rng, &key, &r, &s) @@ -27115,8 +26394,6 @@ static int test_wc_ecc_verify_hash_ex(void) sig = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, sig == 0 ? passed : failed); - printf(testingFmt, "wc_ecc_verify_hash_ex()"); /* Test bad args. */ if (ret == 0) { if (wc_ecc_verify_hash_ex(NULL, &s, shortHash, shortHashLen, &verify_ok, &key) @@ -27152,7 +26429,6 @@ static int test_wc_ecc_verify_hash_ex(void) ver = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ver == 0 ? passed : failed); wc_ecc_free(&key); mp_free(&r); @@ -27163,9 +26439,10 @@ static int test_wc_ecc_verify_hash_ex(void) if (ret == 0 && (sig != 0 || ver != 0)) { ret = WOLFSSL_FATAL_ERROR; } -#endif - return ret; + res = TEST_RES_CHECK(ret == 0); +#endif + return res; } /* END test_wc_ecc_verify_hash_ex */ /* @@ -27174,13 +26451,13 @@ static int test_wc_ecc_verify_hash_ex(void) static int test_wc_ecc_mulmod(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) && \ !(defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \ defined(WOLFSSL_VALIDATE_ECC_IMPORT)) ecc_key key1, key2, key3; WC_RNG rng; + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -27208,7 +26485,6 @@ static int test_wc_ecc_mulmod(void) } } - printf(testingFmt, "wc_ecc_mulmod()"); if (ret == 0) { ret = wc_ecc_mulmod(&key1.k, &key2.pubkey, &key3.pubkey, &key2.k, &key3.k, 1); @@ -27232,14 +26508,12 @@ static int test_wc_ecc_mulmod(void) } if (ret == ECC_BAD_ARG_E) { ret = 0; - } else if (ret == 0) { + } + else if (ret == 0) { ret = WOLFSSL_FATAL_ERROR; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_ecc_free(&key1); wc_ecc_free(&key2); wc_ecc_free(&key3); @@ -27248,10 +26522,9 @@ static int test_wc_ecc_mulmod(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif /* HAVE_ECC && !WOLFSSL_ATECC508A */ - return ret; - - + return res; } /* END test_wc_ecc_mulmod */ /* @@ -27259,11 +26532,11 @@ static int test_wc_ecc_mulmod(void) */ static int test_wc_ecc_is_valid_idx(void) { - int ret = 0; - + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) ecc_key key; WC_RNG rng; + int ret; int iVal = -2; int iVal2 = 3000; @@ -27281,12 +26554,12 @@ static int test_wc_ecc_is_valid_idx(void) } } - printf(testingFmt, "wc_ecc_is_valid_idx()"); if (ret == 0) { ret = wc_ecc_is_valid_idx(key.idx); if (ret == 1) { ret = 0; - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } } @@ -27301,9 +26574,6 @@ static int test_wc_ecc_is_valid_idx(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - if (wc_FreeRng(&rng) && ret == 0) { ret = WOLFSSL_FATAL_ERROR; } @@ -27312,8 +26582,9 @@ static int test_wc_ecc_is_valid_idx(void) wc_ecc_fp_free(); #endif + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ecc_is_valid_idx */ @@ -27322,13 +26593,12 @@ static int test_wc_ecc_is_valid_idx(void) */ static int test_wc_ecc_get_curve_id_from_oid(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ECC256) && !defined(HAVE_SELFTEST) && \ !defined(HAVE_FIPS) const byte oid[] = {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07}; word32 len = sizeof(oid); - - printf(testingFmt, "wc_ecc_get_curve_id_from_oid()"); + int ret; /* Bad Cases */ ret = wc_ecc_get_curve_id_from_oid(NULL, len); @@ -27349,24 +26619,21 @@ static int test_wc_ecc_get_curve_id_from_oid(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* END test_wc_ecc_get_curve_id_from_oid */ /* * Testing wc_ecc_sig_size_calc() */ static int test_wc_ecc_sig_size_calc(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(WC_NO_RNG) && !defined(HAVE_SELFTEST) ecc_key key; WC_RNG rng; int sz = 0; - - printf(testingFmt, "wc_ecc_sig_size_calc()"); + int ret = 0; ret = wc_InitRng(&rng); if (ret == 0) { @@ -27385,19 +26652,19 @@ static int test_wc_ecc_sig_size_calc(void) ret = 0; } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); wc_ecc_free(&key); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_ecc_sig_size_calc */ /* * Testing ToTraditional */ static int test_ToTraditional(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(NO_ASN) && (defined(HAVE_PKCS8) || defined(HAVE_PKCS12)) && \ (defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \ defined(OPENSSL_EXTRA_X509_SMALL)) @@ -27405,8 +26672,7 @@ static int test_ToTraditional(void) XFILE f; byte input[TWOK_BUF]; word32 sz; - - printf(testingFmt, "ToTraditional()"); + int ret; f = XFOPEN("./certs/server-keyPkcs8.der", "rb"); AssertTrue((f != XBADFILE)); @@ -27438,10 +26704,9 @@ static int test_ToTraditional(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_ToTraditional*/ /* @@ -27449,14 +26714,13 @@ static int test_ToTraditional(void) */ static int test_wc_EccPrivateKeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT) && !defined(WC_NO_RNG) - byte output[ONEK_BUF]; ecc_key eccKey; WC_RNG rng; word32 inLen; - printf(testingFmt, "wc_EccPrivateKeyToDer()"); + int ret; ret = wc_InitRng(&rng); @@ -27520,10 +26784,9 @@ static int test_wc_EccPrivateKeyToDer(void) } wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_EccPrivateKeyToDer*/ /* @@ -27531,14 +26794,13 @@ static int test_wc_EccPrivateKeyToDer(void) */ static int test_wc_DhPublicKeyDecode(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifndef NO_DH - word32 inOutIdx; - #if defined(WOLFSSL_DH_EXTRA) && defined(USE_CERT_BUFFERS_2048) DhKey key; + word32 inOutIdx; + AssertIntEQ(wc_InitDhKey(&key), 0); - printf(testingFmt, "wc_DhPublicKeyDecode()"); AssertIntEQ(wc_DhPublicKeyDecode(NULL,NULL,NULL,0), BAD_FUNC_ARG); @@ -27559,12 +26821,11 @@ static int test_wc_DhPublicKeyDecode(void) key.pub.used != 0 && key.priv.used == 0); wc_FreeDhKey(&key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - (void)inOutIdx; #endif /* !NO_DH */ - return ret; + return res; } /* @@ -27572,16 +26833,14 @@ static int test_wc_DhPublicKeyDecode(void) */ static int test_wc_Ed25519KeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) - byte output[ONEK_BUF]; ed25519_key ed25519Key; WC_RNG rng; word32 inLen; - - printf(testingFmt, "wc_Ed25519KeyToDer()"); + int ret; ret = wc_InitRng(&rng); @@ -27629,30 +26888,26 @@ static int test_wc_Ed25519KeyToDer(void) } wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_Ed25519KeyToDer*/ /* * Testing wc_Ed25519PrivateKeyToDer */ static int test_wc_Ed25519PrivateKeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) - byte output[ONEK_BUF]; ed25519_key ed25519PrivKey; WC_RNG rng; word32 inLen; - - printf(testingFmt, "wc_Ed25519PrivateKeyToDer()"); + int ret; ret = wc_InitRng(&rng); - if (ret == 0) { ret = wc_ed25519_init(&ed25519PrivKey); if (ret == 0) { @@ -27697,26 +26952,23 @@ static int test_wc_Ed25519PrivateKeyToDer(void) } wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_Ed25519PrivateKeyToDer*/ /* * Testing wc_Ed448KeyToDer */ static int test_wc_Ed448KeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) - byte output[ONEK_BUF]; ed448_key ed448Key; WC_RNG rng; word32 inLen; - - printf(testingFmt, "wc_Ed448KeyToDer()"); + int ret; ret = wc_InitRng(&rng); @@ -27764,26 +27016,23 @@ static int test_wc_Ed448KeyToDer(void) } wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_Ed448KeyToDer*/ /* * Testing wc_Ed448PrivateKeyToDer */ static int test_wc_Ed448PrivateKeyToDer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) && \ (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) - byte output[ONEK_BUF]; ed448_key ed448PrivKey; WC_RNG rng; word32 inLen; - - printf(testingFmt, "wc_Ed448PrivateKeyToDer()"); + int ret; ret = wc_InitRng(&rng); @@ -27831,24 +27080,22 @@ static int test_wc_Ed448PrivateKeyToDer(void) } wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_Ed448PrivateKeyToDer*/ /* * Testing wc_SetSubjectBuffer */ static int test_wc_SetSubjectBuffer(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_CERT_GEN) && !defined(NO_RSA) Cert cert; FILE* file; byte* der; word32 derSz; - - printf(testingFmt, "wc_SetSubjectBuffer()"); + int ret = 0; derSz = FOURK_BUF; der = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -27880,10 +27127,10 @@ static int test_wc_SetSubjectBuffer(void) } } XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_SetSubjectBuffer*/ /* @@ -27891,7 +27138,7 @@ static int test_wc_SetSubjectBuffer(void) */ static int test_wc_SetSubjectKeyIdFromPublicKey_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN) WC_RNG rng; Cert cert; @@ -27908,8 +27155,7 @@ static int test_wc_SetSubjectKeyIdFromPublicKey_ex(void) #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) ed448_key ed448Key; #endif - - printf(testingFmt, "wc_SetSubjectKeyIdFromPublicKey_ex()"); + int ret = 0; #ifndef HAVE_FIPS ret = wc_InitRng_ex(&rng, HEAP_HINT, testDevId); @@ -27972,19 +27218,19 @@ static int test_wc_SetSubjectKeyIdFromPublicKey_ex(void) } #endif - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_SetSubjectKeyIdFromPublicKey_ex*/ + /* * Testing wc_SetAuthKeyIdFromPublicKey_ex */ static int test_wc_SetAuthKeyIdFromPublicKey_ex(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN) WC_RNG rng; Cert cert; @@ -28001,8 +27247,7 @@ static int test_wc_SetAuthKeyIdFromPublicKey_ex(void) #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) ed448_key ed448Key; #endif - - printf(testingFmt, "wc_SetAuthKeyIdFromPublicKey_ex()"); + int ret = 0; #ifndef HAVE_FIPS ret = wc_InitRng_ex(&rng, HEAP_HINT, testDevId); @@ -28065,45 +27310,40 @@ static int test_wc_SetAuthKeyIdFromPublicKey_ex(void) } #endif - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif /*defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN)*/ - return ret; + return res; }/* End test_wc_SetAuthKeyIdFromPublicKey_ex*/ + /* * Testing wc_PKCS7_New() */ -static int test_wc_PKCS7_New (void) +static int test_wc_PKCS7_New(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; - void* heap = NULL; - printf(testingFmt, "wc_PKCS7_New()"); - - pkcs7 = wc_PKCS7_New(heap, testDevId); - AssertNotNull(pkcs7); - - printf(resultFmt, passed); + pkcs7 = wc_PKCS7_New(NULL, testDevId); wc_PKCS7_Free(pkcs7); -#endif - return 0; + res = TEST_RES_CHECK(pkcs7 != NULL); +#endif + return res; } /* END test-wc_PKCS7_New */ /* * Testing wc_PKCS7_Init() */ -static int test_wc_PKCS7_Init (void) +static int test_wc_PKCS7_Init(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; void* heap = NULL; - printf(testingFmt, "wc_PKCS7_Init()"); - pkcs7 = wc_PKCS7_New(heap, testDevId); AssertNotNull(pkcs7); @@ -28112,19 +27352,20 @@ static int test_wc_PKCS7_Init (void) /* Pass in bad args. */ AssertIntEQ(wc_PKCS7_Init(NULL, heap, testDevId), BAD_FUNC_ARG); - printf(resultFmt, passed); wc_PKCS7_Free(pkcs7); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /* END test-wc_PKCS7_Init */ /* * Testing wc_PKCS7_InitWithCert() */ -static int test_wc_PKCS7_InitWithCert (void) +static int test_wc_PKCS7_InitWithCert(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; @@ -28248,8 +27489,6 @@ static int test_wc_PKCS7_InitWithCert (void) 0x7D, 0x1C, 0x44, 0xB1, 0x6E, 0xDF, 0xC8, 0xDA, 0x10, 0x48, 0x2D, 0x53, 0x08, 0xA8, 0xB4}; #endif - printf(testingFmt, "wc_PKCS7_InitWithCert()"); - AssertNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId)); /* If initialization is not successful, it's free'd in init func. */ AssertIntEQ(wc_PKCS7_InitWithCert(pkcs7, (byte*)cert, (word32)certSz), 0); @@ -28272,20 +27511,20 @@ static int test_wc_PKCS7_InitWithCert (void) } #endif - printf(resultFmt, passed); - wc_PKCS7_Free(pkcs7); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /* END test_wc_PKCS7_InitWithCert */ /* * Testing wc_PKCS7_EncodeData() */ -static int test_wc_PKCS7_EncodeData (void) +static int test_wc_PKCS7_EncodeData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; byte output[FOURK_BUF]; @@ -28363,8 +27602,6 @@ static int test_wc_PKCS7_EncodeData (void) AssertIntEQ(wc_PKCS7_InitWithCert(pkcs7, (byte*)cert, certSz), 0); - printf(testingFmt, "wc_PKCS7_EncodeData()"); - pkcs7->content = data; pkcs7->contentSz = sizeof(data); pkcs7->privateKey = key; @@ -28378,12 +27615,11 @@ static int test_wc_PKCS7_EncodeData (void) BAD_FUNC_ARG); AssertIntEQ(wc_PKCS7_EncodeData(pkcs7, output, 5), BUFFER_E); - printf(resultFmt, passed); - wc_PKCS7_Free(pkcs7); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /* END test_wc_PKCS7_EncodeData */ @@ -28438,7 +27674,8 @@ static int rsaSignRawDigestCb(PKCS7* pkcs7, byte* digest, word32 digestSz, if (ret > (int)outSz) { /* output buffer too small */ ret = -1; - } else { + } + else { /* success, ret holds sig size */ XMEMCPY(out, sig, ret); } @@ -28457,6 +27694,7 @@ static int rsaSignRawDigestCb(PKCS7* pkcs7, byte* digest, word32 digestSz, */ static int test_wc_PKCS7_EncodeSignedData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; WC_RNG rng; @@ -28538,8 +27776,6 @@ static int test_wc_PKCS7_EncodeSignedData(void) AssertIntEQ(wc_PKCS7_InitWithCert(pkcs7, cert, certSz), 0); - printf(testingFmt, "wc_PKCS7_EncodeSignedData()"); - pkcs7->content = data; pkcs7->contentSz = (word32)sizeof(data); pkcs7->privateKey = key; @@ -28584,14 +27820,12 @@ static int test_wc_PKCS7_EncodeSignedData(void) AssertIntGT(wc_PKCS7_EncodeSignedData(pkcs7, output, outputSz), 0); #endif - printf(resultFmt, passed); - wc_PKCS7_Free(pkcs7); wc_FreeRng(&rng); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_PKCS7_EncodeSignedData */ @@ -28600,6 +27834,7 @@ static int test_wc_PKCS7_EncodeSignedData(void) */ static int test_wc_PKCS7_EncodeSignedData_ex(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) int ret, i; PKCS7* pkcs7; @@ -28691,8 +27926,6 @@ static int test_wc_PKCS7_EncodeSignedData_ex(void) AssertIntEQ(wc_PKCS7_InitWithCert(pkcs7, cert, certSz), 0); - printf(testingFmt, "wc_PKCS7_EncodeSignedData()"); - pkcs7->content = NULL; /* not used for ex */ pkcs7->contentSz = (word32)sizeof(data); pkcs7->privateKey = key; @@ -28801,14 +28034,12 @@ static int test_wc_PKCS7_EncodeSignedData_ex(void) outputHead, outputHeadSz, outputFoot, 0), ASN_PARSE_E); #endif - printf(resultFmt, passed); - wc_PKCS7_Free(pkcs7); wc_FreeRng(&rng); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_PKCS7_EncodeSignedData_ex */ @@ -29106,6 +28337,7 @@ static int CreatePKCS7SignedData(unsigned char* output, int outputSz, */ static int test_wc_PKCS7_VerifySignedData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; byte output[6000]; /* Large size needed for bundles with int CA certs */ @@ -29121,8 +28353,6 @@ static int test_wc_PKCS7_VerifySignedData(void) byte hashBuf[WC_MAX_DIGEST_SIZE]; word32 hashSz = wc_HashGetDigestSize(hashType); - printf(testingFmt, "wc_PKCS7_VerifySignedData()"); - #ifndef NO_RSA /* Success test with RSA certs/key */ AssertIntGT((outputSz = CreatePKCS7SignedData(output, outputSz, data, @@ -29284,10 +28514,9 @@ static int test_wc_PKCS7_VerifySignedData(void) wc_PKCS7_Free(pkcs7); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_PKCS7_VerifySignedData() */ @@ -29397,8 +28626,9 @@ static int myCEKwrapFunc(PKCS7* pkcs7, byte* cek, word32 cekSz, byte* keyId, /* * Testing wc_PKCS7_EncodeEnvelopedData() */ -static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) +static int test_wc_PKCS7_EncodeDecodeEnvelopedData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) PKCS7* pkcs7; #ifdef ECC_TIMING_RESISTANT @@ -29576,8 +28806,6 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) AssertIntEQ(wc_InitRng(&rng), 0); #endif - printf(testingFmt, "wc_PKCS7_EncodeEnvelopedData()"); - AssertNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId)); AssertIntEQ(wc_PKCS7_Init(pkcs7, HEAP_HINT, testDevId), 0); @@ -29607,7 +28835,7 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) /* Verify the size of each buffer. */ AssertIntEQ((word32)sizeof(input)/sizeof(char), decodedSz); /* Don't free the last time through the loop. */ - if (i < testSz - 1 ){ + if (i < testSz - 1) { wc_PKCS7_Free(pkcs7); AssertNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId)); } @@ -29620,11 +28848,8 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) AssertIntEQ(wc_PKCS7_EncodeEnvelopedData(pkcs7, NULL, (word32)sizeof(output)), BAD_FUNC_ARG); AssertIntEQ(wc_PKCS7_EncodeEnvelopedData(pkcs7, output, 0), BAD_FUNC_ARG); - printf(resultFmt, passed); /* Decode. */ - printf(testingFmt, "wc_PKCS7_DecodeEnvelopedData()"); - AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(NULL, output, (word32)sizeof(output), decoded, (word32)sizeof(decoded)), BAD_FUNC_ARG); AssertIntEQ(wc_PKCS7_DecodeEnvelopedData(pkcs7, output, @@ -29694,8 +28919,6 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) } #endif /* !NO_AES && !NO_AES_256 */ - - printf(resultFmt, passed); #ifndef NO_RSA if (rsaCert) { XFREE(rsaCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); @@ -29747,17 +28970,19 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData (void) wc_PKCS7_Free(pkcs7); } #endif /* USE_CERT_BUFFERS_2048 && !NO_DES3 */ -#endif /* HAVE_PKCS7 */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* HAVE_PKCS7 */ + return res; } /* END test_wc_PKCS7_EncodeEnvelopedData() */ /* * Testing wc_PKCS7_EncodeEncryptedData() */ -static int test_wc_PKCS7_EncodeEncryptedData (void) +static int test_wc_PKCS7_EncodeEncryptedData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_PKCS7_ENCRYPTED_DATA) PKCS7* pkcs7 = NULL; byte* tmpBytePtr = NULL; @@ -29868,7 +29093,6 @@ static int test_wc_PKCS7_EncodeEncryptedData (void) AssertIntEQ(wc_PKCS7_Init(pkcs7, HEAP_HINT, testDevId), 0); } - printf(testingFmt, "wc_PKCS7_EncodeEncryptedData()"); AssertIntEQ(wc_PKCS7_EncodeEncryptedData(NULL, encrypted, sizeof(encrypted)),BAD_FUNC_ARG); AssertIntEQ(wc_PKCS7_EncodeEncryptedData(pkcs7, NULL, @@ -29902,10 +29126,6 @@ static int test_wc_PKCS7_EncodeEncryptedData (void) sizeof(encrypted)), BAD_FUNC_ARG); pkcs7->encryptionKeySz = tmpWrd32; - printf(resultFmt, passed); - - printf(testingFmt, "wc_PKCS7_EncodeEncryptedData()"); - AssertIntEQ(wc_PKCS7_DecodeEncryptedData(NULL, encrypted, encryptedSz, decoded, sizeof(decoded)), BAD_FUNC_ARG); AssertIntEQ(wc_PKCS7_DecodeEncryptedData(pkcs7, NULL, encryptedSz, @@ -29927,11 +29147,11 @@ static int test_wc_PKCS7_EncodeEncryptedData (void) AssertIntEQ(wc_PKCS7_DecodeEncryptedData(pkcs7, encrypted, encryptedSz, decoded, sizeof(decoded)), BAD_FUNC_ARG); - printf(resultFmt, passed); wc_PKCS7_Free(pkcs7); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /* END test_wc_PKCS7_EncodeEncryptedData() */ /* @@ -29939,6 +29159,7 @@ static int test_wc_PKCS7_EncodeEncryptedData (void) */ static int test_wc_PKCS7_Degenerate(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) PKCS7* pkcs7; char fName[] = "./certs/test-degenerate.p7b"; @@ -29947,8 +29168,6 @@ static int test_wc_PKCS7_Degenerate(void) word32 derSz; int ret; - printf(testingFmt, "wc_PKCS7_Degenerate()"); - AssertNotNull(f = XFOPEN(fName, "rb")); AssertIntGT((ret = (int)fread(der, 1, sizeof(der), f)), 0); derSz = (word32)ret; @@ -29973,10 +29192,9 @@ static int test_wc_PKCS7_Degenerate(void) AssertIntEQ(wc_PKCS7_VerifySignedData(pkcs7, der, derSz), PKCS7_NO_SIGNER_E); wc_PKCS7_Free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_PKCS7_Degenerate() */ #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && \ @@ -30177,6 +29395,7 @@ static byte berContent[] = { */ static int test_wc_PKCS7_BER(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && \ defined(ASN_BER_TO_DER) PKCS7* pkcs7; @@ -30189,8 +29408,6 @@ static int test_wc_PKCS7_BER(void) word32 derSz; int ret; - printf(testingFmt, "wc_PKCS7_BER()"); - AssertNotNull(f = XFOPEN(fName, "rb")); AssertIntGT((ret = (int)fread(der, 1, sizeof(der), f)), 0); derSz = (word32)ret; @@ -30240,14 +29457,14 @@ static int test_wc_PKCS7_BER(void) wc_PKCS7_Free(pkcs7); #endif /* !NO_DES3 */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_PKCS7_BER() */ static int test_PKCS7_signed_enveloped(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_RSA) && !defined(NO_AES) && \ !defined(NO_FILESYSTEM) XFILE f; @@ -30271,8 +29488,6 @@ static int test_PKCS7_signed_enveloped(void) int decodedSz = FOURK_BUF; #endif - printf(testingFmt, "PKCS7_signed_enveloped"); - /* load cert */ AssertNotNull(f = XFOPEN(cliCertDerFile, "rb")); AssertIntGT((certSz = (int)XFREAD(cert, 1, sizeof(cert), f)), 0); @@ -30414,21 +29629,19 @@ static int test_PKCS7_signed_enveloped(void) wc_PKCS7_Free(pkcs7); #endif - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* HAVE_PKCS7 && !NO_RSA && !NO_AES */ - - return 0; + return res; } -static int test_wc_PKCS7_NoDefaultSignedAttribs (void) + +static int test_wc_PKCS7_NoDefaultSignedAttribs(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \ && !defined(NO_AES) PKCS7* pkcs7; void* heap = NULL; - printf(testingFmt, "wc_PKCS7_NoDefaultSignedAttribs()"); - pkcs7 = wc_PKCS7_New(heap, testDevId); AssertNotNull(pkcs7); AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, testDevId), 0); @@ -30439,13 +29652,14 @@ static int test_wc_PKCS7_NoDefaultSignedAttribs (void) wc_PKCS7_Free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wc_PKCS7_SetOriEncryptCtx (void) + +static int test_wc_PKCS7_SetOriEncryptCtx(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \ && !defined(NO_AES) PKCS7* pkcs7; @@ -30453,8 +29667,6 @@ static int test_wc_PKCS7_SetOriEncryptCtx (void) WOLFSSL_CTX* ctx; ctx = NULL; - printf(testingFmt, "wc_PKCS7_SetOriEncryptCtx()"); - pkcs7 = wc_PKCS7_New(heap, testDevId); AssertNotNull(pkcs7); AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, testDevId), 0); @@ -30465,13 +29677,14 @@ static int test_wc_PKCS7_SetOriEncryptCtx (void) wc_PKCS7_Free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wc_PKCS7_SetOriDecryptCtx (void) + +static int test_wc_PKCS7_SetOriDecryptCtx(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \ && !defined(NO_AES) PKCS7* pkcs7; @@ -30479,8 +29692,6 @@ static int test_wc_PKCS7_SetOriDecryptCtx (void) WOLFSSL_CTX* ctx; ctx = NULL; - printf(testingFmt, "wc_PKCS7_SetOriDecryptCtx()"); - pkcs7 = wc_PKCS7_New(heap, testDevId); AssertNotNull(pkcs7); AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, testDevId), 0); @@ -30490,14 +29701,15 @@ static int test_wc_PKCS7_SetOriDecryptCtx (void) AssertIntEQ(wc_PKCS7_SetOriDecryptCtx(pkcs7, ctx), 0); wc_PKCS7_Free(pkcs7); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wc_PKCS7_DecodeCompressedData(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \ && !defined(NO_AES) && defined(HAVE_LIBZ) PKCS7* pkcs7; @@ -30510,8 +29722,6 @@ static int test_wc_PKCS7_DecodeCompressedData(void) byte* cert_buf = NULL; size_t cert_sz = 0; - printf(testingFmt, "wc_PKCS7_DecodeCompressedData()"); - AssertIntEQ(load_file(cert, &cert_buf, &cert_sz), 0); AssertNotNull((decompressed = (byte*)XMALLOC(cert_sz, heap, DYNAMIC_TYPE_TMP_BUFFER))); @@ -30569,14 +29779,14 @@ static int test_wc_PKCS7_DecodeCompressedData(void) free(cert_buf); wc_PKCS7_Free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_i2d_PKCS12(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_PWDBASED) && defined(HAVE_PKCS12) \ && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \ && !defined(NO_AES) && !defined(NO_DES3) && !defined(NO_SHA) @@ -30590,8 +29800,6 @@ static int test_wc_i2d_PKCS12(void) const char p12_f[] = "./certs/test-servercert.p12"; XFILE f; - printf(testingFmt, "wc_i2d_PKCS12"); - f = XFOPEN(p12_f, "rb"); AssertNotNull(f); derSz = (int)XFREAD(der, 1, sizeof(der), f); @@ -30630,19 +29838,18 @@ static int test_wc_i2d_PKCS12(void) AssertIntEQ(outSz, derSz); wc_PKCS12_free(pkcs12); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* Testing wc_SignatureGetSize() for signature type ECC */ static int test_wc_SignatureGetSize_ecc(void) { - int ret = 0; - #ifndef NO_SIG_WRAPPER + int res = TEST_SKIPPED; +#ifndef NO_SIG_WRAPPER + int ret; #if defined(HAVE_ECC) && !defined(NO_ECC256) enum wc_SignatureType sig_type; word32 key_len; @@ -30660,7 +29867,6 @@ static int test_wc_SignatureGetSize_ecc(void) if (ret == 0) { ret = wc_ecc_import_raw(&ecc, qx, qy, d, "SECP256R1"); } - printf(testingFmt, "wc_SigntureGetSize_ecc()"); if (ret == 0) { /* Input for signature type ECC */ sig_type = WC_SIGNATURE_TYPE_ECC; @@ -30683,7 +29889,8 @@ static int test_wc_SignatureGetSize_ecc(void) ret = SIG_TYPE_E; } } - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } wc_ecc_free(&ecc); @@ -30691,24 +29898,17 @@ static int test_wc_SignatureGetSize_ecc(void) ret = SIG_TYPE_E; #endif - if (ret == SIG_TYPE_E) { - ret = 0; - } - else { - ret = WOLFSSL_FATAL_ERROR; - } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - #endif /* NO_SIG_WRAPPER */ - return ret; + res = TEST_RES_CHECK(ret == SIG_TYPE_E); +#endif /* NO_SIG_WRAPPER */ + return res; }/* END test_wc_SignatureGetSize_ecc() */ /* Testing wc_SignatureGetSize() for signature type rsa */ static int test_wc_SignatureGetSize_rsa(void) { + int res = TEST_SKIPPED; +#ifndef NO_SIG_WRAPPER int ret = 0; - #ifndef NO_SIG_WRAPPER #ifndef NO_RSA enum wc_SignatureType sig_type; word32 key_len; @@ -30751,7 +29951,8 @@ static int test_wc_SignatureGetSize_rsa(void) #else ret = WOLFSSL_FATAL_ERROR; #endif - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } @@ -30762,7 +29963,6 @@ static int test_wc_SignatureGetSize_rsa(void) ret = wc_RsaPrivateKeyDecode(tmp, &idx, &rsa_key, (word32)bytes); } - printf(testingFmt, "wc_SigntureGetSize_rsa()"); if (ret == 0) { /* Input for signature type RSA */ sig_type = WC_SIGNATURE_TYPE_RSA; @@ -30778,10 +29978,11 @@ static int test_wc_SignatureGetSize_rsa(void) ret = wc_SignatureGetSize(sig_type, NULL, key_len); } #ifndef HAVE_USER_RSA - if (ret == BAD_FUNC_ARG) { + if (ret == BAD_FUNC_ARG) #else - if (ret == 0) { + if (ret == 0) #endif + { key_len = (word32)0; ret = wc_SignatureGetSize(sig_type, &rsa_key, key_len); } @@ -30789,7 +29990,8 @@ static int test_wc_SignatureGetSize_rsa(void) ret = SIG_TYPE_E; } } - } else { + } + else { ret = WOLFSSL_FATAL_ERROR; } wc_FreeRsaKey(&rsa_key); @@ -30798,15 +30000,9 @@ static int test_wc_SignatureGetSize_rsa(void) ret = SIG_TYPE_E; #endif - if (ret == SIG_TYPE_E) { - ret = 0; - }else { - ret = WOLFSSL_FATAL_ERROR; - } - - printf(resultFmt, ret == 0 ? passed : failed); - #endif /* NO_SIG_WRAPPER */ - return ret; + res = TEST_RES_CHECK(ret == SIG_TYPE_E); +#endif /* NO_SIG_WRAPPER */ + return res; }/* END test_wc_SignatureGetSize_rsa(void) */ /*----------------------------------------------------------------------------* @@ -30860,23 +30056,17 @@ static int test_wc_HashInit(void) } /* end of for loop */ - printf(testingFmt, "wc_HashInit()"); - if (ret==0) { /* all tests have passed */ - printf(resultFmt, passed); - } - else { /* a test has failed */ - printf(resultFmt, failed); - } - return ret; + return TEST_RES_CHECK(ret == 0); } /* end of test_wc_HashInit */ /* * Unit test function for wc_HashSetFlags() */ static int test_wc_HashSetFlags(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_HASH_FLAGS wc_HashAlg hash; + int ret = 0; word32 flags = 0; int i, j; int notSupportedLen; @@ -30917,8 +30107,6 @@ static int test_wc_HashSetFlags(void) /* dynamically finds the length */ int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType)); - printf(testingFmt, "wc_HashSetFlags()"); - /* For loop to test various arguments... */ for (i = 0; i < enumlen; i++) { ret = wc_HashInit(&hash, enumArray[i]); @@ -30942,12 +30130,12 @@ static int test_wc_HashSetFlags(void) } /* For loop to test not supported cases */ notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType)); - for (j = 0; ret == 0 && j < notSupportedLen; j++){ + for (j = 0; ret == 0 && j < notSupportedLen; j++) { ret = wc_HashInit(&hash, notSupported[j]); if (ret == 0) { ret = -1; } - else if (ret == BAD_FUNC_ARG){ + else if (ret == BAD_FUNC_ARG) { ret = wc_HashSetFlags(&hash, notSupported[j], flags); if (ret == 0) { ret = -1; @@ -30967,20 +30155,19 @@ static int test_wc_HashSetFlags(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_HashSetFlags */ /* * Unit test function for wc_HashGetFlags() */ static int test_wc_HashGetFlags(void) { - int ret = 0; + int res = TEST_SKIPPED; #ifdef WOLFSSL_HASH_FLAGS wc_HashAlg hash; + int ret = 0; word32 flags = 0; int i, j; @@ -31019,8 +30206,6 @@ static int test_wc_HashGetFlags(void) int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType)); int notSupportedLen; - printf(testingFmt, "wc_HashGetFlags()"); - /* For loop to test various arguments... */ for (i = 0; i < enumlen; i++) { ret = wc_HashInit(&hash, enumArray[i]); @@ -31045,12 +30230,12 @@ static int test_wc_HashGetFlags(void) } /* For loop to test not supported cases */ notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType)); - for (j = 0; ret == 0 && j < notSupportedLen; j++){ + for (j = 0; ret == 0 && j < notSupportedLen; j++) { ret = wc_HashInit(&hash, notSupported[j]); if (ret == 0) { ret = -1; } - else if (ret == BAD_FUNC_ARG){ + else if (ret == BAD_FUNC_ARG) { ret = wc_HashGetFlags(&hash, notSupported[j], &flags); if (ret == 0) { ret = -1; @@ -31070,11 +30255,9 @@ static int test_wc_HashGetFlags(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; } /* END test_wc_HashGetFlags */ /*----------------------------------------------------------------------------* @@ -31083,23 +30266,22 @@ static int test_wc_HashGetFlags(void) static int test_wolfSSL_lhash(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL const char testStr[] = "Like a true nature's child\n" "We were born\n" "Born to be wild"; - printf(testingFmt, "wolfSSL_LH_strhash()"); - AssertIntEQ(lh_strhash(testStr), 0x5b7541dc); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_NAME(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \ !defined(NO_CERTS) && !defined(NO_FILESYSTEM) \ && !defined(NO_RSA) && defined(WOLFSSL_CERT_GEN) && \ @@ -31126,8 +30308,6 @@ static int test_wolfSSL_X509_NAME(void) }; #endif - printf(testingFmt, "wolfSSL_X509_NAME()"); - #ifndef OPENSSL_EXTRA_X509_SMALL /* test compile of deprecated function, returns 0 */ AssertIntEQ(CRYPTO_thread_id(), 0); @@ -31155,8 +30335,9 @@ static int test_wolfSSL_X509_NAME(void) tmp = buf; AssertIntGT((sz = i2d_X509_NAME((X509_NAME*)a, &tmp)), 0); if (sz > 0 && tmp == buf) { - printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); - printf(" Expected pointer to be incremented\n"); + fprintf(stderr, "\nERROR - %s line %d failed with:", __FILE__, + __LINE__); + fprintf(stderr, " Expected pointer to be incremented\n"); abort(); } @@ -31200,21 +30381,19 @@ static int test_wolfSSL_X509_NAME(void) X509_NAME_free(d2i_name); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_DES3) */ - - return 0; + return res; } static int test_wolfSSL_X509_NAME_hash(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) \ && !defined(NO_RSA) && !defined(NO_SHA) && !defined(NO_BIO) BIO* bio; X509* x509 = NULL; - printf(testingFmt, "wolfSSL_X509_NAME_hash"); - AssertNotNull(bio = BIO_new(BIO_s_file())); AssertIntGT(BIO_read_filename(bio, svrCertFile), 0); AssertNotNull(PEM_read_bio_X509(bio, &x509, NULL, NULL)); @@ -31222,14 +30401,15 @@ static int test_wolfSSL_X509_NAME_hash(void) AssertIntEQ(X509_NAME_hash(X509_get_issuer_name(x509)), 0xFDB2DA4); X509_free(x509); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_NAME_print_ex(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || (defined(OPENSSL_EXTRA) && \ (defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || \ defined(HAVE_LIGHTY) || defined(WOLFSSL_HAPROXY) || \ @@ -31250,8 +30430,6 @@ static int test_wolfSSL_X509_NAME_print_ex(void) const char* expRFC5523 = "CN=\\#wolfssl.com\\<\\>\\;, C=\\ US\\,\\+\\\"\\\\\\ "; - printf(testingFmt, "wolfSSL_X509_NAME_print_ex"); - /* Test with real cert (svrCertFile) first */ AssertNotNull(bio = BIO_new(BIO_s_file())); AssertIntGT(BIO_read_filename(bio, svrCertFile), 0); @@ -31360,15 +30538,15 @@ static int test_wolfSSL_X509_NAME_print_ex(void) X509_NAME_free(name); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifndef NO_BIO static int test_wolfSSL_X509_INFO_multiple_info(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) STACK_OF(X509_INFO) *info_stack; X509_INFO *info; @@ -31424,15 +30602,16 @@ static int test_wolfSSL_X509_INFO_multiple_info(void) sk_X509_INFO_pop_free(info_stack, X509_INFO_free); BIO_free(concatBIO); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif #ifndef NO_BIO static int test_wolfSSL_X509_INFO(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) STACK_OF(X509_INFO) *info_stack; X509_INFO *info; @@ -31457,8 +30636,6 @@ static int test_wolfSSL_X509_INFO(void) 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d }; - printf(testingFmt, "wolfSSL_X509_INFO"); - AssertNotNull(cert = BIO_new_file(cliCertFileExt, "rb")); AssertNotNull(info_stack = PEM_X509_INFO_read_bio(cert, NULL, NULL, NULL)); for (i = 0; i < sk_X509_INFO_num(info_stack); i++) { @@ -31487,15 +30664,15 @@ static int test_wolfSSL_X509_INFO(void) sk_X509_INFO_pop_free(info_stack, X509_INFO_free); BIO_free(cert); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif static int test_wolfSSL_X509_subject_name_hash(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) \ && !defined(NO_RSA) && (!defined(NO_SHA) || !defined(NO_SHA256)) X509* x509; @@ -31503,8 +30680,6 @@ static int test_wolfSSL_X509_subject_name_hash(void) unsigned long ret1 = 0; unsigned long ret2 = 0; - printf(testingFmt, "wolfSSL_X509_subject_name_hash()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); AssertNotNull(subjectName = wolfSSL_X509_get_subject_name(x509)); @@ -31527,14 +30702,15 @@ static int test_wolfSSL_X509_subject_name_hash(void) #endif X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_X509_issuer_name_hash(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) \ && !defined(NO_RSA) && (!defined(NO_SHA) || !defined(NO_SHA256)) X509* x509; @@ -31542,8 +30718,6 @@ static int test_wolfSSL_X509_issuer_name_hash(void) unsigned long ret1 = 0; unsigned long ret2 = 0; - printf(testingFmt, "wolfSSL_X509_issuer_name_hash()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); AssertNotNull(issuertName = wolfSSL_X509_get_issuer_name(x509)); @@ -31566,22 +30740,21 @@ static int test_wolfSSL_X509_issuer_name_hash(void) #endif X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_X509_check_host(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) \ && !defined(NO_SHA) && !defined(NO_RSA) X509* x509; const char altName[] = "example.com"; - printf(testingFmt, "wolfSSL_X509_check_host()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); @@ -31596,22 +30769,19 @@ static int test_wolfSSL_X509_check_host(void) AssertIntEQ(X509_check_host(NULL, altName, XSTRLEN(altName), 0, NULL), WOLFSSL_FAILURE); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_check_email(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN) && !defined(NO_RSA) X509* x509; const char goodEmail[] = "info@wolfssl.com"; const char badEmail[] = "disinfo@wolfssl.com"; - printf(testingFmt, "wolfSSL_X509_check_email()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); @@ -31634,14 +30804,14 @@ static int test_wolfSSL_X509_check_email(void) AssertIntEQ(wolfSSL_X509_check_email(NULL, goodEmail, 0, 0), WOLFSSL_FAILURE); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFSSL_CERT_GEN */ - - return 0; + return res; } static int test_wolfSSL_DES(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DES3) const_DES_cblock myDes; DES_cblock iv; @@ -31650,8 +30820,6 @@ static int test_wolfSSL_DES(void) DES_LONG dl; unsigned char msg[] = "hello wolfssl"; - printf(testingFmt, "wolfSSL_DES()"); - DES_check_key(1); DES_set_key(&myDes, &key); @@ -31664,7 +30832,8 @@ static int test_wolfSSL_DES(void) /* set odd parity for success case */ DES_set_odd_parity(&myDes); AssertIntEQ(DES_check_key_parity(&myDes), 1); - printf("%02x %02x %02x %02x", myDes[0], myDes[1], myDes[2], myDes[3]); + fprintf(stderr, "%02x %02x %02x %02x", myDes[0], myDes[1], myDes[2], + myDes[3]); AssertIntEQ(DES_set_key_checked(&myDes, &key), 0); for (i = 0; i < sizeof(DES_key_schedule); i++) { AssertIntEQ(key[i], myDes[i]); @@ -31702,14 +30871,14 @@ static int test_wolfSSL_DES(void) AssertIntGT((dl = DES_cbc_cksum(msg, &key, sizeof(msg), &myDes, &iv)), 0); AssertIntEQ(dl, 480052723); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_DES3) */ - - return 0; + return res; } static int test_wc_PemToDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && defined(WOLFSSL_PEM_TO_DER) && !defined(NO_FILESYSTEM) int ret; DerBuffer* pDer = NULL; @@ -31719,8 +30888,6 @@ static int test_wc_PemToDer(void) int eccKey = 0; EncryptedInfo info; - printf(testingFmt, "wc_PemToDer()"); - XMEMSET(&info, 0, sizeof(info)); ret = load_file(ca_cert, &cert_buf, &cert_sz); @@ -31756,33 +30923,32 @@ static int test_wc_PemToDer(void) free(cert_buf); } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_AllocDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) int ret; DerBuffer* pDer = NULL; word32 testSize = 1024; - printf(testingFmt, "wc_AllocDer()"); - ret = wc_AllocDer(&pDer, testSize, CERT_TYPE, HEAP_HINT); AssertIntEQ(ret, 0); AssertNotNull(pDer); wc_FreeDer(&pDer); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wc_CertPemToDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && defined(WOLFSSL_PEM_TO_DER) && !defined(NO_FILESYSTEM) int ret; const char* ca_cert = "./certs/ca-cert.pem"; @@ -31790,8 +30956,6 @@ static int test_wc_CertPemToDer(void) size_t cert_sz = 0, cert_dersz = 0; byte* cert_der = NULL; - printf(testingFmt, "wc_CertPemToDer()"); - ret = load_file(ca_cert, &cert_buf, &cert_sz); if (ret == 0) { cert_dersz = cert_sz; /* DER will be smaller than PEM */ @@ -31808,14 +30972,14 @@ static int test_wc_CertPemToDer(void) if (cert_buf) free(cert_buf); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_PubKeyPemToDer(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_PEM_TO_DER) && !defined(NO_FILESYSTEM) && \ (defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER)) int ret; @@ -31824,9 +30988,6 @@ static int test_wc_PubKeyPemToDer(void) size_t cert_sz = 0, cert_dersz = 0; byte* cert_der = NULL; - printf(testingFmt, "wc_PubKeyPemToDer()"); - - ret = wc_PubKeyPemToDer(cert_buf, (int)cert_sz, cert_der, (int)cert_dersz); AssertIntGE(ret, BAD_FUNC_ARG); @@ -31847,14 +31008,14 @@ static int test_wc_PubKeyPemToDer(void) if (cert_buf) free(cert_buf); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_PemPubKeyToDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && \ (defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER)) int ret; @@ -31862,8 +31023,6 @@ static int test_wc_PemPubKeyToDer(void) size_t cert_dersz = 1024; byte* cert_der = (byte*)malloc(cert_dersz); - printf(testingFmt, "wc_PemPubKeyToDer()"); - ret = wc_PemPubKeyToDer(NULL, cert_der, (int)cert_dersz); AssertIntGE(ret, BAD_FUNC_ARG); @@ -31874,14 +31033,14 @@ static int test_wc_PemPubKeyToDer(void) free(cert_der); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_GetPubKeyDerFromCert(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) || defined(HAVE_ECC) int ret; word32 idx = 0; @@ -31921,8 +31080,6 @@ static int test_wc_GetPubKeyDerFromCert(void) #endif #endif - printf(testingFmt, "wc_GetPubKeyDerFromCert()"); - #ifndef NO_RSA #if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) @@ -32037,15 +31194,14 @@ static int test_wc_GetPubKeyDerFromCert(void) wc_FreeDecodedCert(&decoded); #endif - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* !NO_RSA || HAVE_ECC */ - - return 0; + return res; } static int test_wc_CheckCertSigPubKey(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) && defined(WOLFSSL_PEM_TO_DER) && defined(HAVE_ECC) int ret; @@ -32058,8 +31214,6 @@ static int test_wc_CheckCertSigPubKey(void) word32 keyDerSz = (word32)sizeof(keyDer); DecodedCert decoded; - printf(testingFmt, "wc_CheckCertSigPubKey()"); - ret = load_file(ca_cert, &cert_buf, &cert_sz); if (ret == 0) { cert_dersz = (word32)cert_sz; /* DER will be smaller than PEM */ @@ -32115,14 +31269,14 @@ static int test_wc_CheckCertSigPubKey(void) if (cert_buf) free(cert_buf); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_certs(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) X509* x509ext; @@ -32139,8 +31293,6 @@ static int test_wolfSSL_certs(void) BASIC_CONSTRAINTS* bc; int crit; - printf(testingFmt, "wolfSSL_certs()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(SSLv23_server_method())); #else @@ -32362,22 +31514,20 @@ static int test_wolfSSL_certs(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_CERTS */ - - return 0; + return res; } static int test_wolfSSL_X509_check_private_key(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_RSA) && \ defined(USE_CERT_BUFFERS_2048) && !defined(NO_CHECK_PRIVATE_KEY) X509* x509; EVP_PKEY* pkey = NULL; const byte* key; - printf(testingFmt, "wolfSSL_X509_check_private_key()"); - /* Check with correct key */ AssertNotNull((x509 = X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM))); @@ -32401,15 +31551,16 @@ static int test_wolfSSL_X509_check_private_key(void) EVP_PKEY_free(pkey); X509_free(x509); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_ASN1_TIME_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_RSA) \ && (defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(WOLFSSL_NGINX) || \ defined(WOLFSSL_HAPROXY)) && defined(USE_CERT_BUFFERS_2048) && \ @@ -32420,8 +31571,6 @@ static int test_wolfSSL_ASN1_TIME_print(void) ASN1_TIME* t; unsigned char buf[25]; - printf(testingFmt, "wolfSSL_ASN1_TIME_print()"); - AssertNotNull(bio = BIO_new(BIO_s_mem())); AssertNotNull(x509 = wolfSSL_X509_load_certificate_buffer(der, sizeof_client_cert_der_2048, WOLFSSL_FILETYPE_ASN1)); @@ -32442,14 +31591,14 @@ static int test_wolfSSL_ASN1_TIME_print(void) BIO_free(bio); X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_UTCTIME_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) && !defined(NO_BIO) BIO* bio; ASN1_UTCTIME* utc = NULL; @@ -32457,8 +31606,6 @@ static int test_wolfSSL_ASN1_UTCTIME_print(void) const char* validDate = "190424111501Z"; /* UTC = YYMMDDHHMMSSZ */ const char* invalidDate = "190424111501X"; /* UTC = YYMMDDHHMMSSZ */ - printf(testingFmt, "ASN1_UTCTIME_print()"); - /* NULL parameter check */ AssertNotNull(bio = BIO_new(BIO_s_mem())); AssertIntEQ(ASN1_UTCTIME_print(bio, utc), 0); @@ -32490,22 +31637,20 @@ static int test_wolfSSL_ASN1_UTCTIME_print(void) XFREE(utc, NULL, DYNAMIC_TYPE_ASN1); BIO_free(bio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_ASN_TIME && !NO_BIO */ - - return 0; + return res; } static int test_wolfSSL_ASN1_TIME_diff_compare(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) ASN1_TIME* fromTime; ASN1_TIME* toTime; int daysDiff; int secsDiff; - printf(testingFmt, "test_wolfSSL_ASN1_TIME_diff"); - AssertNotNull((fromTime = ASN1_TIME_new())); /* Feb 22, 2003, 21:15:15 */ AssertIntEQ(ASN1_TIME_set_string(fromTime, "030222211515Z"), WOLFSSL_SUCCESS); @@ -32573,20 +31718,18 @@ static int test_wolfSSL_ASN1_TIME_diff_compare(void) ASN1_TIME_free(fromTime); ASN1_TIME_free(toTime); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_GENERALIZEDTIME_free(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) WOLFSSL_ASN1_GENERALIZEDTIME* asn1_gtime; unsigned char nullstr[32]; - printf(testingFmt, "test_wolfSSL_ASN1_GENERALIZEDTIME_free"); - XMEMSET(nullstr, 0, 32); asn1_gtime = (WOLFSSL_ASN1_GENERALIZEDTIME*)XMALLOC( sizeof(WOLFSSL_ASN1_GENERALIZEDTIME), NULL, @@ -32600,15 +31743,15 @@ static int test_wolfSSL_ASN1_GENERALIZEDTIME_free(void) XFREE(asn1_gtime, NULL, DYNAMIC_TYPE_TMP_BUFFER); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_private_keys(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -32616,8 +31759,6 @@ static int test_wolfSSL_private_keys(void) WOLFSSL_CTX* ctx; EVP_PKEY* pkey = NULL; - printf(testingFmt, "wolfSSL_private_keys()"); - OpenSSL_add_all_digests(); OpenSSL_add_all_algorithms(); @@ -32818,15 +31959,15 @@ static int test_wolfSSL_private_keys(void) (void)ctx; (void)pkey; - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ - - return 0; + return res; } static int test_wolfSSL_PEM_read_PrivateKey(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) \ && !defined(NO_FILESYSTEM) XFILE file; @@ -32839,8 +31980,6 @@ static int test_wolfSSL_PEM_read_PrivateKey(void) const unsigned char tbs[] = {0, 1, 2, 3, 4, 5, 6, 7}; size_t tbsLen = sizeof(tbs); - printf(testingFmt, "test_wolfSSL_PEM_read_PrivateKey()"); - /* Check error case. */ AssertNull(pkey = PEM_read_PrivateKey(NULL, NULL, NULL, NULL)); @@ -32864,22 +32003,20 @@ static int test_wolfSSL_PEM_read_PrivateKey(void) EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PEM_read_PUBKEY(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) \ && !defined(NO_FILESYSTEM) XFILE file; const char* fname = "./certs/client-keyPub.pem"; EVP_PKEY* pkey; - printf(testingFmt, "test_wolfSSL_PEM_read_PUBKEY()"); - /* Check error case. */ AssertNull(pkey = PEM_read_PUBKEY(NULL, NULL, NULL, NULL)); @@ -32889,13 +32026,15 @@ static int test_wolfSSL_PEM_read_PUBKEY(void) AssertNotNull(pkey = PEM_read_PUBKEY(file, NULL, NULL, NULL)); EVP_PKEY_free(pkey); XFCLOSE(file); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_PEM_PrivateKey(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ (!defined(NO_RSA) || defined(HAVE_ECC)) && defined(USE_CERT_BUFFERS_2048) @@ -33076,8 +32215,6 @@ static int test_wolfSSL_PEM_PrivateKey(void) int i; BIO* pub_bio = NULL; - printf(testingFmt, "wolfSSL_PEM_PrivateKey()"); - XMEMSET(extra, BIO_PEM_TEST_CHAR, sizeof(extra)); AssertNotNull(bio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem())); @@ -33243,7 +32380,7 @@ static int test_wolfSSL_PEM_PrivateKey(void) } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #ifndef NO_BIO (void)bio; @@ -33252,53 +32389,49 @@ static int test_wolfSSL_PEM_PrivateKey(void) (void)server_key; #endif /* OPENSSL_EXTRA && !NO_CERTS && !NO_RSA && USE_CERT_BUFFERS_2048 */ - - return 0; + return res; } static int test_wolfSSL_PEM_file_RSAKey(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \ defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && \ !defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) RSA* rsa = NULL; XFILE fp; - printf(testingFmt, "wolfSSL_PEM_file_RSAKey"); - AssertTrue((fp = XFOPEN("./certs/rsa-pub-2048.pem", "rb")) != XBADFILE); AssertNotNull((rsa = PEM_read_RSA_PUBKEY(fp, NULL, NULL, NULL))); XFCLOSE(fp); AssertIntEQ(RSA_size(rsa), 256); AssertIntEQ(PEM_write_RSAPublicKey(XBADFILE, rsa), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSAPublicKey(stdout, NULL), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSAPublicKey(stdout, rsa), WOLFSSL_SUCCESS); + AssertIntEQ(PEM_write_RSAPublicKey(stderr, NULL), WOLFSSL_FAILURE); + AssertIntEQ(PEM_write_RSAPublicKey(stderr, rsa), WOLFSSL_SUCCESS); AssertIntEQ(PEM_write_RSA_PUBKEY(XBADFILE, rsa), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSA_PUBKEY(stdout, NULL), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSA_PUBKEY(stdout, rsa), WOLFSSL_SUCCESS); + AssertIntEQ(PEM_write_RSA_PUBKEY(stderr, NULL), WOLFSSL_FAILURE); + AssertIntEQ(PEM_write_RSA_PUBKEY(stderr, rsa), WOLFSSL_SUCCESS); RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \ (defined(WOLFSSL_KEY_GEN) || WOLFSSL_CERT_GEN) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_CERTS) */ - - return 0; + return res; } static int test_wolfSSL_PEM_file_RSAPrivateKey(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && \ (defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM)) RSA* rsa = NULL; XFILE f = NULL; - printf(testingFmt, "wolfSSL_PEM_file_RSAPrivateKey()"); - f = XFOPEN(svrKeyFile, "r"); AssertTrue((f != XBADFILE)); AssertNotNull((rsa = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL))); @@ -33306,9 +32439,9 @@ static int test_wolfSSL_PEM_file_RSAPrivateKey(void) AssertIntEQ(PEM_write_RSAPrivateKey(XBADFILE, rsa, NULL, NULL, 0, NULL, NULL), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSAPrivateKey(stdout, NULL, NULL, NULL, 0, NULL, + AssertIntEQ(PEM_write_RSAPrivateKey(stderr, NULL, NULL, NULL, 0, NULL, NULL), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_RSAPrivateKey(stdout, rsa, NULL, NULL, 0, NULL, NULL), + AssertIntEQ(PEM_write_RSAPrivateKey(stderr, rsa, NULL, NULL, 0, NULL, NULL), WOLFSSL_SUCCESS); RSA_free(rsa); @@ -33322,23 +32455,21 @@ static int test_wolfSSL_PEM_file_RSAPrivateKey(void) XFCLOSE(f); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ - - return 0; + return res; } #ifndef NO_BIO static int test_wolfSSL_PEM_bio_RSAKey(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \ defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && \ !defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) RSA* rsa = NULL; BIO* bio = NULL; - printf(testingFmt, "wolfSSL_PEM_bio_RSAKey"); - /* PrivateKey */ AssertNotNull(bio = BIO_new_file(svrKeyFile, "rb")); AssertNull((rsa = PEM_read_bio_RSAPrivateKey(NULL, NULL, NULL, NULL))); @@ -33382,24 +32513,22 @@ static int test_wolfSSL_PEM_bio_RSAKey(void) RSA_free(rsa); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \ (defined(WOLFSSL_KEY_GEN) || WOLFSSL_CERT_GEN) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_CERTS) */ - - return 0; + return res; } static int test_wolfSSL_PEM_bio_RSAPrivateKey(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) RSA* rsa = NULL; RSA* rsa_dup = NULL; BIO* bio = NULL; - printf(testingFmt, "wolfSSL_PEM_RSAPrivateKey()"); - AssertNotNull(bio = BIO_new_file(svrKeyFile, "rb")); AssertNotNull((rsa = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL))); AssertIntEQ(RSA_size(rsa), 256); @@ -33429,14 +32558,14 @@ static int test_wolfSSL_PEM_bio_RSAPrivateKey(void) BIO_free(bio); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ - - return 0; + return res; } static int test_wolfSSL_PEM_read_RSA_PUBKEY(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) XFILE file; @@ -33451,21 +32580,21 @@ static int test_wolfSSL_PEM_read_RSA_PUBKEY(void) AssertIntEQ(RSA_size(rsa), 256); RSA_free(rsa); XFCLOSE(file); -#endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ + return res; } static int test_wolfSSL_PEM_bio_DSAKey(void) { + int res = TEST_SKIPPED; #ifndef HAVE_SELFTEST #if (defined(WOLFSSL_QT) || defined(OPENSSL_ALL)) && !defined(NO_CERTS) && \ defined(WOLFSSL_KEY_GEN) && !defined(NO_FILESYSTEM) && !defined(NO_DSA) DSA* dsa = NULL; BIO* bio = NULL; - printf(testingFmt, "wolfSSL_PEM_bio_DSAKey"); - /* PrivateKey */ AssertNotNull(bio = BIO_new_file("./certs/1024/dsa1024.pem", "rb")); AssertNull((dsa = PEM_read_bio_DSAPrivateKey(NULL, NULL, NULL, NULL))); @@ -33501,24 +32630,22 @@ static int test_wolfSSL_PEM_bio_DSAKey(void) DSA_free(dsa); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(WOLFSSL_QT) || defined(OPENSSL_ALL)) && \ !defined(NO_CERTS) && defined(WOLFSSL_KEY_GEN) && \ !defined(NO_FILESYSTEM) && !defined(NO_DSA) */ #endif /* HAVE_SELFTEST */ - - return 0; + return res; } static int test_wolfSSL_PEM_bio_ECKey(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \ defined(WOLFSSL_KEY_GEN) && !defined(NO_FILESYSTEM) && defined(HAVE_ECC) EC_KEY* ec = NULL; BIO* bio = NULL; - printf(testingFmt, "wolfSSL_PEM_bio_ECKey"); - /* PrivateKey */ AssertNotNull(bio = BIO_new_file("./certs/ecc-key.pem", "rb")); AssertNull((ec = PEM_read_bio_ECPrivateKey(NULL, NULL, NULL, NULL))); @@ -33546,8 +32673,8 @@ static int test_wolfSSL_PEM_bio_ECKey(void) /* Same test as above, but with a file pointer rather than a BIO. */ AssertIntEQ(PEM_write_EC_PUBKEY(NULL, ec), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_EC_PUBKEY(stdout, NULL), WOLFSSL_FAILURE); - AssertIntEQ(PEM_write_EC_PUBKEY(stdout, ec), WOLFSSL_SUCCESS); + AssertIntEQ(PEM_write_EC_PUBKEY(stderr, NULL), WOLFSSL_FAILURE); + AssertIntEQ(PEM_write_EC_PUBKEY(stderr, ec), WOLFSSL_SUCCESS); EC_KEY_free(ec); @@ -33560,14 +32687,14 @@ static int test_wolfSSL_PEM_bio_ECKey(void) EC_KEY_free(ec); #endif /* HAVE_ECC */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) */ - - return 0; + return res; } static int test_wolfSSL_PEM_PUBKEY(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) BIO* bio = NULL; EVP_PKEY* pkey = NULL; @@ -33622,15 +32749,17 @@ static int test_wolfSSL_PEM_PUBKEY(void) (void)bio; (void)pkey; -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #endif /* !NO_BIO */ static int test_DSA_do_sign_verify(void) { + int res = TEST_SKIPPED; #if !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \ !defined(NO_DSA) @@ -33662,7 +32791,6 @@ static int test_DSA_do_sign_verify(void) XFCLOSE(fp); #endif /* END USE_CERT_BUFFERS_1024 */ - printf(testingFmt, "DSA_do_sign_verify()"); XMEMSET(digest, 202, sizeof(digest)); AssertNotNull(dsa = DSA_new()); @@ -33676,14 +32804,16 @@ static int test_DSA_do_sign_verify(void) DSA_SIG_free(sig); DSA_free(dsa); + + res = TEST_RES_CHECK(1); #endif #endif /* !HAVE_SELFTEST && !HAVE_FIPS */ - - return 0; + return res; } static int test_wolfSSL_tmp_dh(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_DSA) && !defined(NO_RSA) && !defined(NO_DH) && !defined(NO_BIO) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -33701,8 +32831,6 @@ static int test_wolfSSL_tmp_dh(void) SSL* ssl; SSL_CTX* ctx; - printf(testingFmt, "wolfSSL_tmp_dh()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -33747,22 +32875,22 @@ static int test_wolfSSL_tmp_dh(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } static int test_wolfSSL_ctrl(void) { + int res = TEST_SKIPPED; #if defined (OPENSSL_EXTRA) && !defined(NO_BIO) byte buff[6000]; BIO* bio; int bytes; BUF_MEM* ptr = NULL; - printf(testingFmt, "wolfSSL_crtl()"); + XMEMSET(buff, 0, sizeof(buff)); bytes = sizeof(buff); bio = BIO_new_mem_buf((void*)buff, bytes); @@ -33777,15 +32905,16 @@ static int test_wolfSSL_ctrl(void) */ BIO_free(bio); - printf(resultFmt, passed); -#endif /* defined(OPENSSL_EXTRA) && !defined(NO_BIO) */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* defined(OPENSSL_EXTRA) && !defined(NO_BIO) */ + return res; } static int test_wolfSSL_EVP_PKEY_new_mac_key(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA static const unsigned char pw[] = "password"; static const int pwSz = sizeof(pw) - 1; @@ -33793,8 +32922,6 @@ static int test_wolfSSL_EVP_PKEY_new_mac_key(void) const unsigned char* checkPw = NULL; WOLFSSL_EVP_PKEY* key = NULL; - printf(testingFmt, "wolfSSL_EVP_PKEY_new_mac_key()"); - AssertNull(key = wolfSSL_EVP_PKEY_new_mac_key(0, NULL, pw, pwSz)); AssertNull(key = wolfSSL_EVP_PKEY_new_mac_key(0, NULL, NULL, pwSz)); @@ -33830,22 +32957,20 @@ static int test_wolfSSL_EVP_PKEY_new_mac_key(void) AssertIntEQ((int)checkPwSz, 0); wolfSSL_EVP_PKEY_free(key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_new_CMAC_key(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT) - const char *priv = "ABCDEFGHIJKLMNOP"; const WOLFSSL_EVP_CIPHER* cipher = EVP_aes_128_cbc(); WOLFSSL_EVP_PKEY* key = NULL; - printf(testingFmt, "wolfSSL_EVP_PKEY_new_CMAC_key()"); AssertNull(key = wolfSSL_EVP_PKEY_new_CMAC_key( NULL, NULL, AES_128_KEY_SIZE, cipher)); @@ -33858,15 +32983,15 @@ static int test_wolfSSL_EVP_PKEY_new_CMAC_key(void) NULL, (const unsigned char *)priv, AES_128_KEY_SIZE, cipher)); wolfSSL_EVP_PKEY_free(key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT) */ #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_EVP_Digest(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) && !defined(NO_PWDBASED) @@ -33877,21 +33002,19 @@ static int test_wolfSSL_EVP_Digest(void) const char* expOut = "\xBA\x78\x16\xBF\x8F\x01\xCF\xEA\x41\x41\x40\xDE\x5D\xAE\x22" "\x23\xB0\x03\x61\xA3\x96\x17\x7A\x9C\xB4\x10\xFF\x61\xF2\x00" "\x15\xAD"; - printf(testingFmt, "wolfSSL_EVP_Digest()"); AssertIntEQ(wolfSSL_EVP_Digest((unsigned char*)in, inLen, out, &outLen, "SHA256", NULL), 1); AssertIntEQ(outLen, WC_SHA256_DIGEST_SIZE); AssertIntEQ(XMEMCMP(out, expOut, WC_SHA256_DIGEST_SIZE), 0); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* OPEN_EXTRA && ! NO_SHA256 */ - - return 0; + return res; } static int test_wolfSSL_EVP_Digest_all(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA const char* digests[] = { #ifndef NO_MD5 @@ -33938,28 +33061,24 @@ static int test_wolfSSL_EVP_Digest_all(void) byte out[WC_MAX_DIGEST_SIZE]; unsigned int outLen; - printf(testingFmt, "wolfSSL_EVP_Digest_all"); - for (d = digests; *d != NULL; d++) { AssertIntEQ(EVP_Digest(in, inLen, out, &outLen, *d, NULL), 1); AssertIntGT(outLen, 0); AssertIntEQ(EVP_MD_size(*d), outLen); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_MD_size(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA WOLFSSL_EVP_MD_CTX mdCtx; - printf(testingFmt, "wolfSSL_EVP_MD_size()"); - #ifdef WOLFSSL_SHA3 #ifndef WOLFSSL_NOSHA3_224 wolfSSL_EVP_MD_CTX_init(&mdCtx); @@ -34081,20 +33200,17 @@ static int test_wolfSSL_EVP_MD_size(void) /* Cleanup is valid on uninit'ed struct */ AssertIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_EVP_MD_pkey_type(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA const WOLFSSL_EVP_MD* md; - printf(testingFmt, "test_wolfSSL_EVP_MD_pkey_type()"); - #ifndef NO_MD5 AssertNotNull(md = EVP_md5()); AssertIntEQ(EVP_MD_pkey_type(md), NID_md5WithRSAEncryption); @@ -34118,10 +33234,9 @@ static int test_wolfSSL_EVP_MD_pkey_type(void) AssertIntEQ(EVP_MD_pkey_type(md), NID_sha512WithRSAEncryption); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifdef OPENSSL_EXTRA @@ -34134,7 +33249,6 @@ static void test_hmac_signing(const WOLFSSL_EVP_MD *type, const byte* testKey, WOLFSSL_EVP_PKEY* key; WOLFSSL_EVP_MD_CTX mdCtx; - printf(testingFmt, "wolfSSL_EVP_MD_hmac_signing()"); AssertNotNull(key = wolfSSL_EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, testKey, (int)testKeySz)); wolfSSL_EVP_MD_CTX_init(&mdCtx); @@ -34182,6 +33296,7 @@ static void test_hmac_signing(const WOLFSSL_EVP_MD *type, const byte* testKey, static int test_wolfSSL_EVP_MD_hmac_signing(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA static const unsigned char testKey[] = { @@ -34316,15 +33431,15 @@ static int test_wolfSSL_EVP_MD_hmac_signing(void) #endif #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_EVP_MD_rsa_signing(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \ defined(USE_CERT_BUFFERS_2048) WOLFSSL_EVP_PKEY* privKey; @@ -34347,8 +33462,6 @@ static int test_wolfSSL_EVP_MD_rsa_signing(void) }; - printf(testingFmt, "wolfSSL_EVP_MD_rsa_signing()"); - cp = client_key_der_2048; AssertNotNull((privKey = wolfSSL_d2i_PrivateKey(EVP_PKEY_RSA, NULL, &cp, sizeof_client_key_der_2048))); @@ -34433,15 +33546,15 @@ static int test_wolfSSL_EVP_MD_rsa_signing(void) wolfSSL_EVP_PKEY_free(pubKey); wolfSSL_EVP_PKEY_free(privKey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_MD_ecc_signing(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256) WOLFSSL_EVP_PKEY* privKey; WOLFSSL_EVP_PKEY* pubKey; @@ -34452,8 +33565,6 @@ static int test_wolfSSL_EVP_MD_ecc_signing(void) const unsigned char* p; unsigned char check[2048/8]; - printf(testingFmt, "wolfSSL_EVP_MD_ecc_signing()"); - cp = ecc_clikey_der_256; privKey = wolfSSL_d2i_PrivateKey(EVP_PKEY_EC, NULL, &cp, sizeof_ecc_clikey_der_256); @@ -34504,15 +33615,15 @@ static int test_wolfSSL_EVP_MD_ecc_signing(void) wolfSSL_EVP_PKEY_free(pubKey); wolfSSL_EVP_PKEY_free(privKey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_CTX_add_extra_chain_cert(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_BIO) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -34526,8 +33637,6 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void) STACK_OF(X509) *chain = NULL; STACK_OF(X509) *chain2 = NULL; - printf(testingFmt, "wolfSSL_CTX_add_extra_chain_cert()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -34607,18 +33716,19 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void) sk_X509_pop_free(chain, X509_free); sk_X509_pop_free(chain2, X509_free); SSL_CTX_free(ctx); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined (NO_BIO) */ - - return 0; + return res; } #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) static int test_wolfSSL_ERR_peek_last_error_line(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL) && \ !defined(NO_OLD_TLS) && !defined(WOLFSSL_NO_TLS12) && \ @@ -34636,8 +33746,6 @@ static int test_wolfSSL_ERR_peek_last_error_line(void) const char* file = NULL; const char* data = NULL; - printf(testingFmt, "wolfSSL_ERR_peek_last_error_line()"); - /* create a failed connection and inspect the error */ #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -34711,16 +33819,14 @@ static int test_wolfSSL_ERR_peek_last_error_line(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); + fprintf(stderr, "\nTesting error print out\n"); + ERR_print_errors_fp(stderr); + fprintf(stderr, "Done testing print out\n\n"); - printf("\nTesting error print out\n"); - ERR_print_errors_fp(stdout); - printf("Done testing print out\n\n"); - fflush(stdout); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(DEBUG_WOLFSSL) */ - - return 0; + return res; } #endif @@ -34730,18 +33836,18 @@ static int verify_cb(int ok, X509_STORE_CTX *ctx) { (void) ok; (void) ctx; - printf("ENTER verify_cb\n"); + fprintf(stderr, "ENTER verify_cb\n"); return SSL_SUCCESS; } #endif static int test_wolfSSL_X509_Name_canon(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_SHA) && \ defined(WOLFSSL_CERT_GEN) && \ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && !defined(NO_RSA) - const long ex_hash1 = 0x0fdb2da4; const long ex_hash2 = 0x9f3e8c9e; X509_NAME *name = NULL; @@ -34752,7 +33858,6 @@ static int test_wolfSSL_X509_Name_canon(void) byte *pbuf = NULL; word32 len = 0; (void) ex_hash2; - printf(testingFmt, "test_wolfSSL_X509_Name_canon()"); file = XFOPEN(caCertFile, "rb"); AssertNotNull(file); @@ -34795,16 +33900,14 @@ static int test_wolfSSL_X509_Name_canon(void) X509_free(x509); XFREE(pbuf, NULL, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - - return 0; + return res; } static int test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) const int MAX_DIR = 4; const char paths[][32] = { @@ -34823,8 +33926,6 @@ static int test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) (void) sk; - printf(testingFmt, "test_wolfSSL_X509_LOOKUP_ctrl_hash_dir()"); - XMEMSET(CertCrl_path, 0, MAX_FILENAME_SZ); /* illegal string */ @@ -34852,7 +33953,7 @@ static int test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) p = &CertCrl_path[0]; total_len = 0; - for(i = MAX_DIR - 1; i>=0 && total_len < MAX_FILENAME_SZ; i--) { + for (i = MAX_DIR - 1; i>=0 && total_len < MAX_FILENAME_SZ; i--) { len = (int)XSTRLEN((const char*)&paths[i]); total_len += len; XSTRNCPY(p, paths[i], MAX_FILENAME_SZ - total_len); @@ -34871,15 +33972,14 @@ static int test_wolfSSL_X509_LOOKUP_ctrl_hash_dir(void) X509_STORE_free(str); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - - return 0; + return res; } static int test_wolfSSL_X509_LOOKUP_ctrl_file(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \ defined(WOLFSSL_SIGNER_DER_CERT) @@ -34912,7 +34012,6 @@ static int test_wolfSSL_X509_LOOKUP_ctrl_file(void) "" }; #endif - printf(testingFmt, "test_wolfSSL_X509_LOOKUP_ctrl_file()"); AssertNotNull(file1=fopen("./certs/ca-cert.pem", "rb")); AssertNotNull(cert1 = wolfSSL_PEM_read_X509(file1, NULL, NULL, NULL)); @@ -35002,30 +34101,29 @@ static int test_wolfSSL_X509_LOOKUP_ctrl_file(void) AssertIntEQ(X509_LOOKUP_ctrl(NULL, 0, NULL, 0, NULL), 0); X509_STORE_free(str); - #endif - - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } + static int test_wolfSSL_X509_STORE_CTX_trusted_stack_cleanup(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "test_wolfSSL_X509_STORE_CTX_trusted_stack_cleanup()"); - X509_STORE_CTX_cleanup(NULL); X509_STORE_CTX_trusted_stack(NULL, NULL); AssertTrue(1); /* to confirm previous call gives no harm */ - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } + static int test_wolfSSL_X509_STORE_CTX_get0_current_issuer(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) #ifdef WOLFSSL_SIGNER_DER_CERT int cmp; @@ -35038,8 +34136,6 @@ static int test_wolfSSL_X509_STORE_CTX_get0_current_issuer(void) X509_NAME* caName; X509_NAME* issuerName; - printf(testingFmt, "wolfSSL_X509_STORE_CTX_get0_current_issuer()"); - AssertNotNull(ctx = X509_STORE_CTX_new()); AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull((x509Ca = @@ -35069,14 +34165,14 @@ static int test_wolfSSL_X509_STORE_CTX_get0_current_issuer(void) X509_STORE_free(str); X509_free(x509Ca); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PKCS7_certs(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && !defined(NO_BIO) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && defined(HAVE_PKCS7) STACK_OF(X509)* sk = NULL; @@ -35087,8 +34183,6 @@ static int test_wolfSSL_PKCS7_certs(void) int buflen = 0; int i; - printf(testingFmt, "wolfSSL_PKCS7_certs()"); - /* Test twice. Once with d2i and once without to test * that everything is free'd correctly. */ for (i = 0; i < 2; i++) { @@ -35126,15 +34220,15 @@ static int test_wolfSSL_PKCS7_certs(void) PKCS7_free(p7); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && defined(HAVE_PKCS7) */ - - return 0; + return res; } static int test_wolfSSL_X509_STORE_CTX(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) @@ -35146,7 +34240,6 @@ static int test_wolfSSL_X509_STORE_CTX(void) STACK_OF(X509) *sk, *sk2, *sk3; #endif - printf(testingFmt, "wolfSSL_X509_STORE_CTX()"); AssertNotNull(ctx = X509_STORE_CTX_new()); AssertNotNull((str = wolfSSL_X509_STORE_new())); AssertNotNull((x509 = @@ -35245,22 +34338,22 @@ static int test_wolfSSL_X509_STORE_CTX(void) X509_STORE_free(str); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - return 0; + return res; } static int test_wolfSSL_X509_STORE_set_flags(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) X509_STORE* store; X509* x509; - printf(testingFmt, "wolfSSL_X509_STORE_set_flags()"); AssertNotNull((store = wolfSSL_X509_STORE_new())); AssertNotNull((x509 = wolfSSL_X509_load_certificate_file(svrCertFile, WOLFSSL_FILETYPE_PEM))); @@ -35276,23 +34369,21 @@ static int test_wolfSSL_X509_STORE_set_flags(void) wolfSSL_X509_free(x509); wolfSSL_X509_STORE_free(store); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } static int test_wolfSSL_X509_LOOKUP_load_file(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \ (!defined(NO_WOLFSSL_CLIENT) || !defined(WOLFSSL_NO_CLIENT_AUTH)) WOLFSSL_X509_STORE* store; WOLFSSL_X509_LOOKUP* lookup; - printf(testingFmt, "wolfSSL_X509_LOOKUP_load_file()"); - AssertNotNull(store = wolfSSL_X509_STORE_new()); AssertNotNull(lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())); AssertIntEQ(wolfSSL_X509_LOOKUP_load_file(lookup, "certs/client-ca.pem", @@ -35315,20 +34406,19 @@ static int test_wolfSSL_X509_LOOKUP_load_file(void) wolfSSL_X509_STORE_free(store); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && defined(HAVE_CRL) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } static int test_wolfSSL_X509_STORE_CTX_set_time(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) WOLFSSL_X509_STORE_CTX* ctx; time_t c_time; - printf(testingFmt, "wolfSSL_X509_set_time()"); AssertNotNull(ctx = wolfSSL_X509_STORE_CTX_new()); c_time = 365*24*60*60; wolfSSL_X509_STORE_CTX_set_time(ctx, 0, c_time); @@ -35337,14 +34427,14 @@ static int test_wolfSSL_X509_STORE_CTX_set_time(void) AssertTrue(ctx->param->check_time == c_time); wolfSSL_X509_STORE_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_CTX_get0_set1_param(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) int ret; @@ -35354,8 +34444,6 @@ static int test_wolfSSL_CTX_get0_set1_param(void) char testIPv4[] = "127.0.0.1"; char testhostName[] = "foo.hoge.com"; - printf(testingFmt, "wolfSSL_CTX_get0_set1_param()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -35391,23 +34479,21 @@ static int test_wolfSSL_CTX_get0_set1_param(void) XFREE(pvpm, NULL, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* OPENSSL_EXTRA && !defined(NO_RSA)*/ - - return 0; + return res; } static int test_wolfSSL_get0_param(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) SSL_CTX* ctx; SSL* ssl; WOLFSSL_X509_VERIFY_PARAM* pParam; - printf(testingFmt, "wolfSSL_get0_param()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -35423,21 +34509,20 @@ static int test_wolfSSL_get0_param(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* OPENSSL_EXTRA && !defined(NO_RSA)*/ - - return 0; + return res; } static int test_wolfSSL_X509_VERIFY_PARAM_set1_host(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) const char host[] = "www.example.com"; WOLFSSL_X509_VERIFY_PARAM* pParam; - printf(testingFmt, "wolfSSL_X509_VERIFY_PARAM_set1_host()"); - AssertNotNull(pParam = (WOLFSSL_X509_VERIFY_PARAM*)XMALLOC( sizeof(WOLFSSL_X509_VERIFY_PARAM), HEAP_HINT, DYNAMIC_TYPE_OPENSSL)); @@ -35454,14 +34539,14 @@ static int test_wolfSSL_X509_VERIFY_PARAM_set1_host(void) XFREE(pParam, HEAP_HINT, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_set1_host(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) const char host[] = "www.test_wolfSSL_set1_host.com"; @@ -35470,8 +34555,6 @@ static int test_wolfSSL_set1_host(void) SSL* ssl; WOLFSSL_X509_VERIFY_PARAM* pParam; - printf(testingFmt, "wolfSSL_set1_host()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -35501,21 +34584,20 @@ static int test_wolfSSL_set1_host(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) unsigned char buf[16] = {0}; WOLFSSL_X509_VERIFY_PARAM* param; - printf(testingFmt, "test_wolfSSL_X509_VERIFY_PARAM_set1_ip()"); - AssertNotNull(param = X509_VERIFY_PARAM_new()); /* test 127.0.0.1 */ @@ -35569,20 +34651,20 @@ static int test_wolfSSL_X509_VERIFY_PARAM_set1_ip(void) sizeof(param->ipasc)), 0); XFREE(param, HEAP_HINT, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } static int test_wolfSSL_X509_STORE_CTX_get0_store(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) X509_STORE* store; X509_STORE_CTX* ctx; X509_STORE_CTX* ctx_no_init; - printf(testingFmt, "wolfSSL_X509_STORE_CTX_get0_store()"); AssertNotNull((store = X509_STORE_new())); AssertNotNull(ctx = X509_STORE_CTX_new()); AssertNotNull(ctx_no_init = X509_STORE_CTX_new()); @@ -35597,14 +34679,14 @@ static int test_wolfSSL_X509_STORE_CTX_get0_store(void) wolfSSL_X509_STORE_CTX_free(ctx_no_init); X509_STORE_free(store); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_CTX_set_client_CA_list(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_BIO) WOLFSSL_CTX* ctx; @@ -35614,7 +34696,6 @@ static int test_wolfSSL_CTX_set_client_CA_list(void) STACK_OF(X509_NAME)* ca_list = NULL; int i, names_len; - printf(testingFmt, "wolfSSL_CTX_set_client_CA_list()"); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); /* Send two X501 names in cert request */ names = SSL_load_client_CA_file(cliCertFile); @@ -35651,8 +34732,6 @@ static int test_wolfSSL_CTX_set_client_CA_list(void) AssertIntEQ(sk_X509_NAME_find(names, name), i); } - printf(resultFmt, passed); - #if !defined(SINGLE_THREADED) && defined(SESSION_CERTS) { tcp_ready ready; @@ -35663,7 +34742,7 @@ static int test_wolfSSL_CTX_set_client_CA_list(void) WOLFSSL_CTX* ctx_client; SOCKET_T sockfd = 0; - printf(testingFmt, "wolfSSL_get_client_CA_list() with handshake"); + /* wolfSSL_get_client_CA_list() with handshake */ StartTCP(); InitTcpReady(&ready); @@ -35713,20 +34792,20 @@ static int test_wolfSSL_CTX_set_client_CA_list(void) join_thread(serverThread); FreeTcpReady(&ready); - - printf(resultFmt, passed); } #endif wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); -#endif /* OPENSSL_EXTRA && !NO_RSA && !NO_CERTS && !NO_WOLFSSL_CLIENT && !NO_BIO */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA && !NO_RSA && !NO_CERTS && !NO_WOLFSSL_CLIENT && !NO_BIO */ + return res; } static int test_wolfSSL_CTX_add_client_CA(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_CERTS) && \ !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx; @@ -35735,7 +34814,6 @@ static int test_wolfSSL_CTX_add_client_CA(void) STACK_OF(X509_NAME)* ca_list; int ret = 0; - printf(testingFmt, "wolfSSL_CTX_add_client_CA()"); AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method())); /* Add client cert */ x509 = X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM); @@ -35757,10 +34835,9 @@ static int test_wolfSSL_CTX_add_client_CA(void) X509_free(x509_a); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_RSA && !NO_CERTS && !NO_WOLFSSL_CLIENT */ - - return 0; + return res; } #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) static THREAD_RETURN WOLFSSL_THREAD server_task(void* args) @@ -35815,12 +34892,13 @@ static THREAD_RETURN WOLFSSL_THREAD server_task(void* args) if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; - printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff)); + fprintf(stderr, "error = %d, %s\n", err, + wolfSSL_ERR_error_string(err, buff)); } else { if (0 < (idx = wolfSSL_read(ssl, input, sizeof(input)-1))) { input[idx] = 0; - printf("Client message: %s\n", input); + fprintf(stderr, "Client message: %s\n", input); } AssertIntEQ(len, wolfSSL_write(ssl, msg, len)); @@ -35863,28 +34941,27 @@ static void keyLog_callback(const WOLFSSL* ssl, const char* line ) #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK */ static int test_wolfSSL_CTX_set_keylog_callback(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) && \ !defined(NO_WOLFSSL_CLIENT) SSL_CTX* ctx; - printf( testingFmt, "wolfSSL_CTX_set_keylog_callback()"); AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method())); SSL_CTX_set_keylog_callback(ctx, keyLog_callback ); SSL_CTX_free(ctx); SSL_CTX_set_keylog_callback(NULL, NULL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK && !NO_WOLFSSL_CLIENT */ - - return 0; + return res; } static int test_wolfSSL_CTX_get_keylog_callback(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) && \ !defined(NO_WOLFSSL_CLIENT) SSL_CTX* ctx; - printf( testingFmt, "wolfSSL_CTX_get_keylog_callback()"); AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method())); AssertPtrEq(SSL_CTX_get_keylog_callback(ctx),NULL); SSL_CTX_set_keylog_callback(ctx, keyLog_callback ); @@ -35892,18 +34969,18 @@ static int test_wolfSSL_CTX_get_keylog_callback(void) SSL_CTX_set_keylog_callback(ctx, NULL ); AssertPtrEq(SSL_CTX_get_keylog_callback(ctx),NULL); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK && !NO_WOLFSSL_CLIENT */ - - return 0; + return res; } static int test_wolfSSL_Tls12_Key_Logging_test(void) { - #if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) - /* This test is intended for checking whether keylog callback is called - * in client during TLS handshake between the client and a server. - */ + int res = TEST_SKIPPED; +#if defined(OPENSSL_EXTRA) && defined(HAVE_SECRET_CALLBACK) +/* This test is intended for checking whether keylog callback is called + * in client during TLS handshake between the client and a server. + */ tcp_ready ready; func_args client_args; @@ -35919,8 +34996,6 @@ static int test_wolfSSL_Tls12_Key_Logging_test(void) char reply[1024]; int msgSz = (int)XSTRLEN(msg); - printf(testingFmt, "wolfSSL_Tls12_Key_Logging_test()"); - #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); #endif @@ -35990,8 +35065,8 @@ static int test_wolfSSL_Tls12_Key_Logging_test(void) AssertNotNull(fp); - while(XFGETS( buff, (int)sizeof(buff),fp) != NULL ) { - if(0 == strncmp(buff,"CLIENT_RANDOM ", + while (XFGETS( buff, (int)sizeof(buff),fp) != NULL ) { + if (0 == strncmp(buff,"CLIENT_RANDOM ", sizeof("CLIENT_RANDOM ")-1)) { found = 1; break; @@ -36000,19 +35075,19 @@ static int test_wolfSSL_Tls12_Key_Logging_test(void) XFCLOSE(fp); /* a log starting with "CLIENT_RANDOM " should exit in the file */ AssertNotNull( found ); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK */ - - return 0; + return res; } static int test_wolfSSL_Tls13_Key_Logging_test(void) { - #if defined(WOLFSSL_TLS13) && defined(OPENSSL_EXTRA) && \ + int res = TEST_SKIPPED; +#if defined(WOLFSSL_TLS13) && defined(OPENSSL_EXTRA) && \ defined(HAVE_SECRET_CALLBACK) - /* This test is intended for checking whether keylog callback is called - * in client during TLS handshake between the client and a server. - */ +/* This test is intended for checking whether keylog callback is called + * in client during TLS handshake between the client and a server. + */ tcp_ready ready; func_args client_args; @@ -36028,8 +35103,6 @@ static int test_wolfSSL_Tls13_Key_Logging_test(void) char reply[1024]; int msgSz = (int)XSTRLEN(msg); - printf(testingFmt, "wolfSSL_Tls13_Key_Logging_test()"); - #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); #endif @@ -36121,17 +35194,15 @@ static int test_wolfSSL_Tls13_Key_Logging_test(void) } XFCLOSE(fp); for (i = 0; i < 4; i++) { - if( found[i] != 0) + if (found[i] != 0) numfnd++; } AssertIntEQ(numfnd, 4); } - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_SECRET_CALLBACK && WOLFSSL_TLS13 */ - - return 0; + return res; } #if defined(HAVE_IO_TESTS_DEPENDENCIES) && \ @@ -36177,6 +35248,7 @@ static void set_post_auth_cb(WOLFSSL* ssl) static int test_wolfSSL_Tls13_postauth(void) { + int res = TEST_SKIPPED; #if defined(HAVE_IO_TESTS_DEPENDENCIES) && \ defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH) @@ -36187,7 +35259,6 @@ static int test_wolfSSL_Tls13_postauth(void) callback_functions client_cbf; THREAD_TYPE serverThread; - printf(testingFmt, "wolfSSL_Tls13_postauth()"); XMEMSET(&client_args, 0, sizeof(func_args)); XMEMSET(&server_args, 0, sizeof(func_args)); @@ -36233,15 +35304,16 @@ static int test_wolfSSL_Tls13_postauth(void) join_thread(serverThread); FreeTcpReady(&ready); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_NID(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \ !defined(NO_RSA) && defined(USE_CERT_BUFFERS_2048) && !defined(NO_ASN) int sigType; @@ -36258,7 +35330,6 @@ static int test_wolfSSL_X509_NID(void) char orgName[80]; char orgUnit[80]; - printf(testingFmt, "wolfSSL_X509_NID()"); /* ------ PARSE ORIGINAL SELF-SIGNED CERTIFICATE ------ */ /* convert cert from DER to internal WOLFSSL_X509 struct */ @@ -36311,14 +35382,14 @@ static int test_wolfSSL_X509_NID(void) EVP_PKEY_free(pubKeyTmp); X509_free(cert); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_CTX_set_srp_username(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ && !defined(NO_SHA256) && !defined(WC_NO_RNG) && !defined(NO_WOLFSSL_CLIENT) @@ -36328,8 +35399,6 @@ static int test_wolfSSL_CTX_set_srp_username(void) const char *password = "TESTPASSWORD"; int r; - printf(testingFmt, "wolfSSL_CTX_set_srp_username()"); - ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); AssertNotNull(ctx); r = wolfSSL_CTX_set_srp_username(ctx, (char *)username); @@ -36350,15 +35419,15 @@ static int test_wolfSSL_CTX_set_srp_username(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFCRYPT_HAVE_SRP */ /* && !NO_SHA256 && !WC_NO_RNG && !NO_WOLFSSL_CLIENT */ - - return 0; + return res; } static int test_wolfSSL_CTX_set_srp_password(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ && !defined(NO_SHA256) && !defined(WC_NO_RNG) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX* ctx; @@ -36366,7 +35435,6 @@ static int test_wolfSSL_CTX_set_srp_password(void) const char *password = "TESTPASSWORD"; int r; - printf(testingFmt, "wolfSSL_CTX_set_srp_password()"); ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); AssertNotNull(ctx); r = wolfSSL_CTX_set_srp_password(ctx, (char *)password); @@ -36381,15 +35449,15 @@ static int test_wolfSSL_CTX_set_srp_password(void) AssertIntEQ(r,SSL_SUCCESS); wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFCRYPT_HAVE_SRP */ /* && !NO_SHA256 && !WC_NO_RNG && !NO_WOLFSSL_CLIENT */ - - return 0; + return res; } static int test_wolfSSL_X509_STORE(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) X509_STORE *store; @@ -36402,7 +35470,6 @@ static int test_wolfSSL_X509_STORE(void) const char caCert[] = "./certs/ca-cert.pem"; XFILE fp; - printf(testingFmt, "test_wolfSSL_X509_STORE"); AssertNotNull(store = (X509_STORE *)X509_STORE_new()); AssertNotNull((ca = wolfSSL_X509_load_certificate_file(caCert, SSL_FILETYPE_PEM))); @@ -36479,14 +35546,15 @@ static int test_wolfSSL_X509_STORE(void) #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ } #endif - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_STORE_load_locations(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && \ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) && !defined(NO_RSA) SSL_CTX *ctx; @@ -36503,8 +35571,6 @@ static int test_wolfSSL_X509_STORE_load_locations(void) const char crl_file[] = "./certs/crl/crl.pem"; #endif - printf(testingFmt, "wolfSSL_X509_STORE_load_locations"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(SSLv23_server_method())); #else @@ -36539,14 +35605,15 @@ static int test_wolfSSL_X509_STORE_load_locations(void) #endif SSL_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_X509_STORE_get0_objects(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && \ !defined(NO_WOLFSSL_DIR) && !defined(NO_RSA) X509_STORE *store; @@ -36556,8 +35623,6 @@ static int test_X509_STORE_get0_objects(void) STACK_OF(X509_OBJECT) *objs; int i; - printf(testingFmt, "wolfSSL_X509_STORE_get0_objects"); - /* Setup store */ #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(SSLv23_server_method())); @@ -36614,14 +35679,15 @@ static int test_X509_STORE_get0_objects(void) X509_STORE_free(store_cpy); SSL_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_BN(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN) && !defined(WOLFSSL_SP_MATH) BIGNUM* a; BIGNUM* b; @@ -36629,8 +35695,6 @@ static int test_wolfSSL_BN(void) BIGNUM* d; ASN1_INTEGER* ai; - printf(testingFmt, "wolfSSL_BN()"); - AssertNotNull(b = BN_new()); AssertNotNull(c = BN_new()); AssertNotNull(d = BN_new()); @@ -36823,10 +35887,9 @@ static int test_wolfSSL_BN(void) BN_free(a); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_ASN) */ - - return 0; + return res; } #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ @@ -36863,7 +35926,7 @@ static int msgCb(SSL_CTX *ctx, SSL *ssl) BIO* bio; #endif (void) ctx; - printf("\n===== msgcb called ====\n"); + fprintf(stderr, "\n===== msgcb called ====\n"); #if defined(SESSION_CERTS) && defined(TEST_PEER_CERT_CHAIN) AssertTrue(SSL_get_peer_cert_chain(ssl) != NULL); AssertIntEQ(((WOLFSSL_X509_CHAIN *)SSL_get_peer_cert_chain(ssl))->count, 2); @@ -36874,7 +35937,7 @@ static int msgCb(SSL_CTX *ctx, SSL *ssl) #if defined(OPENSSL_ALL) && defined(SESSION_CERTS) && !defined(NO_BIO) bio = BIO_new(BIO_s_file()); - BIO_set_fp(bio, stdout, BIO_NOCLOSE); + BIO_set_fp(bio, stderr, BIO_NOCLOSE); sk = SSL_get_peer_cert_chain(ssl); AssertNotNull(sk); if (!sk) { @@ -36888,9 +35951,9 @@ static int msgCb(SSL_CTX *ctx, SSL *ssl) AssertNotNull(x509); if (!x509) break; - printf("Certificate at index [%d] = :\n",i); + fprintf(stderr, "Certificate at index [%d] = :\n",i); X509_print(bio,x509); - printf("\n\n"); + fprintf(stderr, "\n\n"); } BIO_free(bio); #endif @@ -36901,6 +35964,7 @@ static int msgCb(SSL_CTX *ctx, SSL *ssl) static int test_wolfSSL_msgCb(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL) && \ defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(NO_WOLFSSL_CLIENT) && \ @@ -36915,8 +35979,6 @@ static int test_wolfSSL_msgCb(void) callback_functions client_cb; callback_functions server_cb; - printf(testingFmt, "test_wolfSSL_msgCb"); - /* create a failed connection and inspect the error */ #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -36961,15 +36023,14 @@ static int test_wolfSSL_msgCb(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_either_side(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)) && \ !defined(NO_FILESYSTEM) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) @@ -36983,8 +36044,6 @@ static int test_wolfSSL_either_side(void) callback_functions client_cb; callback_functions server_cb; - printf(testingFmt, "test_wolfSSL_either_side"); - /* create a failed connection and inspect the error */ #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -37032,15 +36091,14 @@ static int test_wolfSSL_either_side(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_DTLS_either_side(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)) && \ !defined(NO_FILESYSTEM) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \ @@ -37055,8 +36113,6 @@ static int test_wolfSSL_DTLS_either_side(void) callback_functions client_cb; callback_functions server_cb; - printf(testingFmt, "test_wolfSSL_DTLS_either_side"); - /* create a failed connection and inspect the error */ #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -37104,21 +36160,19 @@ static int test_wolfSSL_DTLS_either_side(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_generate_cookie(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_DTLS) && defined(OPENSSL_EXTRA) && defined(USE_WOLFSSL_IO) SSL_CTX* ctx; SSL* ssl; byte buf[FOURK_BUF] = {0}; - printf(testingFmt, "test_generate_cookie"); - AssertNotNull(ctx = wolfSSL_CTX_new(wolfDTLS_method())); AssertNotNull(ssl = SSL_new(ctx)); @@ -37136,14 +36190,14 @@ static int test_generate_cookie(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_set_options(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) WOLFSSL* ssl; @@ -37160,8 +36214,6 @@ static int test_wolfSSL_set_options(void) void *arg = (void *)TEST_ARG; #endif - printf(testingFmt, "wolfSSL_set_options()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); #else @@ -37269,15 +36321,15 @@ static int test_wolfSSL_set_options(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } static int test_wolfSSL_sk_SSL_CIPHER(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) @@ -37285,8 +36337,6 @@ static int test_wolfSSL_sk_SSL_CIPHER(void) SSL_CTX* ctx; STACK_OF(SSL_CIPHER) *sk, *dupSk; - printf(testingFmt, "wolfSSL_sk_SSL_CIPHER_*()"); - #ifndef NO_WOLFSSL_SERVER AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); #else @@ -37308,16 +36358,16 @@ static int test_wolfSSL_sk_SSL_CIPHER(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } static int test_wolfSSL_set1_curves_list(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) SSL* ssl = NULL; @@ -37369,15 +36419,15 @@ static int test_wolfSSL_set1_curves_list(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } static int test_wolfSSL_set1_sigalgs_list(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_RSA) #if !defined(NO_WOLFSSL_CLIENT) || !defined(NO_WOLFSSL_SERVER) SSL* ssl; @@ -37495,24 +36545,23 @@ static int test_wolfSSL_set1_sigalgs_list(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_CLIENT || !NO_WOLFSSL_SERVER */ #endif - - return 0; + return res; } /* Testing wolfSSL_set_tlsext_status_type function. * PRE: OPENSSL and HAVE_CERTIFICATE_STATUS_REQUEST defined. */ -static int test_wolfSSL_set_tlsext_status_type(void){ +static int test_wolfSSL_set_tlsext_status_type(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CERTIFICATE_STATUS_REQUEST) && \ !defined(NO_RSA) && !defined(NO_WOLFSSL_SERVER) SSL* ssl; SSL_CTX* ctx; - printf(testingFmt, "wolfSSL_set_tlsext_status_type()"); - AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); AssertTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, SSL_FILETYPE_PEM)); AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM)); @@ -37522,15 +36571,17 @@ static int test_wolfSSL_set_tlsext_status_type(void){ AssertIntEQ(SSL_get_tlsext_status_type(ssl), TLSEXT_STATUSTYPE_ocsp); SSL_free(ssl); SSL_CTX_free(ctx); - #endif /* OPENSSL_EXTRA && HAVE_CERTIFICATE_STATUS_REQUEST && !NO_RSA */ - return 0; + res = TEST_RES_CHECK(1); + #endif /* OPENSSL_EXTRA && HAVE_CERTIFICATE_STATUS_REQUEST && !NO_RSA */ + return res; } #ifndef NO_BIO static int test_wolfSSL_PEM_read_bio(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) byte buff[6000]; @@ -37540,8 +36591,6 @@ static int test_wolfSSL_PEM_read_bio(void) BIO* bio = NULL; BUF_MEM* buf; - printf(testingFmt, "wolfSSL_PEM_read_bio()"); - f = XFOPEN(cliCertFile, "rb"); AssertTrue((f != XBADFILE)); bytes = (int)XFREAD(buff, 1, sizeof(buff), f); @@ -37562,11 +36611,10 @@ static int test_wolfSSL_PEM_read_bio(void) BUF_MEM_free(buf); X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } @@ -37586,6 +36634,7 @@ static long bioCallback(BIO *bio, int cmd, const char* argp, int argi, static int test_wolfSSL_BIO(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) const unsigned char* p; byte buff[20]; @@ -37595,8 +36644,6 @@ static int test_wolfSSL_BIO(void) char* bufPt; int i; - printf(testingFmt, "wolfSSL_BIO()"); - for (i = 0; i < 20; i++) { buff[i] = i; } @@ -37813,10 +36860,9 @@ static int test_wolfSSL_BIO(void) BIO_vfree(NULL); BIO_vfree(bio1); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif /* !NO_BIO */ @@ -37824,12 +36870,11 @@ static int test_wolfSSL_BIO(void) static int test_wolfSSL_ASN1_STRING(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) ASN1_STRING* str = NULL; const char data[] = "hello wolfSSL"; - printf(testingFmt, "wolfSSL_ASN1_STRING()"); - AssertNotNull(str = ASN1_STRING_type_new(V_ASN1_OCTET_STRING)); AssertIntEQ(ASN1_STRING_type(str), V_ASN1_OCTET_STRING); AssertIntEQ(ASN1_STRING_set(str, (const void*)data, sizeof(data)), 1); @@ -37838,18 +36883,17 @@ static int test_wolfSSL_ASN1_STRING(void) ASN1_STRING_free(str); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_BIT_STRING(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL ASN1_BIT_STRING* str; - printf(testingFmt, "test_wolfSSL_ASN1_BIT_STRING()"); AssertNotNull(str = ASN1_BIT_STRING_new()); AssertIntEQ(ASN1_BIT_STRING_set_bit(str, 42, 1), 1); @@ -37860,14 +36904,15 @@ static int test_wolfSSL_ASN1_BIT_STRING(void) AssertIntEQ(ASN1_BIT_STRING_get_bit(str, 83), 0); ASN1_BIT_STRING_free(str); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_a2i_ASN1_INTEGER(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_BIO) BIO *bio, *out; ASN1_INTEGER* ai; @@ -37878,8 +36923,6 @@ static int test_wolfSSL_a2i_ASN1_INTEGER(void) const char expected1[] = "123456"; const char expected2[] = "112345678912345678901234567890"; - printf(testingFmt, "test_wolfSSL_a2i_ASN1_INTEGER()"); - AssertNotNull(bio = BIO_new_mem_buf(buf, -1)); AssertNotNull(out = BIO_new(BIO_s_mem())); AssertNotNull(ai = ASN1_INTEGER_new()); @@ -37907,15 +36950,14 @@ static int test_wolfSSL_a2i_ASN1_INTEGER(void) BIO_free(bio); ASN1_INTEGER_free(ai); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_a2i_IPADDRESS(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(WOLFSSL_USER_IO) const unsigned char* data; int dataSz = 0; @@ -37930,7 +36972,6 @@ static int test_wolfSSL_a2i_IPADDRESS(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - printf(testingFmt, "test_wolfSSL_a2i_IPADDRESS()"); AssertNull(st = a2i_IPADDRESS("127.0.0.1bad")); AssertNotNull(st = a2i_IPADDRESS("127.0.0.1")); @@ -37954,21 +36995,18 @@ static int test_wolfSSL_a2i_IPADDRESS(void) AssertIntEQ(XMEMCMP(data, ipv6_exp, dataSz), 0); ASN1_STRING_free(st); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_DES_ecb_encrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DES3) && defined(WOLFSSL_DES_ECB) WOLFSSL_DES_cblock input1,input2,output1,output2,back1,back2; WOLFSSL_DES_key_schedule key; - printf(testingFmt, "wolfSSL_DES_ecb_encrypt()"); - XMEMCPY(key,"12345678",sizeof(WOLFSSL_DES_key_schedule)); XMEMCPY(input1, "Iamhuman",sizeof(WOLFSSL_DES_cblock)); XMEMCPY(input2, "Whoisit?",sizeof(WOLFSSL_DES_cblock)); @@ -37993,17 +37031,16 @@ static int test_wolfSSL_DES_ecb_encrypt(void) AssertIntEQ(ret2,0); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_TIME_adj(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) \ && !defined(USER_TIME) && !defined(TIME_OVERRIDES) - const int year = 365*24*60*60; const int day = 24*60*60; const int hour = 60*60; @@ -38018,8 +37055,6 @@ static int test_wolfSSL_ASN1_TIME_adj(void) char date_str[CTC_DATE_SIZE + 1]; time_t t; - printf(testingFmt, "wolfSSL_ASN1_TIME_adj()"); - AssertNotNull(s = wolfSSL_ASN1_TIME_new()); /* UTC notation test */ /* 2000/2/15 20:30:00 */ @@ -38085,23 +37120,21 @@ static int test_wolfSSL_ASN1_TIME_adj(void) AssertIntEQ(0, XMEMCMP(date_str, "000222211515Z", 13)); XFREE(asn_time, NULL, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_TIME_to_tm(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(WOLFSSL_NGINX) || \ defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) \ && !defined(NO_ASN_TIME) ASN1_TIME asnTime; struct tm tm; - printf(testingFmt, "wolfSSL_ASN1_TIME_to_tm()"); - XMEMSET(&asnTime, 0, sizeof(ASN1_TIME)); AssertIntEQ(ASN1_TIME_set_string(&asnTime, "000222211515Z"), 1); AssertIntEQ(ASN1_TIME_to_tm(&asnTime, &tm), 1); @@ -38118,21 +37151,19 @@ static int test_wolfSSL_ASN1_TIME_to_tm(void) AssertIntEQ(tm.tm_yday, 52); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_cmp_time(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) \ && !defined(USER_TIME) && !defined(TIME_OVERRIDES) WOLFSSL_ASN1_TIME asn_time; time_t t; - printf(testingFmt, "wolfSSL_X509_cmp_time()"); - AssertIntEQ(0, wolfSSL_X509_cmp_time(NULL, &t)); XMEMSET(&asn_time, 0, sizeof(WOLFSSL_ASN1_TIME)); AssertIntEQ(0, wolfSSL_X509_cmp_time(&asn_time, &t)); @@ -38140,14 +37171,14 @@ static int test_wolfSSL_X509_cmp_time(void) AssertIntEQ(ASN1_TIME_set_string(&asn_time, "000222211515Z"), 1); AssertIntEQ(-1, wolfSSL_X509_cmp_time(&asn_time, NULL)); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_time_adj(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) && \ !defined(USER_TIME) && !defined(TIME_OVERRIDES) && \ defined(USE_CERT_BUFFERS_2048) && !defined(NO_RSA) && \ @@ -38155,8 +37186,6 @@ static int test_wolfSSL_X509_time_adj(void) X509* x509; time_t t, not_before, not_after; - printf(testingFmt, "wolfSSL_X509_time_adj()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_buffer( client_cert_der_2048, sizeof_client_cert_der_2048, WOLFSSL_FILETYPE_ASN1)); @@ -38171,15 +37200,15 @@ static int test_wolfSSL_X509_time_adj(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM)\ && !defined(NO_RSA) X509* x509; @@ -38192,8 +37221,6 @@ static int test_wolfSSL_X509(void) char der[] = "certs/ca-cert.der"; XFILE fp; - printf(testingFmt, "wolfSSL_X509()"); - AssertNotNull(x509 = X509_new()); X509_free(x509); @@ -38245,14 +37272,14 @@ static int test_wolfSSL_X509(void) X509_free(x509); /* refCount = 1 */ X509_free(x509); /* refCount = 0, free */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_get_ext_count(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) int ret = 0; @@ -38260,8 +37287,6 @@ static int test_wolfSSL_X509_get_ext_count(void) const char ocspRootCaFile[] = "./certs/ocsp/root-ca-cert.pem"; FILE* f; - printf(testingFmt, "wolfSSL_X509_get_ext_count()"); - /* NULL parameter check */ AssertIntEQ(X509_get_ext_count(NULL), WOLFSSL_FAILURE); @@ -38279,29 +37304,26 @@ static int test_wolfSSL_X509_get_ext_count(void) AssertNotNull(x509 = wolfSSL_PEM_read_X509(f, NULL, NULL, NULL)); fclose(f); - printf(testingFmt, "wolfSSL_X509_get_ext_count() valid input"); + /* wolfSSL_X509_get_ext_count() valid input */ AssertIntEQ((ret = wolfSSL_X509_get_ext_count(x509)), 5); - printf(resultFmt, ret == 4 ? passed : failed); - printf(testingFmt, "wolfSSL_X509_get_ext_count() NULL argument"); + /* wolfSSL_X509_get_ext_count() NULL argument */ AssertIntEQ((ret = wolfSSL_X509_get_ext_count(NULL)), WOLFSSL_FAILURE); - printf(resultFmt, ret == WOLFSSL_FAILURE ? passed : failed); wolfSSL_X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_sign2(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_ALT_NAMES) && \ defined(WOLFSSL_CERT_EXT) && \ (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME)) - WOLFSSL_X509 *x509, *ca; const unsigned char *der; const unsigned char *pt; @@ -38428,8 +37450,6 @@ static int test_wolfSSL_X509_sign2(void) 0x4a, 0xa6, 0xe4, 0xbd, 0xa5, 0xc6, 0xec }; - printf(testingFmt, "wolfSSL_X509_sign2"); - pt = ca_key_der_2048; AssertNotNull(priv = wolfSSL_d2i_PrivateKey(EVP_PKEY_RSA, NULL, &pt, sizeof_ca_key_der_2048)); @@ -38462,15 +37482,16 @@ static int test_wolfSSL_X509_sign2(void) wolfSSL_EVP_PKEY_free(priv); wolfSSL_ASN1_TIME_free(notBefore); wolfSSL_ASN1_TIME_free(notAfter); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_sign(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) && !defined(NO_RSA) int ret; @@ -38500,8 +37521,6 @@ static int test_wolfSSL_X509_sign(void) byte sn[16]; int snSz = sizeof(sn); - printf(testingFmt, "wolfSSL_X509_sign"); - /* Set X509_NAME fields */ AssertNotNull(name = X509_NAME_new()); AssertIntEQ(X509_NAME_add_entry_by_txt(name, "countryName", MBSTRING_UTF8, @@ -38660,18 +37679,17 @@ static int test_wolfSSL_X509_sign(void) X509_free(x509); X509_free(ca); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_get0_tbs_sigalg(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) X509* x509 = NULL; const X509_ALGOR* alg; - printf(testingFmt, "wolfSSL_X509_get0_tbs_sigalg"); AssertNotNull(x509 = X509_new()); @@ -38680,14 +37698,14 @@ static int test_wolfSSL_X509_get0_tbs_sigalg(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_ALGOR_get0(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && \ !defined(NO_SHA256) && !defined(NO_RSA) X509* x509 = NULL; @@ -38695,7 +37713,6 @@ static int test_wolfSSL_X509_ALGOR_get0(void) const X509_ALGOR* alg; int pptype = 0; const void *ppval = NULL; - printf(testingFmt, "wolfSSL_X509_ALGOR_get0"); AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); @@ -38715,15 +37732,15 @@ static int test_wolfSSL_X509_ALGOR_get0(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_VERIFY_PARAM(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) X509_VERIFY_PARAM *paramTo; X509_VERIFY_PARAM *paramFrom; @@ -38733,8 +37750,6 @@ static int test_wolfSSL_X509_VERIFY_PARAM(void) char testhostName1[] = "foo.hoge.com"; char testhostName2[] = "foobar.hoge.com"; - printf(testingFmt, "wolfSSL_X509()"); - paramTo = X509_VERIFY_PARAM_new(); AssertNotNull(paramTo); XMEMSET(paramTo, 0, sizeof(X509_VERIFY_PARAM )); @@ -38855,11 +37870,10 @@ static int test_wolfSSL_X509_VERIFY_PARAM(void) X509_VERIFY_PARAM_free(paramTo); X509_VERIFY_PARAM_free(paramFrom); X509_VERIFY_PARAM_free(NULL); /* to confirm NULL parameter gives no harm */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_EXTRA) && defined(HAVE_IO_TESTS_DEPENDENCIES) @@ -38903,8 +37917,6 @@ static int test_wolfSSL_check_domain(void) callback_functions func_cb_client; callback_functions func_cb_server; - printf(testingFmt, "wolfSSL_check_domain"); - XMEMSET(&client_args, 0, sizeof(func_args)); XMEMSET(&server_args, 0, sizeof(func_args)); XMEMSET(&func_cb_client, 0, sizeof(callback_functions)); @@ -38947,19 +37959,17 @@ static int test_wolfSSL_check_domain(void) AssertIntEQ(test_wolfSSL_check_domain_verify_count, 1); #endif - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } #endif /* OPENSSL_EXTRA && HAVE_IO_TESTS_DEPENDENCIES */ static int test_wolfSSL_X509_get_X509_PUBKEY(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) X509* x509 = NULL; X509_PUBKEY* pubKey; - printf(testingFmt, "wolfSSL_X509_get_X509_PUBKEY"); AssertNotNull(x509 = X509_new()); @@ -38968,14 +37978,14 @@ static int test_wolfSSL_X509_get_X509_PUBKEY(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_PUBKEY_RSA(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && \ !defined(NO_SHA256) && !defined(NO_RSA) X509* x509 = NULL; @@ -38990,8 +38000,6 @@ static int test_wolfSSL_X509_PUBKEY_RSA(void) X509_ALGOR *pa; const void *pval; - printf(testingFmt, "wolfSSL_X509_PUBKEY_RSA"); - AssertNotNull(x509 = X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); @@ -39021,14 +38029,14 @@ static int test_wolfSSL_X509_PUBKEY_RSA(void) X509_free(x509); EVP_PKEY_free(evpKey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_PUBKEY_EC(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && defined(HAVE_ECC) X509* x509 = NULL; ASN1_OBJECT* obj = NULL; @@ -39044,8 +38052,6 @@ static int test_wolfSSL_X509_PUBKEY_EC(void) const void *pval; char buf[50]; - printf(testingFmt, "wolfSSL_X509_PUBKEY_EC"); - AssertNotNull(x509 = X509_load_certificate_file(cliEccCertFile, SSL_FILETYPE_PEM)); AssertNotNull(pubKey = X509_get_X509_PUBKEY(x509)); @@ -39069,14 +38075,14 @@ static int test_wolfSSL_X509_PUBKEY_EC(void) X509_free(x509); EVP_PKEY_free(evpKey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_PUBKEY_DSA(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && !defined(NO_DSA) word32 bytes; #ifdef USE_CERT_BUFFERS_1024 @@ -39099,8 +38105,6 @@ static int test_wolfSSL_X509_PUBKEY_DSA(void) X509_ALGOR *pa; const void *pval; - printf(testingFmt, "wolfSSL_X509_PUBKEY_DSA"); - #ifdef USE_CERT_BUFFERS_1024 XMEMSET(tmp, 0, sizeof(tmp)); XMEMCPY(tmp, dsa_key_der_1024, sizeof_dsa_key_der_1024); @@ -39147,18 +38151,18 @@ static int test_wolfSSL_X509_PUBKEY_DSA(void) X509_PUBKEY_free(pubKey); EVP_PKEY_free(evpKey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RAND(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) byte seed[16]; - printf(testingFmt, "wolfSSL_RAND()"); + XMEMSET(seed, 0, sizeof(seed)); RAND_seed(seed, sizeof(seed)); AssertIntEQ(RAND_poll(), 1); @@ -39174,24 +38178,25 @@ static int test_wolfSSL_RAND(void) } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BUF(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BUF_MEM* buf; AssertNotNull(buf = BUF_MEM_new()); AssertIntEQ(BUF_MEM_grow(buf, 10), 10); AssertIntEQ(BUF_MEM_grow(buf, -1), 0); BUF_MEM_free(buf); - #endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); + #endif + return res; } #if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_NO_OPENSSL_RAND_CB) @@ -39263,6 +38268,7 @@ static int stub_rand_status(void) static int test_wolfSSL_RAND_set_rand_method(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_NO_OPENSSL_RAND_CB) RAND_METHOD rand_methods = {NULL, NULL, NULL, NULL, NULL, NULL}; unsigned char* buf = NULL; @@ -39271,8 +38277,6 @@ static int test_wolfSSL_RAND_set_rand_method(void) byte* was_cleanup_called = was_stub_rand_cleanup_called(); byte* was_add_called = was_stub_rand_add_called(); - printf(testingFmt, "wolfSSL_RAND_set_rand_method()"); - buf = (byte*)XMALLOC(32 * sizeof(byte), NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -39314,14 +38318,14 @@ static int test_wolfSSL_RAND_set_rand_method(void) XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !WOLFSSL_NO_OPENSSL_RAND_CB */ - - return 0; + return res; } static int test_wolfSSL_RAND_bytes(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) const int size1 = RNG_MAX_BLOCK_LEN; /* in bytes */ const int size2 = RNG_MAX_BLOCK_LEN + 1; /* in bytes */ @@ -39330,7 +38334,6 @@ static int test_wolfSSL_RAND_bytes(void) int max_bufsize; byte *my_buf; - printf(testingFmt, "test_wolfSSL_RAND_bytes()"); /* sanity check */ AssertIntEQ(RAND_bytes(NULL, 16), 0); AssertIntEQ(RAND_bytes(NULL, 0), 0); @@ -39352,21 +38355,18 @@ static int test_wolfSSL_RAND_bytes(void) XFREE(my_buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BN_rand(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIGNUM* bn; BIGNUM* range; - printf(testingFmt, "wolfSSL_BN_rand()"); - /* Error conditions. */ /* NULL BN. */ AssertIntEQ(BN_rand(NULL, 0, 0, 0), SSL_FAILURE); @@ -39410,21 +38410,19 @@ static int test_wolfSSL_BN_rand(void) BN_free(bn); BN_free(range); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_pseudo_rand(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIGNUM* bn; unsigned char bin[8]; int i; - printf(testingFmt, "wolfSSL_pseudo_rand()"); - /* BN_pseudo_rand returns 1 on success 0 on failure * int BN_pseudo_rand(BIGNUM* bn, int bits, int top, int bottom) */ for (i = 0; i < 10; i++) { @@ -39443,14 +38441,14 @@ static int test_wolfSSL_pseudo_rand(void) BN_free(bn); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PKCS8_Compat(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && defined(HAVE_ECC) #ifndef NO_BIO PKCS8_PRIV_KEY_INFO* pt; @@ -39462,8 +38460,6 @@ static int test_wolfSSL_PKCS8_Compat(void) EVP_PKEY *pkey = NULL; #endif - printf(testingFmt, "wolfSSL_pkcs8()"); - /* file from wolfssl/certs/ directory */ f = XFOPEN("./certs/ecc-keyPkcs8.pem", "rb"); AssertTrue(f != XBADFILE); @@ -39485,15 +38481,15 @@ static int test_wolfSSL_PKCS8_Compat(void) BIO_free(bio); PKCS8_PRIV_KEY_INFO_free(pt); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } static int test_wolfSSL_PKCS8_d2i(void) { + int res = TEST_SKIPPED; #if !defined(HAVE_FIPS) && defined(OPENSSL_EXTRA) /* This test ends up using HMAC as a part of PBKDF2, and HMAC * requires a 12 byte password in FIPS mode. This test ends up @@ -39705,10 +38701,9 @@ static int test_wolfSSL_PKCS8_d2i(void) #endif /* !NO_FILESYSTEM */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* HAVE_FIPS && OPENSSL_EXTRA */ - - return 0; + return res; } #if defined(ERROR_QUEUE_PER_THREAD) && !defined(NO_ERROR_QUEUE) && \ @@ -39755,13 +38750,12 @@ static THREAD_RETURN WOLFSSL_THREAD test_logging(void* args) static int test_error_queue_per_thread(void) { + int res = TEST_SKIPPED; #if defined(ERROR_QUEUE_PER_THREAD) && !defined(NO_ERROR_QUEUE) && \ defined(OPENSSL_EXTRA) && defined(DEBUG_WOLFSSL) THREAD_TYPE loggingThreads[LOGGING_THREADS]; int i; - printf(testingFmt, "error_queue_per_thread()"); - ERR_clear_error(); /* clear out any error nodes */ loggingThreadsReady = 0; @@ -39771,22 +38765,19 @@ static int test_error_queue_per_thread(void) for (i = 0; i < LOGGING_THREADS; i++) join_thread(loggingThreads[i]); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ERR_put_error(void) { + int res = TEST_SKIPPED; #if !defined(NO_ERROR_QUEUE) && defined(OPENSSL_EXTRA) && \ defined(DEBUG_WOLFSSL) const char* file; int line; - printf(testingFmt, "wolfSSL_ERR_put_error()"); - - ERR_clear_error(); /* clear out any error nodes */ ERR_put_error(0,SYS_F_ACCEPT, 0, "this file", 0); AssertIntEQ(ERR_get_error_line(&file, &line), 0); @@ -39848,10 +38839,9 @@ static int test_wolfSSL_ERR_put_error(void) ERR_clear_error(); AssertIntEQ(ERR_get_error_line(&file, &line), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* @@ -39860,9 +38850,8 @@ static int test_wolfSSL_ERR_put_error(void) */ static int test_wolfSSL_ERR_get_error_order(void) { + int res = TEST_SKIPPED; #ifdef WOLFSSL_HAVE_ERROR_QUEUE - printf(testingFmt, "test_wolfSSL_ERR_get_error_order"); - /* Empty the queue. */ wolfSSL_ERR_clear_error(); @@ -39874,24 +38863,21 @@ static int test_wolfSSL_ERR_get_error_order(void) AssertIntEQ(wolfSSL_ERR_peek_error(), -ASN_SELF_SIGNED_E); AssertIntEQ(wolfSSL_ERR_get_error(), -ASN_SELF_SIGNED_E); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* WOLFSSL_HAVE_ERROR_QUEUE */ - - return 0; + return res; } #ifndef NO_BIO static int test_wolfSSL_ERR_print_errors(void) { + int res = TEST_SKIPPED; #if !defined(NO_ERROR_QUEUE) && defined(OPENSSL_EXTRA) && \ defined(DEBUG_WOLFSSL) && !defined(NO_ERROR_STRINGS) BIO* bio; char buf[1024]; - printf(testingFmt, "wolfSSL_ERR_print_errors()"); - - AssertNotNull(bio = BIO_new(BIO_s_mem())); ERR_clear_error(); /* clear out any error nodes */ ERR_put_error(0,SYS_F_ACCEPT, -173, "ssl.c", 0); @@ -39910,10 +38896,10 @@ static int test_wolfSSL_ERR_print_errors(void) AssertIntEQ(ERR_get_error_line(NULL, NULL), 0); BIO_free(bio); - printf(resultFmt, passed); - #endif - return 0; + res = TEST_RES_CHECK(1); + #endif + return res; } #if !defined(NO_ERROR_QUEUE) && defined(OPENSSL_EXTRA) && \ @@ -39927,13 +38913,12 @@ static int test_wolfSSL_error_cb(const char *str, size_t len, void *u) static int test_wolfSSL_ERR_print_errors_cb(void) { + int res = TEST_SKIPPED; #if !defined(NO_ERROR_QUEUE) && defined(OPENSSL_EXTRA) && \ defined(DEBUG_WOLFSSL) BIO* bio; char buf[1024]; - printf(testingFmt, "wolfSSL_ERR_print_errors_cb()"); - AssertNotNull(bio = BIO_new(BIO_s_mem())); ERR_clear_error(); /* clear out any error nodes */ ERR_put_error(0,SYS_F_ACCEPT, -173, "ssl.c", 0); @@ -39948,61 +38933,52 @@ static int test_wolfSSL_ERR_print_errors_cb(void) AssertIntEQ(BIO_gets(bio, buf, sizeof(buf)), 0); BIO_free(bio); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } /* * Testing WOLFSSL_ERROR_MSG */ static int test_WOLFSSL_ERROR_MSG(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) ||\ defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) const char* msg = TEST_STRING; - printf(testingFmt, "WOLFSSL_ERROR_MSG()"); - WOLFSSL_ERROR_MSG(msg); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(1); #endif - return ret; + return res; }/*End test_WOLFSSL_ERROR_MSG*/ /* * Testing wc_ERR_remove_state */ static int test_wc_ERR_remove_state(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) - - printf(testingFmt, "wc_ERR_remove_state()"); - wc_ERR_remove_state(); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - + res = TEST_RES_CHECK(1); #endif - return ret; + return res; }/*End test_wc_ERR_remove_state*/ /* * Testing wc_ERR_print_errors_fp */ static int test_wc_ERR_print_errors_fp(void) { - int ret = 0; + int res = TEST_SKIPPED; #if (defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)) && \ (!defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)) long sz; XFILE fp; - - printf(testingFmt, "wc_ERR_print_errors_fp()"); + int ret = 0; WOLFSSL_ERROR(BAD_FUNC_ARG); fp = XFOPEN("./tests/test-log-dump-to-file.txt", "ar"); @@ -40021,12 +38997,12 @@ static int test_wc_ERR_print_errors_fp(void) } #endif #endif - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); XFCLOSE(fp); (void)sz; + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/*End test_wc_ERR_print_errors_fp*/ #ifdef DEBUG_WOLFSSL static void Logging_cb(const int logLevel, const char *const logMessage) @@ -40041,7 +39017,6 @@ static void Logging_cb(const int logLevel, const char *const logMessage) static int test_wolfSSL_GetLoggingCb(void) { int ret = 0; - printf(testingFmt, "wolfSSL_GetLoggingCb()"); #ifdef DEBUG_WOLFSSL /* Testing without wolfSSL_SetLoggingCb() */ @@ -40056,7 +39031,7 @@ static int test_wolfSSL_GetLoggingCb(void) /* Testing with wolfSSL_SetLoggingCb() */ if (ret == 0) { ret = wolfSSL_SetLoggingCb(Logging_cb); - if (ret == 0){ + if (ret == 0) { if (wolfSSL_GetLoggingCb() == NULL) { /* Should not be true */ ret = -1; } @@ -40077,10 +39052,7 @@ static int test_wolfSSL_GetLoggingCb(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - - return ret; + return TEST_RES_CHECK(ret == 0); }/*End test_wolfSSL_GetLoggingCb*/ #endif /* !NO_BIO */ @@ -40122,11 +39094,10 @@ static int test_openssl_hmac(const WOLFSSL_EVP_MD* md, int md_len) static int test_wolfSSL_HMAC(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && (!defined(NO_SHA256) || \ defined(WOLFSSL_SHA224) || defined(WOLFSSL_SHA384) || \ defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA3)) - printf(testingFmt, "wolfSSL_HMAC()"); - #ifndef NO_SHA256 test_openssl_hmac(EVP_sha256(), (int)WC_SHA256_DIGEST_SIZE); #endif @@ -40157,14 +39128,14 @@ static int test_wolfSSL_HMAC(void) test_openssl_hmac(EVP_sha1(), (int)WC_SHA_DIGEST_SIZE); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_CMAC(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_CMAC) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_AES_DIRECT) int i; @@ -40173,8 +39144,6 @@ static int test_wolfSSL_CMAC(void) byte out[AES_BLOCK_SIZE]; size_t outLen = AES_BLOCK_SIZE; - printf(testingFmt, "test_wolfSSL_CMAC()"); - for (i=0; i < AES_128_KEY_SIZE; ++i) { key[i] = i; } @@ -40190,10 +39159,9 @@ static int test_wolfSSL_CMAC(void) AssertIntEQ(outLen, AES_BLOCK_SIZE); CMAC_CTX_free(cmacCtx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* WOLFSSL_CMAC && OPENSSL_EXTRA && WOLFSSL_AES_DIRECT */ - - return 0; + return res; } @@ -40202,6 +39170,7 @@ static int test_wolfSSL_OBJ(void) /* Password "wolfSSL test" is only 12 (96-bit) too short for testing in FIPS * mode */ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) && !defined(NO_ASN) && \ !defined(HAVE_FIPS) && !defined(NO_SHA) && defined(WOLFSSL_CERT_EXT) && \ defined(WOLFSSL_CERT_GEN) && !defined(NO_BIO) @@ -40233,8 +39202,6 @@ static int test_wolfSSL_OBJ(void) ASN1_STRING *asn1 = NULL; unsigned char *buf_dyn = NULL; - printf(testingFmt, "wolfSSL_OBJ()"); - AssertIntEQ(OBJ_obj2txt(buf, (int)sizeof(buf), obj, 1), SSL_FAILURE); AssertNotNull(obj = OBJ_nid2obj(NID_any_policy)); AssertIntEQ(OBJ_obj2nid(obj), NID_any_policy); @@ -40330,14 +39297,14 @@ static int test_wolfSSL_OBJ(void) } #endif /* HAVE_PKCS12 */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_i2a_ASN1_OBJECT(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN) && !defined(NO_BIO) ASN1_OBJECT *obj = NULL; BIO *bio = NULL; @@ -40352,19 +39319,19 @@ static int test_wolfSSL_i2a_ASN1_OBJECT(void) BIO_free(bio); ASN1_OBJECT_free(obj); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_OBJ_cmp(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) ASN1_OBJECT *obj = NULL; ASN1_OBJECT *obj2 = NULL; - printf(testingFmt, "wolfSSL_OBJ_cmp()"); - AssertNotNull(obj = OBJ_nid2obj(NID_any_policy)); AssertNotNull(obj2 = OBJ_nid2obj(NID_sha256)); @@ -40378,14 +39345,14 @@ static int test_wolfSSL_OBJ_cmp(void) ASN1_OBJECT_free(obj); ASN1_OBJECT_free(obj2); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OBJ_txt2nid(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_STUB) && defined(WOLFSSL_APACHE_HTTPD) int i; static const struct { @@ -40402,8 +39369,6 @@ static int test_wolfSSL_OBJ_txt2nid(void) { NULL, NULL, NULL, NID_undef } }; - printf(testingFmt, "wolfSSL_OBJ_txt2nid()"); - /* Invalid cases */ AssertIntEQ(OBJ_txt2nid(NULL), NID_undef); AssertIntEQ(OBJ_txt2nid("Bad name"), NID_undef); @@ -40415,14 +39380,14 @@ static int test_wolfSSL_OBJ_txt2nid(void) AssertIntEQ(OBJ_txt2nid(testVals[i].oid), testVals[i].nid); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OBJ_txt2obj(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_APACHE_HTTPD) || (defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN)) int i; @@ -40451,8 +39416,6 @@ static int test_wolfSSL_OBJ_txt2obj(void) { NULL, NULL } }; - printf(testingFmt, "wolfSSL_OBJ_txt2obj()"); - AssertNull(obj = OBJ_txt2obj("Bad name", 0)); AssertNull(obj = OBJ_txt2obj(NULL, 0)); @@ -40493,15 +39456,14 @@ static int test_wolfSSL_OBJ_txt2obj(void) ASN1_OBJECT_free(obj); } - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_i2t_ASN1_OBJECT(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN) @@ -40510,8 +39472,6 @@ static int test_wolfSSL_i2t_ASN1_OBJECT(void) const char* oid = "2.5.29.19"; const char* ln = "X509v3 Basic Constraints"; - printf(testingFmt, "test_wolfSSL_i2t_ASN1_OBJECT()"); - obj = NULL; AssertIntEQ(i2t_ASN1_OBJECT(NULL, sizeof(buf), obj), WOLFSSL_FAILURE); AssertIntEQ(i2t_ASN1_OBJECT(buf, sizeof(buf), NULL), WOLFSSL_FAILURE); @@ -40523,14 +39483,14 @@ static int test_wolfSSL_i2t_ASN1_OBJECT(void) AssertIntEQ(XSTRNCMP(buf, ln, XSTRLEN(ln)), 0); ASN1_OBJECT_free(obj); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFSSL_CERT_EXT && WOLFSSL_CERT_GEN */ - - return 0; + return res; } static int test_wolfSSL_PEM_write_bio_X509(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_AKID_NAME) && \ defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_CERT_GEN) && \ !defined(NO_BIO) && !defined(NO_RSA) @@ -40547,8 +39507,6 @@ static int test_wolfSSL_PEM_write_bio_X509(void) ASN1_TIME* notAfterB = NULL; int expectedLen; - printf(testingFmt, "wolfSSL_PEM_write_bio_X509()"); - AssertNotNull(input = BIO_new_file( "certs/test/cert-ext-multiple.pem", "rb")); AssertIntEQ(wolfSSL_BIO_get_len(input), 2000); @@ -40647,14 +39605,14 @@ static int test_wolfSSL_PEM_write_bio_X509(void) BIO_free(input); BIO_free(output); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_NAME_ENTRY(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) && defined(WOLFSSL_CERT_GEN) X509* x509; @@ -40668,8 +39626,6 @@ static int test_wolfSSL_X509_NAME_ENTRY(void) int i, names_len; #endif - printf(testingFmt, "wolfSSL_X509_NAME_ENTRY()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFile, SSL_FILETYPE_PEM)); #ifndef NO_BIO @@ -40719,7 +39675,7 @@ static int test_wolfSSL_X509_NAME_ENTRY(void) subject = X509_NAME_oneline(nm, 0, 0); #ifdef DEBUG_WOLFSSL - printf("\n\t%s\n", subject); + fprintf(stderr, "\n\t%s\n", subject); #endif XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL); } @@ -40753,22 +39709,20 @@ static int test_wolfSSL_X509_NAME_ENTRY(void) #endif X509_free(x509); /* free's nm */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_set_name(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) X509* x509; X509_NAME* name; - printf(testingFmt, "wolfSSL_X509_set_name()"); - AssertNotNull(name = X509_NAME_new()); AssertIntEQ(X509_NAME_add_entry_by_txt(name, "commonName", MBSTRING_UTF8, (byte*)"wolfssl.com", 11, 0, 1), @@ -40791,14 +39745,14 @@ static int test_wolfSSL_X509_set_name(void) X509_free(x509); X509_NAME_free(name); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL && !NO_CERTS */ - - return 0; + return res; } static int test_wolfSSL_X509_set_notAfter(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) \ && !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ !defined(TIME_OVERRIDES) && !defined(NO_CERTS) && \ @@ -40817,7 +39771,6 @@ static int test_wolfSSL_X509_set_notAfter(void) unsigned char buf[25]; time_t t; - printf(testingFmt, "wolfSSL_X509_set_notAfter()"); /* * Setup asn_time. APACHE HTTPD uses time(NULL) */ @@ -40848,14 +39801,15 @@ static int test_wolfSSL_X509_set_notAfter(void) XFREE(asn_time,NULL,DYNAMIC_TYPE_OPENSSL); X509_free(x); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_set_notBefore(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) \ && !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ !defined(TIME_OVERRIDES) && !defined(NO_CERTS) && \ @@ -40872,7 +39826,6 @@ static int test_wolfSSL_X509_set_notBefore(void) unsigned char buf[25]; time_t t; - printf(testingFmt, "wolfSSL_X509_set_notBefore()"); /* * Setup asn_time. APACHE HTTPD uses time(NULL) */ @@ -40906,14 +39859,15 @@ static int test_wolfSSL_X509_set_notBefore(void) XFREE(asn_time,NULL,DYNAMIC_TYPE_OPENSSL); X509_free(x); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_set_version(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) && \ !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) X509* x509; @@ -40929,16 +39883,16 @@ static int test_wolfSSL_X509_set_version(void) AssertFalse(wolfSSL_X509_set_version(x509, v)); /* Cleanup */ X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifndef NO_BIO static int test_wolfSSL_BIO_gets(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIO* bio; BIO* bio2; @@ -40947,8 +39901,6 @@ static int test_wolfSSL_BIO_gets(void) char bio_buffer[20]; int bufferSz = 20; - printf(testingFmt, "wolfSSL_BIO_gets()"); - /* try with bad args */ AssertNull(bio = BIO_new_mem_buf(NULL, sizeof(msg))); @@ -41056,22 +40008,20 @@ static int test_wolfSSL_BIO_gets(void) BIO_free(bio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_puts(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIO* bio; char input[] = "hello\0world\n.....ok\n\0"; char output[128]; - printf(testingFmt, "wolfSSL_BIO_puts()"); - XMEMSET(output, 0, sizeof(output)); AssertNotNull(bio = BIO_new(BIO_s_mem())); AssertIntEQ(BIO_puts(bio, input), 5); @@ -41087,14 +40037,15 @@ static int test_wolfSSL_BIO_puts(void) AssertIntEQ(BIO_puts(bio, ""), -1); BIO_free(bio); - printf(resultFmt, passed); - #endif - return 0; + res = TEST_RES_CHECK(1); + #endif + return res; } static int test_wolfSSL_BIO_dump(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIO* bio; static const unsigned char data[] = { @@ -41153,10 +40104,9 @@ static int test_wolfSSL_BIO_dump(void) AssertIntEQ(XMEMCMP(output, expectedAll, sizeof(expectedAll) - 1), 0); BIO_free(bio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ @@ -41174,6 +40124,7 @@ static int forceWantRead(WOLFSSL *ssl, char *buf, int sz, void *ctx) static int test_wolfSSL_BIO_should_retry(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_RSA) && defined(HAVE_EXT_CACHE) && \ defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(USE_WOLFSSL_IO) @@ -41189,8 +40140,6 @@ static int test_wolfSSL_BIO_should_retry(void) int ret; BIO* bio; - printf(testingFmt, "wolfSSL_BIO_should_retry()"); - XMEMSET(&server_args, 0, sizeof(func_args)); #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); @@ -41257,14 +40206,14 @@ static int test_wolfSSL_BIO_should_retry(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_connect(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ defined(HAVE_HTTP_CLIENT) && !defined(NO_WOLFSSL_CLIENT) tcp_ready ready; @@ -41279,8 +40228,6 @@ static int test_wolfSSL_BIO_connect(void) char reply[30]; char buff[10] = {0}; - printf(testingFmt, "wolfSSL_BIO_new_connect()"); - AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_load_verify_locations(ctx, caCertFile, 0)); @@ -41366,15 +40313,15 @@ static int test_wolfSSL_BIO_connect(void) wc_ecc_fp_free(); /* free per thread cache */ #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_tls(void) { + int res = TEST_SKIPPED; #if !defined(NO_BIO) && defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT) SSL_CTX* ctx; SSL *ssl; @@ -41382,8 +40329,6 @@ static int test_wolfSSL_BIO_tls(void) BIO *writeBio; int ret, err = 0; - printf(testingFmt, "test_wolfSSL_BIO_tls()"); - AssertNotNull(ctx = SSL_CTX_new(SSLv23_method())); AssertNotNull(ssl = SSL_new(ctx)); @@ -41415,10 +40360,9 @@ static int test_wolfSSL_BIO_tls(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT) @@ -41453,8 +40397,8 @@ static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args) static int test_wolfSSL_BIO_accept(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT) - BIO* serverBindBio; BIO* serverAcceptBio; SSL* sslServer; @@ -41464,8 +40408,6 @@ static int test_wolfSSL_BIO_accept(void) char port[10]; /* 10 bytes should be enough to store the string * representation of the port */ - printf(testingFmt, "wolfSSL_BIO_new_accept()"); - AssertIntGT(snprintf(port, sizeof(port), "%d", wolfSSLPort), 0); AssertNotNull(serverBindBio = BIO_new_accept(port)); @@ -41495,14 +40437,14 @@ static int test_wolfSSL_BIO_accept(void) wc_ecc_fp_free(); /* free per thread cache */ #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_write(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_BASE64_ENCODE) BIO* bio; BIO* bio64; @@ -41514,8 +40456,6 @@ static int test_wolfSSL_BIO_write(void) void* bufPtr = NULL; BUF_MEM* buf = NULL; - printf(testingFmt, "wolfSSL_BIO_write()"); - AssertNotNull(bio64 = BIO_new(BIO_f_base64())); AssertNotNull(bio = BIO_push(bio64, BIO_new(BIO_s_mem()))); @@ -41577,15 +40517,16 @@ static int test_wolfSSL_BIO_write(void) AssertNotNull(bio = BIO_new_mem_buf(out, 0)); AssertIntEQ(BIO_write(bio, msg, sizeof(msg)), sizeof(msg)); BIO_free(bio); - printf(resultFmt, passed); - #endif - return 0; + res = TEST_RES_CHECK(1); + #endif + return res; } static int test_wolfSSL_BIO_printf(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) BIO* bio; int sz = 7; @@ -41593,8 +40534,6 @@ static int test_wolfSSL_BIO_printf(void) char out[60]; char expected[] = "TLS 1.3 for the world : sz = 7"; - printf(testingFmt, "wolfSSL_BIO_printf()"); - XMEMSET(out, 0, sizeof(out)); AssertNotNull(bio = BIO_new(BIO_s_mem())); AssertIntEQ(BIO_printf(bio, "%s : sz = %d", msg, sz), 30); @@ -41603,14 +40542,14 @@ static int test_wolfSSL_BIO_printf(void) AssertIntEQ(XSTRNCMP(out, expected, sizeof(expected)), 0); BIO_free(bio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_f_md(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_SHA256) BIO *bio, *mem; char msg[] = "message to hash"; @@ -41648,8 +40587,6 @@ static int test_wolfSSL_BIO_f_md(void) size_t checkSz = -1; EVP_PKEY* key; - printf(testingFmt, "wolfSSL_BIO_f_md()"); - XMEMSET(out, 0, sizeof(out)); AssertNotNull(bio = BIO_new(BIO_f_md())); AssertNotNull(mem = BIO_new(BIO_s_mem())); @@ -41707,17 +40644,16 @@ static int test_wolfSSL_BIO_f_md(void) BIO_free(bio); BIO_free(mem); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_BIO_up_ref(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) BIO* bio; - printf(testingFmt, "wolfSSL_BIO_up_ref()"); AssertNotNull(bio = BIO_new(BIO_f_md())); AssertIntEQ(BIO_up_ref(NULL), 0); @@ -41727,10 +40663,9 @@ static int test_wolfSSL_BIO_up_ref(void) BIO_free(bio); BIO_free(bio); - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif /* !NO_BIO */ @@ -41800,8 +40735,8 @@ static void serverCertClearCb(WOLFSSL* ssl) static int test_wolfSSL_cert_cb(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_IO_TESTS_DEPENDENCIES) - callback_functions func_cb_client; callback_functions func_cb_server; tcp_ready ready; @@ -41849,13 +40784,14 @@ static int test_wolfSSL_cert_cb(void) fdOpenSession(Task_self()); #endif + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SESSION(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_RSA) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ !defined(NO_SESSION_CACHE) @@ -41879,7 +40815,6 @@ static int test_wolfSSL_SESSION(void) char msg[80]; const char* sendGET = "GET"; - printf(testingFmt, "wolfSSL_SESSION()"); /* TLS v1.3 requires session tickets */ /* CHACHA and POLY1305 required for myTicketEncCb */ #if defined(WOLFSSL_TLS13) && (!defined(HAVE_SESSION_TICKET) && \ @@ -42109,10 +41044,10 @@ static int test_wolfSSL_SESSION(void) wolfSSL_free(ssl); wolfSSL_SESSION_free(sess); wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #if defined(OPENSSL_EXTRA) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ @@ -42184,6 +41119,7 @@ static void SessRemSslSetupCb(WOLFSSL* ssl) static int test_wolfSSL_CTX_sess_set_remove_cb(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \ defined(HAVE_EX_DATA) /* Check that the remove callback gets called for external data in a @@ -42194,8 +41130,6 @@ static int test_wolfSSL_CTX_sess_set_remove_cb(void) func_args server_args; THREAD_TYPE serverThread; - printf(testingFmt, "wolfSSL_CTX_sess_set_remove_cb()"); - XMEMSET(&client_args, 0, sizeof(func_args)); XMEMSET(&server_args, 0, sizeof(func_args)); XMEMSET(&func_cb, 0, sizeof(callback_functions)); @@ -42275,14 +41209,14 @@ static int test_wolfSSL_CTX_sess_set_remove_cb(void) SSL_SESSION_free(clientSess); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ticket_keys(void) { + int res = TEST_SKIPPED; #if defined(HAVE_SESSION_TICKET) && !defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && \ !defined(NO_WOLFSSL_SERVER) WOLFSSL_CTX* ctx; @@ -42326,21 +41260,21 @@ static int test_wolfSSL_ticket_keys(void) WOLFSSL_SUCCESS); wolfSSL_CTX_free(ctx); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #ifndef NO_BIO static int test_wolfSSL_d2i_PUBKEY(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) BIO* bio; EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_d2i_PUBKEY()"); - AssertNotNull(bio = BIO_new(BIO_s_mem())); AssertNull(d2i_PUBKEY_bio(NULL, NULL)); @@ -42383,10 +41317,11 @@ defined(OPENSSL_EXTRA) && defined(WOLFSSL_DH_EXTRA) BIO_free(bio); (void)pkey; - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if (defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO)) && !defined(NO_RSA) @@ -42403,8 +41338,6 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void) unsigned char* bufPtr = buff; #endif - printf(testingFmt, "wolfSSL_d2i_PrivateKeys_bio()"); - /* test creating new EVP_PKEY with bad arg */ AssertNull((pkey = d2i_PrivateKey_bio(NULL, NULL))); @@ -42517,9 +41450,8 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void) ctx = NULL; BIO_free(bio); bio = NULL; - printf(resultFmt, passed); - return 0; + return TEST_RES_CHECK(1); } #endif /* OPENSSL_ALL || WOLFSSL_ASIO */ @@ -42528,6 +41460,7 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void) static int test_wolfSSL_sk_GENERAL_NAME(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_RSA) X509* x509; @@ -42540,8 +41473,6 @@ static int test_wolfSSL_sk_GENERAL_NAME(void) XFILE f; STACK_OF(GENERAL_NAME)* sk; - printf(testingFmt, "wolfSSL_sk_GENERAL_NAME()"); - f = XFOPEN(cliCertDerFileExt, "rb"); AssertTrue((f != XBADFILE)); AssertIntGT((bytes = (int)XFREAD(buf, 1, sizeof(buf), f)), 0); @@ -42560,13 +41491,13 @@ static int test_wolfSSL_sk_GENERAL_NAME(void) switch (gn->type) { case GEN_DNS: - printf("found type GEN_DNS\n"); + fprintf(stderr, "found type GEN_DNS\n"); break; case GEN_EMAIL: - printf("found type GEN_EMAIL\n"); + fprintf(stderr, "found type GEN_EMAIL\n"); break; case GEN_URI: - printf("found type GEN_URI\n"); + fprintf(stderr, "found type GEN_URI\n"); break; } } @@ -42583,16 +41514,15 @@ static int test_wolfSSL_sk_GENERAL_NAME(void) } } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_GENERAL_NAME_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_BIO) && !defined(NO_RSA) - X509* x509; GENERAL_NAME* gn; unsigned char buf[4096]; @@ -42625,8 +41555,6 @@ static int test_wolfSSL_GENERAL_NAME_print(void) const char* ediStr = "EdiPartyName:"; - printf(testingFmt, "test_wolfSSL_GENERAL_NAME_print()"); - /* BIO to output */ AssertNotNull(out = BIO_new(BIO_s_mem())); @@ -42768,14 +41696,14 @@ static int test_wolfSSL_GENERAL_NAME_print(void) BIO_free(out); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL */ - - return 0; + return res; } static int test_wolfSSL_sk_DIST_POINT(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ !defined(NO_RSA) X509* x509; @@ -42791,8 +41719,6 @@ static int test_wolfSSL_sk_DIST_POINT(void) STACK_OF(GENERAL_NAME)* gns; const char cliCertDerCrlDistPoint[] = "./certs/client-crl-dist.der"; - printf(testingFmt, "wolfSSL_sk_DIST_POINT()"); - f = XFOPEN(cliCertDerCrlDistPoint, "rb"); AssertTrue((f != XBADFILE)); AssertIntGT((bytes = (int)XFREAD(buf, 1, sizeof(buf), f)), 0); @@ -42828,14 +41754,14 @@ static int test_wolfSSL_sk_DIST_POINT(void) X509_free(x509); CRL_DIST_POINTS_free(dps); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_MD4(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_MD4) MD4_CTX md4; unsigned char out[16]; /* MD4_DIGEST_SIZE */ @@ -42845,7 +41771,6 @@ static int test_wolfSSL_MD4(void) "\xcc\x05\x36"; int msgSz = (int)XSTRLEN(msg); - printf(testingFmt, "wolfSSL_MD4()"); XMEMSET(out, 0, sizeof(out)); MD4_Init(&md4); @@ -42853,20 +41778,19 @@ static int test_wolfSSL_MD4(void) MD4_Final(out, &md4); AssertIntEQ(XMEMCMP(out, test, sizeof(out)), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_verify_mode(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) WOLFSSL* ssl; WOLFSSL_CTX* ctx; - printf(testingFmt, "test_wolfSSL_verify()"); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, cliCertFile, SSL_FILETYPE_PEM)); @@ -42918,23 +41842,22 @@ static int test_wolfSSL_verify_mode(void) WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT); SSL_free(ssl); - SSL_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_verify_depth(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL* ssl; WOLFSSL_CTX* ctx; long depth; - printf(testingFmt, "test_wolfSSL_verify_depth()"); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, cliCertFile, SSL_FILETYPE_PEM)); @@ -42956,10 +41879,10 @@ static int test_wolfSSL_verify_depth(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #if defined(OPENSSL_EXTRA) && !defined(NO_HMAC) @@ -43011,7 +41934,6 @@ static int test_HMAC_CTX_helper(const EVP_MD* type, unsigned char* digest) /* test HMAC_Init with NULL key */ /* init after copy */ - printf("test HMAC_Init with NULL key (0)\n"); HMAC_CTX_init(&ctx1); AssertIntEQ(HMAC_Init(&ctx1, (const void*)key, keySz, type), SSL_SUCCESS); AssertIntEQ(HMAC_Update(&ctx1, msg, msgSz), SSL_SUCCESS); @@ -43033,7 +41955,6 @@ static int test_HMAC_CTX_helper(const EVP_MD* type, unsigned char* digest) AssertIntEQ(XMEMCMP(digest, digest2, digestSz), 0); /* long key */ - printf("test HMAC_Init with NULL key (1)\n"); HMAC_CTX_init(&ctx1); AssertIntEQ(HMAC_Init(&ctx1, (const void*)long_key, long_keySz, type), SSL_SUCCESS); AssertIntEQ(HMAC_Update(&ctx1, msg, msgSz), SSL_SUCCESS); @@ -43055,7 +41976,6 @@ static int test_HMAC_CTX_helper(const EVP_MD* type, unsigned char* digest) AssertIntEQ(XMEMCMP(digest, digest2, digestSz), 0); /* init before copy */ - printf("test HMAC_Init with NULL key (2)\n"); HMAC_CTX_init(&ctx1); AssertIntEQ(HMAC_Init(&ctx1, (const void*)key, keySz, type), SSL_SUCCESS); AssertIntEQ(HMAC_Update(&ctx1, msg, msgSz), SSL_SUCCESS); @@ -43081,12 +42001,11 @@ static int test_HMAC_CTX_helper(const EVP_MD* type, unsigned char* digest) static int test_wolfSSL_HMAC_CTX(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_HMAC) unsigned char digest[64]; int digestSz; - printf(testingFmt, "wolfSSL_HMAC_CTX()"); - #ifndef NO_SHA AssertIntEQ((digestSz = test_HMAC_CTX_helper(EVP_sha1(), digest)), 20); AssertIntEQ(XMEMCMP("\xD9\x68\x77\x23\x70\xFB\x53\x70\x53\xBA\x0E\xDC\xDA" @@ -43131,10 +42050,9 @@ static int test_wolfSSL_HMAC_CTX(void) "\xE4\x98\xDD", digest, digestSz), 0); #endif /* !NO_MD5 */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_WOLFSSL_CLIENT) @@ -43144,10 +42062,10 @@ static void sslMsgCb(int w, int version, int type, const void* buf, int i; unsigned char* pt = (unsigned char*)buf; - printf("%s %d bytes of version %d , type %d : ", (w)?"Writing":"Reading", - (int)sz, version, type); - for (i = 0; i < (int)sz; i++) printf("%02X", pt[i]); - printf("\n"); + fprintf(stderr, "%s %d bytes of version %d , type %d : ", + (w)?"Writing":"Reading", (int)sz, version, type); + for (i = 0; i < (int)sz; i++) fprintf(stderr, "%02X", pt[i]); + fprintf(stderr, "\n"); (void)ssl; (void)arg; } @@ -43155,11 +42073,11 @@ static void sslMsgCb(int w, int version, int type, const void* buf, static int test_wolfSSL_msg_callback(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL* ssl; WOLFSSL_CTX* ctx; - printf(testingFmt, "wolfSSL_msg_callback()"); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, cliCertFile, @@ -43177,17 +42095,15 @@ static int test_wolfSSL_msg_callback(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SHA(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(HAVE_SELFTEST) - printf(testingFmt, "wolfSSL_SHA()"); - #if !defined(NO_SHA) && defined(NO_OLD_SHA_NAMES) && \ (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION > 2)) @@ -43272,10 +42188,9 @@ static int test_wolfSSL_SHA(void) } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* test_EVP_Cipher_extra, Extra-test on EVP_CipherUpdate/Final. see also test.c */ @@ -43287,16 +42202,16 @@ static void binary_dump(void *ptr, int size) int i = 0; unsigned char *p = (unsigned char *) ptr; - printf("{"); - while((p != NULL) && (i < size)) { - if((i % 8) == 0) { - printf("\n"); - printf(" "); - } - printf("0x%02x, ", p[i]); - i++; + fprintf(stderr, "{"); + while ((p != NULL) && (i < size)) { + if ((i % 8) == 0) { + fprintf(stderr, "\n"); + fprintf(stderr, " "); + } + fprintf(stderr, "0x%02x, ", p[i]); + i++; } - printf("\n};\n"); + fprintf(stderr, "\n};\n"); #else (void) ptr; (void) size; @@ -43309,10 +42224,10 @@ static int check_result(unsigned char *data, int len) { int i; - for( ; len; ) { + for ( ; len; ) { last_val = (last_val + 1) % 16; - for(i = 0; i < 16; len--, i++, data++) - if(*data != last_val) { + for (i = 0; i < 16; len--, i++, data++) + if (*data != last_val) { return -1; } } @@ -43346,8 +42261,8 @@ static void set_plain(unsigned char *plain, int rec) #define BLOCKSZ 16 - for(i=0; i<(rec/BLOCKSZ); i++){ - for(j=0; j 0) + if (outl > 0) set_record(cipher, outb, outl); } @@ -43466,7 +42381,7 @@ static int test_wolfSSL_EVP_Cipher_extra(void) init_offset(); - for (j = 0; test_drive[i][j]; j++){ + for (j = 0; test_drive[i][j]; j++) { inl = test_drive[i][j]; get_record(cipher, inb, inl); @@ -43487,13 +42402,14 @@ static int test_wolfSSL_EVP_Cipher_extra(void) EVP_CIPHER_CTX_free(evp); + res = TEST_RES_CHECK(1); #endif /* test_EVP_Cipher */ - - return 0; + return res; } static int test_wolfSSL_PEM_read_DHparams(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) && \ !defined(NO_FILESYSTEM) DH* dh; @@ -43505,8 +42421,6 @@ static int test_wolfSSL_PEM_read_DHparams(void) unsigned char derExpected[300]; int derExpectedSz = 0; - printf(testingFmt, "wolfSSL_PEM_read_DHparams()"); - XMEMSET(derOut, 0, sizeof(derOut)); XMEMSET(derExpected, 0, sizeof(derExpected)); @@ -43541,14 +42455,15 @@ static int test_wolfSSL_PEM_read_DHparams(void) XFCLOSE(fp); DH_free(dh); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_AES_ecb_encrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_AES) && defined(HAVE_AES_ECB) AES_KEY aes; const byte msg[] = @@ -43574,8 +42489,6 @@ static int test_wolfSSL_AES_ecb_encrypt(void) byte out[AES_BLOCK_SIZE]; - printf(testingFmt, "wolfSSL_AES_ecb_encrypt()"); - AssertIntEQ(AES_set_encrypt_key(key, sizeof(key)*8, &aes), 0); XMEMSET(out, 0, AES_BLOCK_SIZE); AES_ecb_encrypt(msg, out, &aes, AES_ENCRYPT); @@ -43593,14 +42506,14 @@ static int test_wolfSSL_AES_ecb_encrypt(void) AES_ecb_encrypt(verify, NULL, &aes, AES_DECRYPT); AES_ecb_encrypt(verify, out, NULL, AES_DECRYPT); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_MD5(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_MD5) byte input1[] = ""; byte input2[] = "message digest"; @@ -43611,8 +42524,6 @@ static int test_wolfSSL_MD5(void) "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61\xd0"; WOLFSSL_MD5_CTX md5; - printf(testingFmt, "wolfSSL_MD5()"); - XMEMSET(&md5, 0, sizeof(md5)); /* Test cases for illegal parameters */ @@ -43661,14 +42572,14 @@ static int test_wolfSSL_MD5(void) } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_MD5_Transform(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_MD5) byte input1[] = ""; byte input2[] = "abc"; @@ -43691,8 +42602,6 @@ static int test_wolfSSL_MD5_Transform(void) MD5_CTX compat; } md5; - printf(testingFmt, "wolfSSL_MD5_Transform()"); - XMEMSET(&md5.compat, 0, sizeof(md5.compat)); XMEMSET(&local, 0, sizeof(local)); @@ -43723,14 +42632,14 @@ static int test_wolfSSL_MD5_Transform(void) AssertIntEQ(XMEMCMP(md5.native.digest, output2, WC_MD5_DIGEST_SIZE), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SHA224(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA224) && \ !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION > 2)) @@ -43742,7 +42651,6 @@ static int test_wolfSSL_SHA224(void) size_t inLen; byte hash[WC_SHA224_DIGEST_SIZE]; - printf(testingFmt, "wolfSSL_SHA224()"); inLen = XSTRLEN((char*)input); XMEMSET(hash, 0, WC_SHA224_DIGEST_SIZE); @@ -43756,13 +42664,13 @@ static int test_wolfSSL_SHA224(void) AssertNotNull(SHA224(input, inLen, hash)); AssertIntEQ(XMEMCMP(hash, output, WC_SHA224_DIGEST_SIZE), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SHA_Transform(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA) #if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))) @@ -43795,8 +42703,6 @@ static int test_wolfSSL_SHA_Transform(void) SHA_CTX compat; } sha1; - printf(testingFmt, "wolfSSL_SHA_Transform()"); - XMEMSET(&sha.compat, 0, sizeof(sha.compat)); XMEMSET(&local, 0, sizeof(local)); @@ -43853,15 +42759,15 @@ static int test_wolfSSL_SHA_Transform(void) WC_SHA_DIGEST_SIZE), 0); AssertIntEQ(SHA_Final(local, &sha1.compat), 1); /* frees resources */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } static int test_wolfSSL_SHA256_Transform(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) #if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))) && \ @@ -43890,8 +42796,6 @@ static int test_wolfSSL_SHA256_Transform(void) SHA256_CTX compat; } sha256; - printf(testingFmt, "wolfSSL_SHA256_Transform()"); - XMEMSET(&sha256.compat, 0, sizeof(sha256.compat)); XMEMSET(&local, 0, sizeof(local)); @@ -43923,15 +42827,15 @@ static int test_wolfSSL_SHA256_Transform(void) WC_SHA256_DIGEST_SIZE), 0); AssertIntEQ(SHA256_Final(local, &sha256.compat), 1); /* frees resources */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } static int test_wolfSSL_SHA256(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) && \ defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) unsigned char input[] = @@ -43943,21 +42847,20 @@ static int test_wolfSSL_SHA256(void) size_t inLen; byte hash[WC_SHA256_DIGEST_SIZE]; - printf(testingFmt, "wolfSSL_SHA256()"); inLen = XSTRLEN((char*)input); XMEMSET(hash, 0, WC_SHA256_DIGEST_SIZE); AssertNotNull(SHA256(input, inLen, hash)); AssertIntEQ(XMEMCMP(hash, output, WC_SHA256_DIGEST_SIZE), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SHA512_Transform(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA512) #if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))) @@ -43993,8 +42896,6 @@ static int test_wolfSSL_SHA512_Transform(void) SHA512_CTX compat; } sha512; - printf(testingFmt, "wolfSSL_SHA512_Transform()"); - XMEMSET(&sha512.compat, 0, sizeof(sha512.compat)); XMEMSET(&local, 0, sizeof(local)); @@ -44028,15 +42929,16 @@ static int test_wolfSSL_SHA512_Transform(void) AssertIntEQ(SHA512_Final(local, &sha512.compat), 1); /* frees resources */ (void)input1; - printf(resultFmt, passed); -#endif -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif +#endif + return res; } static int test_wolfSSL_X509_get_serialNumber(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_RSA) ASN1_INTEGER* a; BIGNUM* bn; @@ -44045,8 +42947,6 @@ static int test_wolfSSL_X509_get_serialNumber(void) byte serial[3]; int serialSz; - printf(testingFmt, "wolfSSL_X509_get_serialNumber()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(svrCertFile, SSL_FILETYPE_PEM)); AssertNotNull(a = X509_get_serialNumber(x509)); @@ -44111,31 +43011,30 @@ static int test_wolfSSL_X509_get_serialNumber(void) ASN1_INTEGER_free(a); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wolfSSL_OpenSSL_add_all_algorithms(void){ +static int test_wolfSSL_OpenSSL_add_all_algorithms(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "wolfSSL_OpenSSL_add_all_algorithms()"); - AssertIntEQ(wolfSSL_add_all_algorithms(),WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_OpenSSL_add_all_algorithms_noconf(),WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_OpenSSL_add_all_algorithms_conf(),WOLFSSL_SUCCESS); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OPENSSL_hexstr2buf(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) #define MAX_HEXSTR_BUFSZ 9 #define NUM_CASES 5 @@ -44163,8 +43062,6 @@ static int test_wolfSSL_OPENSSL_hexstr2buf(void) long len = 0; unsigned char* returnedBuf = NULL; - printf(testingFmt, "test_wolfSSL_OPENSSL_hexstr2buf()"); - for (i = 0; i < NUM_CASES; ++i) { returnedBuf = wolfSSL_OPENSSL_hexstr2buf(inputs[i], &len); @@ -44181,13 +43078,14 @@ static int test_wolfSSL_OPENSSL_hexstr2buf(void) OPENSSL_free(returnedBuf); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wolfSSL_ASN1_STRING_print_ex(void){ +static int test_wolfSSL_ASN1_STRING_print_ex(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN) #ifndef NO_BIO ASN1_STRING* asn_str; @@ -44199,8 +43097,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void){ int p_len; unsigned char rbuf[255]; - printf(testingFmt, "wolfSSL_ASN1_STRING_print_ex()"); - /* setup */ XMEMSET(rbuf, 0, 255); bio = BIO_new(BIO_s_mem()); @@ -44263,14 +43159,15 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void){ ASN1_STRING_free(asn_str); ASN1_STRING_free(esc_str); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_BIO */ #endif - - return 0; + return res; } -static int test_wolfSSL_ASN1_TIME_to_generalizedtime(void){ +static int test_wolfSSL_ASN1_TIME_to_generalizedtime(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) WOLFSSL_ASN1_TIME *t; WOLFSSL_ASN1_TIME *out; @@ -44278,8 +43175,6 @@ static int test_wolfSSL_ASN1_TIME_to_generalizedtime(void){ int tlen = 0; unsigned char *data; - printf(testingFmt, "wolfSSL_ASN1_TIME_to_generalizedtime()"); - /* UTC Time test */ AssertNotNull(t = wolfSSL_ASN1_TIME_new()); XMEMSET(t->data, 0, ASN_GENERALIZED_TIME_SIZE); @@ -44329,21 +43224,21 @@ static int test_wolfSSL_ASN1_TIME_to_generalizedtime(void){ XFREE(gtime, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(t, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } -static int test_wolfSSL_X509_CA_num(void){ +static int test_wolfSSL_X509_CA_num(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && \ defined(HAVE_ECC) && !defined(NO_RSA) WOLFSSL_X509_STORE *store; WOLFSSL_X509 *x509_1, *x509_2; int ca_num = 0; - printf(testingFmt, "wolfSSL_X509_CA_num()"); - store = wolfSSL_X509_STORE_new(); x509_1 = wolfSSL_X509_load_certificate_file(svrCertFile, WOLFSSL_FILETYPE_PEM); wolfSSL_X509_STORE_add_cert(store, x509_1); @@ -44358,34 +43253,33 @@ static int test_wolfSSL_X509_CA_num(void){ wolfSSL_X509_free(x509_1); wolfSSL_X509_free(x509_2); wolfSSL_X509_STORE_free(store); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } -static int test_wolfSSL_X509_check_ca(void){ +static int test_wolfSSL_X509_check_ca(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) WOLFSSL_X509 *x509; - printf(testingFmt, "wolfSSL_X509_check_ca()"); - x509 = wolfSSL_X509_load_certificate_file(svrCertFile, WOLFSSL_FILETYPE_PEM); AssertIntEQ(wolfSSL_X509_check_ca(x509), 1); wolfSSL_X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wolfSSL_X509_check_ip_asc(void){ +static int test_wolfSSL_X509_check_ip_asc(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) WOLFSSL_X509 *x509; - printf(testingFmt, "wolfSSL_X509_check_ip_asc()"); - x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); #if 0 /* TODO: add cert gen for testing positive case */ @@ -44395,14 +43289,14 @@ static int test_wolfSSL_X509_check_ip_asc(void){ AssertIntEQ(wolfSSL_X509_check_ip_asc(x509, NULL, 0), 0); wolfSSL_X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_make_cert(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) int ret; Cert cert; @@ -44422,8 +43316,6 @@ static int test_wolfSSL_make_cert(void) ASN1_STRING* entryValue; #endif - printf(testingFmt, "wolfSSL Make Certs"); - XMEMSET(&name, 0, sizeof(CertName)); /* set up cert name */ @@ -44559,31 +43451,32 @@ static int test_wolfSSL_make_cert(void) wc_FreeRsaKey(&key); wc_FreeRng(&rng); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } -static int test_wolfSSL_X509_get_version(void){ +static int test_wolfSSL_X509_get_version(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) WOLFSSL_X509 *x509; - printf(testingFmt, "wolfSSL_X509_get_version()"); - x509 = wolfSSL_X509_load_certificate_file(svrCertFile, WOLFSSL_FILETYPE_PEM); AssertNotNull(x509); AssertIntEQ((int)wolfSSL_X509_get_version(x509), 2); wolfSSL_X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wolfSSL_DES_ncbc(void){ +static int test_wolfSSL_DES_ncbc(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DES3) const_DES_cblock myDes; DES_cblock iv = {1}; @@ -44595,8 +43488,6 @@ static int test_wolfSSL_DES_ncbc(void){ unsigned char exp[] = {0x31, 0x98, 0x2F, 0x3A, 0x55, 0xBF, 0xD8, 0xC4}; unsigned char exp2[] = {0xC7, 0x45, 0x8B, 0x28, 0x10, 0x53, 0xE0, 0x58}; - printf(testingFmt, "wolfSSL_DES_ncbc()"); - /* partial block test */ DES_set_key(&key, &myDes); DES_ncbc_encrypt(msg, out, 3, &myDes, &iv, DES_ENCRYPT); @@ -44626,14 +43517,14 @@ static int test_wolfSSL_DES_ncbc(void){ AssertIntEQ(XMEMCMP(msg, pln, 8), 0); AssertIntEQ(XMEMCMP(exp2, iv, DES_BLOCK_SIZE), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_AES_cbc_encrypt(void) { + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AES_CBC) && defined(OPENSSL_EXTRA) AES_KEY aes; AES_KEY* aesN = NULL; @@ -44677,7 +43568,7 @@ static int test_wolfSSL_AES_cbc_encrypt(void) #define RESET_IV(x, y) XMEMCPY(x, y, AES_BLOCK_SIZE) - printf(testingFmt, "Stressing wolfSSL_AES_cbc_encrypt()"); + /* Stressing wolfSSL_AES_cbc_encrypt() */ STRESS_T(pt128N, out, len, &aes, iv128tmp, 1, ct128, AES_BLOCK_SIZE, 0); STRESS_T(pt128, out, len, &aes, iv128N, 1, ct128, AES_BLOCK_SIZE, 0); @@ -44687,36 +43578,32 @@ static int test_wolfSSL_AES_cbc_encrypt(void) AssertIntNE(XMEMCMP(out, ct128, AES_BLOCK_SIZE), 0); STRESS_T(pt128, out, lenB, &aes, iv128tmp, 1, ct128, AES_BLOCK_SIZE, 0); - printf(resultFmt, "Stress Tests: passed"); - printf(testingFmt, "Stressing wolfSSL_AES_set_encrypt_key"); + /* Stressing wolfSSL_AES_set_encrypt_key */ AssertIntNE(wolfSSL_AES_set_encrypt_key(key128N, sizeof(key128)*8, &aes),0); AssertIntNE(wolfSSL_AES_set_encrypt_key(key128, sizeof(key128)*8, aesN),0); AssertIntNE(wolfSSL_AES_set_encrypt_key(key128, keySz0, &aes), 0); AssertIntNE(wolfSSL_AES_set_encrypt_key(key128, keySzN, &aes), 0); - printf(resultFmt, "Stress Tests: passed"); - printf(testingFmt, "Stressing wolfSSL_AES_set_decrypt_key"); + /* Stressing wolfSSL_AES_set_decrypt_key */ AssertIntNE(wolfSSL_AES_set_decrypt_key(key128N, sizeof(key128)*8, &aes),0); AssertIntNE(wolfSSL_AES_set_decrypt_key(key128N, sizeof(key128)*8, aesN),0); AssertIntNE(wolfSSL_AES_set_decrypt_key(key128, keySz0, &aes), 0); AssertIntNE(wolfSSL_AES_set_decrypt_key(key128, keySzN, &aes), 0); - printf(resultFmt, "Stress Tests: passed"); #ifdef WOLFSSL_AES_128 - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 128-bit"); + /* wolfSSL_AES_cbc_encrypt() 128-bit */ XMEMSET(out, 0, AES_BLOCK_SIZE); RESET_IV(iv128tmp, iv128); AssertIntEQ(wolfSSL_AES_set_encrypt_key(key128, sizeof(key128)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(pt128, out, len, &aes, iv128tmp, AES_ENCRYPT); AssertIntEQ(XMEMCMP(out, ct128, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #ifdef HAVE_AES_DECRYPT - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 128-bit in decrypt mode"); + /* wolfSSL_AES_cbc_encrypt() 128-bit in decrypt mode */ XMEMSET(out, 0, AES_BLOCK_SIZE); RESET_IV(iv128tmp, iv128); len = sizeof(ct128); @@ -44724,7 +43611,6 @@ static int test_wolfSSL_AES_cbc_encrypt(void) AssertIntEQ(wolfSSL_AES_set_decrypt_key(key128, sizeof(key128)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(ct128, out, len, &aes, iv128tmp, AES_DECRYPT); AssertIntEQ(XMEMCMP(out, pt128, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #endif @@ -44751,18 +43637,17 @@ static int test_wolfSSL_AES_cbc_encrypt(void) len = sizeof(pt192); - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 192-bit"); + /* wolfSSL_AES_cbc_encrypt() 192-bit */ XMEMSET(out, 0, AES_BLOCK_SIZE); RESET_IV(iv192tmp, iv192); AssertIntEQ(wolfSSL_AES_set_encrypt_key(key192, sizeof(key192)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(pt192, out, len, &aes, iv192tmp, AES_ENCRYPT); AssertIntEQ(XMEMCMP(out, ct192, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #ifdef HAVE_AES_DECRYPT - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 192-bit in decrypt mode"); + /* wolfSSL_AES_cbc_encrypt() 192-bit in decrypt mode */ len = sizeof(ct192); RESET_IV(iv192tmp, iv192); XMEMSET(out, 0, AES_BLOCK_SIZE); @@ -44770,7 +43655,6 @@ static int test_wolfSSL_AES_cbc_encrypt(void) AssertIntEQ(wolfSSL_AES_set_decrypt_key(key192, sizeof(key192)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(ct192, out, len, &aes, iv192tmp, AES_DECRYPT); AssertIntEQ(XMEMCMP(out, pt192, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #endif } @@ -44798,18 +43682,17 @@ static int test_wolfSSL_AES_cbc_encrypt(void) len = sizeof(pt256); - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 256-bit"); + /* wolfSSL_AES_cbc_encrypt() 256-bit */ XMEMSET(out, 0, AES_BLOCK_SIZE); RESET_IV(iv256tmp, iv256); AssertIntEQ(wolfSSL_AES_set_encrypt_key(key256, sizeof(key256)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(pt256, out, len, &aes, iv256tmp, AES_ENCRYPT); AssertIntEQ(XMEMCMP(out, ct256, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #ifdef HAVE_AES_DECRYPT - printf(testingFmt, "wolfSSL_AES_cbc_encrypt() 256-bit in decrypt mode"); + /* wolfSSL_AES_cbc_encrypt() 256-bit in decrypt mode */ len = sizeof(ct256); RESET_IV(iv256tmp, iv256); XMEMSET(out, 0, AES_BLOCK_SIZE); @@ -44817,7 +43700,6 @@ static int test_wolfSSL_AES_cbc_encrypt(void) AssertIntEQ(wolfSSL_AES_set_decrypt_key(key256, sizeof(key256)*8, &aes), 0); wolfSSL_AES_cbc_encrypt(ct256, out, len, &aes, iv256tmp, AES_DECRYPT); AssertIntEQ(XMEMCMP(out, pt256, AES_BLOCK_SIZE), 0); - printf(resultFmt, "passed"); #endif @@ -44826,45 +43708,47 @@ static int test_wolfSSL_AES_cbc_encrypt(void) byte wrapCipher[sizeof(key256) + KEYWRAP_BLOCK_SIZE] = { 0 }; byte wrapPlain[sizeof(key256)] = { 0 }; byte wrapIV[KEYWRAP_BLOCK_SIZE] = { 0 }; - printf(testingFmt, "wolfSSL_AES_wrap_key() 256-bit NULL iv"); + + /* wolfSSL_AES_wrap_key() 256-bit NULL iv */ AssertIntEQ(wolfSSL_AES_set_encrypt_key(key256, sizeof(key256)*8, &aes), 0); AssertIntEQ(wolfSSL_AES_wrap_key(&aes, NULL, wrapCipher, key256, 15), WOLFSSL_FAILURE); AssertIntEQ(wolfSSL_AES_wrap_key(&aes, NULL, wrapCipher, key256, sizeof(key256)), sizeof(wrapCipher)); - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_AES_unwrap_key() 256-bit NULL iv"); + + /* wolfSSL_AES_unwrap_key() 256-bit NULL iv */ AssertIntEQ(wolfSSL_AES_set_decrypt_key(key256, sizeof(key256)*8, &aes), 0); AssertIntEQ(wolfSSL_AES_unwrap_key(&aes, NULL, wrapPlain, wrapCipher, 23), WOLFSSL_FAILURE); AssertIntEQ(wolfSSL_AES_unwrap_key(&aes, NULL, wrapPlain, wrapCipher, sizeof(wrapCipher)), sizeof(wrapPlain)); AssertIntEQ(XMEMCMP(wrapPlain, key256, sizeof(key256)), 0); - printf(resultFmt, "passed"); XMEMSET(wrapCipher, 0, sizeof(wrapCipher)); XMEMSET(wrapPlain, 0, sizeof(wrapPlain)); - printf(testingFmt, "wolfSSL_AES_wrap_key() 256-bit custom iv"); + + /* wolfSSL_AES_wrap_key() 256-bit custom iv */ AssertIntEQ(wolfSSL_AES_set_encrypt_key(key256, sizeof(key256)*8, &aes), 0); AssertIntEQ(wolfSSL_AES_wrap_key(&aes, wrapIV, wrapCipher, key256, sizeof(key256)), sizeof(wrapCipher)); - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_AES_unwrap_key() 256-bit custom iv"); + + /* wolfSSL_AES_unwrap_key() 256-bit custom iv */ AssertIntEQ(wolfSSL_AES_set_decrypt_key(key256, sizeof(key256)*8, &aes), 0); AssertIntEQ(wolfSSL_AES_unwrap_key(&aes, wrapIV, wrapPlain, wrapCipher, sizeof(wrapCipher)), sizeof(wrapPlain)); AssertIntEQ(XMEMCMP(wrapPlain, key256, sizeof(key256)), 0); - printf(resultFmt, "passed"); } #endif /* HAVE_AES_KEYWRAP */ } #endif /* WOLFSSL_AES_256 */ -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_CRYPTO_cts128(void) { + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AES_CBC) && defined(OPENSSL_EXTRA) \ && defined(HAVE_CTS) byte tmp[64]; /* Largest vector size */ @@ -44944,15 +43828,17 @@ static int test_wolfSSL_CRYPTO_cts128(void) vects[i].inLen); AssertIntEQ(XMEMCMP(tmp, vects[i].input, vects[i].inLen), 0); } -#endif /* !NO_AES && HAVE_AES_CBC && OPENSSL_EXTRA && HAVE_CTS */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* !NO_AES && HAVE_AES_CBC && OPENSSL_EXTRA && HAVE_CTS */ + return res; } #if defined(OPENSSL_ALL) #if !defined(NO_ASN) static int test_wolfSSL_ASN1_STRING_to_UTF8(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) WOLFSSL_X509* x509; WOLFSSL_X509_NAME* subject; @@ -44969,7 +43855,7 @@ static int test_wolfSSL_ASN1_STRING_to_UTF8(void) AssertNotNull(x509 = wolfSSL_PEM_read_X509(file, NULL, NULL, NULL)); fclose(file); - printf(testingFmt, "wolfSSL_ASN1_STRING_to_UTF8(): NID_commonName"); + /* wolfSSL_ASN1_STRING_to_UTF8(): NID_commonName */ AssertNotNull(subject = wolfSSL_X509_get_subject_name(x509)); AssertIntEQ((idx = wolfSSL_X509_NAME_get_index_by_NID(subject, NID_commonName, -1)), 5); @@ -44978,28 +43864,25 @@ static int test_wolfSSL_ASN1_STRING_to_UTF8(void) AssertIntEQ((len = wolfSSL_ASN1_STRING_to_UTF8(&actual_output, a)), 15); result = strncmp((const char*)actual_output, targetOutput, len); AssertIntEQ(result, 0); - printf(resultFmt, result == 0 ? passed : failed); - printf(testingFmt, "wolfSSL_ASN1_STRING_to_UTF8(NULL, valid): "); + /* wolfSSL_ASN1_STRING_to_UTF8(NULL, valid) */ AssertIntEQ((len = wolfSSL_ASN1_STRING_to_UTF8(NULL, a)), WOLFSSL_FATAL_ERROR); - printf(resultFmt, len == WOLFSSL_FATAL_ERROR ? passed : failed); - printf(testingFmt, "wolfSSL_ASN1_STRING_to_UTF8(valid, NULL): "); + /* wolfSSL_ASN1_STRING_to_UTF8(valid, NULL) */ AssertIntEQ((len = wolfSSL_ASN1_STRING_to_UTF8(&actual_output, NULL)), WOLFSSL_FATAL_ERROR); - printf(resultFmt, len == WOLFSSL_FATAL_ERROR ? passed : failed); - printf(testingFmt, "wolfSSL_ASN1_STRING_to_UTF8(NULL, NULL): "); + /* wolfSSL_ASN1_STRING_to_UTF8(NULL, NULL) */ AssertIntEQ((len = wolfSSL_ASN1_STRING_to_UTF8(NULL, NULL)), WOLFSSL_FATAL_ERROR); - printf(resultFmt, len == WOLFSSL_FATAL_ERROR ? passed : failed); wolfSSL_X509_free(x509); XFREE(actual_output, NULL, DYNAMIC_TYPE_TMP_BUFFER); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_ASN1_UNIVERSALSTRING_to_string(void) @@ -45015,8 +43898,6 @@ static int test_wolfSSL_ASN1_UNIVERSALSTRING_to_string(void) }; char output[] = "Test"; - printf(testingFmt, "test_wolfSSL_ASN1_UNIVERSALSTRING_to_string()"); - AssertNotNull(asn1str_test = ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)); AssertIntEQ(ASN1_STRING_set(asn1str_test, input, sizeof(input)), 1); AssertIntEQ(ASN1_UNIVERSALSTRING_to_string(asn1str_test), 1); @@ -45029,14 +43910,13 @@ static int test_wolfSSL_ASN1_UNIVERSALSTRING_to_string(void) ASN1_STRING_free(asn1str_test); ASN1_STRING_free(asn1str_answer); - printf(resultFmt, "passed"); - - return 0; + return TEST_RES_CHECK(1); } #endif /* !defined(NO_ASN) */ static int test_wolfSSL_sk_CIPHER_description(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_COMPRESSION; int i,j,k; @@ -45052,8 +43932,6 @@ static int test_wolfSSL_sk_CIPHER_description(void) const char certPath[] = "./certs/client-cert.pem"; XMEMSET(buf, 0, sizeof(buf)); - printf(testingFmt, "wolfSSL_sk_CIPHER_description"); - AssertNotNull(method = TLSv1_2_client_method()); AssertNotNull(ctx = SSL_CTX_new(method)); @@ -45098,14 +43976,14 @@ static int test_wolfSSL_sk_CIPHER_description(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_get_ciphers_compat(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) const SSL_METHOD *method = NULL; const char certPath[] = "./certs/client-cert.pem"; @@ -45114,7 +43992,6 @@ static int test_wolfSSL_get_ciphers_compat(void) WOLFSSL *ssl = NULL; const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_COMPRESSION; - printf(testingFmt, "wolfSSL_get_ciphers_compat"); method = SSLv23_client_method(); AssertNotNull(method); ctx = SSL_CTX_new(method); @@ -45139,10 +44016,9 @@ static int test_wolfSSL_get_ciphers_compat(void) SSL_free(ssl); SSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_PUBKEY_get(void) @@ -45162,7 +44038,6 @@ static int test_wolfSSL_X509_PUBKEY_get(void) evpPkey->type = WOLFSSL_SUCCESS; key->pkey = evpPkey; - printf(testingFmt, "wolfSSL_X509_PUBKEY_get()"); AssertNotNull(retEvpPkey = wolfSSL_X509_PUBKEY_get(key)); AssertIntEQ(retEvpPkey->type, WOLFSSL_SUCCESS); @@ -45170,13 +44045,13 @@ static int test_wolfSSL_X509_PUBKEY_get(void) key->pkey = NULL; AssertNull(retEvpPkey = wolfSSL_X509_PUBKEY_get(key)); - printf(resultFmt,retEvpPkey == NULL ? passed : failed); - return 0; + return TEST_RES_CHECK(retEvpPkey == NULL); } static int test_wolfSSL_EC_KEY_dup(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && (defined(OPENSSL_EXTRA) || \ defined(OPENSSL_EXTRA_X509_SMALL)) @@ -45185,8 +44060,6 @@ static int test_wolfSSL_EC_KEY_dup(void) ecc_key* srcKey; ecc_key* destKey; - printf(testingFmt, "wolfSSL_EC_KEY_dup()"); - AssertNotNull(ecKey = wolfSSL_EC_KEY_new()); AssertIntEQ(wolfSSL_EC_KEY_generate_key(ecKey), 1); @@ -45269,14 +44142,14 @@ static int test_wolfSSL_EC_KEY_dup(void) wolfSSL_EC_KEY_free(ecKey); /* 2 */ wolfSSL_EC_KEY_free(ecKey); /* 1, free */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_set1_get1_DSA(void) { + int res = TEST_SKIPPED; #if !defined (NO_DSA) && !defined(HAVE_SELFTEST) && defined(WOLFSSL_KEY_GEN) DSA *dsa = NULL; DSA *setDsa = NULL; @@ -45315,9 +44188,6 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DSA(void) XFCLOSE(fp); #endif /* END USE_CERT_BUFFERS_1024 */ - printf(testingFmt, - "wolfSSL_EVP_PKEY_set1_DSA and wolfSSL_EVP_PKEY_get1_DSA"); - /* Create hash to later Sign and Verify */ AssertIntEQ(SHA1_Init(&sha), WOLFSSL_SUCCESS); AssertIntEQ(SHA1_Update(&sha, tmp, bytes), WOLFSSL_SUCCESS); @@ -45360,19 +44230,20 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DSA(void) /* Should Pass: set dsa into set1Pkey */ AssertIntEQ(EVP_PKEY_set1_DSA(set1Pkey, dsa), WOLFSSL_SUCCESS); - printf(resultFmt, passed); DSA_free(dsa); DSA_free(setDsa); EVP_PKEY_free(pkey); EVP_PKEY_free(set1Pkey); -#endif /* !NO_DSA && !HAVE_SELFTEST && WOLFSSL_KEY_GEN */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* !NO_DSA && !HAVE_SELFTEST && WOLFSSL_KEY_GEN */ + return res; } /* END test_EVP_PKEY_set1_get1_DSA */ static int test_wolfSSL_DSA_SIG(void) { + int res = TEST_SKIPPED; #if !defined(NO_DSA) && !defined(HAVE_SELFTEST) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_FIPS) DSA *dsa = NULL; @@ -45385,8 +44256,6 @@ static int test_wolfSSL_DSA_SIG(void) const BIGNUM *priv = NULL; const byte digest[WC_SHA_DIGEST_SIZE] = {0}; - printf(testingFmt, "wolfSSL_DSA_SIG"); - AssertNotNull(dsa = DSA_generate_parameters(2048, NULL, 0, NULL, NULL, NULL, NULL)); DSA_free(dsa); @@ -45408,25 +44277,22 @@ static int test_wolfSSL_DSA_SIG(void) AssertIntEQ(DSA_set0_key(dsa2, (BIGNUM*)pub, (BIGNUM*)priv), 1); AssertIntEQ(DSA_do_verify(digest, sizeof(digest), sig, dsa2), 1); - printf(resultFmt, passed); - DSA_free(dsa); DSA_free(dsa2); DSA_SIG_free(sig); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_set1_get1_EC_KEY (void) { + int res = TEST_SKIPPED; #ifdef HAVE_ECC WOLFSSL_EC_KEY *ecKey = NULL; WOLFSSL_EC_KEY *ecGet1 = NULL; EVP_PKEY *pkey = NULL; - printf(testingFmt, - "wolfSSL_EVP_PKEY_set1_EC_KEY and wolfSSL_EVP_PKEY_get1_EC_KEY"); AssertNotNull(ecKey = wolfSSL_EC_KEY_new()); AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); @@ -45446,15 +44312,14 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_EC_KEY (void) wolfSSL_EC_KEY_free(ecGet1); EVP_PKEY_free(pkey); - /* PASSED */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ - - return 0; + return res; } /* END test_EVP_PKEY_set1_get1_EC_KEY */ static int test_wolfSSL_EVP_PKEY_set1_get1_DH (void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) || defined(WOLFSSL_OPENSSH) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) #if !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) && !defined(NO_FILESYSTEM) @@ -45469,8 +44334,6 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DH (void) long len = 0; int code = -1; - printf(testingFmt,"wolfSSL_EVP_PKEY_set1_DH and wolfSSL_EVP_PKEY_get1_DH"); - XMEMSET(buf, 0, sizeof(buf)); f = XFOPEN(dh2048, "rb"); @@ -45499,16 +44362,17 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DH (void) EVP_PKEY_free(pkey); DH_free(setDh); DH_free(dh); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* !NO_DH && WOLFSSL_DH_EXTRA && !NO_FILESYSTEM */ #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* OPENSSL_ALL || WOLFSSL_QT || WOLFSSL_OPENSSH */ - - return 0; + return res; } /* END test_EVP_PKEY_set1_get1_DH */ static int test_wolfSSL_CTX_ctrl(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) char caFile[] = "./certs/client-ca.pem"; @@ -45527,7 +44391,6 @@ static int test_wolfSSL_CTX_ctrl(void) #ifdef HAVE_ECC WOLFSSL_EC_KEY* ecKey; #endif - printf(testingFmt, "wolfSSL_CTX_ctrl"); AssertNotNull(ctx = SSL_CTX_new(wolfSSLv23_server_method())); @@ -45675,15 +44538,16 @@ static int test_wolfSSL_CTX_ctrl(void) wolfSSL_EC_KEY_free(ecKey); #endif SSL_CTX_free(ctx); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) */ - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_assign(void) { + int res = TEST_SKIPPED; int type; WOLFSSL_EVP_PKEY* pkey; #ifndef NO_RSA @@ -45698,7 +44562,6 @@ static int test_wolfSSL_EVP_PKEY_assign(void) (void)pkey; - printf(testingFmt, "wolfSSL_EVP_PKEY_assign"); #ifndef NO_RSA type = EVP_PKEY_RSA; AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); @@ -45708,6 +44571,7 @@ static int test_wolfSSL_EVP_PKEY_assign(void) AssertIntEQ(wolfSSL_EVP_PKEY_assign(pkey,-1,rsa), WOLFSSL_FAILURE); AssertIntEQ(wolfSSL_EVP_PKEY_assign(pkey,type,rsa), WOLFSSL_SUCCESS); wolfSSL_EVP_PKEY_free(pkey); + res = TEST_RES_CHECK(1); #endif /* NO_RSA */ #ifndef NO_DSA @@ -45719,6 +44583,7 @@ static int test_wolfSSL_EVP_PKEY_assign(void) AssertIntEQ(wolfSSL_EVP_PKEY_assign(pkey,-1,dsa), WOLFSSL_FAILURE); AssertIntEQ(wolfSSL_EVP_PKEY_assign(pkey,type,dsa), WOLFSSL_SUCCESS); wolfSSL_EVP_PKEY_free(pkey); + res = TEST_RES_CHECK(1); #endif /* NO_DSA */ #ifdef HAVE_ECC @@ -45732,20 +44597,17 @@ static int test_wolfSSL_EVP_PKEY_assign(void) AssertIntEQ(wolfSSL_EC_KEY_generate_key(ecKey), 1); AssertIntEQ(wolfSSL_EVP_PKEY_assign(pkey,type,ecKey), WOLFSSL_SUCCESS); wolfSSL_EVP_PKEY_free(pkey); + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ (void)type; - printf(resultFmt, passed); - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_base_id(void) { WOLFSSL_EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_EVP_PKEY_base_id"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertIntEQ(wolfSSL_EVP_PKEY_base_id(NULL), NID_undef); @@ -45754,16 +44616,12 @@ static int test_wolfSSL_EVP_PKEY_base_id(void) EVP_PKEY_free(pkey); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_PKEY_id(void) { WOLFSSL_EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_EVP_PKEY_id"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertIntEQ(wolfSSL_EVP_PKEY_id(NULL), 0); @@ -45772,13 +44630,12 @@ static int test_wolfSSL_EVP_PKEY_id(void) EVP_PKEY_free(pkey); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_PKEY_paramgen(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && \ !defined(NO_ECC_SECP) && \ /* This last bit is taken from ecc.c. It is the condition that @@ -45788,8 +44645,6 @@ static int test_wolfSSL_EVP_PKEY_paramgen(void) EVP_PKEY_CTX* ctx; EVP_PKEY* pkey = NULL; - printf(testingFmt, "wolfSSL_EVP_PKEY_paramgen"); - /* Test error conditions. */ AssertIntEQ(EVP_PKEY_paramgen(NULL, &pkey), WOLFSSL_FAILURE); AssertNotNull(ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)); @@ -45818,10 +44673,9 @@ static int test_wolfSSL_EVP_PKEY_paramgen(void) EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_keygen(void) @@ -45838,8 +44692,6 @@ static int test_wolfSSL_EVP_PKEY_keygen(void) byte* derBuffer = NULL; #endif - printf(testingFmt, "wolfSSL_EVP_PKEY_keygen"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); @@ -45885,17 +44737,13 @@ static int test_wolfSSL_EVP_PKEY_keygen(void) } #endif - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_PKEY_keygen_init(void) { WOLFSSL_EVP_PKEY* pkey; EVP_PKEY_CTX *ctx; - printf(testingFmt, "wolfSSL_EVP_PKEY_keygen_init"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); @@ -45905,30 +44753,27 @@ static int test_wolfSSL_EVP_PKEY_keygen_init(void) EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_PKEY_missing_parameters(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_WOLFSSL_STUB) WOLFSSL_EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_EVP_PKEY_missing_parameters"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertIntEQ(wolfSSL_EVP_PKEY_missing_parameters(pkey), 0); EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_copy_parameters(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DH) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_SELFTEST) && (defined(OPENSSL_ALL) || defined(WOLFSSL_QT) || \ defined(WOLFSSL_OPENSSH)) && defined(WOLFSSL_DH_EXTRA) && \ @@ -45944,8 +44789,6 @@ static int test_wolfSSL_EVP_PKEY_copy_parameters(void) BIGNUM* g2; BIGNUM* q2; - printf(testingFmt, "wolfSSL_EVP_PKEY_copy_parameters"); - /* create DH with DH_get_2048_256 params */ AssertNotNull(params = wolfSSL_EVP_PKEY_new()); AssertNotNull(dh = DH_get_2048_256()); @@ -45978,11 +44821,11 @@ static int test_wolfSSL_EVP_PKEY_copy_parameters(void) EVP_PKEY_free(copy); EVP_PKEY_free(params); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits(void) { WOLFSSL_EVP_PKEY* pkey; @@ -45990,8 +44833,6 @@ static int test_wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits(void) int bits = 2048; - printf(testingFmt, "wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); @@ -46002,9 +44843,7 @@ static int test_wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits(void) EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_CIPHER_CTX_iv_length(void) @@ -46056,10 +44895,8 @@ static int test_wolfSSL_EVP_CIPHER_CTX_iv_length(void) }; - printf(testingFmt, "wolfSSL_EVP_CIPHER_CTX_iv_length"); enumlen = (sizeof(enumArray)/sizeof(int)); - for(i = 0; i < enumlen; i++) - { + for (i = 0; i < enumlen; i++) { ctx = EVP_CIPHER_CTX_new(); init = wolfSSL_EVP_get_cipherbynid(enumArray[i]); @@ -46071,34 +44908,33 @@ static int test_wolfSSL_EVP_CIPHER_CTX_iv_length(void) EVP_CIPHER_CTX_free(ctx); } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } + static int test_wolfSSL_EVP_CIPHER_CTX_key_length(void) { + int res = TEST_SKIPPED; #if !defined(NO_DES3) byte key[AES_256_KEY_SIZE] = {0}; byte iv[AES_BLOCK_SIZE] = {0}; EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); const EVP_CIPHER *init = EVP_des_ede3_cbc(); - printf(testingFmt, "wolfSSL_EVP_CIPHER_CTX_key_length"); - - wolfSSL_EVP_CIPHER_CTX_init(ctx); AssertIntEQ(EVP_CipherInit(ctx, init, key, iv, 1), WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_EVP_CIPHER_CTX_key_length(ctx), 24); EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } + static int test_wolfSSL_EVP_CIPHER_CTX_set_key_length(void) { + int res = TEST_SKIPPED; #if !defined(NO_DES3) byte key[AES_256_KEY_SIZE] = {0}; byte iv[AES_BLOCK_SIZE] = {0}; @@ -46106,10 +44942,6 @@ static int test_wolfSSL_EVP_CIPHER_CTX_set_key_length(void) EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); const EVP_CIPHER *init = EVP_des_ede3_cbc(); - printf(testingFmt, "wolfSSL_EVP_CIPHER_CTX_set_key_length"); - - - wolfSSL_EVP_CIPHER_CTX_init(ctx); AssertIntEQ(EVP_CipherInit(ctx, init, key, iv, 1), WOLFSSL_SUCCESS); @@ -46119,13 +44951,15 @@ static int test_wolfSSL_EVP_CIPHER_CTX_set_key_length(void) WOLFSSL_SUCCESS); EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } + static int test_wolfSSL_EVP_CIPHER_CTX_set_iv(void) { + int res = TEST_SKIPPED; #if defined(HAVE_AESGCM) && !defined(NO_DES3) byte key[DES3_KEY_SIZE] = {0}; byte iv[DES_BLOCK_SIZE] = {0}; @@ -46133,8 +44967,6 @@ static int test_wolfSSL_EVP_CIPHER_CTX_set_iv(void) EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); const EVP_CIPHER *init = EVP_des_ede3_cbc(); - printf(testingFmt, "wolfSSL_EVP_CIPHER_CTX_set_iv"); - wolfSSL_EVP_CIPHER_CTX_init(ctx); AssertIntEQ(EVP_CipherInit(ctx, init, key, iv, 1), WOLFSSL_SUCCESS); @@ -46151,143 +44983,99 @@ static int test_wolfSSL_EVP_CIPHER_CTX_set_iv(void) /* Good case */ AssertIntEQ(wolfSSL_EVP_CIPHER_CTX_set_iv(ctx, iv, ivLen), 1); - EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } + static int test_wolfSSL_EVP_PKEY_CTX_new_id(void) { WOLFSSL_ENGINE* e = NULL; int id = 0; EVP_PKEY_CTX *ctx; - printf(testingFmt, "wolfSSL_EVP_PKEY_CTX_new_id"); - AssertNotNull(ctx = wolfSSL_EVP_PKEY_CTX_new_id(id, e)); EVP_PKEY_CTX_free(ctx); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } + static int test_wolfSSL_EVP_rc4(void) { + int res = TEST_SKIPPED; #if !defined(NO_RC4) - - printf(testingFmt, "wolfSSL_EVP_rc4"); - - AssertNotNull(wolfSSL_EVP_rc4()); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(wolfSSL_EVP_rc4() != NULL); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_enc_null(void) { - printf(testingFmt, "wolfSSL_EVP_enc_null"); - - AssertNotNull(wolfSSL_EVP_enc_null()); - - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(wolfSSL_EVP_enc_null() != NULL); } static int test_wolfSSL_EVP_rc2_cbc(void) + { + int res = TEST_SKIPPED; #if defined(WOLFSSL_QT) && !defined(NO_WOLFSSL_STUB) - - printf(testingFmt, "wolfSSL_EVP_rc2_cbc"); - - AssertNull(wolfSSL_EVP_rc2_cbc()); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(wolfSSL_EVP_rc2_cbc() == NULL); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_mdc2(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_STUB) - - printf(testingFmt, "wolfSSL_EVP_mdc2"); - - AssertNull(wolfSSL_EVP_mdc2()); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(wolfSSL_EVP_mdc2() == NULL); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_md4(void) { + int res = TEST_SKIPPED; #if !defined(NO_MD4) - - printf(testingFmt, "wolfSSL_EVP_md4"); - - AssertNotNull(wolfSSL_EVP_md4()); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(wolfSSL_EVP_md4() != NULL); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_aes_256_gcm(void) { - - printf(testingFmt, "wolfSSL_EVP_aes_256_gcm"); - - AssertNotNull(wolfSSL_EVP_aes_256_gcm()); - - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(wolfSSL_EVP_aes_256_gcm() != NULL); } + static int test_wolfSSL_EVP_aes_192_gcm(void) { - printf(testingFmt, "wolfSSL_EVP_aes_192_gcm"); - - AssertNotNull(wolfSSL_EVP_aes_192_gcm()); - - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(wolfSSL_EVP_aes_192_gcm() != NULL); } + static int test_wolfSSL_EVP_ripemd160(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_STUB) - - printf(testingFmt, "wolfSSL_EVP_ripemd160"); - - AssertNull(wolfSSL_EVP_ripemd160()); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(wolfSSL_EVP_ripemd160() == NULL); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_get_digestbynid(void) { - printf(testingFmt, "wolfSSL_EVP_get_digestbynid"); - #ifndef NO_MD5 AssertNotNull(wolfSSL_EVP_get_digestbynid(NID_md5)); #endif AssertNotNull(wolfSSL_EVP_get_digestbynid(NID_sha1)); AssertNull(wolfSSL_EVP_get_digestbynid(0)); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } + static int test_wolfSSL_EVP_MD_nid(void) { - printf(testingFmt, "wolfSSL_EVP_MD_nid"); - #ifndef NO_MD5 AssertIntEQ(EVP_MD_nid(EVP_md5()), NID_md5); #endif @@ -46299,37 +45087,33 @@ static int test_wolfSSL_EVP_MD_nid(void) #endif AssertIntEQ(EVP_MD_nid(NULL), NID_undef); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } + static int test_wolfSSL_EVP_PKEY_get0_EC_KEY(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) WOLFSSL_EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_EVP_PKEY_get0_EC_KEY"); - AssertNotNull(pkey = EVP_PKEY_new()); AssertNull(EVP_PKEY_get0_EC_KEY(pkey)); EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_X_STATE(void) { + int res = TEST_SKIPPED; #if !defined(NO_DES3) && !defined(NO_RC4) - byte key[DES3_KEY_SIZE] = {0}; byte iv[DES_IV_SIZE] = {0}; EVP_CIPHER_CTX *ctx; const EVP_CIPHER *init; - printf(testingFmt, "wolfSSL_EVP_X_STATE"); - /* Bad test cases */ ctx = EVP_CIPHER_CTX_new(); init = EVP_des_ede3_cbc(); @@ -46351,23 +45135,19 @@ static int test_wolfSSL_EVP_X_STATE(void) AssertNotNull(wolfSSL_EVP_X_STATE(ctx)); EVP_CIPHER_CTX_free(ctx); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_X_STATE_LEN(void) { + int res = TEST_SKIPPED; #if !defined(NO_DES3) && !defined(NO_RC4) - byte key[DES3_KEY_SIZE] = {0}; byte iv[DES_IV_SIZE] = {0}; EVP_CIPHER_CTX *ctx; const EVP_CIPHER *init; - printf(testingFmt, "wolfSSL_EVP_X_STATE_LEN"); - /* Bad test cases */ ctx = EVP_CIPHER_CTX_new(); init = EVP_des_ede3_cbc(); @@ -46389,16 +45169,15 @@ static int test_wolfSSL_EVP_X_STATE_LEN(void) AssertIntEQ(wolfSSL_EVP_X_STATE_LEN(ctx), sizeof(Arc4)); EVP_CIPHER_CTX_free(ctx); - - - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_CIPHER_block_size(void) { + int res = TEST_SKIPPED; + #ifdef HAVE_AES_CBC #ifdef WOLFSSL_AES_128 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_cbc()), AES_BLOCK_SIZE); @@ -46409,6 +45188,7 @@ static int test_wolfSSL_EVP_CIPHER_block_size(void) #ifdef WOLFSSL_AES_256 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_cbc()), AES_BLOCK_SIZE); #endif + res = TEST_RES_CHECK(1); #endif #ifdef HAVE_AESGCM @@ -46421,6 +45201,7 @@ static int test_wolfSSL_EVP_CIPHER_block_size(void) #ifdef WOLFSSL_AES_256 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_gcm()), 1); #endif + res = TEST_RES_CHECK(1); #endif #ifdef WOLFSSL_AES_COUNTER @@ -46433,6 +45214,7 @@ static int test_wolfSSL_EVP_CIPHER_block_size(void) #ifdef WOLFSSL_AES_256 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ctr()), 1); #endif + res = TEST_RES_CHECK(1); #endif #ifdef HAVE_AES_ECB @@ -46445,6 +45227,7 @@ static int test_wolfSSL_EVP_CIPHER_block_size(void) #ifdef WOLFSSL_AES_256 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ecb()), AES_BLOCK_SIZE); #endif + res = TEST_RES_CHECK(1); #endif #ifdef WOLFSSL_AES_OFB @@ -46457,17 +45240,20 @@ static int test_wolfSSL_EVP_CIPHER_block_size(void) #ifdef WOLFSSL_AES_256 AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ofb()), 1); #endif + res = TEST_RES_CHECK(1); #endif #ifndef NO_RC4 AssertIntEQ(EVP_CIPHER_block_size(wolfSSL_EVP_rc4()), 1); + res = TEST_RES_CHECK(1); #endif #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) AssertIntEQ(EVP_CIPHER_block_size(wolfSSL_EVP_chacha20_poly1305()), 1); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_EVP_CIPHER_iv_length(void) @@ -46567,18 +45353,15 @@ static int test_wolfSSL_EVP_CIPHER_iv_length(void) #endif }; - printf(testingFmt, "wolfSSL_EVP_CIPHER_iv_length"); enumlen = (sizeof(enumArray)/sizeof(int)); - for(i = 0; i < enumlen; i++) - { + for (i = 0; i < enumlen; i++) { const EVP_CIPHER *c = EVP_get_cipherbynid(enumArray[i]); AssertIntEQ(EVP_CIPHER_iv_length(c), iv_lengths[i]); } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } + static int test_wolfSSL_EVP_SignInit_ex(void) { WOLFSSL_EVP_MD_CTX mdCtx; @@ -46586,29 +45369,22 @@ static int test_wolfSSL_EVP_SignInit_ex(void) const EVP_MD* md; md = "SHA256"; - printf(testingFmt, "wolfSSL_EVP_SignInit_ex"); - wolfSSL_EVP_MD_CTX_init(&mdCtx); AssertIntEQ(wolfSSL_EVP_SignInit_ex(&mdCtx, md, e), WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_EVP_DigestFinal_ex(void) { + int res = TEST_SKIPPED; #if !defined(NO_SHA256) WOLFSSL_EVP_MD_CTX mdCtx; unsigned int s = 0; unsigned char md[WC_SHA256_DIGEST_SIZE]; unsigned char md2[WC_SHA256_DIGEST_SIZE]; - - printf(testingFmt, "wolfSSL_EVP_DigestFinal_ex"); - - /* Bad Case */ #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)) @@ -46630,14 +45406,13 @@ static int test_wolfSSL_EVP_DigestFinal_ex(void) AssertIntEQ(wolfSSL_EVP_DigestFinal_ex(&mdCtx, md2, &s), WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), WOLFSSL_SUCCESS); - - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_assign_DH(void) { + int res = TEST_SKIPPED; #if !defined(NO_DH) && \ !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)) FILE* f = NULL; @@ -46656,8 +45431,6 @@ static int test_wolfSSL_EVP_PKEY_assign_DH(void) XFCLOSE(f); - printf(testingFmt, "wolfSSL_EVP_PKEY_assign_DH"); - AssertNotNull(dh = wolfSSL_d2i_DHparams(NULL, &pt, len)); AssertIntEQ(DH_generate_key(dh), WOLFSSL_SUCCESS); @@ -46671,22 +45444,20 @@ static int test_wolfSSL_EVP_PKEY_assign_DH(void) /* Good case */ AssertIntEQ(wolfSSL_EVP_PKEY_assign_DH(pkey, dh), WOLFSSL_SUCCESS); - EVP_PKEY_free(pkey); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_QT_EVP_PKEY_CTX_free(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) EVP_PKEY* pkey; EVP_PKEY_CTX* ctx; - printf(testingFmt, "test_wolfSSL_QT_EVP_PKEY_CTX_free"); - AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); AssertNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL)); @@ -46700,13 +45471,15 @@ static int test_wolfSSL_QT_EVP_PKEY_CTX_free(void) #endif EVP_PKEY_free(pkey); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } + static int test_wolfSSL_EVP_PKEY_param_check(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) #if !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) && !defined(NO_FILESYSTEM) @@ -46722,8 +45495,6 @@ static int test_wolfSSL_EVP_PKEY_param_check(void) long len = 0; int code = -1; - printf(testingFmt, "test_wolfSSL_EVP_PKEY_param_check"); - XMEMSET(buf, 0, sizeof(buf)); f = XFOPEN(dh2048, "rb"); @@ -46753,14 +45524,15 @@ static int test_wolfSSL_EVP_PKEY_param_check(void) DH_free(setDh); DH_free(dh); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } + static int test_wolfSSL_EVP_BytesToKey(void) { + int res = TEST_SKIPPED; #if !defined(NO_AES) && defined(HAVE_AES_CBC) byte key[AES_BLOCK_SIZE] = {0}; byte iv[AES_BLOCK_SIZE] = {0}; @@ -46776,8 +45548,6 @@ static int test_wolfSSL_EVP_BytesToKey(void) type = wolfSSL_EVP_get_cipherbynid(NID_aes_128_cbc); - printf(testingFmt, "EVP_BytesToKey"); - /* Bad cases */ AssertIntEQ(EVP_BytesToKey(NULL, md, salt, data, sz, count, key, iv), 0); @@ -46792,13 +45562,14 @@ static int test_wolfSSL_EVP_BytesToKey(void) AssertIntEQ(EVP_BytesToKey(type, md, salt, data, sz, count, key, iv), 16); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } + static int test_evp_cipher_aes_gcm(void) { + int res = TEST_SKIPPED; #if defined(HAVE_AESGCM) && ((!defined(HAVE_FIPS) && \ !defined(HAVE_SELFTEST)) || (defined(HAVE_FIPS_VERSION) && \ (HAVE_FIPS_VERSION >= 2))) @@ -46920,8 +45691,6 @@ static int test_evp_cipher_aes_gcm(void) EVP_CIPHER_CTX* decCtx = NULL; int i, j, outl; - printf(testingFmt, "test_evp_cipher_aes_gcm"); - /****************************************************/ for (i = 0; i < 3; ++i) { AssertNotNull(encCtx = EVP_CIPHER_CTX_new()); @@ -46996,7 +45765,7 @@ static int test_evp_cipher_aes_gcm(void) DYNAMIC_TYPE_TMP_BUFFER)); /* Encrypt plaintext. */ - if (i == 2){ + if (i == 2) { AssertIntEQ(EVP_CipherUpdate(encCtx, cipherText, &outl, plainTexts[j], plainTextSzs[j]), SSL_SUCCESS); @@ -47051,7 +45820,7 @@ static int test_evp_cipher_aes_gcm(void) /* Decrypt ciphertext. */ AssertNotNull(calcPlainText = (byte*)XMALLOC(plainTextSzs[j], NULL, DYNAMIC_TYPE_TMP_BUFFER)); - if (i == 2){ + if (i == 2) { AssertIntEQ(EVP_CipherUpdate(decCtx, calcPlainText, &outl, cipherText, plainTextSzs[j]), SSL_SUCCESS); @@ -47082,10 +45851,9 @@ static int test_evp_cipher_aes_gcm(void) EVP_CIPHER_CTX_free(decCtx); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OBJ_ln(void) { @@ -47119,8 +45887,6 @@ static int test_wolfSSL_OBJ_ln(void) }; size_t i = 0, maxIdx = sizeof(ln_set)/sizeof(char*); - printf(testingFmt, "wolfSSL_OBJ_ln"); - AssertIntEQ(OBJ_ln2nid(NULL), NID_undef); #ifdef HAVE_ECC @@ -47146,9 +45912,7 @@ static int test_wolfSSL_OBJ_ln(void) AssertStrEQ(OBJ_nid2ln(nid_set[i]), ln_set[i]); } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static int test_wolfSSL_OBJ_sn(void) @@ -47163,17 +45927,13 @@ static int test_wolfSSL_OBJ_sn(void) WOLFSSL_ORG_NAME, WOLFSSL_ORGUNIT_NAME, WOLFSSL_EMAIL_ADDR}; - printf(testingFmt, "wolfSSL_OBJ_sn"); - AssertIntEQ(wolfSSL_OBJ_sn2nid(NULL), NID_undef); for (i = 0; i < maxIdx; i++) { AssertIntEQ(wolfSSL_OBJ_sn2nid(sn_wolf_set[i]), nid_set[i]); AssertStrEQ(wolfSSL_OBJ_nid2sn(nid_set[i]), sn_open_set[i]); } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } #if !defined(NO_BIO) @@ -47190,6 +45950,7 @@ static int TXT_DB_cmp(const WOLFSSL_STRING *a, const WOLFSSL_STRING *b) static int test_wolfSSL_TXT_DB(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_BIO) BIO *bio; TXT_DB *db = NULL; @@ -47204,8 +45965,6 @@ static int test_wolfSSL_TXT_DB(void) }; char** fields_copy; - printf(testingFmt, "wolfSSL_TXT_DB"); - /* Test read */ AssertNotNull(bio = BIO_new(BIO_s_file())); AssertIntGT(BIO_read_filename(bio, "./tests/TXT_DB.txt"), 0); @@ -47234,22 +45993,20 @@ static int test_wolfSSL_TXT_DB(void) TXT_DB_free(db); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_NCONF(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_BIO) const char* confFile = "./tests/NCONF_test.cnf"; CONF* conf = NULL; long eline = 0; long num = 0; - printf(testingFmt, "wolfSSL_NCONF"); - AssertNotNull(conf = NCONF_new(NULL)); AssertIntEQ(NCONF_load(conf, confFile, &eline), 1); @@ -47265,23 +46022,21 @@ static int test_wolfSSL_NCONF(void) NCONF_free(conf); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif /* OPENSSL_ALL */ static int test_wolfSSL_EC_KEY_set_group(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_ECC256) && !defined(NO_ECC_SECP) && \ defined(OPENSSL_EXTRA) EC_KEY *key = NULL; EC_GROUP *group = NULL; const EC_GROUP *group2 = NULL; - printf(testingFmt, "wolfSSL_EC_KEY_dup()"); - AssertNotNull(group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)); AssertNotNull(key = EC_KEY_new()); AssertIntEQ(EC_KEY_set_group(key, group), WOLFSSL_SUCCESS); @@ -47291,20 +46046,18 @@ static int test_wolfSSL_EC_KEY_set_group(void) EC_GROUP_free(group); EC_KEY_free(key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EC_KEY_set_conv_form(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && defined(OPENSSL_EXTRA) && !defined(NO_BIO) BIO* bio; EC_KEY* key; - printf(testingFmt, "test_wolfSSL_EC_KEY_set_conv_form"); - /* Error condition: NULL key. */ AssertIntLT(EC_KEY_get_conv_form(NULL), 0); @@ -47321,48 +46074,46 @@ static int test_wolfSSL_EC_KEY_set_conv_form(void) BIO_free(bio); EC_KEY_free(key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EC_KEY_print_fp(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && ((defined(HAVE_ECC224) && defined(HAVE_ECC256)) || \ defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256 && \ defined(OPENSSL_EXTRA) && defined(XFPRINTF) && !defined(NO_FILESYSTEM) && \ !defined(NO_STDIO_FILESYSTEM) EC_KEY* key = NULL; - printf(testingFmt, "test_wolfSSL_EC_KEY_print_fp"); - /* Bad file pointer. */ AssertIntEQ(wolfSSL_EC_KEY_print_fp(NULL, key, 0), WOLFSSL_FAILURE); /* NULL key. */ - AssertIntEQ(wolfSSL_EC_KEY_print_fp(stdout, NULL, 0), WOLFSSL_FAILURE); + AssertIntEQ(wolfSSL_EC_KEY_print_fp(stderr, NULL, 0), WOLFSSL_FAILURE); AssertNotNull((key = wolfSSL_EC_KEY_new_by_curve_name(NID_secp224r1))); /* Negative indent. */ - AssertIntEQ(wolfSSL_EC_KEY_print_fp(stdout, key, -1), WOLFSSL_FAILURE); + AssertIntEQ(wolfSSL_EC_KEY_print_fp(stderr, key, -1), WOLFSSL_FAILURE); - AssertIntEQ(wolfSSL_EC_KEY_print_fp(stdout, key, 4), WOLFSSL_SUCCESS); + AssertIntEQ(wolfSSL_EC_KEY_print_fp(stderr, key, 4), WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_EC_KEY_generate_key(key), WOLFSSL_SUCCESS); - AssertIntEQ(wolfSSL_EC_KEY_print_fp(stdout, key, 4), WOLFSSL_SUCCESS); + AssertIntEQ(wolfSSL_EC_KEY_print_fp(stderr, key, 4), WOLFSSL_SUCCESS); wolfSSL_EC_KEY_free(key); AssertNotNull((key = wolfSSL_EC_KEY_new_by_curve_name( NID_X9_62_prime256v1))); AssertIntEQ(wolfSSL_EC_KEY_generate_key(key), WOLFSSL_SUCCESS); - AssertIntEQ(wolfSSL_EC_KEY_print_fp(stdout, key, 4), WOLFSSL_SUCCESS); + AssertIntEQ(wolfSSL_EC_KEY_print_fp(stderr, key, 4), WOLFSSL_SUCCESS); wolfSSL_EC_KEY_free(key); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509V3_EXT_get(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) FILE* f; int numOfExt =0; @@ -47376,7 +46127,7 @@ static int test_wolfSSL_X509V3_EXT_get(void) { AssertNotNull(x509 = wolfSSL_PEM_read_X509(f, NULL, NULL, NULL)); fclose(f); - printf(testingFmt, "wolfSSL_X509V3_EXT_get() return struct and nid test"); + /* wolfSSL_X509V3_EXT_get() return struct and nid test */ AssertIntEQ((numOfExt = wolfSSL_X509_get_ext_count(x509)), 5); for (i = 0; i < numOfExt; i++) { AssertNotNull(ext = wolfSSL_X509_get_ext(x509, i)); @@ -47384,20 +46135,20 @@ static int test_wolfSSL_X509V3_EXT_get(void) { AssertNotNull(method = wolfSSL_X509V3_EXT_get(ext)); AssertIntEQ(method->ext_nid, extNid); } - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_X509V3_EXT_get() NULL argument test"); + /* wolfSSL_X509V3_EXT_get() NULL argument test */ AssertNull(method = wolfSSL_X509V3_EXT_get(NULL)); - printf(resultFmt, "passed"); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509V3_EXT_nconf(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL const char *ext_names[] = { "subjectKeyIdentifier", @@ -47423,8 +46174,6 @@ static int test_wolfSSL_X509V3_EXT_nconf(void) X509_EXTENSION* ext; X509* x509 = X509_new(); - printf(testingFmt, "wolfSSL_X509V3_EXT_nconf()"); - for (i = 0; i < ext_names_count; i++) { ext = X509V3_EXT_nconf(NULL, NULL, ext_names[i], ext_values[i]); AssertNotNull(ext); @@ -47445,13 +46194,13 @@ static int test_wolfSSL_X509V3_EXT_nconf(void) } X509_free(x509); - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509V3_EXT(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) FILE* f; int numOfExt = 0, nid = 0, i = 0, expected, actual; @@ -47469,8 +46218,6 @@ static int test_wolfSSL_X509V3_EXT(void) { WOLFSSL_ACCESS_DESCRIPTION* ad; WOLFSSL_GENERAL_NAME* gn; - printf(testingFmt, "wolfSSL_X509V3_EXT_d2i()"); - /* Check NULL argument */ AssertNull(wolfSSL_X509V3_EXT_d2i(NULL)); @@ -47590,14 +46337,15 @@ static int test_wolfSSL_X509V3_EXT(void) { (void) aia; (void) ad; (void) adObj; (void) gn; #endif wolfSSL_X509_free(x509); - printf(resultFmt, "passed"); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_get_extension_flags(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) XFILE f; X509* x509; @@ -47605,8 +46353,6 @@ static int test_wolfSSL_X509_get_extension_flags(void) unsigned int keyUsageFlags; unsigned int extKeyUsageFlags; - printf(testingFmt, "test_wolfSSL_X509_get_extension_flags"); - /* client-int-cert.pem has the following extension flags. */ extFlags = EXFLAG_KUSAGE | EXFLAG_XKUSAGE; /* and the following key usage flags. */ @@ -47639,13 +46385,14 @@ static int test_wolfSSL_X509_get_extension_flags(void) AssertIntEQ(X509_get_key_usage(x509), keyUsageFlags); X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL */ - - return 0; + return res; } -static int test_wolfSSL_X509_get_ext(void){ +static int test_wolfSSL_X509_get_ext(void) +{ + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) int ret = 0; FILE* f; @@ -47657,32 +46404,30 @@ static int test_wolfSSL_X509_get_ext(void){ fclose(f); AssertIntEQ((ret = wolfSSL_X509_get_ext_count(x509)), 5); - printf(testingFmt, "wolfSSL_X509_get_ext() valid input"); + /* wolfSSL_X509_get_ext() valid input */ AssertNotNull(foundExtension = wolfSSL_X509_get_ext(x509, 0)); - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_X509_get_ext() valid x509, idx out of bounds"); + /* wolfSSL_X509_get_ext() valid x509, idx out of bounds */ AssertNull(foundExtension = wolfSSL_X509_get_ext(x509, -1)); AssertNull(foundExtension = wolfSSL_X509_get_ext(x509, 100)); - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_X509_get_ext() NULL x509, idx out of bounds"); + /* wolfSSL_X509_get_ext() NULL x509, idx out of bounds */ AssertNull(foundExtension = wolfSSL_X509_get_ext(NULL, -1)); AssertNull(foundExtension = wolfSSL_X509_get_ext(NULL, 100)); - printf(resultFmt, "passed"); - printf(testingFmt, "wolfSSL_X509_get_ext() NULL x509, valid idx"); + /* wolfSSL_X509_get_ext() NULL x509, valid idx */ AssertNull(foundExtension = wolfSSL_X509_get_ext(NULL, 0)); - printf(resultFmt, "passed"); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_get_ext_by_NID(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) int rc; FILE* f; @@ -47717,13 +46462,15 @@ static int test_wolfSSL_X509_get_ext_by_NID(void) AssertIntEQ(obj->type, EXT_KEY_USAGE_OID); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_get_ext_subj_alt_name(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) int rc; XFILE f; @@ -47736,8 +46483,6 @@ static int test_wolfSSL_X509_get_ext_subj_alt_name(void) 0x30, 0x13, 0x82, 0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x87, 0x04, 0x7f, 0x00, 0x00, 0x01}; - printf(testingFmt, "test_wolfSSL_X509_get_ext_subj_alt_name"); - f = XFOPEN("./certs/server-cert.pem", "rb"); AssertTrue(f != XBADFILE); AssertNotNull(x509 = PEM_read_X509(f, NULL, NULL, NULL)); @@ -47753,14 +46498,14 @@ static int test_wolfSSL_X509_get_ext_subj_alt_name(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_EXTENSION_new(void) { + int res = TEST_SKIPPED; #if defined (OPENSSL_ALL) WOLFSSL_X509_EXTENSION* ext; @@ -47770,75 +46515,72 @@ static int test_wolfSSL_X509_EXTENSION_new(void) AssertIntEQ(WOLFSSL_SUCCESS, ext->obj->nid); wolfSSL_X509_EXTENSION_free(ext); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_EXTENSION_get_object(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) WOLFSSL_X509* x509; WOLFSSL_X509_EXTENSION* ext; WOLFSSL_ASN1_OBJECT* o; FILE* file; - int nid = 0; AssertNotNull(file = fopen("./certs/server-cert.pem", "rb")); AssertNotNull(x509 = wolfSSL_PEM_read_X509(file, NULL, NULL, NULL)); fclose(file); - printf(testingFmt, "wolfSSL_X509_EXTENSION_get_object() testing ext idx 0"); + /* wolfSSL_X509_EXTENSION_get_object() testing ext idx 0 */ AssertNotNull(ext = wolfSSL_X509_get_ext(x509, 0)); AssertNotNull(o = wolfSSL_X509_EXTENSION_get_object(ext)); AssertIntEQ(o->nid, 128); - nid = o->nid; - printf(resultFmt, nid == 128 ? passed : failed); - printf(testingFmt, "wolfSSL_X509_EXTENSION_get_object() NULL argument"); + /* wolfSSL_X509_EXTENSION_get_object() NULL argument */ AssertNull(o = wolfSSL_X509_EXTENSION_get_object(NULL)); - printf(resultFmt, passed); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_EXTENSION_get_data(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) WOLFSSL_X509* x509; WOLFSSL_X509_EXTENSION* ext; WOLFSSL_ASN1_STRING* str; FILE* file; - printf(testingFmt, "wolfSSL_X509_EXTENSION_get_data"); - AssertNotNull(file = fopen("./certs/server-cert.pem", "rb")); AssertNotNull(x509 = wolfSSL_PEM_read_X509(file, NULL, NULL, NULL)); fclose(file); AssertNotNull(ext = wolfSSL_X509_get_ext(x509, 0)); AssertNotNull(str = wolfSSL_X509_EXTENSION_get_data(ext)); - printf(resultFmt, passed); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_EXTENSION_get_critical(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_RSA) WOLFSSL_X509* x509; WOLFSSL_X509_EXTENSION* ext; FILE* file; int crit; - printf(testingFmt, "wolfSSL_X509_EXTENSION_get_critical"); - AssertNotNull(file = fopen("./certs/server-cert.pem", "rb")); AssertNotNull(x509 = wolfSSL_PEM_read_X509(file, NULL, NULL, NULL)); fclose(file); @@ -47846,19 +46588,19 @@ static int test_wolfSSL_X509_EXTENSION_get_critical(void) crit = wolfSSL_X509_EXTENSION_get_critical(ext); AssertIntEQ(crit, 0); - printf(resultFmt, passed); wolfSSL_X509_free(x509); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509V3_EXT_print(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && defined(OPENSSL_ALL) && !defined(NO_BIO) && \ !defined(NO_RSA) - printf(testingFmt, "wolfSSL_X509V3_EXT_print"); { FILE* f; @@ -47907,12 +46649,12 @@ static int test_wolfSSL_X509V3_EXT_print(void) }; int* n; - AssertNotNull(bio = BIO_new_fp(stdout, BIO_NOCLOSE)); + AssertNotNull(bio = BIO_new_fp(stderr, BIO_NOCLOSE)); AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(cliCertFileExt, WOLFSSL_FILETYPE_PEM)); - printf("\nPrinting extension values:\n"); + fprintf(stderr, "\nPrinting extension values:\n"); for (i = 0, n = nids; i<(sizeof(nids)/sizeof(int)); i++, n++) { /* X509_get_ext_by_NID should return 3 for now. If that changes then @@ -47920,26 +46662,26 @@ static int test_wolfSSL_X509V3_EXT_print(void) AssertIntEQ((idx = X509_get_ext_by_NID(x509, *n, -1)), 3); AssertNotNull(ext = X509_get_ext(x509, idx)); AssertIntEQ(X509V3_EXT_print(bio, ext, 0, 0), 1); - printf("\n"); + fprintf(stderr, "\n"); } BIO_free(bio); X509_free(x509); } - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_cmp(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_RSA) FILE* file1; FILE* file2; WOLFSSL_X509* cert1; WOLFSSL_X509* cert2; - int ret = 0; AssertNotNull(file1=fopen("./certs/server-cert.pem", "rb")); AssertNotNull(file2=fopen("./certs/3072/client-cert.pem", "rb")); @@ -47949,44 +46691,34 @@ static int test_wolfSSL_X509_cmp(void) fclose(file1); fclose(file2); - printf(testingFmt, "wolfSSL_X509_cmp() testing matching certs"); - ret = wolfSSL_X509_cmp(cert1, cert1); + /* wolfSSL_X509_cmp() testing matching certs */ AssertIntEQ(0, wolfSSL_X509_cmp(cert1, cert1)); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); - printf(testingFmt, "wolfSSL_X509_cmp() testing mismatched certs"); - ret = wolfSSL_X509_cmp(cert1, cert2); + /* wolfSSL_X509_cmp() testing mismatched certs */ AssertIntEQ(-1, wolfSSL_X509_cmp(cert1, cert2)); - printf(resultFmt, ret == -1 ? passed : failed); - printf(testingFmt, "wolfSSL_X509_cmp() testing NULL, valid args"); - ret = wolfSSL_X509_cmp(NULL, cert2); + /* wolfSSL_X509_cmp() testing NULL, valid args */ AssertIntEQ(BAD_FUNC_ARG, wolfSSL_X509_cmp(NULL, cert2)); - printf(resultFmt, ret == BAD_FUNC_ARG ? passed : failed); - printf(testingFmt, "wolfSSL_X509_cmp() testing valid, NULL args"); - ret = wolfSSL_X509_cmp(cert1, NULL); + /* wolfSSL_X509_cmp() testing valid, NULL args */ AssertIntEQ(BAD_FUNC_ARG, wolfSSL_X509_cmp(cert1, NULL)); - printf(resultFmt, ret == BAD_FUNC_ARG ? passed : failed); - printf(testingFmt, "wolfSSL_X509_cmp() testing NULL, NULL args"); - ret = wolfSSL_X509_cmp(NULL, NULL); + /* wolfSSL_X509_cmp() testing NULL, NULL args */ AssertIntEQ(BAD_FUNC_ARG, wolfSSL_X509_cmp(NULL, NULL)); - printf(resultFmt, ret == BAD_FUNC_ARG ? passed : failed); wolfSSL_X509_free(cert1); wolfSSL_X509_free(cert2); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_PKEY_up_ref(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) EVP_PKEY* pkey; - printf(testingFmt, "wolfSSL_PKEY_up_ref()"); pkey = EVP_PKEY_new(); AssertIntEQ(EVP_PKEY_up_ref(NULL), 0); @@ -47996,22 +46728,20 @@ static int test_wolfSSL_PKEY_up_ref(void) EVP_PKEY_free(pkey); EVP_PKEY_free(pkey); - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_d2i_and_i2d_PublicKey(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) EVP_PKEY* pkey; const unsigned char* p; unsigned char* der = NULL; int derLen; - printf(testingFmt, "test_wolfSSL_d2i_and_i2d_PublicKey()"); - p = client_keypub_der_2048; /* Check that key can be successfully decoded. */ AssertNotNull(pkey = wolfSSL_d2i_PublicKey(EVP_PKEY_RSA, NULL, &p, @@ -48025,14 +46755,14 @@ static int test_wolfSSL_d2i_and_i2d_PublicKey(void) XFREE(der, HEAP_HINT, DYNAMIC_TYPE_OPENSSL); EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_d2i_and_i2d_DSAparams(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DSA) DSA* dsa; char file[] = "./certs/dsaparams.der"; @@ -48042,8 +46772,6 @@ static int test_wolfSSL_d2i_and_i2d_DSAparams(void) int derOutLen; byte* derOut = NULL; - printf(testingFmt, "test_wolfSSL_d2i_and_i2d_DSAparams()"); - f = XFOPEN(file, "rb"); AssertTrue(f != XBADFILE); AssertTrue(XFSEEK(f, 0, XSEEK_END) == 0); @@ -48066,17 +46794,16 @@ static int test_wolfSSL_d2i_and_i2d_DSAparams(void) XFREE(derOut, HEAP_HINT, DYNAMIC_TYPE_OPENSSL); DSA_free(dsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_i2d_PrivateKey(void) { + int res = TEST_SKIPPED; #if (!defined(NO_RSA) || defined(HAVE_ECC)) && defined(OPENSSL_EXTRA) && !defined(NO_ASN) && !defined(NO_PWDBASED) - printf(testingFmt, "wolfSSL_i2d_PrivateKey()"); #if !defined(NO_RSA) && defined(USE_CERT_BUFFERS_2048) { EVP_PKEY* pkey; @@ -48115,14 +46842,14 @@ static int test_wolfSSL_i2d_PrivateKey(void) } #endif - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_id_get0_info(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY)) && defined(HAVE_OCSP) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) X509* cert; @@ -48136,8 +46863,6 @@ static int test_wolfSSL_OCSP_id_get0_info(void) ASN1_INTEGER* serial = NULL; ASN1_INTEGER* x509Int; - printf(testingFmt, "wolfSSL_OCSP_id_get0_info()"); - AssertNotNull(cert = wolfSSL_X509_load_certificate_file(svrCertFile, SSL_FILETYPE_PEM)); AssertNotNull(issuer = @@ -48178,14 +46903,14 @@ static int test_wolfSSL_OCSP_id_get0_info(void) X509_free(cert); /* free's x509Int */ X509_free(issuer); - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_i2d_OCSP_CERTID(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY)) && defined(HAVE_OCSP) WOLFSSL_OCSP_CERTID certId; byte* targetBuffer; @@ -48202,8 +46927,6 @@ static int test_wolfSSL_i2d_OCSP_CERTID(void) }; int ret, i; - printf(testingFmt, "wolfSSL_i2d_OCSP_CERTID()"); - XMEMSET(&certId, 0, sizeof(WOLFSSL_OCSP_CERTID)); certId.rawCertId = rawCertId; certId.rawCertIdSize = sizeof(rawCertId); @@ -48235,14 +46958,14 @@ static int test_wolfSSL_i2d_OCSP_CERTID(void) XFREE(targetBuffer, NULL, DYNAMIC_TYPE_OPENSSL); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_d2i_OCSP_CERTID(void) { + int res = TEST_SKIPPED; #if (defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY)) && defined(HAVE_OCSP) WOLFSSL_OCSP_CERTID* certId; WOLFSSL_OCSP_CERTID* certIdBad; @@ -48260,8 +46983,6 @@ static int test_wolfSSL_d2i_OCSP_CERTID(void) rawCertIdPtr = &rawCertId[0]; - printf(testingFmt, "wolfSSL_d2i_OCSP_CERTID()"); - /* If the cert ID is NULL the function should allocate it and copy the * data to it. */ certId = NULL; @@ -48300,31 +47021,30 @@ static int test_wolfSSL_d2i_OCSP_CERTID(void) certIdBad = wolfSSL_d2i_OCSP_CERTID(&certId, &rawCertIdPtr, 0); AssertNull(certIdBad); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_id_cmp(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_OCSP) OCSP_CERTID id1; OCSP_CERTID id2; - printf(testingFmt, "wolfSSL_OCSP_id_cmp()"); XMEMSET(&id1, 0, sizeof(id1)); XMEMSET(&id2, 0, sizeof(id2)); AssertIntEQ(OCSP_id_cmp(&id1, &id2), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_SINGLERESP_get0_id(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_OCSP) WOLFSSL_OCSP_SINGLERESP single; const WOLFSSL_OCSP_CERTID* certId; @@ -48332,18 +47052,16 @@ static int test_wolfSSL_OCSP_SINGLERESP_get0_id(void) XMEMSET(&single, 0, sizeof(single)); certId = wolfSSL_OCSP_SINGLERESP_get0_id(&single); - printf(testingFmt, "wolfSSL_OCSP_SINGLERESP_get0_id()"); - AssertPtrEq(&single, certId); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_single_get0_status(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_OCSP) WOLFSSL_OCSP_SINGLERESP single; CertStatus certStatus; @@ -48351,8 +47069,6 @@ static int test_wolfSSL_OCSP_single_get0_status(void) WOLFSSL_ASN1_TIME* nextDate; int ret, i; - printf(testingFmt, "wolfSSL_OCSP_single_get0_status()"); - XMEMSET(&single, 0, sizeof(WOLFSSL_OCSP_SINGLERESP)); XMEMSET(&certStatus, 0, sizeof(CertStatus)); @@ -48370,22 +47086,20 @@ static int test_wolfSSL_OCSP_single_get0_status(void) AssertPtrEq(thisDate, &certStatus.thisDateParsed); AssertPtrEq(nextDate, &certStatus.nextDateParsed); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_resp_count(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_OCSP) WOLFSSL_OCSP_BASICRESP basicResp; WOLFSSL_OCSP_SINGLERESP singleRespOne; WOLFSSL_OCSP_SINGLERESP singleRespTwo; int count; - printf(testingFmt, "wolfSSL_OCSP_resp_count()"); - XMEMSET(&basicResp, 0, sizeof(WOLFSSL_OCSP_BASICRESP)); XMEMSET(&singleRespOne, 0, sizeof(WOLFSSL_OCSP_SINGLERESP)); XMEMSET(&singleRespTwo, 0, sizeof(WOLFSSL_OCSP_SINGLERESP)); @@ -48401,22 +47115,20 @@ static int test_wolfSSL_OCSP_resp_count(void) count = wolfSSL_OCSP_resp_count(&basicResp); AssertIntEQ(count, 2); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_OCSP_resp_get0(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_OCSP) WOLFSSL_OCSP_BASICRESP basicResp; WOLFSSL_OCSP_SINGLERESP singleRespOne; WOLFSSL_OCSP_SINGLERESP singleRespTwo; WOLFSSL_OCSP_SINGLERESP* ret; - printf(testingFmt, "wolfSSL_OCSP_resp_get0()"); - XMEMSET(&basicResp, 0, sizeof(WOLFSSL_OCSP_BASICRESP)); XMEMSET(&singleRespOne, 0, sizeof(WOLFSSL_OCSP_SINGLERESP)); XMEMSET(&singleRespTwo, 0, sizeof(WOLFSSL_OCSP_SINGLERESP)); @@ -48430,14 +47142,14 @@ static int test_wolfSSL_OCSP_resp_get0(void) ret = wolfSSL_OCSP_resp_get0(&basicResp, 1); AssertPtrEq(ret, &singleRespTwo); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_derive(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) || defined(WOLFSSL_OPENSSH) #if (!defined(NO_DH) && defined(WOLFSSL_DH_EXTRA)) || defined(HAVE_ECC) @@ -48447,8 +47159,6 @@ static int test_wolfSSL_EVP_PKEY_derive(void) EVP_PKEY *pkey, *peerkey; const unsigned char* key; - printf(testingFmt, "wolfSSL_EVP_PKEY_derive()"); - #if !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) /* DH */ key = dh_key_der_2048; @@ -48493,15 +47203,15 @@ static int test_wolfSSL_EVP_PKEY_derive(void) XFREE(skey, NULL, DYNAMIC_TYPE_OPENSSL); #endif /* HAVE_ECC */ - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif /* (!NO_DH && WOLFSSL_DH_EXTRA) || HAVE_ECC */ #endif /* OPENSSL_ALL || WOLFSSL_QT || WOLFSSL_OPENSSH */ - - return 0; + return res; } static int test_wolfSSL_EVP_PBE_scrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_SCRYPT) && defined(HAVE_PBKDF2) && \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 5)) #if !defined(NO_PWDBASED) && !defined(NO_SHA256) @@ -48525,8 +47235,6 @@ static int test_wolfSSL_EVP_PBE_scrypt(void) 0x8A, 0xA3, 0x91, 0xE7, 0x99, 0xCE, 0x10, 0xA2, 0x77, 0x53, 0xE7, 0xE9, 0xC0, 0x9A}; - printf(testingFmt, "wolfSSL_EVP_PBE_scrypt()"); - /* N r p mx key keylen */ ret = EVP_PBE_scrypt(pwd, pwdlen, salt, saltlen, 0, 1, 1, 0, key, 64); AssertIntEQ(ret, 0); /* N must be greater than 1 */ @@ -48581,24 +47289,21 @@ static int test_wolfSSL_EVP_PBE_scrypt(void) ret = XMEMCMP(expectedKey, key, sizeof(expectedKey)); AssertIntEQ(ret, 0); /* derived key must be the same as expected-key */ - printf(resultFmt, "passed"); - + res = TEST_RES_CHECK(1); #endif /* !NO_PWDBASED && !NO_SHA256 */ #endif /* OPENSSL_EXTRA && HAVE_SCRYPT && HAVE_PBKDF2 */ - - return 0; + return res; } static int test_wolfSSL_EC_get_builtin_curves(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) EC_builtin_curve* curves = NULL; size_t crv_len = 0; size_t i = 0; - printf(testingFmt, "wolfSSL_EC_get_builtin_curves"); - AssertIntGT((crv_len = EC_get_builtin_curves(NULL, 0)), 0); AssertNotNull(curves = (EC_builtin_curve*) XMALLOC(sizeof(EC_builtin_curve)*crv_len, NULL, @@ -48612,32 +47317,31 @@ static int test_wolfSSL_EC_get_builtin_curves(void) } XFREE(curves, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* defined(HAVE_ECC) || defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) */ - - return 0; + return res; } static int test_no_op_functions(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "no_op_functions()"); - /* this makes sure wolfSSL can compile and run these no-op functions */ SSL_load_error_strings(); ENGINE_load_builtin_engines(); OpenSSL_add_all_ciphers(); AssertIntEQ(CRYPTO_malloc_init(), 0); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_CRYPTO_memcmp(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_EXTRA char a[] = "wolfSSL (formerly CyaSSL) is a small, fast, portable " "implementation of TLS/SSL for embedded devices to the cloud."; @@ -48648,9 +47352,10 @@ static int test_wolfSSL_CRYPTO_memcmp(void) AssertIntEQ(CRYPTO_memcmp(a, b, sizeof(a)), 0); AssertIntNE(CRYPTO_memcmp(a, c, sizeof(a)), 0); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } /*----------------------------------------------------------------------------* @@ -48659,6 +47364,7 @@ static int test_wolfSSL_CRYPTO_memcmp(void) static int test_wc_CreateEncryptedPKCS8Key(void) { + int res = TEST_SKIPPED; #if defined(HAVE_PKCS8) && !defined(NO_PWDBASED) && defined(WOLFSSL_AES_256) \ && !defined(NO_AES_CBC) && !defined(NO_RSA) && !defined(NO_SHA) WC_RNG rng; @@ -48669,8 +47375,6 @@ static int test_wc_CreateEncryptedPKCS8Key(void) word32 passwordSz = (word32)XSTRLEN(password); word32 tradIdx = 0; - printf(testingFmt, "test_wc_CreateEncryptedPKCS8Key"); - AssertIntEQ(wc_InitRng(&rng), 0); /* Call with NULL for out buffer to get necessary length. */ AssertIntEQ(wc_CreateEncryptedPKCS8Key((byte*)server_key_der_2048, @@ -48697,14 +47401,14 @@ static int test_wc_CreateEncryptedPKCS8Key(void) XFREE(encKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); wc_FreeRng(&rng); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_GetPkcs8TraditionalOffset(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(HAVE_PKCS8) int length, derSz; word32 inOutIdx; @@ -48712,8 +47416,6 @@ static int test_wc_GetPkcs8TraditionalOffset(void) XFILE file; byte der[2048]; - printf(testingFmt, "wc_GetPkcs8TraditionalOffset"); - file = XFOPEN(path, "rb"); AssertTrue(file != XBADFILE); derSz = (int)XFREAD(der, 1, sizeof(der), file); @@ -48740,14 +47442,14 @@ static int test_wc_GetPkcs8TraditionalOffset(void) length = wc_GetPkcs8TraditionalOffset(der, &inOutIdx, derSz); AssertIntEQ(length, ASN_PARSE_E); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* NO_ASN */ - - return 0; + return res; } static int test_wc_SetSubjectRaw(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) && !defined(NO_RSA) const char* joiCertFile = "./certs/test/cert-ext-joi.der"; @@ -48756,8 +47458,6 @@ static int test_wc_SetSubjectRaw(void) const byte* peerCertBuf; Cert forgedCert; - printf(testingFmt, "test_wc_SetSubjectRaw()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(joiCertFile, WOLFSSL_FILETYPE_ASN1)); AssertNotNull(peerCertBuf = wolfSSL_X509_get_der(x509, &peerCertSz)); @@ -48768,32 +47468,30 @@ static int test_wc_SetSubjectRaw(void) wolfSSL_FreeX509(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_GetSubjectRaw(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) Cert cert; byte *subjectRaw; - printf(testingFmt, "test_wc_GetSubjectRaw()"); - AssertIntEQ(0, wc_InitCert(&cert)); AssertIntEQ(0, wc_GetSubjectRaw(&subjectRaw, &cert)); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_SetIssuerRaw(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) && !defined(NO_RSA) const char* joiCertFile = "./certs/test/cert-ext-joi.der"; @@ -48802,8 +47500,6 @@ static int test_wc_SetIssuerRaw(void) const byte* peerCertBuf; Cert forgedCert; - printf(testingFmt, "test_wc_SetIssuerRaw()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(joiCertFile, WOLFSSL_FILETYPE_ASN1)); AssertNotNull(peerCertBuf = wolfSSL_X509_get_der(x509, &peerCertSz)); @@ -48814,14 +47510,14 @@ static int test_wc_SetIssuerRaw(void) wolfSSL_FreeX509(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wc_SetIssueBuffer(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) && !defined(NO_RSA) const char* joiCertFile = "./certs/test/cert-ext-joi.der"; @@ -48830,8 +47526,6 @@ static int test_wc_SetIssueBuffer(void) const byte* peerCertBuf; Cert forgedCert; - printf(testingFmt, "test_wc_SetIssuerBuffer()"); - AssertNotNull(x509 = wolfSSL_X509_load_certificate_file(joiCertFile, WOLFSSL_FILETYPE_ASN1)); AssertNotNull(peerCertBuf = wolfSSL_X509_get_der(x509, &peerCertSz)); @@ -48842,10 +47536,9 @@ static int test_wc_SetIssueBuffer(void) wolfSSL_FreeX509(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* @@ -48853,23 +47546,21 @@ static int test_wc_SetIssueBuffer(void) */ static int test_wc_SetSubjectKeyId(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) && defined(HAVE_ECC) Cert cert; const char* file = "certs/ecc-client-keyPub.pem"; - printf(testingFmt, "wc_SetSubjectKeyId()"); - AssertIntEQ(0, wc_InitCert(&cert)); AssertIntEQ(0, wc_SetSubjectKeyId(&cert, file)); AssertIntEQ(BAD_FUNC_ARG, wc_SetSubjectKeyId(NULL, file)); AssertIntGT(0, wc_SetSubjectKeyId(&cert, "badfile.name")); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_SetSubjectKeyId */ /* @@ -48877,28 +47568,27 @@ static int test_wc_SetSubjectKeyId(void) */ static int test_wc_SetSubject(void) { + int res = TEST_SKIPPED; #if !defined(NO_ASN) && !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_EXT) && defined(HAVE_ECC) Cert cert; const char* file = "./certs/ca-ecc-cert.pem"; - printf(testingFmt, "wc_SetSubject()"); - AssertIntEQ(0, wc_InitCert(&cert)); AssertIntEQ(0, wc_SetSubject(&cert, file)); AssertIntEQ(BAD_FUNC_ARG, wc_SetSubject(NULL, file)); AssertIntGT(0, wc_SetSubject(&cert, "badfile.name")); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* END test_wc_SetSubject */ static int test_CheckCertSignature(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && defined(WOLFSSL_SMALL_CERT_VERIFY) WOLFSSL_CERT_MANAGER* cm = NULL; #if !defined(NO_FILESYSTEM) && (!defined(NO_RSA) || defined(HAVE_ECC)) @@ -48971,20 +47661,20 @@ static int test_CheckCertSignature(void) #endif wolfSSL_CertManagerFree(cm); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wc_ParseCert(void) { + int res = TEST_SKIPPED; #if !defined(NO_CERTS) && !defined(NO_RSA) DecodedCert decodedCert; const byte* rawCert = client_cert_der_2048; const int rawCertSize = sizeof_client_cert_der_2048; - printf(testingFmt, "wc_ParseCert"); - wc_InitDecodedCert(&decodedCert, rawCert, rawCertSize, NULL); AssertIntEQ(wc_ParseCert(&decodedCert, CERT_TYPE, NO_VERIFY, NULL), 0); #ifndef IGNORE_NAME_CONSTRAINTS @@ -48994,14 +47684,14 @@ static int test_wc_ParseCert(void) #endif wc_FreeDecodedCert(&decodedCert); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_MakeCertWithPathLen(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_CERT_REQ) && defined(WOLFSSL_CERT_GEN) && defined(HAVE_ECC) const byte expectedPathLen = 7; Cert cert; @@ -49011,8 +47701,6 @@ static int test_MakeCertWithPathLen(void) WC_RNG rng; ecc_key key; - printf(testingFmt, "test_MakeCertWithPathLen"); - AssertIntEQ(wc_InitRng(&rng), 0); AssertIntEQ(wc_ecc_init(&key), 0); AssertIntEQ(wc_ecc_make_key(&rng, 32, &key), 0); @@ -49049,11 +47737,9 @@ static int test_MakeCertWithPathLen(void) AssertIntEQ(wc_ecc_free(&key), 0); AssertIntEQ(wc_FreeRng(&rng), 0); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /*----------------------------------------------------------------------------* @@ -49062,11 +47748,10 @@ static int test_MakeCertWithPathLen(void) static int test_wc_ecc_get_curve_size_from_name(void) { + int res = TEST_SKIPPED; #ifdef HAVE_ECC int ret; - printf(testingFmt, "wc_ecc_get_curve_size_from_name"); - #if !defined(NO_ECC256) && !defined(NO_ECC_SECP) ret = wc_ecc_get_curve_size_from_name("SECP256R1"); AssertIntEQ(ret, 32); @@ -49080,19 +47765,17 @@ static int test_wc_ecc_get_curve_size_from_name(void) ret = wc_ecc_get_curve_size_from_name(NULL); AssertIntEQ(ret, BAD_FUNC_ARG); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ - - return 0; + return res; } static int test_wc_ecc_get_curve_id_from_name(void) { + int res = TEST_SKIPPED; #ifdef HAVE_ECC int id; - printf(testingFmt, "wc_ecc_get_curve_id_from_name"); - #if !defined(NO_ECC256) && !defined(NO_ECC_SECP) id = wc_ecc_get_curve_id_from_name("SECP256R1"); AssertIntEQ(id, ECC_SECP256R1); @@ -49106,10 +47789,9 @@ static int test_wc_ecc_get_curve_id_from_name(void) id = wc_ecc_get_curve_id_from_name(NULL); AssertIntEQ(id, BAD_FUNC_ARG); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ - - return 0; + return res; } #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \ @@ -49127,8 +47809,6 @@ static int test_wc_ecc_get_curve_id_from_dp_params(void) #endif WOLFSSL_EC_KEY *ecKey = NULL; - printf(testingFmt, "wc_ecc_get_curve_id_from_dp_params"); - #if !defined(NO_ECC256) && !defined(NO_ECC_SECP) id = wc_ecc_get_curve_id_from_name("SECP256R1"); AssertIntEQ(id, ECC_SECP256R1); @@ -49153,14 +47833,13 @@ static int test_wc_ecc_get_curve_id_from_dp_params(void) AssertIntEQ(id, BAD_FUNC_ARG); wolfSSL_EC_KEY_free(ecKey); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } #endif /* defined(OPENSSL_EXTRA) && defined(HAVE_ECC) */ static int test_wc_ecc_get_curve_id_from_params(void) { + int res = TEST_SKIPPED; #ifdef HAVE_ECC int id; @@ -49223,8 +47902,6 @@ static int test_wc_ecc_get_curve_id_from_params(void) int cofactor = 1; int fieldSize = 256; - printf(testingFmt, "wc_ecc_get_curve_id_from_params"); - #if !defined(NO_ECC256) && !defined(NO_ECC_SECP) id = wc_ecc_get_curve_id_from_params(fieldSize, prime, sizeof(prime), Af, sizeof(Af), Bf, sizeof(Bf), order, sizeof(order), @@ -49251,13 +47928,13 @@ static int test_wc_ecc_get_curve_id_from_params(void) Gx, sizeof(Gx), Gy, sizeof(Gy), cofactor); AssertIntEQ(id, ECC_CURVE_INVALID); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_encrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_FAST_RSA) WOLFSSL_RSA* rsa = NULL; @@ -49275,7 +47952,6 @@ static int test_wolfSSL_EVP_PKEY_encrypt(void) byte* outEncTmp = NULL; byte* outDecTmp = NULL; #endif - printf(testingFmt, "wolfSSL_EVP_PKEY_encrypt()"); AssertNotNull(outEnc = (byte*)XMALLOC(rsaKeySz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER)); XMEMSET(outEnc, 0, rsaKeySz); @@ -49345,13 +48021,14 @@ static int test_wolfSSL_EVP_PKEY_encrypt(void) XFREE(outEncTmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); XFREE(outDecTmp, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); #endif - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_EVP_PKEY_sign_verify(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) #if !defined (NO_DSA) && !defined(HAVE_SELFTEST) && defined(WOLFSSL_KEY_GEN) WOLFSSL_DSA* dsa = NULL; @@ -49387,7 +48064,6 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(void) #endif #endif - printf(testingFmt, "wolfSSL_EVP_PKEY_sign_verify()"); AssertNotNull(sig = (byte*)XMALLOC(keySz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER)); AssertNotNull(sigVerify = @@ -49546,14 +48222,15 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(void) XFREE(sig, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sigVerify, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } static int test_EVP_PKEY_rsa(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) WOLFSSL_RSA* rsa; WOLFSSL_EVP_PKEY* pkey; @@ -49566,15 +48243,14 @@ static int test_EVP_PKEY_rsa(void) AssertPtrEq(EVP_PKEY_get0_RSA(pkey), rsa); wolfSSL_EVP_PKEY_free(pkey); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_EVP_PKEY_ec(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) WOLFSSL_EC_KEY* ecKey; @@ -49590,20 +48266,19 @@ static int test_EVP_PKEY_ec(void) AssertIntEQ(EVP_PKEY_assign_EC_KEY(pkey, ecKey), WOLFSSL_SUCCESS); wolfSSL_EVP_PKEY_free(pkey); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } static int test_EVP_PKEY_cmp(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) EVP_PKEY *a, *b; const unsigned char *in; - printf(testingFmt, "wolfSSL_EVP_PKEY_cmp()"); #if !defined(NO_RSA) && defined(USE_CERT_BUFFERS_2048) in = client_key_der_2048; AssertNotNull(a = wolfSSL_d2i_PrivateKey(EVP_PKEY_RSA, NULL, @@ -49686,21 +48361,20 @@ static int test_EVP_PKEY_cmp(void) (void)in; - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_ERR_load_crypto_strings(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) ERR_load_crypto_strings(); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_ALL) && !defined(NO_CERTS) @@ -49712,6 +48386,7 @@ static void free_x509(X509* x) static int test_sk_X509(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) { STACK_OF(X509)* s; @@ -49799,21 +48474,19 @@ static int test_sk_X509(void) X509_free(xList[i]); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_sk_X509_CRL(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && defined(HAVE_CRL) X509_CRL* crl; XFILE fp; STACK_OF(X509_CRL)* s; - printf(testingFmt, "test_sk_X509_CRL"); - fp = XFOPEN("./certs/crl/crl.pem", "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(crl = (X509_CRL*)PEM_read_X509_CRL(fp, (X509_CRL **)NULL, NULL, NULL)); @@ -49826,14 +48499,14 @@ static int test_sk_X509_CRL(void) AssertPtrEq(sk_X509_CRL_value(s, 0), crl); sk_X509_CRL_free(s); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_X509_get_signature_nid(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) X509* x509; @@ -49843,14 +48516,14 @@ static int test_X509_get_signature_nid(void) AssertIntEQ(X509_get_signature_nid(x509), NID_sha256WithRSAEncryption); X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_X509_REQ(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) && !defined(NO_BIO) X509_NAME* name; @@ -49977,14 +48650,14 @@ static int test_X509_REQ(void) X509_NAME_free(name); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfssl_PKCS7(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) && !defined(NO_BIO) PKCS7* pkcs7; byte data[FOURK_BUF]; @@ -50039,14 +48712,14 @@ static int test_wolfssl_PKCS7(void) PKCS7_free(NULL); PKCS7_free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PKCS7_sign(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) && !defined(NO_BIO) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) @@ -50071,8 +48744,6 @@ static int test_wolfSSL_PKCS7_sign(void) X509* caCert = NULL; X509_STORE* store = NULL; - printf(testingFmt, "wolfSSL_PKCS7_sign()"); - /* read signer cert/key into BIO */ AssertNotNull(certBio = BIO_new_file(cert, "r")); AssertNotNull(keyBio = BIO_new_file(key, "r")); @@ -50225,33 +48896,32 @@ static int test_wolfSSL_PKCS7_sign(void) BIO_free(certBio); BIO_free(caBio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PKCS7_SIGNED_new(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) PKCS7_SIGNED* pkcs7; - printf(testingFmt, "wolfSSL_PKCS7_SIGNED_new()"); - pkcs7 = PKCS7_SIGNED_new(); AssertNotNull(pkcs7); AssertIntEQ(pkcs7->contentOID, SIGNED_DATA); PKCS7_SIGNED_free(pkcs7); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #ifndef NO_BIO static int test_wolfSSL_PEM_write_bio_PKCS7(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) PKCS7* pkcs7 = NULL; BIO* bio = NULL; @@ -50327,7 +48997,6 @@ static int test_wolfSSL_PEM_write_bio_PKCS7(void) #else #error PKCS7 requires ECC or RSA #endif - printf(testingFmt, "wolfSSL_PEM_write_bio_PKCS7()"); AssertNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId)); /* initialize with DER encoded cert */ @@ -50359,16 +49028,15 @@ static int test_wolfSSL_PEM_write_bio_PKCS7(void) wc_PKCS7_Free(pkcs7); wc_FreeRng(&rng); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifdef HAVE_SMIME static int test_wolfSSL_SMIME_read_PKCS7(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) PKCS7* pkcs7 = NULL; @@ -50380,8 +49048,6 @@ static int test_wolfSSL_SMIME_read_PKCS7(void) static const char contTypeText[] = "Content-Type: text/plain\r\n\r\n"; XFILE smimeTestFile = XFOPEN("./certs/test/smime-test.p7s", "r"); - printf(testingFmt, "wolfSSL_SMIME_read_PKCS7()"); - /* smime-test.p7s */ bio = wolfSSL_BIO_new(wolfSSL_BIO_s_file()); AssertNotNull(bio); @@ -50446,16 +49112,15 @@ static int test_wolfSSL_SMIME_read_PKCS7(void) if (bcont) BIO_free(bcont); wolfSSL_PKCS7_free(pkcs7); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SMIME_write_PKCS7(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) && !defined(NO_RSA) - PKCS7* p7 = NULL; PKCS7* p7Ver = NULL; int flags = 0; @@ -50476,8 +49141,6 @@ static int test_wolfSSL_SMIME_write_PKCS7(void) X509* caCert = NULL; X509_STORE* store = NULL; - printf(testingFmt, "wolfSSL_SMIME_write_PKCS7()"); - /* read signer cert/key into BIO */ AssertNotNull(certBio = BIO_new_file(cert, "r")); AssertNotNull(keyBio = BIO_new_file(key, "r")); @@ -50584,10 +49247,9 @@ static int test_wolfSSL_SMIME_write_PKCS7(void) BIO_free(certBio); BIO_free(caBio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif /* HAVE_SMIME */ #endif /* !NO_BIO */ @@ -50596,6 +49258,7 @@ static int test_wolfSSL_SMIME_write_PKCS7(void) * returns 0) */ static int test_X509_STORE_No_SSL_CTX(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && \ !defined(NO_WOLFSSL_DIR) && defined(HAVE_CRL) && \ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \ @@ -50613,8 +49276,6 @@ static int test_X509_STORE_No_SSL_CTX(void) XFILE fp; X509_LOOKUP * lookup; - printf(testingFmt, "test_X509_STORE_No_SSL_CTX"); - AssertNotNull(store = (X509_STORE *)X509_STORE_new()); /* Set up store with CA */ @@ -50658,17 +49319,16 @@ static int test_X509_STORE_No_SSL_CTX(void) X509_free(cert); X509_free(ca); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } /* Test of X509 store use outside of SSL context w/ CRL lookup, but * with X509_LOOKUP_add_dir and X509_FILETYPE_ASN1. */ static int test_X509_LOOKUP_add_dir(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && \ !defined(NO_WOLFSSL_DIR) && defined(HAVE_CRL) && \ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \ @@ -50686,8 +49346,6 @@ static int test_X509_LOOKUP_add_dir(void) XFILE fp; X509_LOOKUP * lookup; - printf(testingFmt, "test_X509_LOOKUP_add_dir"); - AssertNotNull(store = (X509_STORE *)X509_STORE_new()); /* Set up store with CA */ @@ -50772,11 +49430,9 @@ static int test_X509_LOOKUP_add_dir(void) X509_free(cert); X509_free(ca); - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } @@ -50796,32 +49452,32 @@ static int test_X509_LOOKUP_add_dir(void) switch (type) { case TESTING_RSA: #ifdef NO_RSA - printf("RSA disabled, skipping test\n"); + fprintf(stderr, "RSA disabled, skipping test\n"); return ASN_SIG_CONFIRM_E; #else break; #endif case TESTING_ECC: #ifndef HAVE_ECC - printf("ECC disabled, skipping test\n"); + fprintf(stderr, "ECC disabled, skipping test\n"); return ASN_SIG_CONFIRM_E; #else break; #endif default: - printf("Bad function argument\n"); + fprintf(stderr, "Bad function argument\n"); return BAD_FUNC_ARG; } cm = wolfSSL_CertManagerNew(); if (cm == NULL) { - printf("wolfSSL_CertManagerNew failed\n"); + fprintf(stderr, "wolfSSL_CertManagerNew failed\n"); return -1; } #ifndef NO_FILESYSTEM ret = wolfSSL_CertManagerLoadCA(cm, ca, 0); if (ret != WOLFSSL_SUCCESS) { - printf("wolfSSL_CertManagerLoadCA failed\n"); + fprintf(stderr, "wolfSSL_CertManagerLoadCA failed\n"); wolfSSL_CertManagerFree(cm); return ret; } @@ -50855,8 +49511,6 @@ static int test_X509_LOOKUP_add_dir(void) ret = verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_RSA); } - printf("Signature failure test: RSA: Ret %d\n", ret); - if (cert_buf) free(cert_buf); #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) @@ -50868,7 +49522,7 @@ static int test_X509_LOOKUP_add_dir(void) ret = 0; } #endif /* NO_WOLFSSL_CLIENT && NO_WOLFSSL_SERVER */ - return ret; + return TEST_RES_CHECK(ret == 0); } static int test_EccSigFailure_cm(void) @@ -50889,8 +49543,6 @@ static int test_X509_LOOKUP_add_dir(void) ret = verify_sig_cm(ca_cert, cert_buf, cert_sz, TESTING_ECC); } - printf("Signature failure test: ECC: Ret %d\n", ret); - if (cert_buf) free(cert_buf); @@ -50906,7 +49558,7 @@ static int test_X509_LOOKUP_add_dir(void) ret = 0; } #endif /* NO_WOLFSSL_CLIENT && NO_WOLFSSL_SERVER */ - return ret; + return TEST_RES_CHECK(ret == 0); } #endif /* !NO_FILESYSTEM */ @@ -51502,7 +50154,7 @@ static int test_tls13_apis(void) #endif #endif - return 0; + return TEST_RES_CHECK(1); } #if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER) && \ @@ -51543,6 +50195,7 @@ static int CsRecv(WOLFSSL* ssl, char* buf, int sz, void* ctx) static int test_tls13_cipher_suites(void) { + int res = TEST_SKIPPED; #if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER) && \ defined(HAVE_ECC) && defined(BUILD_TLS_AES_128_GCM_SHA256) && \ defined(BUILD_TLS_AES_256_GCM_SHA384) @@ -51624,8 +50277,6 @@ static int test_tls13_cipher_suites(void) TLS13_BYTE, TLS_AES_256_GCM_SHA384 }; #endif - printf(testingFmt, "test_tls13_cipher_suites"); - /* Set up wolfSSL context. */ AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_server_method())); AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, eccCertFile, @@ -51715,10 +50366,9 @@ static int test_tls13_cipher_suites(void) wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif @@ -51789,6 +50439,7 @@ static void test_dh_ssl_setup_fail(WOLFSSL* ssl) static int test_DhCallbacks(void) { + int res = TEST_SKIPPED; #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_DH) && \ !defined(NO_AES) && defined(HAVE_AES_CBC) && \ @@ -51803,8 +50454,6 @@ static int test_DhCallbacks(void) callback_functions func_cb_server; int test; - printf(testingFmt, "test_DhCallbacks"); - #ifndef NO_WOLFSSL_CLIENT AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method())); #else @@ -51942,10 +50591,9 @@ static int test_DhCallbacks(void) fdOpenSession(Task_self()); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #endif /* HAVE_PK_CALLBACKS */ @@ -51961,7 +50609,7 @@ static int test_wc_RNG_GenerateBlock_Reseed(void) ret = wc_InitRng(&rng); if (ret == 0) { - for(i = 0; i < WC_RESEED_INTERVAL + 10; i++) { + for (i = 0; i < WC_RESEED_INTERVAL + 10; i++) { ret = wc_RNG_GenerateBlock(&rng, key, sizeof(key)); if (ret != 0) { break; @@ -51971,7 +50619,7 @@ static int test_wc_RNG_GenerateBlock_Reseed(void) wc_FreeRng(&rng); - return ret; + return TEST_RES_CHECK(ret == 0); } #endif /* TEST_RESEED_INTERVAL */ @@ -51984,7 +50632,7 @@ static int test_wc_RNG_GenerateBlock(void) ret = wc_InitRng(&rng); if (ret == 0) { - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { ret = wc_RNG_GenerateBlock(&rng, key, sizeof(key)); if (ret != 0) { break; @@ -51997,7 +50645,7 @@ static int test_wc_RNG_GenerateBlock(void) (void)rng; /* for WC_NO_RNG case */ (void)key; - return ret; + return TEST_RES_CHECK(ret == 0); } #endif /* @@ -52005,13 +50653,11 @@ static int test_wc_RNG_GenerateBlock(void) */ static int test_get_rand_digit(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(WC_NO_RNG) && defined(WOLFSSL_PUBLIC_MP) - - WC_RNG rng; - mp_digit d; - - printf(testingFmt, "get_rand_digit()"); + int ret = 0; + WC_RNG rng; + mp_digit d; ret = wc_InitRng(&rng); @@ -52041,10 +50687,9 @@ static int test_get_rand_digit(void) ret = wc_FreeRng(&rng); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_get_rand_digit*/ /* @@ -52052,12 +50697,11 @@ static int test_get_rand_digit(void) */ static int test_get_digit_count(void) { - int ret = 0; + int res = TEST_SKIPPED; #if !defined(WOLFSSL_SP_MATH) && defined(WOLFSSL_PUBLIC_MP) + int ret = 0; mp_int a; - printf(testingFmt, "get_digit_count()"); - if (mp_init(&a) != MP_OKAY) { ret = -1; } @@ -52068,11 +50712,11 @@ static int test_get_digit_count(void) ret = get_digit_count(&a); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); mp_clear(&a); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_get_digit_count*/ /* @@ -52080,15 +50724,14 @@ static int test_get_digit_count(void) */ static int test_mp_cond_copy(void) { - int ret = 0; + int res = TEST_SKIPPED; #if (defined(HAVE_ECC) || defined(WOLFSSL_MP_COND_COPY)) && \ defined(WOLFSSL_PUBLIC_MP) + int ret = 0; mp_int a; mp_int b; int copy = 0; - printf(testingFmt, "mp_cond_copy()"); - if (mp_init(&a) != MP_OKAY) { ret = -1; } @@ -52119,12 +50762,12 @@ static int test_mp_cond_copy(void) ret = mp_cond_copy(&a, copy, &b); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); mp_clear(&a); mp_clear(&b); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_mp_cond_copy*/ /* @@ -52132,14 +50775,13 @@ static int test_mp_cond_copy(void) */ static int test_mp_rand(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WC_RSA_BLINDING) && defined(WOLFSSL_PUBLIC_MP) + int ret = 0; mp_int a; int digits = 1; WC_RNG rng; - printf(testingFmt, "mp_rand()"); - if (mp_init(&a) != MP_OKAY) { ret = -1; } @@ -52169,25 +50811,24 @@ static int test_mp_rand(void) ret = mp_rand(&a, digits, &rng); } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); mp_clear(&a); wc_FreeRng(&rng); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_mp_rand*/ /* * Testing get_digit */ static int test_get_digit(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(WOLFSSL_PUBLIC_MP) + int ret = 0; mp_int a; int n = 0; - printf(testingFmt, "get_digit()"); - if (mp_init(&a) != MP_OKAY) { ret = -1; } @@ -52212,28 +50853,26 @@ static int test_get_digit(void) } } - - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); mp_clear(&a); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_get_digit*/ /* * Testing wc_export_int */ static int test_wc_export_int(void) { - int ret = 0; + int res = TEST_SKIPPED; #if (defined(HAVE_ECC) || defined(WOLFSSL_EXPORT_INT)) && \ defined(WOLFSSL_PUBLIC_MP) + int ret = 0; mp_int mp; byte buf[32]; word32 keySz = (word32)sizeof(buf); word32 len = (word32)sizeof(buf); - printf(testingFmt, "wc_export_int()"); - if (mp_init(&mp) != MP_OKAY) { ret = -1; } @@ -52273,68 +50912,58 @@ static int test_wc_export_int(void) } } - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); mp_clear(&mp); + + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_export_int*/ static int test_wc_InitRngNonce(void) { - int ret=0; + int res = TEST_SKIPPED; #if !defined(WC_NO_RNG) && !defined(HAVE_SELFTEST) && \ (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) + int ret; WC_RNG rng; byte nonce[] = "\x0D\x74\xDB\x42\xA9\x10\x77\xDE" "\x45\xAC\x13\x7A\xE1\x48\xAF\x16"; word32 nonceSz = sizeof(nonce); - - printf(testingFmt, "wc_InitRngNonce()"); - - if (ret == 0){ - ret = wc_InitRngNonce(&rng, nonce, nonceSz); - } - + ret = wc_InitRngNonce(&rng, nonce, nonceSz); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/* End test_wc_InitRngNonce*/ /* * Testing wc_InitRngNonce_ex */ static int test_wc_InitRngNonce_ex(void) { - int ret=0; + int res = TEST_SKIPPED; #if !defined(WC_NO_RNG) && !defined(HAVE_SELFTEST) && \ (!defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) + int ret; WC_RNG rng; byte nonce[] = "\x0D\x74\xDB\x42\xA9\x10\x77\xDE" "\x45\xAC\x13\x7A\xE1\x48\xAF\x16"; word32 nonceSz = sizeof(nonce); - printf(testingFmt, "wc_InitRngNonce_ex()"); - - if (ret == 0){ - ret = wc_InitRngNonce_ex(&rng, nonce, nonceSz, HEAP_HINT, testDevId); - } - + ret = wc_InitRngNonce_ex(&rng, nonce, nonceSz, HEAP_HINT, testDevId); wc_FreeRng(&rng); - printf(resultFmt, ret == 0 ? passed : failed); - fflush(stdout); + res = TEST_RES_CHECK(ret == 0); #endif - return ret; + return res; }/*End test_wc_InitRngNonce_ex*/ static int test_wolfSSL_X509_CRL(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) X509_CRL *crl; @@ -52360,8 +50989,6 @@ static int test_wolfSSL_X509_CRL(void) XFILE fp; int i; - printf(testingFmt, "test_wolfSSL_X509_CRL"); - for (i = 0; pem[i][0] != '\0'; i++) { fp = XFOPEN(pem[i], "rb"); @@ -52389,7 +51016,7 @@ static int test_wolfSSL_X509_CRL(void) #endif #ifdef HAVE_TEST_d2i_X509_CRL_fp - for(i = 0; der[i][0] != '\0'; i++){ + for (i = 0; der[i][0] != '\0'; i++) { fp = XFOPEN(der[i], "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(crl = (X509_CRL *)d2i_X509_CRL_fp((fp, X509_CRL **)NULL)); @@ -52405,15 +51032,14 @@ static int test_wolfSSL_X509_CRL(void) } #endif - printf(resultFmt, passed); - fflush(stdout); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_X509_load_crl_file(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) && !defined(NO_BIO) int i; @@ -52433,8 +51059,6 @@ static int test_wolfSSL_X509_load_crl_file(void) WOLFSSL_X509_STORE* store; WOLFSSL_X509_LOOKUP* lookup; - printf(testingFmt, "wolfSSL_X509_load_crl_file"); - AssertNotNull(store = wolfSSL_X509_STORE_new()); AssertNotNull(lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())); @@ -52498,14 +51122,14 @@ static int test_wolfSSL_X509_load_crl_file(void) X509_STORE_free(store); store = NULL; - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_d2i_X509_REQ(void) { + int res = TEST_SKIPPED; #if defined(WOLFSSL_CERT_REQ) && !defined(NO_RSA) && !defined(NO_BIO) && \ (defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)) && \ !defined(WOLFSSL_SP_MATH) @@ -52652,34 +51276,35 @@ static int test_wolfSSL_d2i_X509_REQ(void) X509_free(req); EVP_PKEY_free(pub_key); } + + res = TEST_RES_CHECK(1); #endif /* !NO_DSA && !HAVE_SELFTEST */ #endif /* WOLFSSL_CERT_REQ && (OPENSSL_ALL || OPENSSL_EXTRA) */ - - return 0; + return res; } static int test_wolfSSL_PEM_read_X509(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) X509 *x509 = NULL; XFILE fp; - printf(testingFmt, "wolfSSL_PEM_read_X509"); fp = XFOPEN(svrCertFile, "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(x509 = (X509 *)PEM_read_X509(fp, (X509 **)NULL, NULL, NULL)); X509_free(x509); XFCLOSE(fp); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PEM_read(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_BIO) const char* filename = "./certs/server-keyEnc.pem"; XFILE fp; @@ -52693,7 +51318,6 @@ static int test_wolfSSL_PEM_read(void) size_t fileDataSz; byte* out; - printf(testingFmt, "wolfSSL_PEM_read"); fp = XFOPEN(filename, "rb"); AssertTrue((fp != XBADFILE)); @@ -52786,14 +51410,14 @@ static int test_wolfSSL_PEM_read(void) XFREE(header, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(data, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfssl_EVP_aes_gcm_AAD_2_parts(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_AES) && defined(HAVE_AESGCM) && \ !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) const byte iv[12] = { 0 }; @@ -52814,8 +51438,6 @@ static int test_wolfssl_EVP_aes_gcm_AAD_2_parts(void) int tlen; EVP_CIPHER_CTX* ctx = NULL; - printf(testingFmt, "wolfssl_EVP_aes_gcm_AAD_2_parts"); - /* ENCRYPT */ /* Send AAD and data in 1 part */ AssertNotNull(ctx = EVP_CIPHER_CTX_new()); @@ -52905,16 +51527,16 @@ static int test_wolfssl_EVP_aes_gcm_AAD_2_parts(void) /* Test AAD re-use */ EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -#if defined(OPENSSL_EXTRA) && !defined(NO_AES) && defined(HAVE_AESGCM) && \ - !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) static int test_wolfssl_EVP_aes_gcm_zeroLen(void) { + int res = TEST_SKIPPED; +#if defined(OPENSSL_EXTRA) && !defined(NO_AES) && defined(HAVE_AESGCM) && \ + !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) /* Zero length plain text */ byte key[] = { @@ -52968,12 +51590,14 @@ static int test_wolfssl_EVP_aes_gcm_zeroLen(void) EVP_CIPHER_CTX_free(en); EVP_CIPHER_CTX_free(de); - return 0; -} + res = TEST_RES_CHECK(1); #endif + return res; +} static int test_wolfssl_EVP_aes_gcm(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_AES) && defined(HAVE_AESGCM) && \ !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS) @@ -52999,8 +51623,6 @@ static int test_wolfssl_EVP_aes_gcm(void) EVP_CIPHER_CTX en[2]; EVP_CIPHER_CTX de[2]; - printf(testingFmt, "wolfssl_EVP_aes_gcm"); - for (i = 0; i < 2; i++) { EVP_CIPHER_CTX_init(&en[i]); @@ -53079,17 +51701,14 @@ static int test_wolfssl_EVP_aes_gcm(void) AssertIntEQ(wolfSSL_EVP_CIPHER_CTX_cleanup(&de[i]), 1); } - test_wolfssl_EVP_aes_gcm_zeroLen(); - - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_AES && HAVE_AESGCM */ - - return 0; + return res; } static int test_wolfssl_EVP_chacha20_poly1305(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CHACHA) && defined(HAVE_POLY1305) byte key[CHACHA20_POLY1305_AEAD_KEYSIZE]; byte iv [CHACHA20_POLY1305_AEAD_IV_SIZE]; @@ -53101,8 +51720,6 @@ static int test_wolfssl_EVP_chacha20_poly1305(void) EVP_CIPHER_CTX* ctx; int outSz; - printf(testingFmt, "test_wolfssl_EVP_chacha20_poly1305"); - /* Encrypt. */ AssertNotNull((ctx = EVP_CIPHER_CTX_new())); AssertIntEQ(EVP_EncryptInit_ex(ctx, EVP_chacha20_poly1305(), NULL, NULL, @@ -53174,14 +51791,14 @@ static int test_wolfssl_EVP_chacha20_poly1305(void) AssertIntEQ(outSz, 0); EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfssl_EVP_chacha20(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_CHACHA) byte key[CHACHA_MAX_KEY_SZ]; byte iv [WOLFSSL_EVP_CHACHA_IV_BYTES]; @@ -53191,8 +51808,6 @@ static int test_wolfssl_EVP_chacha20(void) EVP_CIPHER_CTX* ctx; int outSz; - printf(testingFmt, "test_wolfssl_EVP_chacha20"); - /* Encrypt. */ AssertNotNull((ctx = EVP_CIPHER_CTX_new())); AssertIntEQ(EVP_EncryptInit_ex(ctx, EVP_chacha20(), NULL, NULL, @@ -53236,14 +51851,14 @@ static int test_wolfssl_EVP_chacha20(void) AssertIntEQ(outSz, 0); EVP_CIPHER_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EVP_PKEY_hkdf(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_HKDF) EVP_PKEY_CTX* ctx; byte salt[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -53277,8 +51892,6 @@ static int test_wolfSSL_EVP_PKEY_hkdf(void) 0xD7, 0xE2, 0x15, 0xBC, 0xB8, 0x10, 0xEF, 0x6C, 0x4D, 0x7A }; - printf(testingFmt, "test_wolfSSL_EVP_PKEY_hkdf"); - AssertNotNull((ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL))); AssertIntEQ(EVP_PKEY_derive_init(ctx), WOLFSSL_SUCCESS); /* NULL ctx. */ @@ -53353,15 +51966,15 @@ static int test_wolfSSL_EVP_PKEY_hkdf(void) EVP_PKEY_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_HKDF */ - - return 0; + return res; } #ifndef NO_BIO static int test_wolfSSL_PEM_X509_INFO_read_bio(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) BIO* bio; X509_INFO* info; @@ -53370,7 +51983,6 @@ static int test_wolfSSL_PEM_X509_INFO_read_bio(void) char exp1[] = "/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com"; char exp2[] = "/C=US/ST=Montana/L=Bozeman/O=wolfSSL/OU=Support/CN=www.wolfssl.com/emailAddress=info@wolfssl.com"; - printf(testingFmt, "wolfSSL_PEM_X509_INFO_read_bio"); AssertNotNull(bio = BIO_new(BIO_s_file())); AssertIntGT(BIO_read_filename(bio, svrCertFile), 0); AssertNotNull(sk = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL)); @@ -53396,15 +52008,16 @@ static int test_wolfSSL_PEM_X509_INFO_read_bio(void) sk_X509_INFO_pop_free(sk, X509_INFO_free); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #endif /* !NO_BIO */ static int test_wolfSSL_X509_NAME_ENTRY_get_object(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) X509 *x509; X509_NAME* name; @@ -53412,7 +52025,6 @@ static int test_wolfSSL_X509_NAME_ENTRY_get_object(void) X509_NAME_ENTRY *ne; ASN1_OBJECT *object = NULL; - printf(testingFmt, "wolfSSL_X509_NAME_ENTRY_get_object"); x509 = wolfSSL_X509_load_certificate_file(cliCertFile, WOLFSSL_FILETYPE_PEM); AssertNotNull(x509); name = X509_get_subject_name(x509); @@ -53425,21 +52037,19 @@ static int test_wolfSSL_X509_NAME_ENTRY_get_object(void) X509_free(x509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_ASN1_INTEGER_get_set(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN) ASN1_INTEGER *a; long val; int ret; - printf(testingFmt, "test_wolfSSL_ASN1_INTEGER_get_set"); - a = ASN1_INTEGER_new(); val = 0; ret = ASN1_INTEGER_set(NULL, val); @@ -53510,10 +52120,9 @@ static int test_wolfSSL_ASN1_INTEGER_get_set(void) AssertIntEQ(ASN1_INTEGER_get(a), val); ASN1_INTEGER_free(a); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #if defined(OPENSSL_EXTRA) @@ -53525,6 +52134,7 @@ typedef struct ASN1IntTestVector { #endif static int test_wolfSSL_d2i_ASN1_INTEGER(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) size_t i; WOLFSSL_ASN1_INTEGER* a = NULL; @@ -53583,8 +52193,6 @@ static int test_wolfSSL_d2i_ASN1_INTEGER(void) }; static const size_t NUM_TEST_VECTORS = sizeof(testVectors)/sizeof(testVectors[0]); - printf(testingFmt, "test_wolfSSL_d2i_ASN1_INTEGER"); - /* Check d2i error conditions */ /* NULL pointer to input. */ AssertNull((a = wolfSSL_d2i_ASN1_INTEGER(&b, NULL, 1))); @@ -53656,14 +52264,14 @@ static int test_wolfSSL_d2i_ASN1_INTEGER(void) wolfSSL_ASN1_INTEGER_free(a); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_X509_STORE_get1_certs(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SIGNER_DER_CERT) && \ !defined(NO_FILESYSTEM) && !defined(NO_RSA) X509_STORE_CTX *storeCtx; @@ -53673,8 +52281,6 @@ static int test_wolfSSL_X509_STORE_get1_certs(void) X509_NAME *subject; WOLF_STACK_OF(WOLFSSL_X509) *certs; - printf(testingFmt, "wolfSSL_X509_STORE_get1_certs()"); - AssertNotNull(caX509 = X509_load_certificate_file(caCertFile, SSL_FILETYPE_PEM)); AssertNotNull((svrX509 = @@ -53709,10 +52315,9 @@ static int test_wolfSSL_X509_STORE_get1_certs(void) X509_free(svrX509); X509_free(caX509); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && WOLFSSL_SIGNER_DER_CERT && !NO_FILESYSTEM */ - - return 0; + return res; } /* Testing code used in dpp.c in hostap */ @@ -53735,6 +52340,7 @@ IMPLEMENT_ASN1_FUNCTIONS(DPP_BOOTSTRAPPING_KEY) static int test_wolfSSL_IMPLEMENT_ASN1_FUNCTIONS(void) { + int res = TEST_SKIPPED; /* Testing code used in dpp.c in hostap */ #if defined(OPENSSL_ALL) && defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) @@ -53787,20 +52393,21 @@ static int test_wolfSSL_IMPLEMENT_ASN1_FUNCTIONS(void) EVP_PKEY_free(key); EC_KEY_free(eckey); DPP_BOOTSTRAPPING_KEY_free(bootstrap); + + res = TEST_RES_CHECK(1); #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* WOLFSSL_WPAS && HAVE_ECC && USE_CERT_BUFFERS_256 */ - - return 0; + return res; } static int test_wolfSSL_i2c_ASN1_INTEGER(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_ASN) ASN1_INTEGER *a; unsigned char *pp,*tpp; int ret; - printf(testingFmt, "wolfSSL_i2c_ASN1_INTEGER"); a = wolfSSL_ASN1_INTEGER_new(); @@ -53886,10 +52493,9 @@ static int test_wolfSSL_i2c_ASN1_INTEGER(void) XFREE(tpp, NULL, DYNAMIC_TYPE_TMP_BUFFER); wolfSSL_ASN1_INTEGER_free(a); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_ASN */ - - return 0; + return res; } #ifndef NO_INLINE @@ -53926,13 +52532,14 @@ static int test_ForceZero(void) } } - return 0; + return TEST_RES_CHECK(1); } #ifndef NO_BIO static int test_wolfSSL_X509_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) && !defined(HAVE_FAST_RSA) && defined(XSNPRINTF) X509 *x509; @@ -53941,7 +52548,6 @@ static int test_wolfSSL_X509_print(void) const X509_ALGOR *cert_sig_alg; #endif - printf(testingFmt, "wolfSSL_X509_print"); x509 = X509_load_certificate_file(svrCertFile, WOLFSSL_FILETYPE_PEM); AssertNotNull(x509); @@ -53962,7 +52568,7 @@ static int test_wolfSSL_X509_print(void) #endif BIO_free(bio); - AssertNotNull(bio = BIO_new_fd(STDOUT_FILENO, BIO_NOCLOSE)); + AssertNotNull(bio = BIO_new_fd(STDERR_FILENO, BIO_NOCLOSE)); #if defined(OPENSSL_ALL) && !defined(NO_WOLFSSL_DIR) /* Print signature */ @@ -53970,31 +52576,30 @@ static int test_wolfSSL_X509_print(void) AssertIntEQ(X509_signature_print(bio, cert_sig_alg, NULL), SSL_SUCCESS); #endif - /* print to stdout */ + /* print to stderr */ #if !defined(NO_WOLFSSL_DIR) AssertIntEQ(X509_print(bio, x509), SSL_SUCCESS); #endif /* print again */ - AssertIntEQ(X509_print_fp(stdout, x509), SSL_SUCCESS); + AssertIntEQ(X509_print_fp(stderr, x509), SSL_SUCCESS); X509_free(x509); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_X509_CRL_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && defined(HAVE_CRL)\ && !defined(NO_FILESYSTEM) && defined(XSNPRINTF) X509_CRL* crl; BIO *bio; XFILE fp; - printf(testingFmt, "test_X509_CRL_print"); - fp = XFOPEN("./certs/crl/crl.pem", "rb"); AssertTrue((fp != XBADFILE)); AssertNotNull(crl = (X509_CRL*)PEM_read_X509_CRL(fp, (X509_CRL **)NULL, @@ -54006,18 +52611,18 @@ static int test_wolfSSL_X509_CRL_print(void) X509_CRL_free(crl); BIO_free(bio); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_BIO_get_len(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_BIO) BIO *bio = NULL; const char txt[] = "Some example text to push to the BIO."; - printf(testingFmt, "wolfSSL_BIO_get_len"); AssertIntEQ(wolfSSL_BIO_get_len(bio), BAD_FUNC_ARG); @@ -54027,17 +52632,18 @@ static int test_wolfSSL_BIO_get_len(void) AssertIntEQ(wolfSSL_BIO_get_len(bio), sizeof(txt)); BIO_free(bio); - AssertNotNull(bio = BIO_new_fd(STDOUT_FILENO, BIO_NOCLOSE)); + AssertNotNull(bio = BIO_new_fd(STDERR_FILENO, BIO_NOCLOSE)); AssertIntEQ(wolfSSL_BIO_get_len(bio), WOLFSSL_BAD_FILE); BIO_free(bio); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } -static int test_wolfSSL_ASN1_STRING_print(void){ +static int test_wolfSSL_ASN1_STRING_print(void) +{ + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_ASN) && !defined(NO_CERTS) ASN1_STRING* asnStr = NULL; const char HELLO_DATA[]= \ @@ -54051,8 +52657,6 @@ static int test_wolfSSL_ASN1_STRING_print(void){ BIO *bio; int p_len, i; - printf(testingFmt, "wolfSSL_ASN1_STRING_print()"); - /* setup */ for (i = 0; i < (int)sizeof(HELLO_DATA); i++) { @@ -54089,16 +52693,16 @@ static int test_wolfSSL_ASN1_STRING_print(void){ BIO_free(bio); ASN1_STRING_free(asnStr); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_ASN && !NO_CERTS */ - - return 0; + return res; } #endif /* !NO_BIO */ static int test_wolfSSL_ASN1_get_object(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && defined(USE_CERT_BUFFERS_256) const unsigned char* derBuf = cliecc_cert_der_256; int len = sizeof_cliecc_cert_der_256; @@ -54106,8 +52710,6 @@ static int test_wolfSSL_ASN1_get_object(void) int tag = 0, cls = 0; ASN1_OBJECT *a; - printf(testingFmt, "wolfSSL_ASN1_get_object()"); - /* Read a couple TLV triplets and make sure they match the expected values */ AssertIntEQ(ASN1_get_object(&derBuf, &asnLen, &tag, &cls, len) & 0x80, 0); @@ -54151,14 +52753,14 @@ static int test_wolfSSL_ASN1_get_object(void) AssertNotNull(d2i_ASN1_OBJECT(&a, &derBuf, len)); ASN1_OBJECT_free(a); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && HAVE_ECC && USE_CERT_BUFFERS_256 */ - - return 0; + return res; } static int test_wolfSSL_RSA(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \ defined(WOLFSSL_KEY_GEN) RSA* rsa; @@ -54171,8 +52773,6 @@ static int test_wolfSSL_RSA(void) const BIGNUM *dmq1; const BIGNUM *iqmp; - printf(testingFmt, "wolfSSL_RSA()"); - AssertNotNull(rsa = RSA_new()); AssertIntEQ(RSA_size(NULL), 0); AssertIntEQ(RSA_size(rsa), 0); @@ -54294,14 +52894,14 @@ static int test_wolfSSL_RSA(void) } #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_DER(void) { + int res = TEST_SKIPPED; #if !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \ !defined(NO_RSA) && !defined(HAVE_USER_RSA) && defined(OPENSSL_EXTRA) @@ -54338,8 +52938,6 @@ static int test_wolfSSL_RSA_DER(void) {NULL, 0} }; - printf(testingFmt, "test_wolfSSL_RSA_DER()"); - AssertNull(d2i_RSAPublicKey(&rsa, NULL, pub[0].sz)); buff = pub[0].der; AssertNull(d2i_RSAPublicKey(&rsa, &buff, 1)); @@ -54383,34 +52981,32 @@ static int test_wolfSSL_RSA_DER(void) RSA_free(rsa); } - printf(resultFmt, passed); - + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_print(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \ !defined(NO_RSA) && !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_FAST_RSA) && !defined(NO_BIO) BIO *bio; WOLFSSL_RSA* rsa = NULL; - printf(testingFmt, "wolfSSL_RSA_print"); - AssertNotNull(bio = BIO_new_fd(STDOUT_FILENO, BIO_NOCLOSE)); + AssertNotNull(bio = BIO_new_fd(STDERR_FILENO, BIO_NOCLOSE)); AssertNotNull(rsa = RSA_new()); AssertIntEQ(RSA_print(NULL, rsa, 0), -1); AssertIntEQ(RSA_print_fp(XBADFILE, rsa, 0), 0); AssertIntEQ(RSA_print(bio, NULL, 0), -1); - AssertIntEQ(RSA_print_fp(stdout, NULL, 0), 0); + AssertIntEQ(RSA_print_fp(stderr, NULL, 0), 0); /* Some very large number of indent spaces. */ AssertIntEQ(RSA_print(bio, rsa, 128), -1); /* RSA is empty. */ AssertIntEQ(RSA_print(bio, rsa, 0), 0); - AssertIntEQ(RSA_print_fp(stdout, rsa, 0), 0); + AssertIntEQ(RSA_print_fp(stderr, rsa, 0), 0); RSA_free(rsa); AssertNotNull(rsa = RSA_generate_key(2048, 3, NULL, NULL)); @@ -54418,21 +53014,22 @@ static int test_wolfSSL_RSA_print(void) AssertIntEQ(RSA_print(bio, rsa, 0), 1); AssertIntEQ(RSA_print(bio, rsa, 4), 1); AssertIntEQ(RSA_print(bio, rsa, -1), 1); - AssertIntEQ(RSA_print_fp(stdout, rsa, 0), 1); - AssertIntEQ(RSA_print_fp(stdout, rsa, 4), 1); - AssertIntEQ(RSA_print_fp(stdout, rsa, -1), 1); + AssertIntEQ(RSA_print_fp(stderr, rsa, 0), 1); + AssertIntEQ(RSA_print_fp(stderr, rsa, 4), 1); + AssertIntEQ(RSA_print_fp(stderr, rsa, -1), 1); BIO_free(bio); RSA_free(rsa); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } #ifndef NO_RSA static int test_wolfSSL_RSA_padding_add_PKCS1_PSS(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && defined(WC_RSA_PSS) && !defined(WC_NO_RNG) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) RSA *rsa; @@ -54487,15 +53084,17 @@ static int test_wolfSSL_RSA_padding_add_PKCS1_PSS(void) AssertIntEQ(RSA_verify_PKCS1_PSS(rsa, mHash, EVP_sha256(), em, 10), 1); RSA_free(rsa); + + res = TEST_RES_CHECK(1); #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* OPENSSL_ALL && WC_RSA_PSS && !WC_NO_RNG*/ - - return 0; + return res; } #endif static int test_wolfSSL_RSA_sign_sha3(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256) #if defined(OPENSSL_ALL) && defined(WC_RSA_PSS) && !defined(WC_NO_RNG) RSA *rsa; @@ -54509,23 +53108,21 @@ static int test_wolfSSL_RSA_sign_sha3(void) 0x6f, 0x8a, 0x3c, 0x42, 0xab, 0x21, 0xad, 0x28 }; - printf(testingFmt, "wolfSSL_RSA_sign_sha3"); - AssertNotNull(d2i_RSAPrivateKey(&rsa, &derBuf, sizeof_client_key_der_2048)); AssertIntEQ(RSA_sign(NID_sha3_256, mHash, sizeof(mHash), sigRet, &sigLen, rsa), 1); RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_ALL && WC_RSA_PSS && !WC_NO_RNG*/ #endif /* !NO_RSA && WOLFSSL_SHA3 && !WOLFSSL_NOSHA3_256*/ - - return 0; + return res; } static int test_wolfSSL_RSA_get0_key(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) RSA *rsa = NULL; const BIGNUM* n = NULL; @@ -54546,8 +53143,6 @@ static int test_wolfSSL_RSA_get0_key(void) derSz = 0; #endif - printf(testingFmt, "test_wolfSSL_RSA_get0_key()"); - if (der != NULL) { RSA_get0_key(NULL, NULL, NULL, NULL); RSA_get0_key(rsa, NULL, NULL, NULL); @@ -54573,20 +53168,18 @@ static int test_wolfSSL_RSA_get0_key(void) RSA_free(rsa); } - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_meth(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA *rsa; RSA_METHOD *rsa_meth; - printf(testingFmt, "test_wolfSSL_RSA_meth"); - #ifdef WOLFSSL_KEY_GEN AssertNotNull(rsa = RSA_generate_key(2048, 3, NULL, NULL)); RSA_free(rsa); @@ -54641,14 +53234,14 @@ static int test_wolfSSL_RSA_meth(void) /* rsa_meth is freed here */ RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_verify(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) && \ !defined(NO_FILESYSTEM) #ifndef NO_BIO @@ -54665,8 +53258,6 @@ static int test_wolfSSL_RSA_verify(void) EVP_PKEY *evpPkey, *evpPubkey; size_t sz; - printf(testingFmt, "wolfSSL_RSA_verify"); - /* generate hash */ SHA256_Init(&c); SHA256_Update(&c, text, strlen(text)); @@ -54720,15 +53311,16 @@ static int test_wolfSSL_RSA_verify(void) X509_free(cert); BIO_free(bio); XFREE(buf, NULL, DYNAMIC_TYPE_FILE); - printf(resultFmt, passed); -#endif -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif +#endif + return res; } static int test_wolfSSL_RSA_sign(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA *rsa; unsigned char hash[SHA256_DIGEST_LENGTH]; @@ -54748,8 +53340,6 @@ static int test_wolfSSL_RSA_sign(void) unsigned int signatureLen; const unsigned char* der; - printf(testingFmt, "wolfSSL_RSA_sign"); - XMEMSET(hash, 0, sizeof(hash)); der = privDer; @@ -54781,14 +53371,14 @@ static int test_wolfSSL_RSA_sign(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_sign_ex(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA *rsa; unsigned char hash[SHA256_DIGEST_LENGTH]; @@ -54820,8 +53410,6 @@ static int test_wolfSSL_RSA_sign_ex(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - printf(testingFmt, "wolfSSL_RSA_sign_ex"); - XMEMSET(hash, 0, sizeof(hash)); AssertNotNull(rsa = wolfSSL_RSA_new()); @@ -54872,15 +53460,15 @@ static int test_wolfSSL_RSA_sign_ex(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_public_decrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA *rsa; unsigned char msg[SHA256_DIGEST_LENGTH]; @@ -55012,8 +53600,6 @@ static int test_wolfSSL_RSA_public_decrypt(void) int i; #endif - printf(testingFmt, "wolfSSL_RSA_public_decrypt"); - XMEMSET(msg, 0, sizeof(msg)); der = pubDer; @@ -55052,14 +53638,14 @@ static int test_wolfSSL_RSA_public_decrypt(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_private_encrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA *rsa; unsigned char msg[SHA256_DIGEST_LENGTH]; @@ -55182,8 +53768,6 @@ static int test_wolfSSL_RSA_private_encrypt(void) #endif const unsigned char* der; - printf(testingFmt, "wolfSSL_RSA_private_encrypt"); - XMEMSET(msg, 0x00, sizeof(msg)); der = privDer; @@ -55216,21 +53800,19 @@ static int test_wolfSSL_RSA_private_encrypt(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_public_encrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA* rsa; const unsigned char msg[2048/8] = { 0 }; unsigned char encMsg[2048/8]; - printf(testingFmt, "wolfSSL_RSA_public_decrypt"); - AssertNotNull(rsa = RSA_new()); AssertIntEQ(RSA_public_encrypt(-1, msg, encMsg, rsa, @@ -55249,21 +53831,19 @@ static int test_wolfSSL_RSA_public_encrypt(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_private_decrypt(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) RSA* rsa; unsigned char msg[2048/8]; const unsigned char encMsg[2048/8] = { 0 }; - printf(testingFmt, "wolfSSL_RSA_private_decrypt"); - AssertNotNull(rsa = RSA_new()); AssertIntEQ(RSA_private_decrypt(-1, encMsg, msg, rsa, @@ -55282,14 +53862,14 @@ static int test_wolfSSL_RSA_private_decrypt(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_GenAdd(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) RSA *rsa; #ifdef USE_CERT_BUFFERS_1024 @@ -55305,8 +53885,6 @@ static int test_wolfSSL_RSA_GenAdd(void) #endif const unsigned char* der; - printf(testingFmt, "wolfSSL_RSA_GenAdd"); - der = privDer; rsa = NULL; AssertNotNull(d2i_RSAPrivateKey(&rsa, &der, privDerSz)); @@ -55328,14 +53906,14 @@ static int test_wolfSSL_RSA_GenAdd(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_blinding_on(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_WOLFSSL_STUB) RSA *rsa; WOLFSSL_BN_CTX *bnCtx; @@ -55348,8 +53926,6 @@ static int test_wolfSSL_RSA_blinding_on(void) #endif const unsigned char* der; - printf(testingFmt, "wolfSSL_RSA_blinding_on"); - der = privDer; rsa = NULL; AssertNotNull(d2i_RSAPrivateKey(&rsa, &der, privDerSz)); @@ -55364,20 +53940,18 @@ static int test_wolfSSL_RSA_blinding_on(void) wolfSSL_BN_CTX_free(bnCtx); RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_RSA_ex_data(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(OPENSSL_EXTRA) RSA* rsa; unsigned char data[1]; - printf(testingFmt, "wolfSSL_RSA_ex_data"); - rsa = RSA_new(); AssertNull(wolfSSL_RSA_get_ex_data(NULL, 0)); @@ -55401,14 +53975,14 @@ static int test_wolfSSL_RSA_ex_data(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_RSA && OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_RSA_LoadDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && (defined(OPENSSL_EXTRA) || \ defined(OPENSSL_EXTRA_X509_SMALL)) RSA *rsa; @@ -55420,8 +53994,6 @@ static int test_wolfSSL_RSA_LoadDer(void) size_t privDerSz = sizeof_client_key_der_2048; #endif - printf(testingFmt, "wolfSSL_RSA_LoadDer"); - AssertNotNull(rsa = RSA_new()); AssertIntEQ(wolfSSL_RSA_LoadDer(NULL, privDer, (int)privDerSz), -1); @@ -55432,15 +54004,15 @@ static int test_wolfSSL_RSA_LoadDer(void) RSA_free(rsa); - printf(resultFmt, passed); -#endif - - return 0; + res = TEST_RES_CHECK(1); +#endif /* !NO_RSA && OPENSSL_EXTRA */ + return res; } /* Local API. */ static int test_wolfSSL_RSA_To_Der(void) { + int res = TEST_SKIPPED; #ifdef WOLFSSL_TEST_STATIC_BUILD #if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) && \ defined(OPENSSL_EXTRA) && !defined(NO_RSA) @@ -55461,8 +54033,6 @@ static int test_wolfSSL_RSA_To_Der(void) const unsigned char* der; unsigned char* outDer = NULL; - printf(testingFmt, "wolfSSL_RSA_To_Der"); - der = privDer; rsa = NULL; AssertNotNull(wolfSSL_d2i_RSAPrivateKey(&rsa, &der, privDerSz)); @@ -55498,23 +54068,21 @@ static int test_wolfSSL_RSA_To_Der(void) AssertIntEQ(wolfSSL_RSA_To_Der(rsa, &outDer, 0, HEAP_HINT), BAD_FUNC_ARG); RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } /* wolfSSL_PEM_read_RSAPublicKey is a stub function. */ static int test_wolfSSL_PEM_read_RSAPublicKey(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) XFILE file; const char* fname = "./certs/server-keyPub.pem"; RSA *rsa; - printf(testingFmt, "wolfSSL_PEM_read_RSAPublicKey"); - AssertNull(wolfSSL_PEM_read_RSAPublicKey(XBADFILE, NULL, NULL, NULL)); file = XFOPEN(fname, "rb"); @@ -55524,14 +54092,32 @@ static int test_wolfSSL_PEM_read_RSAPublicKey(void) RSA_free(rsa); XFCLOSE(file); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif + return res; +} - return 0; +/* wolfSSL_PEM_read_RSAPublicKey is a stub function. */ +static int test_wolfSSL_PEM_write_RSA_PUBKEY(void) +{ + int res = TEST_SKIPPED; +#if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \ + defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) + RSA* rsa = NULL; + + AssertIntEQ(wolfSSL_PEM_write_RSA_PUBKEY(XBADFILE, NULL), 0); + AssertIntEQ(wolfSSL_PEM_write_RSA_PUBKEY(stderr, NULL), 0); + /* Valid but stub so returns 0. */ + AssertIntEQ(wolfSSL_PEM_write_RSA_PUBKEY(stderr, rsa), 0); + + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_PEM_write_RSAPrivateKey(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_USER_RSA) && (defined(WOLFSSL_PEM_TO_DER) || \ defined(WOLFSSL_DER_TO_PEM)) && !defined(NO_FILESYSTEM) @@ -55548,10 +54134,8 @@ static int test_wolfSSL_PEM_write_RSAPrivateKey(void) unsigned char passwd[] = "password"; #endif - printf(testingFmt, "wolfSSL_PEM_write_RSAPrivateKey"); - AssertNotNull(rsa = RSA_new()); - AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stdout, rsa, NULL, NULL, 0, + AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stderr, rsa, NULL, NULL, 0, NULL, NULL), 0); RSA_free(rsa); @@ -55561,27 +54145,27 @@ static int test_wolfSSL_PEM_write_RSAPrivateKey(void) AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(XBADFILE, rsa, NULL, NULL, 0, NULL, NULL), 0); - AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stdout, NULL, NULL, NULL, 0, + AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stderr, NULL, NULL, NULL, 0, NULL, NULL), 0); - AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stdout, rsa, NULL, NULL, 0, + AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stderr, rsa, NULL, NULL, 0, NULL, NULL), 1); #ifndef NO_AES - AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stdout, rsa, EVP_aes_128_cbc(), + AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stderr, rsa, EVP_aes_128_cbc(), NULL, 0, NULL, NULL), 1); - AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stdout, rsa, EVP_aes_128_cbc(), + AssertIntEQ(wolfSSL_PEM_write_RSAPrivateKey(stderr, rsa, EVP_aes_128_cbc(), passwd, sizeof(passwd) - 1, NULL, NULL), 1); #endif RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PEM_write_mem_RSAPrivateKey(void) { + int res = TEST_SKIPPED; #if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \ !defined(HAVE_USER_RSA) && (defined(WOLFSSL_PEM_TO_DER) || \ defined(WOLFSSL_DER_TO_PEM)) @@ -55600,8 +54184,6 @@ static int test_wolfSSL_PEM_write_mem_RSAPrivateKey(void) unsigned char* pem; int plen; - printf(testingFmt, "wolfSSL_PEM_write_mem_RSAPrivateKey"); - AssertNotNull(rsa = RSA_new()); AssertIntEQ(wolfSSL_PEM_write_mem_RSAPrivateKey(rsa, NULL, NULL, 0, &pem, &plen), 0); @@ -55632,14 +54214,14 @@ static int test_wolfSSL_PEM_write_mem_RSAPrivateKey(void) RSA_free(rsa); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_DH(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DH) DH *dh = NULL; BIGNUM* p; @@ -55734,8 +54316,6 @@ static int test_wolfSSL_DH(void) (void)pub; (void)priv; - printf(testingFmt, "test_wolfSSL_DH"); - dh = wolfSSL_DH_new(); AssertNotNull(dh); @@ -55868,14 +54448,14 @@ static int test_wolfSSL_DH(void) AssertIntEQ(wolfSSL_DH_size(NULL), -1); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA && !NO_DH */ - - return 0; + return res; } static int test_wolfSSL_DH_dup(void) { + int res = TEST_SKIPPED; #if !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) #if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH) || \ defined(OPENSSL_EXTRA) @@ -55907,15 +54487,15 @@ static int test_wolfSSL_DH_dup(void) wolfSSL_DH_free(dh); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif - - return 0; + return res; } static int test_wolfSSL_DH_check(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL #ifndef NO_DH #ifndef NO_BIO @@ -55972,8 +54552,6 @@ static int test_wolfSSL_DH_check(void) WOLFSSL_BIGNUM* gTmp = NULL; int codes = -1; - printf(testingFmt, "wolfSSL_DH_check"); - #ifndef NO_DSA /* Initialize DH */ f = XFOPEN(file, "rb"); @@ -56051,16 +54629,16 @@ static int test_wolfSSL_DH_check(void) AssertIntEQ(codes, DH_CHECK_P_NOT_PRIME); DH_free(dh); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif #endif /* !NO_DH && !NO_DSA */ #endif - - return 0; + return res; } static int test_wolfSSL_DH_prime(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DH) WOLFSSL_BIGNUM* bn; #if WOLFSSL_MAX_BN_BITS >= 768 @@ -56121,14 +54699,14 @@ static int test_wolfSSL_DH_prime(void) AssertNull(bn); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_DH_1536_prime(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DH) BIGNUM* bn; unsigned char bits[200]; @@ -56160,21 +54738,20 @@ static int test_wolfSSL_DH_1536_prime(void) 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, }; - printf(testingFmt, "wolfSSL_DH_1536_prime()"); bn = get_rfc3526_prime_1536(NULL); AssertNotNull(bn); AssertIntEQ(sz, BN_bn2bin((const BIGNUM*)bn, bits)); AssertIntEQ(0, XMEMCMP(expected, bits, sz)); BN_free(bn); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_DH_get_2048_256(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_DH) WOLFSSL_DH* dh; const WOLFSSL_BIGNUM* pBn; @@ -56240,8 +54817,6 @@ static int test_wolfSSL_DH_get_2048_256(void) byte* qReturned; byte* gReturned; - printf(testingFmt, "wolfSSL_DH_get_2048_256()"); - AssertNotNull((dh = wolfSSL_DH_get_2048_256())); wolfSSL_DH_get0_pqg(dh, &pBn, &qBn, &gBn); @@ -56268,14 +54843,14 @@ static int test_wolfSSL_DH_get_2048_256(void) XFREE(gReturned, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(qReturned, NULL, DYNAMIC_TYPE_TMP_BUFFER); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_PEM_write_DHparams(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_BIO) && \ !defined(NO_DH) && defined(WOLFSSL_DH_EXTRA) && !defined(NO_FILESYSTEM) DH* dh; @@ -56300,8 +54875,6 @@ static int test_wolfSSL_PEM_write_DHparams(void) "MAA=\n" "-----END DH PARAMETERS-----\n"; - printf(testingFmt, "wolfSSL_PEM_write_DHparams()"); - AssertNotNull(fp = XFOPEN(dhParamFile, "rb")); AssertIntGT((pemSz = (int)XFREAD(pem, 1, sizeof(pem), fp)), 0); XFCLOSE(fp); @@ -56344,14 +54917,14 @@ static int test_wolfSSL_PEM_write_DHparams(void) AssertIntEQ(XMEMCMP(pem, expected, pemSz), 0); XFCLOSE(fp); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_d2i_DHparams(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL #if !defined(NO_DH) && (defined(HAVE_FFDHE_2048) || defined(HAVE_FFDHE_3072)) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) @@ -56370,7 +54943,6 @@ static int test_wolfSSL_d2i_DHparams(void) /* Test 2048 bit parameters */ #ifdef HAVE_FFDHE_2048 - printf(testingFmt, "wolfSSL_d2i_DHparams() 2048-bit"); f = XFOPEN(params1, "rb"); AssertTrue(f != XBADFILE); len = (long)XFREAD(buf, 1, sizeof(buf), f); @@ -56391,15 +54963,14 @@ static int test_wolfSSL_d2i_DHparams(void) AssertNull(wolfSSL_d2i_DHparams(NULL, &pt, 10)); DH_free(dh); - printf(resultFmt, passed); *buf = 0; pt = buf; + res = TEST_RES_CHECK(1); #endif /* HAVE_FFDHE_2048 */ /* Test 3072 bit parameters */ #ifdef HAVE_FFDHE_3072 - printf(testingFmt, "wolfSSL_d2i_DHparams() 3072-bit"); f = XFOPEN(params2, "rb"); AssertTrue(f != XBADFILE); len = (long)XFREAD(buf, 1, sizeof(buf), f); @@ -56417,18 +54988,18 @@ static int test_wolfSSL_d2i_DHparams(void) AssertNull(wolfSSL_d2i_DHparams(NULL, &pt, -1)); DH_free(dh); + res = TEST_RES_CHECK(1); #endif /* HAVE_FFDHE_3072 */ - printf(resultFmt, passed); #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* !NO_DH */ #endif - - return 0; + return res; } static int test_wolfSSL_DH_LoadDer(void) { + int res = TEST_SKIPPED; #if !defined(NO_DH) && (!defined(HAVE_FIPS) || FIPS_VERSION_GT(2,0)) && \ defined(OPENSSL_EXTRA) static const byte dh2048[] = { @@ -56480,14 +55051,14 @@ static int test_wolfSSL_DH_LoadDer(void) wolfSSL_DH_free(dh); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_i2d_DHparams(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL #if !defined(NO_DH) && (defined(HAVE_FFDHE_2048) || defined(HAVE_FFDHE_3072)) #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2)) @@ -56509,7 +55080,6 @@ static int test_wolfSSL_i2d_DHparams(void) pt = buf; pt2 = buf; - printf(testingFmt, "wolfSSL_i2d_DHparams() 2048-bit"); f = XFOPEN(params1, "rb"); AssertTrue(f != XBADFILE); len = (long)XFREAD(buf, 1, sizeof(buf), f); @@ -56528,7 +55098,6 @@ static int test_wolfSSL_i2d_DHparams(void) AssertIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 268); DH_free(dh); - printf(resultFmt, passed); *buf = 0; #endif @@ -56538,7 +55107,6 @@ static int test_wolfSSL_i2d_DHparams(void) pt = buf; pt2 = buf; - printf(testingFmt, "wolfSSL_i2d_DHparams() 3072-bit"); f = XFOPEN(params2, "rb"); AssertTrue(f != XBADFILE); len = (long)XFREAD(buf, 1, sizeof(buf), f); @@ -56565,12 +55133,11 @@ static int test_wolfSSL_i2d_DHparams(void) AssertIntEQ(wolfSSL_i2d_DHparams(dh, &pt2), 0); DH_free(dh); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* !NO_DH && (HAVE_FFDHE_2048 || HAVE_FFDHE_3072) */ #endif - - return 0; + return res; } @@ -56622,6 +55189,7 @@ static int test_openssl_make_self_signed_certificate(EVP_PKEY* pkey) static int test_openssl_generate_key_and_cert(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) #if !defined(NO_RSA) { @@ -56669,6 +55237,7 @@ static int test_openssl_generate_key_and_cert(void) EVP_PKEY_free(pkey); } + res = TEST_RES_CHECK(1); #endif /* !NO_RSA */ #ifdef HAVE_ECC @@ -56693,14 +55262,15 @@ static int test_openssl_generate_key_and_cert(void) EVP_PKEY_free(pkey); } + res = TEST_RES_CHECK(1); #endif /* HAVE_ECC */ #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_stubs_are_stubs(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_STUB) WOLFSSL_CTX* ctx = NULL; WOLFSSL_CTX* ctxN = NULL; @@ -56711,7 +55281,7 @@ static int test_stubs_are_stubs(void) ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()); AssertNotNull(ctx); #else - return; + return res; #endif #define CHECKZERO_RET(x, y, z) AssertIntEQ((int) x(y), 0); \ @@ -56735,13 +55305,15 @@ static int test_stubs_are_stubs(void) CHECKZERO_RET(wolfSSL_CTX_sess_timeouts, ctx, ctxN); wolfSSL_CTX_free(ctx); ctx = NULL; -#endif /* OPENSSL_EXTRA && !NO_WOLFSSL_STUB */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA && !NO_WOLFSSL_STUB */ + return res; } static int test_CONF_modules_xxx(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) CONF_modules_free(); AssertTrue(1); /* to confirm previous call gives no harm */ @@ -56755,15 +55327,14 @@ static int test_CONF_modules_xxx(void) CONF_modules_unload(-1); AssertTrue(1); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_CRYPTO_set_dynlock_xxx(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "CRYPTO_set_dynlock_xxx()"); - CRYPTO_set_dynlock_create_callback( (struct CRYPTO_dynlock_value *(*)(const char*, int))NULL); @@ -56783,38 +55354,38 @@ static int test_CRYPTO_set_dynlock_xxx(void) (void (*)(int, struct CRYPTO_dynlock_value *, const char*, int))1); AssertTrue(1); /* to confirm previous call gives no harm */ - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } static int test_CRYPTO_THREADID_xxx(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "CRYPTO_THREADID_xxx()"); - CRYPTO_THREADID_current((CRYPTO_THREADID*)NULL); CRYPTO_THREADID_current((CRYPTO_THREADID*)1); AssertIntEQ(CRYPTO_THREADID_hash((const CRYPTO_THREADID*)NULL), 0); - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } static int test_ENGINE_cleanup(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "ENGINE_cleanup()"); ENGINE_cleanup(); AssertTrue(1); /* to confirm previous call gives no harm */ - printf(resultFmt, passed); -#endif /* OPENSSL_EXTRA */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* OPENSSL_EXTRA */ + return res; } static int test_wolfSSL_CTX_LoadCRL(void) { + int res = TEST_SKIPPED; #if defined(HAVE_CRL) && !defined(NO_RSA) WOLFSSL_CTX* ctx = NULL; WOLFSSL* ssl = NULL; @@ -56880,13 +55451,14 @@ static int test_wolfSSL_CTX_LoadCRL(void) AssertIntEQ(wolfSSL_CertManagerLoadCRLFile(cm, validFilePath, pemType), WOLFSSL_SUCCESS); wolfSSL_CertManagerFree(cm); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_SetTmpEC_DHE_Sz(void) { + int res = TEST_SKIPPED; #if defined(HAVE_ECC) && !defined(NO_WOLFSSL_CLIENT) WOLFSSL_CTX *ctx; WOLFSSL *ssl; @@ -56899,18 +55471,19 @@ static int test_SetTmpEC_DHE_Sz(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_CTX_get0_privatekey(void) { + int res = TEST_SKIPPED; #ifdef OPENSSL_ALL WOLFSSL_CTX* ctx = NULL; - printf(testingFmt, "wolfSSL_CTX_get0_privatekey()"); - #ifndef NO_RSA AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_method())); AssertNull(SSL_CTX_get0_privatekey(ctx)); @@ -56934,14 +55507,15 @@ static int test_wolfSSL_CTX_get0_privatekey(void) wolfSSL_CTX_free(ctx); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_dtls_set_mtu(void) { + int res = TEST_SKIPPED; #if (defined(WOLFSSL_DTLS_MTU) || defined(WOLFSSL_SCTP)) && \ defined(WOLFSSL_DTLS) WOLFSSL_CTX* ctx = NULL; @@ -56976,11 +55550,10 @@ static int test_wolfSSL_dtls_set_mtu(void) wolfSSL_free(ssl); wolfSSL_CTX_free(ctx); - printf(testingFmt, "wolfSSL_dtls_set_mtu()"); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(SINGLE_THREADED) && \ @@ -57037,7 +55610,7 @@ static void test_wolfSSL_dtls_plaintext_server(WOLFSSL* ssl) byte reply[40]; AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0); reply[sizeof(reply) - 1] = '\0'; - printf("Client message: %s\n", reply); + fprintf(stderr, "Client message: %s\n", reply); AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg)); } @@ -57058,7 +55631,7 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl) AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg)); AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0); reply[sizeof(reply) - 1] = '\0'; - printf("Server response: %s\n", reply); + fprintf(stderr, "Server response: %s\n", reply); } static int test_wolfSSL_dtls_plaintext(void) @@ -57077,8 +55650,6 @@ static int test_wolfSSL_dtls_plaintext(void) test_wolfSSL_dtls_plaintext_client}, }; - printf(testingFmt, "test_wolfSSL_dtls_plaintext"); - for (i = 0; i < sizeof(params)/sizeof(*params); i++) { XMEMSET(&func_cb_client, 0, sizeof(callback_functions)); XMEMSET(&func_cb_server, 0, sizeof(callback_functions)); @@ -57092,18 +55663,16 @@ static int test_wolfSSL_dtls_plaintext(void) test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server); if (!func_cb_client.return_code) - return -1; + return TEST_FAIL; if (!func_cb_server.return_code) - return -2; + return TEST_FAIL; } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } #else static int test_wolfSSL_dtls_plaintext(void) { - return 0; + return TEST_SKIPPED; } #endif @@ -57235,8 +55804,6 @@ static int test_wolfSSL_dtls_fragments(void) #endif }; - printf(testingFmt, "test_wolfSSL_dtls_fragments"); - for (i = 0; i < sizeof(params)/sizeof(*params); i++) { XMEMSET(&func_cb_client, 0, sizeof(callback_functions)); XMEMSET(&func_cb_server, 0, sizeof(callback_functions)); @@ -57260,9 +55827,7 @@ static int test_wolfSSL_dtls_fragments(void) AssertIntEQ(func_cb_server.last_err, DTLS_TOO_MANY_FRAGMENTS_E); } - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl) @@ -57299,7 +55864,7 @@ static int _test_wolfSSL_ignore_alert_before_cookie(byte version12) client_cbs.method = wolfDTLSv1_3_client_method; server_cbs.method = wolfDTLSv1_3_server_method; #else - return 0; + return TEST_SKIPPED; #endif /* WOLFSSL_DTLS13 */ } @@ -57307,11 +55872,11 @@ static int _test_wolfSSL_ignore_alert_before_cookie(byte version12) test_wolfSSL_client_server_nofail(&client_cbs, &server_cbs); if (!client_cbs.return_code) - return -1; + return TEST_FAIL; if (!server_cbs.return_code) - return -1; + return TEST_FAIL; - return 0; + return TEST_SUCCESS; } static int test_wolfSSL_ignore_alert_before_cookie(void) @@ -57378,11 +55943,11 @@ static int _test_wolfSSL_dtls_bad_record( test_wolfSSL_client_server_nofail(&client_cbs, &server_cbs); if (!client_cbs.return_code) - return -1; + return TEST_FAIL; if (!server_cbs.return_code) - return -1; + return TEST_FAIL; - return 0; + return TEST_SUCCESS; } static int test_wolfSSL_dtls_bad_record(void) @@ -57390,26 +55955,26 @@ static int test_wolfSSL_dtls_bad_record(void) int ret; ret = _test_wolfSSL_dtls_bad_record(wolfDTLSv1_2_client_method, wolfDTLSv1_2_server_method); - if (ret != 0) - return ret; #ifdef WOLFSSL_DTLS13 + if (ret != TEST_SUCCESS) + return ret; return _test_wolfSSL_dtls_bad_record(wolfDTLSv1_3_client_method, wolfDTLSv1_3_server_method); #else - return 0; + return ret; #endif /* WOLFSSL_DTLS13 */ } #else static int test_wolfSSL_dtls_fragments(void) { - return 0; + return TEST_SKIPPED; } static int test_wolfSSL_ignore_alert_before_cookie(void) { - return 0; + return TEST_SKIPPED; } static int test_wolfSSL_dtls_bad_record(void) { - return 0; + return TEST_SKIPPED; } #endif @@ -57587,8 +56152,6 @@ static int test_wolfSSL_dtls_AEAD_limit(void) XMEMSET(&func_cb_client, 0, sizeof(callback_functions)); XMEMSET(&func_cb_server, 0, sizeof(callback_functions)); - printf(testingFmt, "test_wolfSSL_dtls_AEAD_limit"); - func_cb_client.doUdp = func_cb_server.doUdp = 1; func_cb_server.method = wolfDTLSv1_3_server_method; func_cb_client.method = wolfDTLSv1_3_client_method; @@ -57598,17 +56161,16 @@ static int test_wolfSSL_dtls_AEAD_limit(void) test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server); if (!func_cb_client.return_code) - return -1; + return TEST_FAIL; if (!func_cb_server.return_code) - return -2; + return TEST_FAIL; - printf(resultFmt, passed); - return 0; + return TEST_SUCCESS; } #else static int test_wolfSSL_dtls_AEAD_limit(void) { - return 0; + return TEST_SKIPPED; } #endif @@ -57699,8 +56261,6 @@ static int test_wolfSSL_dtls_stateless(void) #endif }; - printf(testingFmt, "test_wolfSSL_dtls_stateless"); - for (i = 0; i < sizeof(test_params)/sizeof(*test_params); i++) { XMEMSET(&client_cbs, 0, sizeof(client_cbs)); XMEMSET(&server_cbs, 0, sizeof(server_cbs)); @@ -57713,18 +56273,17 @@ static int test_wolfSSL_dtls_stateless(void) test_wolfSSL_client_server_nofail(&client_cbs, &server_cbs); if (!client_cbs.return_code) - return -1; + return TEST_FAIL; if (!server_cbs.return_code) - return -1; + return TEST_FAIL; } - printf(resultFmt, passed); - return 0; + return TEST_SUCCESS; } #else static int test_wolfSSL_dtls_stateless(void) { - return 0; + return TEST_SKIPPED; } #endif /* WOLFSSL_DTLS13 && WOLFSSL_SEND_HRR_COOKIE && * HAVE_IO_TESTS_DEPENDENCIES && !SINGLE_THREADED */ @@ -57737,8 +56296,9 @@ static int load_ca_into_cm(WOLFSSL_CERT_MANAGER* cm, char* certA) int ret; if ((ret = wolfSSL_CertManagerLoadCA(cm, certA, 0)) != WOLFSSL_SUCCESS) { - printf("loading cert %s failed\n", certA); - printf("Error: (%d): %s\n", ret, wolfSSL_ERR_reason_error_string(ret)); + fprintf(stderr, "loading cert %s failed\n", certA); + fprintf(stderr, "Error: (%d): %s\n", ret, + wolfSSL_ERR_reason_error_string(ret)); return -1; } @@ -57750,11 +56310,13 @@ static int verify_cert_with_cm(WOLFSSL_CERT_MANAGER* cm, char* certA) int ret; if ((ret = wolfSSL_CertManagerVerify(cm, certA, WOLFSSL_FILETYPE_PEM)) != WOLFSSL_SUCCESS) { - printf("could not verify the cert: %s\n", certA); - printf("Error: (%d): %s\n", ret, wolfSSL_ERR_reason_error_string(ret)); + fprintf(stderr, "could not verify the cert: %s\n", certA); + fprintf(stderr, "Error: (%d): %s\n", ret, + wolfSSL_ERR_reason_error_string(ret)); return -1; - } else { - printf("successfully verified: %s\n", certA); + } + else { + fprintf(stderr, "successfully verified: %s\n", certA); } return 0; @@ -57914,7 +56476,7 @@ static int test_various_pathlen_chains(void) /* Test chain G (large chain with varying pathLens) */ if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) @@ -57930,7 +56492,7 @@ static int test_various_pathlen_chains(void) /* Test chain H (5 chain with same pathLens) */ if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } AssertIntLT(test_chainH(cm), 0); @@ -57938,7 +56500,7 @@ static int test_various_pathlen_chains(void) wolfSSL_CertManagerUnloadCAs(cm); wolfSSL_CertManagerFree(cm); if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } @@ -57951,7 +56513,7 @@ static int test_various_pathlen_chains(void) /* Test chain I (only first ICA has pathLen set and it's set to 2, * followed by 2 ICA's, should pass) */ if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } #if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) @@ -57962,7 +56524,7 @@ static int test_various_pathlen_chains(void) wolfSSL_CertManagerUnloadCAs(cm); wolfSSL_CertManagerFree(cm); if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } @@ -57974,7 +56536,7 @@ static int test_various_pathlen_chains(void) /* Test chain J (Again only first ICA has pathLen set and it's set to 2, * this time followed by 3 ICA's, should fail */ if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } AssertIntLT(test_chainJ(cm), 0); @@ -57982,17 +56544,14 @@ static int test_various_pathlen_chains(void) wolfSSL_CertManagerUnloadCAs(cm); wolfSSL_CertManagerFree(cm); if ((cm = wolfSSL_CertManagerNew()) == NULL) { - printf("cert manager new failed\n"); + fprintf(stderr, "cert manager new failed\n"); return -1; } ret = wolfSSL_CertManagerUnloadCAs(cm); wolfSSL_CertManagerFree(cm); - if (ret == WOLFSSL_SUCCESS) { - ret = 0; - } - return ret; + return TEST_RES_CHECK(ret == WOLFSSL_SUCCESS); } #endif /* !NO_RSA && !NO_SHA && !NO_FILESYSTEM && !NO_CERTS */ @@ -58022,7 +56581,8 @@ static int test_export_keying_material_cb(WOLFSSL_CTX *ctx, WOLFSSL *ssl) "extended master secret", XSTR_SIZEOF("extended master secret"), NULL, 0, 0), 0); AssertIntEQ(wolfSSL_export_keying_material(ssl, ekm, sizeof(ekm), "key expansion", XSTR_SIZEOF("key expansion"), NULL, 0, 0), 0); - return 0; + + return TEST_RES_CHECK(1); } static void test_export_keying_material_ssl_cb(WOLFSSL* ssl) @@ -58032,6 +56592,7 @@ static void test_export_keying_material_ssl_cb(WOLFSSL* ssl) static int test_export_keying_material(void) { + int res = TEST_SKIPPED; #ifndef SINGLE_THREADED tcp_ready ready; callback_functions clientCb; @@ -58072,19 +56633,21 @@ static int test_export_keying_material(void) #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); #endif + + res = TEST_RES_CHECK(1); #endif /* !SINGLE_THREADED */ - return 0; + return res; } #endif /* HAVE_KEYING_MATERIAL */ static int test_wolfSSL_THREADID_hash(void) { - int ret = 0; - unsigned long res; + int result = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) + unsigned long res; CRYPTO_THREADID id; - printf(testingFmt, "wolfSSL_THREADID_hash"); + CRYPTO_THREADID_current(NULL); AssertTrue(1); res = CRYPTO_THREADID_hash(NULL); @@ -58092,25 +56655,25 @@ static int test_wolfSSL_THREADID_hash(void) XMEMSET(&id, 0, sizeof(id)); res = CRYPTO_THREADID_hash(&id); AssertTrue( res == 0UL); - printf(resultFmt, passed); + + result = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - (void)res; - return ret; + return result; } static int test_wolfSSL_CTX_set_ecdh_auto(void) { - int ret = 0; - WOLFSSL_CTX* ctx = NULL; + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "SSL_CTX_set_ecdh_auto"); + WOLFSSL_CTX* ctx = NULL; + AssertIntEQ( SSL_CTX_set_ecdh_auto(NULL,0),1); AssertIntEQ( SSL_CTX_set_ecdh_auto(NULL,1),1); AssertIntEQ( SSL_CTX_set_ecdh_auto(ctx,0),1); AssertIntEQ( SSL_CTX_set_ecdh_auto(ctx,1),1); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - (void)ctx; - return ret; + return res; } #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_ERROR_CODE_OPENSSL) && \ @@ -58325,7 +56888,7 @@ static THREAD_RETURN WOLFSSL_THREAD SSL_read_test_client_thread(void* args) */ static int test_wolfSSL_read_detect_TCP_disconnect(void) { - int ret = 0; + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_ERROR_CODE_OPENSSL) && \ defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) tcp_ready ready; @@ -58336,9 +56899,6 @@ static int test_wolfSSL_read_detect_TCP_disconnect(void) callback_functions server_cbf; callback_functions client_cbf; - - printf(testingFmt, "wolfSSL_read_detect_TCP_disconnect()"); - #ifdef WOLFSSL_TIRTOS fdOpenSession(Task_self()); #endif @@ -58379,19 +56939,18 @@ static int test_wolfSSL_read_detect_TCP_disconnect(void) FreeTcpReady(&ready); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return ret; + return res; } static int test_wolfSSL_CTX_get_min_proto_version(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) WOLFSSL_CTX *ctx; (void)ctx; - printf(testingFmt, "wolfSSL_CTX_get_min_proto_version()"); - AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_method())); AssertIntEQ(wolfSSL_CTX_set_min_proto_version(ctx, SSL3_VERSION), WOLFSSL_SUCCESS); #ifdef WOLFSSL_ALLOW_SSLV3 @@ -58437,19 +56996,17 @@ static int test_wolfSSL_CTX_get_min_proto_version(void) wolfSSL_CTX_free(ctx); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) */ - - return 0; + return res; } static int test_wolfSSL_security_level(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) SSL_CTX *ctx; - printf(testingFmt, "test_wolfSSL_security_level()"); - #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); @@ -58466,22 +57023,20 @@ static int test_wolfSSL_security_level(void) (void)ctx; #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_SSL_in_init(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_BIO) SSL_CTX* ctx; SSL* ssl; const char* testCertFile; const char* testKeyFile; - printf(testingFmt, "test_wolfSSL_SSL_in_init()"); - #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); @@ -58518,33 +57073,31 @@ static int test_wolfSSL_SSL_in_init(void) (void)testKeyFile; #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_EC_curve(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) int nid = NID_secp160k1; const char* nid_name; - printf(testingFmt, "test_wolfSSL_EC_curve()"); - AssertNotNull(nid_name = EC_curve_nid2nist(nid)); AssertIntEQ(XMEMCMP(nid_name, "K-160", XSTRLEN("K-160")), 0); AssertIntEQ(EC_curve_nist2nid(nid_name), nid); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_CTX_set_timeout(void) { + int res = TEST_SKIPPED; #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_SESSION_CACHE) int timeout; @@ -58552,8 +57105,6 @@ static int test_wolfSSL_CTX_set_timeout(void) (void)timeout; - printf(testingFmt, "test_wolfSSL_CTX_set_timeout()"); - AssertNotNull(ctx); #if defined(WOLFSSL_ERROR_CODE_OPENSSL) @@ -58575,19 +57126,17 @@ static int test_wolfSSL_CTX_set_timeout(void) #endif wolfSSL_CTX_free(ctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* !NO_WOLFSSL_SERVER && !NO_SESSION_CACHE*/ - - return 0; + return res; } static int test_wolfSSL_OpenSSL_version(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) const char* ver; - printf(testingFmt, "test_wolfSSL_OpenSSL_version()"); - #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L AssertNotNull(ver = OpenSSL_version(0)); #else @@ -58595,20 +57144,19 @@ static int test_wolfSSL_OpenSSL_version(void) #endif AssertIntEQ(XMEMCMP(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING, XSTRLEN("wolfSSL " LIBWOLFSSL_VERSION_STRING)), 0); - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_CONF_CTX_CMDLINE(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) SSL_CTX* ctx = NULL; SSL_CONF_CTX* cctx = NULL; - printf(testingFmt, "test_CONF_CTX_CMDLINE"); - AssertNotNull(cctx = SSL_CONF_CTX_new()); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); @@ -58678,20 +57226,18 @@ static int test_CONF_CTX_CMDLINE(void) SSL_CTX_free(ctx); SSL_CONF_CTX_free(cctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_CONF_CTX_FILE(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) SSL_CTX* ctx = NULL; SSL_CONF_CTX* cctx = NULL; - printf(testingFmt, "test_CONF_CTX_FILE"); - AssertNotNull(cctx = SSL_CONF_CTX_new()); AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())); SSL_CONF_CTX_set_ssl_ctx(cctx, ctx); @@ -58760,18 +57306,16 @@ static int test_CONF_CTX_FILE(void) SSL_CTX_free(ctx); SSL_CONF_CTX_free(cctx); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif /* OPENSSL_EXTRA */ - - return 0; + return res; } static int test_wolfSSL_CRYPTO_get_ex_new_index(void) { + int res = TEST_SKIPPED; #ifdef HAVE_EX_DATA - int idx1,idx2; - - printf(testingFmt, "test_wolfSSL_CRYPTO_get_ex_new_index()"); + int idx1, idx2; /* test for unsupported class index */ AssertIntEQ(wolfSSL_CRYPTO_get_ex_new_index(WOLF_CRYPTO_EX_INDEX_X509_STORE, @@ -58834,23 +57378,21 @@ static int test_wolfSSL_CRYPTO_get_ex_new_index(void) AssertIntNE(idx2, -1); AssertIntNE(idx1, idx2); - printf(resultFmt, "passed"); + res = TEST_RES_CHECK(1); #endif /* HAVE_EX_DATA */ - - return 0; + return res; } static int test_wolfSSL_set_psk_use_session_callback(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(NO_PSK) SSL_CTX* ctx; SSL* ssl; const char* testCertFile; const char* testKeyFile; - printf(testingFmt, "test_wolfSSL_set_psk_use_session_callback()"); - - #ifdef WOLFSSL_TLS13 + #ifdef WOLFSSL_TLS13 #ifdef NO_WOLFSSL_SERVER AssertNotNull(ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())); #else @@ -58888,14 +57430,17 @@ static int test_wolfSSL_set_psk_use_session_callback(void) (void)testCertFile; (void)testKeyFile; #endif - printf(resultFmt, passed); -#endif - return 0; + res = TEST_RES_CHECK(1); +#endif + return res; } static int test_wolfSSL_ERR_strings(void) { + int res = TEST_SKIPPED; + +#if !defined(NO_ERROR_STRINGS) const char* err1 = "unsupported cipher suite"; const char* err2 = "wolfSSL PEM routines"; const char* err = NULL; @@ -58903,8 +57448,6 @@ static int test_wolfSSL_ERR_strings(void) (void)err; (void)err1; (void)err2; -#if !defined(NO_ERROR_STRINGS) - printf(testingFmt, "test_wolfSSL_ERR_strings"); #if defined(OPENSSL_EXTRA) err = ERR_reason_error_string(UNSUPPORTED_SUITE); @@ -58932,49 +57475,53 @@ static int test_wolfSSL_ERR_strings(void) AssertTrue(err != NULL); AssertIntEQ((*err == '\0'), 1); #endif - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_EVP_shake128(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \ defined(WOLFSSL_SHAKE128) - printf(testingFmt, "test_wolfSSL_EVP_shake128"); const EVP_MD* md = NULL; + md = EVP_shake128(); AssertTrue(md != NULL); AssertIntEQ(XSTRNCMP(md, "SHAKE128", XSTRLEN("SHAKE128")), 0); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_wolfSSL_EVP_shake256(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \ defined(WOLFSSL_SHAKE256) const EVP_MD* md = NULL; - printf(testingFmt, "test_wolfSSL_EVP_shake256"); + md = EVP_shake256(); AssertTrue(md != NULL); AssertIntEQ(XSTRNCMP(md, "SHAKE256", XSTRLEN("SHAKE256")), 0); - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_EVP_blake2(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)) const EVP_MD* md = NULL; (void)md; - printf(testingFmt, "test_EVP_blake2"); - #if defined(HAVE_BLAKE2) md = EVP_blake2b512(); AssertTrue(md != NULL); @@ -58986,10 +57533,11 @@ static int test_EVP_blake2(void) AssertTrue(md != NULL); AssertIntEQ(XSTRNCMP(md, "BLAKE2S256", XSTRLEN("BLAKE2S256")), 0); #endif - printf(resultFmt, passed); + + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(OPENSSL_EXTRA) @@ -59019,7 +57567,7 @@ static void list_md_fn(const EVP_MD* m, const char* from, #if !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL_VERBOSE) mn = EVP_get_digestbyname(from); - /* print to stdout */ + /* print to stderr */ AssertNotNull(arg); bio = BIO_new(BIO_s_file()); @@ -59032,22 +57580,21 @@ static void list_md_fn(const EVP_MD* m, const char* from, static int test_EVP_MD_do_all(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "test_EVP_MD_do_all"); - - EVP_MD_do_all(NULL, stdout); + EVP_MD_do_all(NULL, stderr); /* to confirm previous call gives no harm */ AssertTrue(1); - EVP_MD_do_all(list_md_fn, stdout); + EVP_MD_do_all(list_md_fn, stderr); /* to confirm previous call gives no harm */ AssertTrue(1); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(OPENSSL_EXTRA) @@ -59059,7 +57606,7 @@ static void obj_name_t(const OBJ_NAME* nm, void* arg) AssertIntGT(nm->type, OBJ_NAME_TYPE_UNDEF); #if !defined(NO_FILESYSTEM) && defined(DEBUG_WOLFSSL_VERBOSE) - /* print to stdout */ + /* print to stderr */ AssertNotNull(arg); bio = BIO_new(BIO_s_file()); @@ -59072,40 +57619,41 @@ static void obj_name_t(const OBJ_NAME* nm, void* arg) #endif static int test_OBJ_NAME_do_all(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) - printf(testingFmt, "test_OBJ_NAME_do_all"); OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, NULL, NULL); /* to confirm previous call gives no harm */ AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, NULL, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, NULL, stderr); /* to confirm previous call gives no harm */ AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_PKEY_METH, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_PKEY_METH, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_COMP_METH, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_COMP_METH, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_NUM, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_NUM, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_UNDEF, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_UNDEF, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, obj_name_t, stdout); + OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, obj_name_t, stderr); AssertTrue(1); - OBJ_NAME_do_all(-1, obj_name_t, stdout); + OBJ_NAME_do_all(-1, obj_name_t, stderr); AssertTrue(1); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } static int test_SSL_CIPHER_get_xxx(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) && !defined(NO_CERTS) && \ !defined(NO_FILESYSTEM) const SSL_CIPHER* cipher = NULL; @@ -59140,8 +57688,6 @@ static int test_SSL_CIPHER_get_xxx(void) (void)testCertFile; (void)testKeyFile; - printf(testingFmt, "test_SSL_CIPHER_get_xxx"); - #if defined(WOLFSSL_TLS13) cipher_id = "TLS13-AES128-GCM-SHA256"; expect_nid1 = NID_auth_rsa; @@ -59235,13 +57781,13 @@ static int test_SSL_CIPHER_get_xxx(void) if (ctx) SSL_CTX_free(ctx); - if(ssl) + if (ssl) SSL_free(ssl); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - return 0; + return res; } #if defined(WOLF_CRYPTO_CB) && defined(HAVE_IO_TESTS_DEPENDENCIES) @@ -59268,7 +57814,7 @@ static int load_pem_key_file_as_der(const char* privKeyFile, DerBuffer** pDer, (void)encInfo; /* not used in this test */ #ifdef DEBUG_WOLFSSL - printf("%s (%d): Loading PEM %s (len %d) to DER (len %d)\n", + fprintf(stderr, "%s (%d): Loading PEM %s (len %d) to DER (len %d)\n", (ret == 0) ? "Success" : "Failure", ret, privKeyFile, (int)key_sz, (*pDer)->length); #endif @@ -59284,7 +57830,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) if (info->algo_type == WC_ALGO_TYPE_PK) { #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: Pk Type %d\n", info->pk.type); + fprintf(stderr, "test_CryptoCb_Func: Pk Type %d\n", info->pk.type); #endif #ifndef NO_RSA @@ -59302,7 +57848,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) /* perform software based RSA private op */ #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: RSA Priv\n"); + fprintf(stderr, "test_CryptoCb_Func: RSA Priv\n"); #endif ret = load_pem_key_file_as_der(privKeyFile, &pDer, @@ -59324,8 +57870,9 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) } else { /* if decode fails, then fall-back to software based crypto */ - printf("test_CryptoCb_Func: RSA private key decode " - "failed %d, falling back to software\n", ret); + fprintf(stderr, "test_CryptoCb_Func: RSA private " + "key decode failed %d, falling back to " + "software\n", ret); ret = CRYPTOCB_UNAVAILABLE; } wc_FreeRsaKey(&key); @@ -59335,7 +57882,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) } } #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: RSA Type %d, Ret %d, Out %d\n", + fprintf(stderr, "test_CryptoCb_Func: RSA Type %d, Ret %d, Out %d\n", info->pk.rsa.type, ret, *info->pk.rsa.outLen); #endif } @@ -59354,14 +57901,15 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) /* perform software based ECC sign */ #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: ECC Sign\n"); + fprintf(stderr, "test_CryptoCb_Func: ECC Sign\n"); #endif if (info->pk.eccsign.key != NULL && XSTRCMP(info->pk.eccsign.key->label, "ephemeral") == 0) { /* this is an empheral key */ #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: skipping signing op on ephemeral key\n"); + fprintf(stderr, "test_CryptoCb_Func: skipping signing op on " + "ephemeral key\n"); #endif return CRYPTOCB_UNAVAILABLE; } @@ -59385,8 +57933,8 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) } else { /* if decode fails, then fall-back to software based crypto */ - printf("test_CryptoCb_Func: ECC private key decode " - "failed %d, falling back to software\n", ret); + fprintf(stderr, "test_CryptoCb_Func: ECC private key " + "decode failed %d, falling back to software\n", ret); ret = CRYPTOCB_UNAVAILABLE; } wc_ecc_free(&key); @@ -59394,7 +57942,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) wc_FreeDer(&pDer); pDer = NULL; #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: ECC Ret %d, Out %d\n", + fprintf(stderr, "test_CryptoCb_Func: ECC Ret %d, Out %d\n", ret, *info->pk.eccsign.outlen); #endif } @@ -59405,7 +57953,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) /* perform software based ED25519 sign */ #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: ED25519 Sign\n"); + fprintf(stderr, "test_CryptoCb_Func: ED25519 Sign\n"); #endif ret = load_pem_key_file_as_der(privKeyFile, &pDer, &keyFormat); @@ -59433,8 +57981,8 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) } else { /* if decode fails, then fall-back to software based crypto */ - printf("test_CryptoCb_Func: ED25519 private key decode " - "failed %d, falling back to software\n", ret); + fprintf(stderr, "test_CryptoCb_Func: ED25519 private key " + "decode failed %d, falling back to software\n", ret); ret = CRYPTOCB_UNAVAILABLE; } wc_ed25519_free(&key); @@ -59442,7 +57990,7 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx) wc_FreeDer(&pDer); pDer = NULL; #ifdef DEBUG_WOLFSSL - printf("test_CryptoCb_Func: ED25519 Ret %d, Out %d\n", + fprintf(stderr, "test_CryptoCb_Func: ED25519 Ret %d, Out %d\n", ret, *info->pk.ed25519sign.outLen); #endif } @@ -59558,6 +58106,7 @@ static void test_wc_CryptoCb_TLS(int tlsVer, static int test_wc_CryptoCb(void) { + int res = TEST_SKIPPED; #ifdef WOLF_CRYPTO_CB /* TODO: Add crypto callback API tests */ @@ -59589,9 +58138,10 @@ static int test_wc_CryptoCb(void) } #endif #endif /* HAVE_IO_TESTS_DEPENDENCIES */ -#endif /* WOLF_CRYPTO_CB */ - return 0; + res = TEST_RES_CHECK(1); +#endif /* WOLF_CRYPTO_CB */ + return res; } #if defined(WOLFSSL_STATIC_MEMORY) && defined(HAVE_IO_TESTS_DEPENDENCIES) @@ -59741,12 +58291,13 @@ static int test_wolfSSL_CTX_StaticMemory_SSL(WOLFSSL_CTX* ctx) wolfSSL_free(ssl1); wolfSSL_free(ssl2); - return 0; + return TEST_RES_CHECK(1); } #endif /* WOLFSSL_STATIC_MEMORY */ static int test_wolfSSL_CTX_StaticMemory(void) { + int res = TEST_SKIPPED; #ifdef WOLFSSL_STATIC_MEMORY wolfSSL_method_func method_func; WOLFSSL_CTX* ctx; @@ -59759,8 +58310,6 @@ static int test_wolfSSL_CTX_StaticMemory(void) #endif byte svrMem[TEST_TLS_STATIC_MEMSZ]; - printf(testingFmt, "test_wolfSSL_CTX_StaticMemory()"); - #ifndef NO_WOLFSSL_SERVER #ifndef WOLFSSL_NO_TLS12 method_func = wolfTLSv1_2_server_method_ex; @@ -59821,14 +58370,14 @@ static int test_wolfSSL_CTX_StaticMemory(void) #endif #endif /* HAVE_IO_TESTS_DEPENDENCIES */ - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_openssl_FIPS_drbg(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_EXTRA) && !defined(WC_NO_RNG) && defined(HAVE_HASHDRBG) DRBG_CTX* dctx; byte data1[32], data2[32], zeroData[32]; @@ -59843,8 +58392,6 @@ static int test_openssl_FIPS_drbg(void) testSeed[i] = (byte)i; } - printf(testingFmt, "test_openssl_FIPS_drbg()"); - AssertNotNull(dctx = FIPS_get_default_drbg()); AssertIntEQ(FIPS_drbg_init(dctx, 0, 0), WOLFSSL_SUCCESS); AssertIntEQ(FIPS_drbg_set_callbacks(dctx, NULL, NULL, 20, NULL, NULL), @@ -59861,17 +58408,15 @@ static int test_openssl_FIPS_drbg(void) AssertIntNE(XMEMCMP(data1, data2, dlen), 0); AssertIntEQ(FIPS_drbg_uninstantiate(dctx), WOLFSSL_SUCCESS); - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } static int test_wolfSSL_FIPS_mode(void) { + int res = TEST_SKIPPED; #if defined(OPENSSL_ALL) - printf(testingFmt, "test_wolfSSL_FIPS_mode()"); - #ifdef HAVE_FIPS AssertIntEQ(wolfSSL_FIPS_mode(), 1); AssertIntEQ(wolfSSL_FIPS_mode_set(0), WOLFSSL_FAILURE); @@ -59882,10 +58427,9 @@ static int test_wolfSSL_FIPS_mode(void) AssertIntEQ(wolfSSL_FIPS_mode_set(1), WOLFSSL_FAILURE); #endif - printf(resultFmt, passed); + res = TEST_RES_CHECK(1); #endif - - return 0; + return res; } #ifdef WOLFSSL_DTLS @@ -59900,13 +58444,13 @@ static void DUW_TEST_print_window_binary(word32 h, word32 l, word32* w) { /* Prints out a 32 bit binary number in big endian order */ for (j = 0; j < 32; j++, b <<= 1) { if (b & (((word32)1) << 31)) - printf("1"); + fprintf(stderr, "1"); else - printf("0"); + fprintf(stderr, "0"); } - printf(" "); + fprintf(stderr, " "); } - printf("cur_hi %u cur_lo %u\n", h, l); + fprintf(stderr, "cur_hi %u cur_lo %u\n", h, l); #else (void)h; (void)l; @@ -59939,9 +58483,8 @@ static int test_wolfSSL_DtlsUpdateWindow(void) word32 next_lo = 0; word16 next_hi = 0; - printf(testingFmt, "wolfSSL_DtlsUpdateWindow()"); #ifdef WOLFSSL_DEBUG_DTLS_WINDOW - printf("\n"); + fprintf(stderr, "\n"); #endif XMEMSET(window, 0, sizeof window); @@ -59978,10 +58521,7 @@ static int test_wolfSSL_DtlsUpdateWindow(void) DUW_TEST(150, 0xFFFFFFFF, next_hi, next_lo, window, 151, 0, 0, 0x01); DUW_TEST(152, 0xFFFFFFFF, next_hi, next_lo, window, 153, 0, 0, 0x01); - printf(resultFmt, passed); - fflush(stdout); - - return 0; + return TEST_RES_CHECK(1); } #endif /* WOLFSSL_DTLS */ @@ -60048,8 +58588,6 @@ static int test_wolfSSL_DTLS_fragment_buckets(void) { WOLFSSL ssl[1]; - printf(testingFmt, "wolfSSL_DTLS_fragment_buckets()"); - XMEMSET(ssl, 0, sizeof(*ssl)); AssertIntEQ(DFB_TEST(ssl, 0, 100, 0, 100, 0, 1, 100), 0); /* 0-100 */ @@ -60112,9 +58650,7 @@ static int test_wolfSSL_DTLS_fragment_buckets(void) DFB_TEST_RESET(ssl); - printf(resultFmt, passed); - - return 0; + return TEST_RES_CHECK(1); } #endif @@ -60167,12 +58703,12 @@ static int test_WOLFSSL_dtls_version_alert(void) wolfSSL_CTX_free(ctx_c); wolfSSL_CTX_free(ctx_s); - return 0; + return TEST_RES_CHECK(1); } #else static int test_WOLFSSL_dtls_version_alert(void) { - return 0; + return TEST_SKIPPED; } #endif /* defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && * !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && @@ -60376,9 +58912,12 @@ typedef int (*TEST_FUNC)(void); typedef struct { const char *name; TEST_FUNC func; + byte run:1; } TEST_CASE; -#define TEST_DECL(func) { #func, func } +#define TEST_DECL(func) { #func, func, 0 } + +int testAll = 1; TEST_CASE testCases[] = { TEST_DECL(test_fileAccess), @@ -60445,9 +58984,7 @@ TEST_CASE testCases[] = { #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \ defined(HAVE_IO_TESTS_DEPENDENCIES) TEST_DECL(test_wolfSSL_read_write), -#if defined(OPENSSL_EXTRA) && !defined(NO_SESSION_CACHE) && !defined(WOLFSSL_TLS13) TEST_DECL(test_wolfSSL_reuse_WOLFSSLobj), -#endif TEST_DECL(test_wolfSSL_CTX_verifyDepth_ServerClient), TEST_DECL(test_wolfSSL_dtls_export), TEST_DECL(test_wolfSSL_tls_export), @@ -60457,13 +58994,23 @@ TEST_CASE testCases[] = { /* TLS extensions tests */ #ifdef HAVE_IO_TESTS_DEPENDENCIES - TEST_DECL(test_wolfSSL_UseSNI), +#ifdef HAVE_SNI + TEST_DECL(test_wolfSSL_UseSNI_params), + TEST_DECL(test_wolfSSL_UseSNI_connection), + TEST_DECL(test_wolfSSL_SNI_GetFromBuffer), +#endif /* HAVE_SNI */ #endif TEST_DECL(test_wolfSSL_UseTrustedCA), TEST_DECL(test_wolfSSL_UseMaxFragment), TEST_DECL(test_wolfSSL_UseTruncatedHMAC), TEST_DECL(test_wolfSSL_UseSupportedCurve), - TEST_DECL(test_wolfSSL_UseALPN), +#if defined(HAVE_ALPN) && defined(HAVE_IO_TESTS_DEPENDENCIES) + TEST_DECL(test_wolfSSL_UseALPN_connection), + TEST_DECL(test_wolfSSL_UseALPN_params), +#endif +#ifdef HAVE_ALPN_PROTOS_SUPPORT + TEST_DECL(test_wolfSSL_set_alpn_protos), +#endif TEST_DECL(test_wolfSSL_DisableExtendedMasterSecret), TEST_DECL(test_wolfSSL_wolfSSL_UseSecureRenegotiation), @@ -60727,6 +59274,7 @@ TEST_CASE testCases[] = { TEST_DECL(test_wolfSSL_CRYPTO_cts128), TEST_DECL(test_wolfssl_EVP_aes_gcm_AAD_2_parts), TEST_DECL(test_wolfssl_EVP_aes_gcm), + TEST_DECL(test_wolfssl_EVP_aes_gcm_zeroLen), TEST_DECL(test_wolfssl_EVP_chacha20_poly1305), TEST_DECL(test_wolfssl_EVP_chacha20), TEST_DECL(test_wolfSSL_EVP_PKEY_hkdf), @@ -60841,6 +59389,7 @@ TEST_CASE testCases[] = { TEST_DECL(test_wolfSSL_RSA_LoadDer), TEST_DECL(test_wolfSSL_RSA_To_Der), TEST_DECL(test_wolfSSL_PEM_read_RSAPublicKey), + TEST_DECL(test_wolfSSL_PEM_write_RSA_PUBKEY), TEST_DECL(test_wolfSSL_PEM_write_RSAPrivateKey), TEST_DECL(test_wolfSSL_PEM_write_mem_RSAPrivateKey), @@ -61324,6 +59873,84 @@ static void TestCleanup(void) #endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */ } +/* Print out all API test cases with numeric identifier. + */ +void ApiTest_PrintTestCases(void) +{ + int i; + + printf("All Test Cases:"); + for (i = 0; i < TEST_CASE_CNT; i++) { + printf("%3d: %s\n", i + 1, testCases[i].name); + } +} + +/* Add test case with index to the list to run. + * + * @param [in] idx Index of test case to run starting at 1. + * @return 0 on success. + * @return BAD_FUNC_ARG when index is out of range of test case identifiers. + */ +int ApiTest_RunIdx(int idx) +{ + if (idx < 1 || idx > TEST_CASE_CNT) { + printf("Index out of range (1 - %d): %d\n", TEST_CASE_CNT, idx); + return BAD_FUNC_ARG; + } + + testAll = 0; + testCases[idx-1].run = 1; + + return 0; +} + +/* Add test case with name to the list to run. + * + * @param [in] name Name of test case to run. + * @return 0 on success. + * @return BAD_FUNC_ARG when name is not a known test case name. + */ +int ApiTest_RunName(char* name) +{ + int i; + + for (i = 0; i < TEST_CASE_CNT; i++) { + if (XSTRCMP(testCases[i].name, name) == 0) { + testAll = 0; + testCases[i].run = 1; + return 0; + } + } + + printf("Test case name not found: %s\n", name); + printf("Use -list to see all test case names.\n"); + return BAD_FUNC_ARG; +} + +/* Converts the result code to a string. + * + * @param [in] res Test result code. + * @return String describing test result. + */ +static const char* apitest_res_string(int res) +{ + const char* str = "invalid result"; + + switch (res) { + case TEST_SUCCESS: + str = "passed"; + break; + case TEST_FAIL: + str = "failed"; + break; + case TEST_SKIPPED: + str = "skipped"; + break; + } + + return str; +} + void ApiTest(void) { int i; @@ -61333,13 +59960,19 @@ void ApiTest(void) fflush(stdout); for (i = 0; i < TEST_CASE_CNT; ++i) { + /* When not testing all cases then skip if not marked for running. */ + if (!testAll && !testCases[i].run) { + continue; + } + TestSetup(); + printf(" %3d: %-60s:", i + 1, testCases[i].name); + fflush(stdout); ret = testCases[i].func(); - if (ret != 0) { - fprintf(stderr, "%s failed.\n", testCases[i].name); - } - AssertIntEQ(ret, 0); + printf(" %s\n", apitest_res_string(ret)); + fflush(stdout); + AssertIntNE(ret, TEST_FAIL); TestCleanup(); } diff --git a/tests/unit.c b/tests/unit.c index ab2896097..a269c52c9 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -33,6 +33,7 @@ #include +int allTesting = 1; int myoptind = 0; char* myoptarg = NULL; int unit_test(int argc, char** argv); @@ -44,6 +45,21 @@ int main(int argc, char** argv) } #endif +/* Print usage options for unit test. + */ +static void UnitTest_Usage(void) +{ + printf("Usage: ./tests/unit.test \n"); + printf(" -?, --help Display this usage information.\n"); + printf(" --list List the API tests.\n"); + printf(" --api Only perform API tests.\n"); + printf(" - Run the API test identified by number.\n"); + printf(" Can be specified multiple times.\n"); + printf(" - Run the API test identified by name.\n"); + printf(" Can be specified multiple times.\n"); + printf(" Name of cipher suite testing file.\n"); +} + int unit_test(int argc, char** argv) { int ret = 0; @@ -154,39 +170,76 @@ int unit_test(int argc, char** argv) } #endif #endif /* HAVE_FIPS && HAVE_FIPS_VERSION == 5 */ + + while (argc > 1) { + if (argv[1][0] != '-') { + break; + } + + if (XSTRCMP(argv[1], "-?") == 0 || XSTRCMP(argv[1], "--help") == 0) { + UnitTest_Usage(); + goto exit; + } + else if (XSTRCMP(argv[1], "--list") == 0) { + ApiTest_PrintTestCases(); + goto exit; + } + else if (XSTRCMP(argv[1], "--api") == 0) { + } + else if (argv[1][1] >= '0' && argv[1][1] <= '9') { + ret = ApiTest_RunIdx(atoi(argv[1] + 1)); + if (ret != 0) { + goto exit; + } + } + else { + ret = ApiTest_RunName(argv[1] + 1); + if (ret != 0) { + goto exit; + } + } + + allTesting = 0; + argc--; + argv++; + } + #ifdef WOLFSSL_ALLOW_SKIP_UNIT_TESTS if (argc == 1) #endif { ApiTest(); - if ( (ret = HashTest()) != 0){ + if (!allTesting) { + goto exit; + } + + if ((ret = HashTest()) != 0) { fprintf(stderr, "hash test failed with %d\n", ret); goto exit; } -#ifdef WOLFSSL_W64_WRAPPER + #ifdef WOLFSSL_W64_WRAPPER if ((ret = w64wrapper_test()) != 0) { fprintf(stderr, "w64wrapper test failed with %d\n", ret); goto exit; } -#endif /* WOLFSSL_W64_WRAPPER */ + #endif /* WOLFSSL_W64_WRAPPER */ + #ifdef WOLFSSL_QUIC + if ((ret = QuicTest()) != 0) { + printf("quic test failed with %d\n", ret); + goto exit; + } + #endif + + SrpTest(); } -#ifdef WOLFSSL_QUIC - if ( (ret = QuicTest()) != 0){ - printf("quic test failed with %d\n", ret); - goto exit; - } -#endif - - SrpTest(); - #ifndef NO_WOLFSSL_CIPHER_SUITE_TEST #if !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) #ifndef SINGLE_THREADED - if ( (ret = SuiteTest(argc, argv)) != 0){ + if ((ret = SuiteTest(argc, argv)) != 0) { fprintf(stderr, "suite test failed with %d\n", ret); goto exit; } diff --git a/tests/unit.h b/tests/unit.h index 3ac29ad19..2b716f9c2 100644 --- a/tests/unit.h +++ b/tests/unit.h @@ -110,7 +110,11 @@ #define AssertPtrLE(x, y) AssertPtr(x, y, <=, >) +void ApiTest_PrintTestCases(void); +int ApiTest_RunIdx(int idx); +int ApiTest_RunName(char* name); void ApiTest(void); + int SuiteTest(int argc, char** argv); int HashTest(void); void SrpTest(void);