Various typo and copy/paste cleanups.

This commit is contained in:
David Garske
2024-05-15 10:01:40 -07:00
parent c73e4333bf
commit 9166c1aa1c
7 changed files with 56 additions and 53 deletions

View File

@@ -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 */ /* see user_settings PROJECT_DH for HAVE_DH and HAVE_FFDHE_2048 */
#ifndef NO_DH #ifndef NO_DH
ret = wolfSSL_CTX_SetMinDhKey_Sz(ctx, (word16)minDhKeyBits); 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"); ESP_LOGE(TAG, "Error setting minimum DH key size");
} }
#endif #endif
@@ -316,24 +316,28 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
CTX_CLIENT_CERT, CTX_CLIENT_CERT,
CTX_CLIENT_CERT_SIZE, CTX_CLIENT_CERT_SIZE,
CTX_CLIENT_CERT_TYPE); CTX_CLIENT_CERT_TYPE);
if (ret_i != SSL_SUCCESS) { if (ret_i != WOLFSSL_SUCCESS) {
ESP_LOGE(TAG, "ERROR: failed to load chain %d, " ESP_LOGE(TAG, "ERROR: failed to load our cert chain %d, "
"please check the file.", ret_i); "please check the file.", ret_i);
} }
/* Load client certificates into WOLFSSL_CTX */ /* Load client certificates into WOLFSSL_CTX */
WOLFSSL_MSG("Loading...cert"); WOLFSSL_MSG("Loading... CA cert");
ret_i = wolfSSL_CTX_load_verify_buffer(ctx, ret_i = wolfSSL_CTX_load_verify_buffer(ctx,
CTX_CA_CERT, CTX_CA_CERT,
CTX_CA_CERT_SIZE, CTX_CA_CERT_SIZE,
CTX_CA_CERT_TYPE); 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, ret_i = wolfSSL_CTX_use_PrivateKey_buffer(ctx,
CTX_CLIENT_KEY, CTX_CLIENT_KEY,
CTX_CLIENT_KEY_SIZE, CTX_CLIENT_KEY_SIZE,
CTX_CLIENT_KEY_TYPE); CTX_CLIENT_KEY_TYPE);
if(ret_i != SSL_SUCCESS) { if (ret_i != WOLFSSL_SUCCESS) {
wolfSSL_CTX_free(ctx) ; ctx = NULL ;
ESP_LOGE(TAG, "ERROR: failed to load key %d, " ESP_LOGE(TAG, "ERROR: failed to load key %d, "
"please check the file.\n", ret_i) ; "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."); ESP_LOGW(TAG, "WOLFSSL_HAVE_KYBER enabled but no key size available.");
ret_i = ESP_FAIL; ret_i = ESP_FAIL;
#endif #endif
if (ret_i == SSL_SUCCESS) { if (ret_i == WOLFSSL_SUCCESS) {
ESP_LOGI(TAG, "UseKeyShare Kyber success"); ESP_LOGI(TAG, "UseKeyShare Kyber success");
} }
else { 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", ESP_LOGI(TAG, "tls_smp_client_task heap(3) @ %p = %d",
&this_heap, this_heap); &this_heap, this_heap);
#endif #endif
if (ret_i == SSL_SUCCESS) { if (ret_i == WOLFSSL_SUCCESS) {
#ifdef DEBUG_WOLFSSL #ifdef DEBUG_WOLFSSL
ShowCiphers(ssl); ShowCiphers(ssl);
#endif #endif
@@ -534,7 +538,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args)
ESP_LOGE(TAG, "Bidirectional shutdown failed\n"); ESP_LOGE(TAG, "Bidirectional shutdown failed\n");
} }
} /* wolfSSL_connect(ssl) == SSL_SUCCESS) */ } /* wolfSSL_connect(ssl) == WOLFSSL_SUCCESS) */
else { else {
ESP_LOGE(TAG, "ERROR: failed to connect to wolfSSL. " ESP_LOGE(TAG, "ERROR: failed to connect to wolfSSL. "
"Error: %d\n", ret_i); "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 */ /* 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)) { if (TLS_SMP_CLIENT_TASK_BYTES < (6 * 1024)) {
/* Observed approximately 6KB limit for the RTOS task stack size. /* 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"); ESP_LOGW(TAG, "Warning: TLS_SMP_CLIENT_TASK_BYTES < 6KB");
} }
#ifndef WOLFSSL_SMALL_STACK #ifndef WOLFSSL_SMALL_STACK

View File

@@ -104,12 +104,12 @@ WOLFSSL_CTX *wolfSSL_TLS_client_init()
} }
#if !defined(NO_FILESYSTEM) #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); printf("ERROR: can't load \"%s\"\n", cert);
return NULL; return NULL;
} }
#else #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"); printf("ERROR: can't load certificate data\n");
return NULL; return NULL;
} }
@@ -138,14 +138,14 @@ void wolfSSL_TLS_client(void *v_ctx, func_args *args)
T_IPV4EP dst_addr; T_IPV4EP dst_addr;
if(args->argc >= 2){ if(args->argc >= 2){
if((dst_addr.ipaddr = getIPaddr(args->argv[1])) == 0){ if((dst_addr.ipaddr = getIPaddr(args->argv[1])) == 0){
printf("ERROR: IP address\n"); printf("ERROR: IP address\n");
return; return;
} }
if((dst_addr.portno = getPort(args->argv[2])) == 0){ if((dst_addr.portno = getPort(args->argv[2])) == 0){
printf("ERROR: IP address\n"); printf("ERROR: Port number\n");
return; return;
} }
} }
if((ercd = tcp_con_cep(cepid, &my_addr, &dst_addr, TMO_FEVR)) != E_OK) { 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_SetIOReadCtx(ssl, (void *)&cepid);
wolfSSL_SetIOWriteCtx(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)); printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
return; return;
} }

View File

@@ -117,12 +117,12 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
} }
#if !defined(NO_FILESYSTEM) #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); printf("ERROR: can't load \"%s\"\n", cert);
return NULL; return NULL;
} }
#else #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"); printf("ERROR: can't load certificate data\n");
return; return;
} }
@@ -157,7 +157,7 @@ void wolfSSL_TLS_client( )
return; return;
} }
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){ if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n"); printf("ERROR: Port number\n");
return; return;
} }
@@ -175,7 +175,7 @@ void wolfSSL_TLS_client( )
wolfSSL_SetIOReadCtx(ssl, (void *)&cepid); wolfSSL_SetIOReadCtx(ssl, (void *)&cepid);
wolfSSL_SetIOWriteCtx(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)); printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
return; return;
} }

View File

@@ -52,7 +52,6 @@ void wolfssl_thread_entry(void *pvParameters) {
/* FreeRTOS+TCP Objects */ /* FreeRTOS+TCP Objects */
BaseType_t fr_status; BaseType_t fr_status;
socklen_t xSize = sizeof(struct freertos_sockaddr);
xSocket_t xClientSocket = NULL; xSocket_t xClientSocket = NULL;
struct freertos_sockaddr xRemoteAddress; struct freertos_sockaddr xRemoteAddress;
@@ -93,7 +92,7 @@ void wolfssl_thread_entry(void *pvParameters) {
FREERTOS_SOCK_STREAM, FREERTOS_SOCK_STREAM,
FREERTOS_IPPROTO_TCP); FREERTOS_IPPROTO_TCP);
configASSERT(xClientSocket != FREERTOS_INVALID_SOCKET); configASSERT(xClientSocket != FREERTOS_INVALID_SOCKET);
FreeRTOS_bind(xClientSocket, &xRemoteAddress, sizeof(xSize)); FreeRTOS_bind(xClientSocket, &xRemoteAddress, sizeof(xRemoteAddress));
/* Client Socket Connect */ /* Client Socket Connect */
ret = FreeRTOS_connect(xClientSocket, ret = FreeRTOS_connect(xClientSocket,

View File

@@ -151,7 +151,7 @@ void wolfssl_thread_entry(void *pvParameters) {
/* Read the client data into our buff array */ /* Read the client data into our buff array */
if (ret != WOLFSSL_SUCCESS) { if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_set_fd.\n",ret); printf("Error [%d]: wolfSSL_accept.\n",ret);
break; break;
} }
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));

View File

@@ -169,7 +169,7 @@ void wolfSSL_TLS_client_init(const char* cipherlist)
/*---------------------------------------------*/ /*---------------------------------------------*/
if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT, if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT,
SSL_FILETYPE_ASN1) != SSL_SUCCESS){ SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS){
printf("ERROR: can't load certificate data\n"); printf("ERROR: can't load certificate data\n");
return; return;
} }
@@ -225,7 +225,7 @@ void wolfSSL_TLS_client( )
goto out; goto out;
} }
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){ if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n"); printf("ERROR: Port number\n");
goto out; goto out;
} }
@@ -258,7 +258,7 @@ void wolfSSL_TLS_client( )
/* ECDSA client certificate */ /* ECDSA client certificate */
if (wolfSSL_use_certificate_buffer(ssl, cliecc_cert_der_256, 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", printf("ERROR wolfSSL_use_certificate_buffer: %d\n",
wolfSSL_get_error(ssl, 0)); wolfSSL_get_error(ssl, 0));
goto out; goto out;
@@ -268,7 +268,7 @@ void wolfSSL_TLS_client( )
/* RSA client certificate */ /* RSA client certificate */
if (wolfSSL_use_certificate_buffer(ssl, client_cert_der_2048, 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", printf("ERROR wolfSSL_use_certificate_buffer: %d\n",
wolfSSL_get_error(ssl, 0)); wolfSSL_get_error(ssl, 0));
goto out; goto out;
@@ -299,7 +299,7 @@ void wolfSSL_TLS_client( )
if (wolfSSL_use_PrivateKey_buffer(ssl, if (wolfSSL_use_PrivateKey_buffer(ssl,
ecc_clikey_der_256, ecc_clikey_der_256,
sizeof_ecc_clikey_der_256, sizeof_ecc_clikey_der_256,
WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) { WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) {
printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n", printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n",
wolfSSL_get_error(ssl, 0)); wolfSSL_get_error(ssl, 0));
goto out; goto out;
@@ -334,7 +334,7 @@ void wolfSSL_TLS_client( )
#else #else
if (wolfSSL_use_PrivateKey_buffer(ssl, client_key_der_2048, 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", printf("ERROR wolfSSL_use_PrivateKey_buffer: %d\n",
wolfSSL_get_error(ssl, 0)); wolfSSL_get_error(ssl, 0));
goto out; goto out;
@@ -356,7 +356,7 @@ void wolfSSL_TLS_client( )
/* TLS handshake */ /* 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)); printf("ERROR SSL connect: %d\n", wolfSSL_get_error(ssl, 0));
goto out; goto out;
} }

View File

@@ -216,7 +216,7 @@ void wolfSSL_TLS_client( )
goto out; goto out;
} }
if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){ if((dst_addr.portno = getPort(SIMPLE_TLSSERVER_PORT)) == 0){
printf("ERROR: IP address\n"); printf("ERROR: Port number\n");
goto out; goto out;
} }