From 17b57a11965c05a0f3246f92ceadd2686b4e8894 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Thu, 16 May 2024 09:38:38 -0600 Subject: [PATCH] Merge pull request #7537 from dgarske/cleanups_20240515 Various typo and copy/paste cleanups --- .../examples/wolfssl_client/main/client-tls.c | 24 ++++++---- .../cs+/Projects/t4_demo/wolf_client.c | 22 ++++----- .../e2studio/Projects/test/src/wolf_client.c | 8 ++-- .../client-wolfssl/src/wolfssl_thread_entry.c | 3 +- .../server-wolfssl/src/wolfssl_thread_entry.c | 2 +- .../RX65N/GR-ROSE/test/src/wolf_client.c | 48 +++++++++---------- .../test/src/client/simple_tls_tsip_client.c | 2 +- 7 files changed, 56 insertions(+), 53 deletions(-) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c index f8c9e0e81b..1f00afa3c5 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c @@ -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 @@ -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) ; } @@ -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 { @@ -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 @@ -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); @@ -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 diff --git a/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c b/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c index e0d903644c..c556f647af 100644 --- a/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c +++ b/IDE/Renesas/cs+/Projects/t4_demo/wolf_client.c @@ -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; } @@ -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) { @@ -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; } diff --git a/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c b/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c index 37bcfbb84c..314243d0ed 100644 --- a/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/Projects/test/src/wolf_client.c @@ -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; } @@ -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; } @@ -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; } diff --git a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c index d2c1c815c0..5bc8e55ece 100644 --- a/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c @@ -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; @@ -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, diff --git a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c index 30006f63b7..03179846ba 100644 --- a/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c +++ b/IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c @@ -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)); diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c index 76cfb41a57..437ce74775 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c @@ -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 @@ -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, @@ -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; @@ -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; } @@ -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"); @@ -213,11 +213,11 @@ 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){ @@ -225,7 +225,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; } @@ -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 */ @@ -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 @@ -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 */ @@ -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; } diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c index 0bc5caa178..452d0ac747 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/client/simple_tls_tsip_client.c @@ -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; }