forked from wolfSSL/wolfssl
Merge pull request #5136 from douzzer/20220512-stderr
print errors to stderr, not stdout
This commit is contained in:
@@ -491,7 +491,7 @@ static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != msgSz) {
|
if (ret != msgSz) {
|
||||||
printf("SSL_write_early_data msg error %d, %s\n", err,
|
fprintf(stderr, "SSL_write_early_data msg error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(ssl); ssl = NULL;
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -511,7 +511,7 @@ static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != msgSz) {
|
if (ret != msgSz) {
|
||||||
printf("SSL_write_early_data msg error %d, %s\n", err,
|
fprintf(stderr, "SSL_write_early_data msg error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(ssl);
|
wolfSSL_free(ssl);
|
||||||
wolfSSL_CTX_free(ctx);
|
wolfSSL_CTX_free(ctx);
|
||||||
@@ -779,7 +779,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != len) {
|
if (ret != len) {
|
||||||
printf("SSL_write bench error %d!\n", err);
|
fprintf(stderr, "SSL_write bench error %d!\n", err);
|
||||||
if (!exitWithRet)
|
if (!exitWithRet)
|
||||||
err_sys("SSL_write failed");
|
err_sys("SSL_write failed");
|
||||||
goto doExit;
|
goto doExit;
|
||||||
@@ -804,7 +804,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (err != WOLFSSL_ERROR_WANT_READ) {
|
if (err != WOLFSSL_ERROR_WANT_READ) {
|
||||||
printf("SSL_read bench error %d\n", err);
|
fprintf(stderr, "SSL_read bench error %d\n", err);
|
||||||
err_sys("SSL_read failed");
|
err_sys("SSL_read failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -995,7 +995,7 @@ static int SMTP_Shutdown(WOLFSSL* ssl, int wc_shutdown)
|
|||||||
printf("Bidirectional shutdown complete\n");
|
printf("Bidirectional shutdown complete\n");
|
||||||
}
|
}
|
||||||
if (ret != WOLFSSL_SUCCESS)
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
printf("Bidirectional shutdown failed\n");
|
fprintf(stderr, "Bidirectional shutdown failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return WOLFSSL_SUCCESS;
|
return WOLFSSL_SUCCESS;
|
||||||
@@ -1026,7 +1026,7 @@ static int ClientWrite(WOLFSSL* ssl, const char* msg, int msgSz, const char* str
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (ret != msgSz) {
|
if (ret != msgSz) {
|
||||||
printf("SSL_write%s msg error %d, %s\n", str, err,
|
fprintf(stderr, "SSL_write%s msg error %d, %s\n", str, err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
if (!exitWithRet) {
|
if (!exitWithRet) {
|
||||||
err_sys("SSL_write failed");
|
err_sys("SSL_write failed");
|
||||||
@@ -1056,7 +1056,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (err != WOLFSSL_ERROR_WANT_READ && err != APP_DATA_READY) {
|
if (err != WOLFSSL_ERROR_WANT_READ && err != APP_DATA_READY) {
|
||||||
printf("SSL_read reply error %d, %s\n", err,
|
fprintf(stderr, "SSL_read reply error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
if (!exitWithRet) {
|
if (!exitWithRet) {
|
||||||
err_sys("SSL_read failed");
|
err_sys("SSL_read failed");
|
||||||
@@ -1070,7 +1070,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
|
|||||||
if (mustRead && err == WOLFSSL_ERROR_WANT_READ) {
|
if (mustRead && err == WOLFSSL_ERROR_WANT_READ) {
|
||||||
elapsed = current_time(0) - start;
|
elapsed = current_time(0) - start;
|
||||||
if (elapsed > MAX_NON_BLOCK_SEC) {
|
if (elapsed > MAX_NON_BLOCK_SEC) {
|
||||||
printf("Nonblocking read timeout\n");
|
fprintf(stderr, "Nonblocking read timeout\n");
|
||||||
ret = WOLFSSL_FATAL_ERROR;
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1534,12 +1534,12 @@ static void showPeerPEM(WOLFSSL* ssl)
|
|||||||
if (peer) {
|
if (peer) {
|
||||||
WOLFSSL_BIO* bioOut = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
|
WOLFSSL_BIO* bioOut = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
|
||||||
if (bioOut == NULL) {
|
if (bioOut == NULL) {
|
||||||
printf("failed to get bio on stdout\n");
|
fprintf(stderr, "failed to get bio on stdout\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (wolfSSL_BIO_set_fp(bioOut, stdout, BIO_NOCLOSE)
|
if (wolfSSL_BIO_set_fp(bioOut, stdout, BIO_NOCLOSE)
|
||||||
!= WOLFSSL_SUCCESS) {
|
!= WOLFSSL_SUCCESS) {
|
||||||
printf("failed to set stdout to bio output\n");
|
fprintf(stderr, "failed to set stdout to bio output\n");
|
||||||
wolfSSL_BIO_free(bioOut);
|
wolfSSL_BIO_free(bioOut);
|
||||||
bioOut = NULL;
|
bioOut = NULL;
|
||||||
}
|
}
|
||||||
@@ -1774,7 +1774,7 @@ static int client_srtp_test(WOLFSSL *ssl, func_args *args)
|
|||||||
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
if (ret != LENGTH_ONLY_E) {
|
if (ret != LENGTH_ONLY_E) {
|
||||||
printf("DTLS SRTP: Error getting keying material length\n");
|
fprintf(stderr, "DTLS SRTP: Error getting keying material length\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1788,7 +1788,7 @@ static int client_srtp_test(WOLFSSL *ssl, func_args *args)
|
|||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
printf("DTLS SRTP: Error getting keying material\n");
|
fprintf(stderr, "DTLS SRTP: Error getting keying material\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2726,7 +2726,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
printf("external test can't be run in this mode\n");
|
fprintf(stderr, "external test can't be run in this mode\n");
|
||||||
|
|
||||||
((func_args*)args)->return_code = 0;
|
((func_args*)args)->return_code = 0;
|
||||||
XEXIT_T(EXIT_SUCCESS);
|
XEXIT_T(EXIT_SUCCESS);
|
||||||
@@ -2762,7 +2762,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
if (usePqc) {
|
if (usePqc) {
|
||||||
if (version == CLIENT_DOWNGRADE_VERSION ||
|
if (version == CLIENT_DOWNGRADE_VERSION ||
|
||||||
version == EITHER_DOWNGRADE_VERSION)
|
version == EITHER_DOWNGRADE_VERSION)
|
||||||
printf("WARNING: If a TLS 1.3 connection is not negotiated, you "
|
fprintf(stderr,
|
||||||
|
"WARNING: If a TLS 1.3 connection is not negotiated, you "
|
||||||
"will not be using a post-quantum group.\n");
|
"will not be using a post-quantum group.\n");
|
||||||
else if (version != 4)
|
else if (version != 4)
|
||||||
err_sys("can only use post-quantum groups with TLS 1.3");
|
err_sys("can only use post-quantum groups with TLS 1.3");
|
||||||
@@ -3209,7 +3210,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
ret = wolfAsync_DevOpen(&devId);
|
ret = wolfAsync_DevOpen(&devId);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Async device open failed\nRunning without async\n");
|
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||||
}
|
}
|
||||||
wolfSSL_CTX_SetDevId(ctx, devId);
|
wolfSSL_CTX_SetDevId(ctx, devId);
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
@@ -3658,7 +3659,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
err = wolfSSL_get_error(ssl, 0);
|
err = wolfSSL_get_error(ssl, 0);
|
||||||
printf("wolfSSL_connect error %d, %s\n", err,
|
fprintf(stderr, "wolfSSL_connect error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
@@ -3888,7 +3889,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
}
|
}
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
err = wolfSSL_get_error(ssl, 0);
|
err = wolfSSL_get_error(ssl, 0);
|
||||||
printf("wolfSSL_Rehandshake error %d, %s\n", err,
|
fprintf(stderr, "wolfSSL_Rehandshake error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(ssl); ssl = NULL;
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -3897,7 +3898,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("not doing secure resumption with non-blocking");
|
fprintf(stderr, "not doing secure resumption with non-blocking");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!resumeScr) {
|
if (!resumeScr) {
|
||||||
@@ -4056,12 +4057,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
|
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
|
||||||
printf("Bidirectional shutdown failed\n");
|
fprintf(stderr, "Bidirectional shutdown failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret != WOLFSSL_SUCCESS)
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
printf("Bidirectional shutdown failed\n");
|
fprintf(stderr, "Bidirectional shutdown failed\n");
|
||||||
}
|
}
|
||||||
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
|
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
|
||||||
if (atomicUser)
|
if (atomicUser)
|
||||||
@@ -4197,7 +4198,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
ret = NonBlockingSSL_Connect(sslResume); /* will keep retrying on timeout */
|
ret = NonBlockingSSL_Connect(sslResume); /* will keep retrying on timeout */
|
||||||
#endif
|
#endif
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
printf("wolfSSL_connect resume error %d, %s\n", err,
|
fprintf(stderr, "wolfSSL_connect resume error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(sslResume); sslResume = NULL;
|
wolfSSL_free(sslResume); sslResume = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -4210,7 +4211,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
if (wolfSSL_session_reused(sslResume))
|
if (wolfSSL_session_reused(sslResume))
|
||||||
printf("reused session id\n");
|
printf("reused session id\n");
|
||||||
else
|
else
|
||||||
printf("didn't reuse session id!!!\n");
|
fprintf(stderr, "didn't reuse session id!!!\n");
|
||||||
|
|
||||||
#ifdef HAVE_ALPN
|
#ifdef HAVE_ALPN
|
||||||
if (alpnList != NULL) {
|
if (alpnList != NULL) {
|
||||||
@@ -4245,7 +4246,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
printf("Beginning secure renegotiation.\n");
|
printf("Beginning secure renegotiation.\n");
|
||||||
if (wolfSSL_Rehandshake(sslResume) != WOLFSSL_SUCCESS) {
|
if (wolfSSL_Rehandshake(sslResume) != WOLFSSL_SUCCESS) {
|
||||||
err = wolfSSL_get_error(sslResume, 0);
|
err = wolfSSL_get_error(sslResume, 0);
|
||||||
printf("err = %d, %s\n", err,
|
fprintf(stderr, "err = %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(sslResume); sslResume = NULL;
|
wolfSSL_free(sslResume); sslResume = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -4259,7 +4260,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
printf("Beginning secure resumption.\n");
|
printf("Beginning secure resumption.\n");
|
||||||
if (wolfSSL_SecureResume(sslResume) != WOLFSSL_SUCCESS) {
|
if (wolfSSL_SecureResume(sslResume) != WOLFSSL_SUCCESS) {
|
||||||
err = wolfSSL_get_error(sslResume, 0);
|
err = wolfSSL_get_error(sslResume, 0);
|
||||||
printf("err = %d, %s\n", err,
|
fprintf(stderr, "err = %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(sslResume); sslResume = NULL;
|
wolfSSL_free(sslResume); sslResume = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -4378,7 +4379,7 @@ exit:
|
|||||||
client_test(&args);
|
client_test(&args);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
printf("Client not compiled in!\n");
|
fprintf(stderr, "Client not compiled in!\n");
|
||||||
#endif
|
#endif
|
||||||
wolfSSL_Cleanup();
|
wolfSSL_Cleanup();
|
||||||
|
|
||||||
|
@@ -224,7 +224,7 @@ void echoclient_test(void* args)
|
|||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
ret = wolfAsync_DevOpen(&devId);
|
ret = wolfAsync_DevOpen(&devId);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Async device open failed\nRunning without async\n");
|
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||||
}
|
}
|
||||||
wolfSSL_CTX_SetDevId(ctx, devId);
|
wolfSSL_CTX_SetDevId(ctx, devId);
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
@@ -252,7 +252,7 @@ void echoclient_test(void* args)
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
printf("SSL_connect error %d, %s\n", err,
|
fprintf(stderr, "SSL_connect error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
err_sys("SSL_connect failed");
|
err_sys("SSL_connect failed");
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ void echoclient_test(void* args)
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != sendSz) {
|
if (ret != sendSz) {
|
||||||
printf("SSL_write msg error %d, %s\n", err,
|
fprintf(stderr, "SSL_write msg error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
err_sys("SSL_write failed");
|
err_sys("SSL_write failed");
|
||||||
}
|
}
|
||||||
@@ -322,7 +322,7 @@ void echoclient_test(void* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
printf("SSL_read msg error %d, %s\n", err,
|
fprintf(stderr, "SSL_read msg error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
err_sys("SSL_read failed");
|
err_sys("SSL_read failed");
|
||||||
}
|
}
|
||||||
|
@@ -279,7 +279,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
ret = wolfAsync_DevOpen(&devId);
|
ret = wolfAsync_DevOpen(&devId);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Async device open failed\nRunning without async\n");
|
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||||
}
|
}
|
||||||
wolfSSL_CTX_SetDevId(ctx, devId);
|
wolfSSL_CTX_SetDevId(ctx, devId);
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
@@ -342,9 +342,9 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
printf("SSL_accept error = %d, %s\n", err,
|
fprintf(stderr, "SSL_accept error = %d, %s\n", err,
|
||||||
CyaSSL_ERR_error_string(err, buffer));
|
CyaSSL_ERR_error_string(err, buffer));
|
||||||
printf("SSL_accept failed\n");
|
fprintf(stderr, "SSL_accept failed\n");
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CloseSocket(clientfd);
|
CloseSocket(clientfd);
|
||||||
continue;
|
continue;
|
||||||
@@ -356,7 +356,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
#ifdef HAVE_WRITE_DUP
|
#ifdef HAVE_WRITE_DUP
|
||||||
write_ssl = wolfSSL_write_dup(ssl);
|
write_ssl = wolfSSL_write_dup(ssl);
|
||||||
if (write_ssl == NULL) {
|
if (write_ssl == NULL) {
|
||||||
printf("wolfSSL_write_dup failed\n");
|
fprintf(stderr, "wolfSSL_write_dup failed\n");
|
||||||
CyaSSL_free(ssl);
|
CyaSSL_free(ssl);
|
||||||
CloseSocket(clientfd);
|
CloseSocket(clientfd);
|
||||||
continue;
|
continue;
|
||||||
@@ -381,7 +381,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
if (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_ZERO_RETURN){
|
if (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_ZERO_RETURN){
|
||||||
printf("SSL_read echo error %d, %s!\n", err,
|
fprintf(stderr, "SSL_read echo error %d, %s!\n", err,
|
||||||
CyaSSL_ERR_error_string(err, buffer));
|
CyaSSL_ERR_error_string(err, buffer));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -443,7 +443,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != echoSz) {
|
if (ret != echoSz) {
|
||||||
printf("SSL_write get error = %d, %s\n", err,
|
fprintf(stderr, "SSL_write get error = %d, %s\n", err,
|
||||||
CyaSSL_ERR_error_string(err, buffer));
|
CyaSSL_ERR_error_string(err, buffer));
|
||||||
err_sys("SSL_write get failed");
|
err_sys("SSL_write get failed");
|
||||||
}
|
}
|
||||||
@@ -470,7 +470,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
|
|
||||||
if (ret != echoSz) {
|
if (ret != echoSz) {
|
||||||
printf("SSL_write echo error = %d, %s\n", err,
|
fprintf(stderr, "SSL_write echo error = %d, %s\n", err,
|
||||||
CyaSSL_ERR_error_string(err, buffer));
|
CyaSSL_ERR_error_string(err, buffer));
|
||||||
err_sys("SSL_write echo failed");
|
err_sys("SSL_write echo failed");
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
|
|||||||
wolfSSL_read(ssl, bigBuf, sizeof(bigBuf));
|
wolfSSL_read(ssl, bigBuf, sizeof(bigBuf));
|
||||||
for (i = 0; i < sizeof(bigBuf); i++) {
|
for (i = 0; i < sizeof(bigBuf); i++) {
|
||||||
if (bigBuf[i] != (unsigned char)(i & 0xFF)) {
|
if (bigBuf[i] != (unsigned char)(i & 0xFF)) {
|
||||||
printf("big message check fail\n");
|
fprintf(stderr, "big message check fail\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -156,8 +156,8 @@ static int lng_index = 0;
|
|||||||
static void err_sys_ex(int out, const char* msg)
|
static void err_sys_ex(int out, const char* msg)
|
||||||
{
|
{
|
||||||
if (out == 1) { /* if server is running w/ -x flag, print error w/o exit */
|
if (out == 1) { /* if server is running w/ -x flag, print error w/o exit */
|
||||||
printf("wolfSSL error: %s\n", msg);
|
fprintf(stderr, "wolfSSL error: %s\n", msg);
|
||||||
printf("Continuing server execution...\n\n");
|
fprintf(stderr, "Continuing server execution...\n\n");
|
||||||
} else {
|
} else {
|
||||||
err_sys(msg);
|
err_sys(msg);
|
||||||
}
|
}
|
||||||
@@ -418,7 +418,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
|||||||
if (err != WOLFSSL_ERROR_WANT_READ &&
|
if (err != WOLFSSL_ERROR_WANT_READ &&
|
||||||
err != WOLFSSL_ERROR_ZERO_RETURN &&
|
err != WOLFSSL_ERROR_ZERO_RETURN &&
|
||||||
err != APP_DATA_READY) {
|
err != APP_DATA_READY) {
|
||||||
printf("SSL_read echo error %d\n", err);
|
fprintf(stderr, "SSL_read echo error %d\n", err);
|
||||||
err_sys_ex(runWithErrors, "SSL_read failed");
|
err_sys_ex(runWithErrors, "SSL_read failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -453,7 +453,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E);
|
} while (err == WC_PENDING_E);
|
||||||
if (ret != (int)min(len, rx_pos)) {
|
if (ret != (int)min(len, rx_pos)) {
|
||||||
printf("SSL_write echo error %d\n", err);
|
fprintf(stderr, "SSL_write echo error %d\n", err);
|
||||||
err_sys_ex(runWithErrors, "SSL_write failed");
|
err_sys_ex(runWithErrors, "SSL_write failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +528,7 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef WOLFSSL_DTLS
|
#ifdef WOLFSSL_DTLS
|
||||||
if (wolfSSL_dtls(ssl) && err == DECRYPT_ERROR) {
|
if (wolfSSL_dtls(ssl) && err == DECRYPT_ERROR) {
|
||||||
printf("Dropped client's message due to a bad MAC\n");
|
fprintf(stderr, "Dropped client's message due to a bad MAC\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -537,7 +537,7 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
|||||||
&& err != APP_DATA_READY
|
&& err != APP_DATA_READY
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
printf("SSL_read input error %d, %s\n", err,
|
fprintf(stderr, "SSL_read input error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
err_sys_ex(runWithErrors, "SSL_read failed");
|
err_sys_ex(runWithErrors, "SSL_read failed");
|
||||||
}
|
}
|
||||||
@@ -588,7 +588,7 @@ static void ServerWrite(WOLFSSL* ssl, const char* output, int outputLen)
|
|||||||
}
|
}
|
||||||
} while (err == WC_PENDING_E || err == WOLFSSL_ERROR_WANT_WRITE);
|
} while (err == WC_PENDING_E || err == WOLFSSL_ERROR_WANT_WRITE);
|
||||||
if (ret != outputLen) {
|
if (ret != outputLen) {
|
||||||
printf("SSL_write msg error %d, %s\n", err,
|
fprintf(stderr, "SSL_write msg error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
err_sys_ex(runWithErrors, "SSL_write failed");
|
err_sys_ex(runWithErrors, "SSL_write failed");
|
||||||
}
|
}
|
||||||
@@ -1290,7 +1290,7 @@ static int server_srtp_test(WOLFSSL *ssl, func_args *args)
|
|||||||
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
if (ret != LENGTH_ONLY_E) {
|
if (ret != LENGTH_ONLY_E) {
|
||||||
printf("DTLS SRTP: Error getting key material length\n");
|
fprintf(stderr, "DTLS SRTP: Error getting key material length\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1304,7 +1304,7 @@ static int server_srtp_test(WOLFSSL *ssl, func_args *args)
|
|||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
printf("DTLS SRTP: Error getting key material\n");
|
fprintf(stderr, "DTLS SRTP: Error getting key material\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2152,7 +2152,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
if (usePqc) {
|
if (usePqc) {
|
||||||
if (version == SERVER_DOWNGRADE_VERSION ||
|
if (version == SERVER_DOWNGRADE_VERSION ||
|
||||||
version == EITHER_DOWNGRADE_VERSION) {
|
version == EITHER_DOWNGRADE_VERSION) {
|
||||||
printf("WARNING: If a TLS 1.3 connection is not negotiated, you "
|
fprintf(stderr,
|
||||||
|
"WARNING: If a TLS 1.3 connection is not negotiated, you "
|
||||||
"will not be using a post-quantum group.\n");
|
"will not be using a post-quantum group.\n");
|
||||||
} else if (version != 4) {
|
} else if (version != 4) {
|
||||||
err_sys("can only use post-quantum groups with TLS 1.3");
|
err_sys("can only use post-quantum groups with TLS 1.3");
|
||||||
@@ -2595,7 +2596,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
ret = wolfAsync_DevOpen(&devId);
|
ret = wolfAsync_DevOpen(&devId);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Async device open failed\nRunning without async\n");
|
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||||
}
|
}
|
||||||
wolfSSL_CTX_SetDevId(ctx, devId);
|
wolfSSL_CTX_SetDevId(ctx, devId);
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
@@ -2946,6 +2947,9 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
/* discard the packet */
|
/* discard the packet */
|
||||||
n = (int)recvfrom(clientfd, (char *)b, sizeof(b), 0,
|
n = (int)recvfrom(clientfd, (char *)b, sizeof(b), 0,
|
||||||
(struct sockaddr *)&client_addr, &client_len);
|
(struct sockaddr *)&client_addr, &client_len);
|
||||||
|
|
||||||
|
if (n <= 0)
|
||||||
|
err_sys_ex(runWithErrors, "recvfrom failed");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isClientHello = 1;
|
isClientHello = 1;
|
||||||
@@ -3073,7 +3077,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
err = SSL_get_error(ssl, 0);
|
err = SSL_get_error(ssl, 0);
|
||||||
printf("SSL_accept error %d, %s\n", err,
|
fprintf(stderr, "SSL_accept error %d, %s\n", err,
|
||||||
ERR_error_string(err, buffer));
|
ERR_error_string(err, buffer));
|
||||||
if (!exitWithRet) {
|
if (!exitWithRet) {
|
||||||
err_sys_ex(runWithErrors, "SSL_accept failed");
|
err_sys_ex(runWithErrors, "SSL_accept failed");
|
||||||
@@ -3262,7 +3266,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
}
|
}
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
err = wolfSSL_get_error(ssl, 0);
|
err = wolfSSL_get_error(ssl, 0);
|
||||||
printf("wolfSSL_Rehandshake error %d, %s\n", err,
|
fprintf(stderr,
|
||||||
|
"wolfSSL_Rehandshake error %d, %s\n", err,
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
wolfSSL_free(ssl); ssl = NULL;
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
@@ -3355,12 +3360,12 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
|
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
|
||||||
printf("Bidirectional shutdown failed\n");
|
fprintf(stderr, "Bidirectional shutdown failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret != WOLFSSL_SUCCESS)
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
printf("Bidirectional shutdown failed\n");
|
fprintf(stderr, "Bidirectional shutdown failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
@@ -3488,7 +3493,7 @@ exit:
|
|||||||
server_test(&args);
|
server_test(&args);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
printf("Server not compiled in!\n");
|
fprintf(stderr, "Server not compiled in!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wolfSSL_Cleanup();
|
wolfSSL_Cleanup();
|
||||||
|
@@ -646,19 +646,19 @@ void ssl_InitSniffer(void)
|
|||||||
#ifdef HAVE_INTEL_QA_SYNC
|
#ifdef HAVE_INTEL_QA_SYNC
|
||||||
devId = wc_CryptoCb_InitIntelQa();
|
devId = wc_CryptoCb_InitIntelQa();
|
||||||
if (devId == INVALID_DEVID) {
|
if (devId == INVALID_DEVID) {
|
||||||
printf("Couldn't init the Intel QA\n");
|
fprintf(stderr, "Couldn't init the Intel QA\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||||
devId = wc_CryptoCb_InitOcteon();
|
devId = wc_CryptoCb_InitOcteon();
|
||||||
if (devId == INVALID_DEVID) {
|
if (devId == INVALID_DEVID) {
|
||||||
printf("Couldn't init the Octeon\n");
|
fprintf(stderr, "Couldn't init the Octeon\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
if (wolfAsync_DevOpen(&devId) < 0) {
|
if (wolfAsync_DevOpen(&devId) < 0) {
|
||||||
printf("Async device open failed\nRunning without async\n");
|
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||||
devId = INVALID_DEVID;
|
devId = INVALID_DEVID;
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||||
@@ -6710,7 +6710,7 @@ int ssl_SetWatchKey_buffer(void* vSniffer, const byte* key, word32 keySz,
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
#ifdef DEBUG_SNIFFER
|
#ifdef DEBUG_SNIFFER
|
||||||
/* print warnings */
|
/* print warnings */
|
||||||
printf("key watch set ephemeral failed %d\n", ret);
|
fprintf(stderr, "key watch set ephemeral failed %d\n", ret);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -6815,7 +6815,7 @@ int ssl_PollSniffer(WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG_SNIFFER
|
#ifdef DEBUG_SNIFFER
|
||||||
printf("Sniffer Server %p: Poll error: %d\n", srv, ret);
|
fprintf(stderr, "Sniffer Server %p: Poll error: %d\n", srv, ret);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -758,7 +758,7 @@ int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags)
|
|||||||
ret = select(nfds, &rfds, &wfds, NULL, &timeout);
|
ret = select(nfds, &rfds, &wfds, NULL, &timeout);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
printf("Timeout: %d\n", ret);
|
fprintf(stderr, "Timeout: %d\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return HTTP_TIMEOUT;
|
return HTTP_TIMEOUT;
|
||||||
}
|
}
|
||||||
@@ -2445,11 +2445,11 @@ int uIPSend(WOLFSSL* ssl, char* buf, int sz, void* _ctx)
|
|||||||
unsigned int bytes_left = sz - total_written;
|
unsigned int bytes_left = sz - total_written;
|
||||||
max_sendlen = tcp_socket_max_sendlen(&ctx->conn.tcp);
|
max_sendlen = tcp_socket_max_sendlen(&ctx->conn.tcp);
|
||||||
if (bytes_left > max_sendlen) {
|
if (bytes_left > max_sendlen) {
|
||||||
printf("Send limited by buffer\r\n");
|
fprintf(stderr, "uIPSend: Send limited by buffer\r\n");
|
||||||
bytes_left = max_sendlen;
|
bytes_left = max_sendlen;
|
||||||
}
|
}
|
||||||
if (bytes_left == 0) {
|
if (bytes_left == 0) {
|
||||||
printf("Buffer full!\r\n");
|
fprintf(stderr, "uIPSend: Buffer full!\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = tcp_socket_send(&ctx->conn.tcp, (unsigned char *)buf + total_written, bytes_left);
|
ret = tcp_socket_send(&ctx->conn.tcp, (unsigned char *)buf + total_written, bytes_left);
|
||||||
|
@@ -5343,7 +5343,7 @@ static void wc_ecc_dump_oids(void)
|
|||||||
|
|
||||||
/* validate sum */
|
/* validate sum */
|
||||||
if (ecc_sets[x].oidSum != sum) {
|
if (ecc_sets[x].oidSum != sum) {
|
||||||
printf(" Sum %u Not Valid!\n", ecc_sets[x].oidSum);
|
fprintf(stderr, " Sum %u Not Valid!\n", ecc_sets[x].oidSum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mOidDumpDone = 1;
|
mOidDumpDone = 1;
|
||||||
|
@@ -152,7 +152,7 @@ void* wolfSSL_Malloc(size_t size)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
#if defined(WOLFSSL_DEBUG_MEMORY_PRINT) && !defined(WOLFSSL_TRACK_MEMORY)
|
#if defined(WOLFSSL_DEBUG_MEMORY_PRINT) && !defined(WOLFSSL_TRACK_MEMORY)
|
||||||
printf("Alloc: %p -> %u at %s:%u\n", res, (word32)size, func, line);
|
fprintf(stderr, "Alloc: %p -> %u at %s:%u\n", res, (word32)size, func, line);
|
||||||
#else
|
#else
|
||||||
(void)func;
|
(void)func;
|
||||||
(void)line;
|
(void)line;
|
||||||
@@ -166,7 +166,7 @@ void* wolfSSL_Malloc(size_t size)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
|
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
|
||||||
if (res && --gMemFailCount == 0) {
|
if (res && --gMemFailCount == 0) {
|
||||||
printf("\n---FORCED MEM FAIL TEST---\n");
|
fprintf(stderr, "\n---FORCED MEM FAIL TEST---\n");
|
||||||
if (free_function) {
|
if (free_function) {
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
free_function(res, func, line);
|
free_function(res, func, line);
|
||||||
@@ -193,7 +193,7 @@ void wolfSSL_Free(void *ptr)
|
|||||||
{
|
{
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
#if defined(WOLFSSL_DEBUG_MEMORY_PRINT) && !defined(WOLFSSL_TRACK_MEMORY)
|
#if defined(WOLFSSL_DEBUG_MEMORY_PRINT) && !defined(WOLFSSL_TRACK_MEMORY)
|
||||||
printf("Free: %p at %s:%u\n", ptr, func, line);
|
fprintf(stderr, "Free: %p at %s:%u\n", ptr, func, line);
|
||||||
#else
|
#else
|
||||||
(void)func;
|
(void)func;
|
||||||
(void)line;
|
(void)line;
|
||||||
@@ -406,7 +406,7 @@ int wolfSSL_load_static_memory(byte* buffer, word32 sz, int flag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Allocated %d bytes for static memory @ %p\n", ava, pt);
|
fprintf(stderr, "Allocated %d bytes for static memory @ %p\n", ava, pt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* divide into chunks of memory and add them to available list */
|
/* divide into chunks of memory and add them to available list */
|
||||||
@@ -630,12 +630,12 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Alloc: %p -> %u at %s:%d\n", res, (word32)size, func, line);
|
fprintf(stderr, "Alloc: %p -> %u at %s:%d\n", res, (word32)size, func, line);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
WOLFSSL_MSG("No heap hint found to use and no malloc");
|
WOLFSSL_MSG("No heap hint found to use and no malloc");
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("ERROR: at %s:%d\n", func, line);
|
fprintf(stderr, "ERROR: at %s:%d\n", func, line);
|
||||||
#endif
|
#endif
|
||||||
#endif /* WOLFSSL_NO_MALLOC */
|
#endif /* WOLFSSL_NO_MALLOC */
|
||||||
#endif /* WOLFSSL_HEAP_TEST */
|
#endif /* WOLFSSL_HEAP_TEST */
|
||||||
@@ -682,7 +682,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
}
|
}
|
||||||
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY
|
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY
|
||||||
else {
|
else {
|
||||||
printf("Size: %ld, Empty: %d\n", size,
|
fprintf(stderr, "Size: %ld, Empty: %d\n", size,
|
||||||
mem->sizeList[i]);
|
mem->sizeList[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -697,7 +697,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
res = pt->buffer;
|
res = pt->buffer;
|
||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Alloc: %p -> %u at %s:%d\n", pt->buffer, pt->sz, func, line);
|
fprintf(stderr, "Alloc: %p -> %u at %s:%d\n", pt->buffer, pt->sz, func, line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* keep track of connection statistics if flag is set */
|
/* keep track of connection statistics if flag is set */
|
||||||
@@ -719,7 +719,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
|||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("ERROR ran out of static memory");
|
WOLFSSL_MSG("ERROR ran out of static memory");
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Looking for %lu bytes at %s:%d\n", size, func, line);
|
fprintf(stderr, "Looking for %lu bytes at %s:%d\n", size, func, line);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
|
|||||||
#ifdef WOLFSSL_HEAP_TEST
|
#ifdef WOLFSSL_HEAP_TEST
|
||||||
if (heap == (void*)WOLFSSL_HEAP_TEST) {
|
if (heap == (void*)WOLFSSL_HEAP_TEST) {
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Free: %p at %s:%d\n", pt, func, line);
|
fprintf(stderr, "Free: %p at %s:%d\n", pt, func, line);
|
||||||
#endif
|
#endif
|
||||||
return free(ptr);
|
return free(ptr);
|
||||||
}
|
}
|
||||||
@@ -821,7 +821,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
|
|||||||
mem->frAlc += 1;
|
mem->frAlc += 1;
|
||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
printf("Free: %p -> %u at %s:%d\n", pt->buffer, pt->sz, func, line);
|
fprintf(stderr, "Free: %p -> %u at %s:%d\n", pt->buffer, pt->sz, func, line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* keep track of connection statistics if flag is set */
|
/* keep track of connection statistics if flag is set */
|
||||||
|
@@ -1404,7 +1404,7 @@ int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout)
|
|||||||
|
|
||||||
/* create/init polling mechanism */
|
/* create/init polling mechanism */
|
||||||
if (wnr_poll_create() != WNR_ERROR_NONE) {
|
if (wnr_poll_create() != WNR_ERROR_NONE) {
|
||||||
printf("ERROR: wnr_poll_create() failed\n");
|
fprintf(stderr, "ERROR: wnr_poll_create() failed\n");
|
||||||
WOLFSSL_MSG("Error initializing netRandom polling mechanism");
|
WOLFSSL_MSG("Error initializing netRandom polling mechanism");
|
||||||
wnr_destroy(wnr_ctx);
|
wnr_destroy(wnr_ctx);
|
||||||
wnr_ctx = NULL;
|
wnr_ctx = NULL;
|
||||||
|
@@ -138,7 +138,7 @@ int wolfCrypt_Init(void)
|
|||||||
time_t seed = time(NULL);
|
time_t seed = time(NULL);
|
||||||
srand((word32)seed);
|
srand((word32)seed);
|
||||||
rngMallocFail = rand() % 2000; /* max 2000 */
|
rngMallocFail = rand() % 2000; /* max 2000 */
|
||||||
printf("\n--- RNG MALLOC FAIL AT %u ---\n", rngMallocFail);
|
fprintf(stderr, "\n--- RNG MALLOC FAIL AT %u ---\n", rngMallocFail);
|
||||||
wolfSSL_SetMemFailCount(rngMallocFail);
|
wolfSSL_SetMemFailCount(rngMallocFail);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1019,7 +1019,7 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
|
|||||||
const char** words = client_showx509_msg[lng_index];
|
const char** words = client_showx509_msg[lng_index];
|
||||||
|
|
||||||
if (x509 == NULL) {
|
if (x509 == NULL) {
|
||||||
printf("%s No Cert\n", hdr);
|
fprintf(stderr, "%s No Cert\n", hdr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,7 +1100,7 @@ static WC_INLINE void ShowX509Chain(WOLFSSL_X509_CHAIN* chain, int count,
|
|||||||
if (chainX509)
|
if (chainX509)
|
||||||
ShowX509(chainX509, hdr);
|
ShowX509(chainX509, hdr);
|
||||||
else
|
else
|
||||||
printf("get_chain_X509 failed\n");
|
fprintf(stderr, "get_chain_X509 failed\n");
|
||||||
wolfSSL_FreeX509(chainX509);
|
wolfSSL_FreeX509(chainX509);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,7 +1128,7 @@ static WC_INLINE void showPeerEx(WOLFSSL* ssl, int lng_index)
|
|||||||
if (peer)
|
if (peer)
|
||||||
ShowX509Ex(peer, words[6], lng_index);
|
ShowX509Ex(peer, words[6], lng_index);
|
||||||
else
|
else
|
||||||
printf("peer has no cert!\n");
|
fprintf(stderr, "peer has no cert!\n");
|
||||||
wolfSSL_FreeX509(peer);
|
wolfSSL_FreeX509(peer);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SHOW_CERTS) && defined(KEEP_OUR_CERT) && \
|
#if defined(SHOW_CERTS) && defined(KEEP_OUR_CERT) && \
|
||||||
@@ -1536,7 +1536,7 @@ static int wolfSentry_NetworkFilterCallback(
|
|||||||
else
|
else
|
||||||
*decision = WOLFSSL_NETFILTER_PASS;
|
*decision = WOLFSSL_NETFILTER_PASS;
|
||||||
} else {
|
} else {
|
||||||
printf("wolfsentry_route_event_dispatch error "
|
fprintf(stderr, "wolfsentry_route_event_dispatch error "
|
||||||
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
|
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
|
||||||
*decision = WOLFSSL_NETFILTER_PASS;
|
*decision = WOLFSSL_NETFILTER_PASS;
|
||||||
}
|
}
|
||||||
@@ -1787,7 +1787,7 @@ static WC_INLINE int tcp_connect_with_wolfSentry(
|
|||||||
&action_results);
|
&action_results);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("wolfsentry_route_event_dispatch error "
|
fprintf(stderr, "wolfsentry_route_event_dispatch error "
|
||||||
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
|
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
|
||||||
decision = WOLFSSL_NETFILTER_PASS;
|
decision = WOLFSSL_NETFILTER_PASS;
|
||||||
} else {
|
} else {
|
||||||
@@ -2549,7 +2549,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
|
|||||||
/* open file (read-only binary) */
|
/* open file (read-only binary) */
|
||||||
lFile = XFOPEN(fname, "rb");
|
lFile = XFOPEN(fname, "rb");
|
||||||
if (!lFile) {
|
if (!lFile) {
|
||||||
printf("Error loading %s\n", fname);
|
fprintf(stderr, "Error loading %s\n", fname);
|
||||||
return BAD_PATH_ERROR;
|
return BAD_PATH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2561,7 +2561,8 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
|
|||||||
*buf = (byte*)malloc(*bufLen);
|
*buf = (byte*)malloc(*bufLen);
|
||||||
if (*buf == NULL) {
|
if (*buf == NULL) {
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
printf("Error allocating %lu bytes\n", (unsigned long)*bufLen);
|
fprintf(stderr,
|
||||||
|
"Error allocating %lu bytes\n", (unsigned long)*bufLen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t readLen = fread(*buf, *bufLen, 1, lFile);
|
size_t readLen = fread(*buf, *bufLen, 1, lFile);
|
||||||
@@ -2744,7 +2745,7 @@ static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
|
|||||||
will be discarded (only with SESSION_CERTS)
|
will be discarded (only with SESSION_CERTS)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf("In verification callback, error = %d, %s\n", store->error,
|
fprintf(stderr, "In verification callback, error = %d, %s\n", store->error,
|
||||||
wolfSSL_ERR_error_string(store->error, buffer));
|
wolfSSL_ERR_error_string(store->error, buffer));
|
||||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
||||||
peer = store->current_cert;
|
peer = store->current_cert;
|
||||||
@@ -2777,7 +2778,7 @@ static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("\tPeer has no cert!\n");
|
fprintf(stderr, "\tPeer has no cert!\n");
|
||||||
#else
|
#else
|
||||||
printf("\tPeer certs: %d\n", store->totalCerts);
|
printf("\tPeer certs: %d\n", store->totalCerts);
|
||||||
#ifdef SHOW_CERTS
|
#ifdef SHOW_CERTS
|
||||||
@@ -3072,7 +3073,9 @@ int StackSizeHWMReset(void)
|
|||||||
printf(" relative stack peak usage = %ld bytes\n", (long int)HWM); \
|
printf(" relative stack peak usage = %ld bytes\n", (long int)HWM); \
|
||||||
_ret = StackSizeHWMReset(); \
|
_ret = StackSizeHWMReset(); \
|
||||||
if ((max >= 0) && (HWM > (ssize_t)(max))) { \
|
if ((max >= 0) && (HWM > (ssize_t)(max))) { \
|
||||||
printf(" relative stack usage at %s L%d exceeds designated max %ld bytes.\n", __FILE__, __LINE__, (long int)(max)); \
|
fprintf(stderr, \
|
||||||
|
" relative stack usage at %s L%d exceeds designated max %ld bytes.\n", \
|
||||||
|
__FILE__, __LINE__, (long int)(max)); \
|
||||||
_ret = -1; \
|
_ret = -1; \
|
||||||
} \
|
} \
|
||||||
_ret; \
|
_ret; \
|
||||||
@@ -3367,7 +3370,7 @@ static WC_INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut,
|
|||||||
|
|
||||||
ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION);
|
ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("AesSetKey failed in myMacEncryptCb\n");
|
fprintf(stderr, "AesSetKey failed in myMacEncryptCb\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
encCtx->keySetup = 1;
|
encCtx->keySetup = 1;
|
||||||
@@ -3423,7 +3426,7 @@ static WC_INLINE int myDecryptVerifyCb(WOLFSSL* ssl,
|
|||||||
|
|
||||||
ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION);
|
ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("AesSetKey failed in myDecryptVerifyCb\n");
|
fprintf(stderr, "AesSetKey failed in myDecryptVerifyCb\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
decCtx->keySetup = 1;
|
decCtx->keySetup = 1;
|
||||||
@@ -3517,7 +3520,7 @@ static WC_INLINE int myEncryptMacCb(WOLFSSL* ssl, unsigned char* macOut,
|
|||||||
|
|
||||||
ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION);
|
ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("AesSetKey failed in myMacEncryptCb\n");
|
fprintf(stderr, "AesSetKey failed in myMacEncryptCb\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
encCtx->keySetup = 1;
|
encCtx->keySetup = 1;
|
||||||
@@ -3615,7 +3618,7 @@ static WC_INLINE int myVerifyDecryptCb(WOLFSSL* ssl,
|
|||||||
|
|
||||||
ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION);
|
ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("AesSetKey failed in myDecryptVerifyCb\n");
|
fprintf(stderr, "AesSetKey failed in myDecryptVerifyCb\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
decCtx->keySetup = 1;
|
decCtx->keySetup = 1;
|
||||||
@@ -5077,20 +5080,20 @@ static WC_INLINE const char* mymktemp(char *tempfn, int len, int num)
|
|||||||
byte out = 0;
|
byte out = 0;
|
||||||
|
|
||||||
if (tempfn == NULL || len < 1 || num < 1 || len <= num) {
|
if (tempfn == NULL || len < 1 || num < 1 || len <= num) {
|
||||||
printf("Bad input\n");
|
fprintf(stderr, "Bad input\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = len - 1;
|
size = len - 1;
|
||||||
|
|
||||||
if (wc_InitRng(&rng) != 0) {
|
if (wc_InitRng(&rng) != 0) {
|
||||||
printf("InitRng failed\n");
|
fprintf(stderr, "InitRng failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = size; x > size - num; x--) {
|
for (x = size; x > size - num; x--) {
|
||||||
if (wc_RNG_GenerateBlock(&rng,(byte*)&out, sizeof(out)) != 0) {
|
if (wc_RNG_GenerateBlock(&rng,(byte*)&out, sizeof(out)) != 0) {
|
||||||
printf("RNG_GenerateBlock failed\n");
|
fprintf(stderr, "RNG_GenerateBlock failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tempfn[x] = alphanum[out % (sizeof(alphanum) - 1)];
|
tempfn[x] = alphanum[out % (sizeof(alphanum) - 1)];
|
||||||
|
@@ -434,7 +434,7 @@ decouple library dependencies with standard string, memory and so on.
|
|||||||
#ifdef WOLFSSL_MALLOC_CHECK
|
#ifdef WOLFSSL_MALLOC_CHECK
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static inline void* malloc_check(size_t sz) {
|
static inline void* malloc_check(size_t sz) {
|
||||||
printf("wolfSSL_malloc failed");
|
fprintf(stderr, "wolfSSL_malloc failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
#define XMALLOC(s, h, t) malloc_check((s))
|
#define XMALLOC(s, h, t) malloc_check((s))
|
||||||
|
Reference in New Issue
Block a user