Skip to content

Commit

Permalink
Merge pull request wolfSSL#7537 from dgarske/cleanups_20240515
Browse files Browse the repository at this point in the history
Various typo and copy/paste cleanups
  • Loading branch information
JacobBarthelmeh authored May 16, 2024
2 parents 2120424 + 9166c1a commit 712ff0a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 53 deletions.
24 changes: 14 additions & 10 deletions IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
/* see user_settings PROJECT_DH for HAVE_DH and HAVE_FFDHE_2048 */
#ifndef NO_DH
ret = wolfSSL_CTX_SetMinDhKey_Sz(ctx, (word16)minDhKeyBits);
if (ret != SSL_SUCCESS) {
if (ret != WOLFSSL_SUCCESS) {
ESP_LOGE(TAG, "Error setting minimum DH key size");
}
#endif
Expand All @@ -316,24 +316,28 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
CTX_CLIENT_CERT,
CTX_CLIENT_CERT_SIZE,
CTX_CLIENT_CERT_TYPE);
if (ret_i != SSL_SUCCESS) {
ESP_LOGE(TAG, "ERROR: failed to load chain %d, "
if (ret_i != WOLFSSL_SUCCESS) {
ESP_LOGE(TAG, "ERROR: failed to load our cert chain %d, "
"please check the file.", ret_i);
}

/* Load client certificates into WOLFSSL_CTX */
WOLFSSL_MSG("Loading...cert");
WOLFSSL_MSG("Loading... CA cert");
ret_i = wolfSSL_CTX_load_verify_buffer(ctx,
CTX_CA_CERT,
CTX_CA_CERT_SIZE,
CTX_CA_CERT_TYPE);
if (ret_i != WOLFSSL_SUCCESS) {
ESP_LOGE(TAG, "ERROR: failed to load CA cert %d, "
"please check the file.\n", ret_i) ;
}

WOLFSSL_MSG("Loading... our key");
ret_i = wolfSSL_CTX_use_PrivateKey_buffer(ctx,
CTX_CLIENT_KEY,
CTX_CLIENT_KEY_SIZE,
CTX_CLIENT_KEY_TYPE);
if(ret_i != SSL_SUCCESS) {
wolfSSL_CTX_free(ctx) ; ctx = NULL ;
if (ret_i != WOLFSSL_SUCCESS) {
ESP_LOGE(TAG, "ERROR: failed to load key %d, "
"please check the file.\n", ret_i) ;
}
Expand Down Expand Up @@ -409,7 +413,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
ESP_LOGW(TAG, "WOLFSSL_HAVE_KYBER enabled but no key size available.");
ret_i = ESP_FAIL;
#endif
if (ret_i == SSL_SUCCESS) {
if (ret_i == WOLFSSL_SUCCESS) {
ESP_LOGI(TAG, "UseKeyShare Kyber success");
}
else {
Expand Down Expand Up @@ -462,7 +466,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
ESP_LOGI(TAG, "tls_smp_client_task heap(3) @ %p = %d",
&this_heap, this_heap);
#endif
if (ret_i == SSL_SUCCESS) {
if (ret_i == WOLFSSL_SUCCESS) {
#ifdef DEBUG_WOLFSSL
ShowCiphers(ssl);
#endif
Expand Down Expand Up @@ -534,7 +538,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
ESP_LOGE(TAG, "Bidirectional shutdown failed\n");
}

} /* wolfSSL_connect(ssl) == SSL_SUCCESS) */
} /* wolfSSL_connect(ssl) == WOLFSSL_SUCCESS) */
else {
ESP_LOGE(TAG, "ERROR: failed to connect to wolfSSL. "
"Error: %d\n", ret_i);
Expand Down Expand Up @@ -569,7 +573,7 @@ WOLFSSL_ESP_TASK tls_smp_client_init(void* args)
/* See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html#functions */
if (TLS_SMP_CLIENT_TASK_BYTES < (6 * 1024)) {
/* Observed approximately 6KB limit for the RTOS task stack size.
* Reminder parameter is bytes, not words as with generic FreeeRTOS. */
* Reminder parameter is bytes, not words as with generic FreeRTOS. */
ESP_LOGW(TAG, "Warning: TLS_SMP_CLIENT_TASK_BYTES < 6KB");
}
#ifndef WOLFSSL_SMALL_STACK
Expand Down
22 changes: 11 additions & 11 deletions IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ WOLFSSL_CTX *wolfSSL_TLS_client_init()
}

#if !defined(NO_FILESYSTEM)
if (wolfSSL_CTX_load_verify_locations(ctx, cert, 0) != SSL_SUCCESS) {
if (wolfSSL_CTX_load_verify_locations(ctx, cert, 0) != WOLFSSL_SUCCESS) {
printf("ERROR: can't load \"%s\"\n", cert);
return NULL;
}
#else
if (wolfSSL_CTX_load_verify_buffer(ctx, cert, SIZEOF_CERT, SSL_FILETYPE_ASN1) != SSL_SUCCESS){
if (wolfSSL_CTX_load_verify_buffer(ctx, cert, SIZEOF_CERT, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS){
printf("ERROR: can't load certificate data\n");
return NULL;
}
Expand Down Expand Up @@ -138,14 +138,14 @@ void wolfSSL_TLS_client(void *v_ctx, func_args *args)
T_IPV4EP dst_addr;

if(args->argc >= 2){
if((dst_addr.ipaddr = getIPaddr(args->argv[1])) == 0){
printf("ERROR: IP address\n");
return;
}
if((dst_addr.portno = getPort(args->argv[2])) == 0){
printf("ERROR: IP address\n");
return;
}
if((dst_addr.ipaddr = getIPaddr(args->argv[1])) == 0){
printf("ERROR: IP address\n");
return;
}
if((dst_addr.portno = getPort(args->argv[2])) == 0){
printf("ERROR: Port number\n");
return;
}
}

if((ercd = tcp_con_cep(cepid, &my_addr, &dst_addr, TMO_FEVR)) != E_OK) {
Expand All @@ -162,7 +162,7 @@ void wolfSSL_TLS_client(void *v_ctx, func_args *args)
wolfSSL_SetIOReadCtx(ssl, (void *)&cepid);
wolfSSL_SetIOWriteCtx(ssl, (void *)&cepid);

if(wolfSSL_connect(ssl) != SSL_SUCCESS) {
if(wolfSSL_connect(ssl) != WOLFSSL_SUCCESS) {
printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
return;
}
Expand Down
8 changes: 4 additions & 4 deletions IDE/Renesas/e2studio/Projects/test/src/wolf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
}

#if !defined(NO_FILESYSTEM)
if (wolfSSL_CTX_load_verify_locations(client_ctx, cert, 0) != SSL_SUCCESS) {
if (wolfSSL_CTX_load_verify_locations(client_ctx, cert, 0) != WOLFSSL_SUCCESS) {
printf("ERROR: can't load \"%s\"\n", cert);
return NULL;
}
#else
if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT, SSL_FILETYPE_ASN1) != SSL_SUCCESS){
if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS){
printf("ERROR: can't load certificate data\n");
return;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ void wolfSSL_TLS_client( )
return;
}
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n");
printf("ERROR: Port number\n");
return;
}

Expand All @@ -175,7 +175,7 @@ void wolfSSL_TLS_client( )
wolfSSL_SetIOReadCtx(ssl, (void *)&cepid);
wolfSSL_SetIOWriteCtx(ssl, (void *)&cepid);

if(wolfSSL_connect(ssl) != SSL_SUCCESS) {
if(wolfSSL_connect(ssl) != WOLFSSL_SUCCESS) {
printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ void wolfssl_thread_entry(void *pvParameters) {

/* FreeRTOS+TCP Objects */
BaseType_t fr_status;
socklen_t xSize = sizeof(struct freertos_sockaddr);
xSocket_t xClientSocket = NULL;
struct freertos_sockaddr xRemoteAddress;

Expand Down Expand Up @@ -93,7 +92,7 @@ void wolfssl_thread_entry(void *pvParameters) {
FREERTOS_SOCK_STREAM,
FREERTOS_IPPROTO_TCP);
configASSERT(xClientSocket != FREERTOS_INVALID_SOCKET);
FreeRTOS_bind(xClientSocket, &xRemoteAddress, sizeof(xSize));
FreeRTOS_bind(xClientSocket, &xRemoteAddress, sizeof(xRemoteAddress));

/* Client Socket Connect */
ret = FreeRTOS_connect(xClientSocket,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void wolfssl_thread_entry(void *pvParameters) {

/* Read the client data into our buff array */
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_set_fd.\n",ret);
printf("Error [%d]: wolfSSL_accept.\n",ret);
break;
}
memset(buff, 0, sizeof(buff));
Expand Down
48 changes: 24 additions & 24 deletions IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
char *cert = "./certs/ca-cert.pem";
#endif
#else
#if defined(USE_ECC_CERT) && defined(USE_CERT_BUFFERS_256)
#if defined(USE_ECC_CERT) && defined(USE_CERT_BUFFERS_256)
const unsigned char *cert = ca_ecc_cert_der_256;
#define SIZEOF_CERT sizeof_ca_ecc_cert_der_256
#else
Expand All @@ -137,7 +137,7 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
if ((client_ctx = wolfSSL_CTX_new_ex(wolfSSLv23_client_method_ex(heapHint),
heapHint)) == NULL) {
printf("ERROR: failed to create WOLFSSL_CTX\n");
return;
return;
}

if ((wolfSSL_CTX_load_static_memory(&client_ctx, NULL, heapBufIO,
Expand All @@ -149,7 +149,7 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
#else

/* Create and initialize WOLFSSL_CTX */
if ((client_ctx =
if ((client_ctx =
wolfSSL_CTX_new(wolfSSLv23_client_method_ex((void *)NULL))) == NULL) {
printf("ERROR: failed to create WOLFSSL_CTX\n");
return;
Expand All @@ -168,8 +168,8 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
/* Root CA certificate */
/*---------------------------------------------*/

if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT,
SSL_FILETYPE_ASN1) != SSL_SUCCESS){
if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT,
SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS){
printf("ERROR: can't load certificate data\n");
return;
}
Expand All @@ -186,15 +186,15 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
/*---------------------------------------------*/

/* use specific cipher */
if (cipherlist != NULL &&
if (cipherlist != NULL &&
wolfSSL_CTX_set_cipher_list(client_ctx, cipherlist) != WOLFSSL_SUCCESS) {
wolfSSL_CTX_free(client_ctx); client_ctx = NULL;
printf("client can't set cipher list");
return;
}

#if defined(WOLFSSL_TLS13)
if (wolfSSL_CTX_UseSupportedCurve(client_ctx, WOLFSSL_ECC_SECP256R1)
if (wolfSSL_CTX_UseSupportedCurve(client_ctx, WOLFSSL_ECC_SECP256R1)
!= WOLFSSL_SUCCESS) {
wolfSSL_CTX_free(client_ctx); client_ctx = NULL;
printf("client can't set use supported curves\n");
Expand All @@ -213,19 +213,19 @@ void wolfSSL_TLS_client( )

#define BUFF_SIZE 256
static const char sendBuff[]= "Hello Server\n" ;

char rcvBuff[BUFF_SIZE] = {0};

static T_IPV4EP my_addr = { 0, 0 };

T_IPV4EP dst_addr;

if((dst_addr.ipaddr = getIPaddr(SIMPLE_TLSSEVER_IP)) == 0){
printf("ERROR: IP address\n");
goto out;
}
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n");
printf("ERROR: Port number\n");
goto out;
}

Expand Down Expand Up @@ -256,22 +256,22 @@ void wolfSSL_TLS_client( )
/*---------------------------------------------*/
#ifdef USE_ECC_CERT

/* ECDSA client certificate */
/* ECDSA client certificate */
if (wolfSSL_use_certificate_buffer(ssl, cliecc_cert_der_256,
sizeof_cliecc_cert_der_256, WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) {
sizeof_cliecc_cert_der_256, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
printf("ERROR wolfSSL_use_certificate_buffer: %d\n",
wolfSSL_get_error(ssl, 0));
goto out;
goto out;
}

#else

/* RSA client certificate */
if (wolfSSL_use_certificate_buffer(ssl, client_cert_der_2048,
sizeof_client_cert_der_2048, WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) {
sizeof_client_cert_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
printf("ERROR wolfSSL_use_certificate_buffer: %d\n",
wolfSSL_get_error(ssl, 0));
goto out;
goto out;
}

#endif /* USE_ECC_CERT */
Expand All @@ -292,17 +292,17 @@ void wolfSSL_TLS_client( )
printf("ERROR tsip_use_PrivateKey_buffer_TLS\n");
goto out;
}

#else

/* DER format ECC private key */
if (wolfSSL_use_PrivateKey_buffer(ssl,
ecc_clikey_der_256,
sizeof_ecc_clikey_der_256,
WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) {
sizeof_ecc_clikey_der_256,
WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n",
wolfSSL_get_error(ssl, 0));
goto out;
goto out;
}

#endif
Expand Down Expand Up @@ -334,10 +334,10 @@ void wolfSSL_TLS_client( )
#else

if (wolfSSL_use_PrivateKey_buffer(ssl, client_key_der_2048,
sizeof_client_key_der_2048, WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) {
sizeof_client_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n",
wolfSSL_get_error(ssl, 0));
goto out;
goto out;
}

#endif /* WOLFSSL_RENESAS_TSIP_TLS */
Expand All @@ -356,7 +356,7 @@ void wolfSSL_TLS_client( )
/* TLS handshake */
/*---------------------------------------------*/

if(wolfSSL_connect(ssl) != SSL_SUCCESS) {
if(wolfSSL_connect(ssl) != WOLFSSL_SUCCESS) {
printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
goto out;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void wolfSSL_TLS_client( )
goto out;
}
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n");
printf("ERROR: Port number\n");
goto out;
}

Expand Down

0 comments on commit 712ff0a

Please sign in to comment.