Whitespace cleanups.

This commit is contained in:
David Garske
2022-11-03 14:38:43 -07:00
parent e26d4f84fc
commit f610df59a9
2 changed files with 82 additions and 82 deletions

View File

@@ -71,8 +71,8 @@
#define MEM_BUFFER_SZ (TEST_PACKET_SIZE + 38 + WC_MAX_DIGEST_SIZE) #define MEM_BUFFER_SZ (TEST_PACKET_SIZE + 38 + WC_MAX_DIGEST_SIZE)
/* make sure memory buffer size is large enough */ /* make sure memory buffer size is large enough */
#if MEM_BUFFER_SZ < 2048 #if MEM_BUFFER_SZ < 2048
#undef MEM_BUFFER_SZ #undef MEM_BUFFER_SZ
#define MEM_BUFFER_SZ 2048 #define MEM_BUFFER_SZ 2048
#endif #endif
#define SHOW_VERBOSE 0 /* 0=tab del (minimal), 1=info, 2=debug, 3=debug w/wolf logs */ #define SHOW_VERBOSE 0 /* 0=tab del (minimal), 1=info, 2=debug, 3=debug w/wolf logs */
#ifndef WOLFSSL_CIPHER_LIST_MAX_SIZE #ifndef WOLFSSL_CIPHER_LIST_MAX_SIZE
@@ -126,9 +126,9 @@ extern UART_HandleTypeDef HAL_CONSOLE_UART;
* Public types/enumerations/variables * Public types/enumerations/variables
****************************************************************************/ ****************************************************************************/
typedef struct func_args { typedef struct func_args {
int argc; int argc;
char** argv; char** argv;
int return_code; int return_code;
} func_args; } func_args;
const char menu1[] = "\n" const char menu1[] = "\n"
@@ -508,7 +508,7 @@ static void ShowPeer(WOLFSSL* ssl)
static int ServerMemSend(info_t* info, char* buf, int sz) static int ServerMemSend(info_t* info, char* buf, int sz)
{ {
#ifdef CMSIS_OS2_H_ #ifdef CMSIS_OS2_H_
osSemaphoreAcquire(info->client.mutex, osWaitForever); osSemaphoreAcquire(info->client.mutex, osWaitForever);
#else #else
osSemaphoreWait(info->client.mutex, osWaitForever); osSemaphoreWait(info->client.mutex, osWaitForever);
#endif #endif
@@ -560,13 +560,13 @@ static int ServerMemRecv(info_t* info, char* buf, int sz)
osSemaphoreRelease(info->server.mutex); osSemaphoreRelease(info->server.mutex);
#ifdef CMSIS_OS2_H_ #ifdef CMSIS_OS2_H_
if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) { if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) {
printf("Server Recv: Timeout!\n"); printf("Server Recv: Timeout!\n");
return WOLFSSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
osSemaphoreAcquire(info->server.mutex, osWaitForever); osSemaphoreAcquire(info->server.mutex, osWaitForever);
#else #else
if (osSignalWait(1, RECV_WAIT_TIMEOUT).status == osEventTimeout) { if (osSignalWait(1, RECV_WAIT_TIMEOUT).status == osEventTimeout) {
printf("Server Recv: Timeout!\n"); printf("Server Recv: Timeout!\n");
return WOLFSSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
osSemaphoreWait(info->server.mutex, osWaitForever); osSemaphoreWait(info->server.mutex, osWaitForever);
@@ -656,14 +656,14 @@ static int ClientMemRecv(info_t* info, char* buf, int sz)
osSemaphoreRelease(info->client.mutex); osSemaphoreRelease(info->client.mutex);
#ifdef CMSIS_OS2_H_ #ifdef CMSIS_OS2_H_
if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) { if (osThreadFlagsWait(1, osFlagsWaitAny, RECV_WAIT_TIMEOUT) == osFlagsErrorTimeout) {
printf("Client Recv: Timeout!\n"); printf("Client Recv: Timeout!\n");
return WOLFSSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
osSemaphoreAcquire(info->client.mutex, osWaitForever); osSemaphoreAcquire(info->client.mutex, osWaitForever);
#else #else
if (osSignalWait(1, RECV_WAIT_TIMEOUT).status == osEventTimeout) { if (osSignalWait(1, RECV_WAIT_TIMEOUT).status == osEventTimeout) {
printf("Client Recv: Timeout!\n"); printf("Client Recv: Timeout!\n");
return WOLFSSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
osSemaphoreWait(info->client.mutex, osWaitForever); osSemaphoreWait(info->client.mutex, osWaitForever);
#endif #endif
@@ -738,29 +738,29 @@ static int bench_tls_client(info_t* info)
/* set up client */ /* set up client */
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
if (tls13) { if (tls13) {
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfTLSv1_3_client_method_ex, ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfTLSv1_3_client_method_ex,
gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10); gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10);
#else #else
cli_ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method()); cli_ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
#endif #endif
} }
#endif #endif
if (!tls13) { if (!tls13) {
#if !defined(WOLFSSL_TLS13) #if !defined(WOLFSSL_TLS13)
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfSSLv23_client_method_ex, ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfSSLv23_client_method_ex,
gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10); gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10);
#else #else
cli_ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); cli_ctx = wolfSSL_CTX_new(wolfSSLv23_client_method());
#endif #endif
#elif !defined(WOLFSSL_NO_TLS12) #elif !defined(WOLFSSL_NO_TLS12)
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfTLSv1_2_client_method_ex, ret = wolfSSL_CTX_load_static_memory(&cli_ctx, wolfTLSv1_2_client_method_ex,
gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10); gWolfCTXCli, sizeof(gWolfCTXCli), WOLFMEM_GENERAL , 10);
#else #else
cli_ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method()); cli_ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
#endif #endif
#endif #endif
} }
@@ -949,7 +949,7 @@ static int bench_tls_client(info_t* info)
exit: exit:
if (ret != 0 && ret != WOLFSSL_SUCCESS) { if (ret != 0 && ret != WOLFSSL_SUCCESS) {
info->doShutdown = 1; info->doShutdown = 1;
printf("Client Error: %d (%s)\n", ret, printf("Client Error: %d (%s)\n", ret,
wolfSSL_ERR_reason_error_string(ret)); wolfSSL_ERR_reason_error_string(ret));
} }
@@ -986,7 +986,7 @@ static void client_thread(const void* args)
#ifdef CMSIS_OS2_H_ #ifdef CMSIS_OS2_H_
osThreadFlagsSet(info->server.threadId, 1); osThreadFlagsSet(info->server.threadId, 1);
#else #else
osSignalSet(info->server.threadId, 1); osSignalSet(info->server.threadId, 1);
#endif #endif
} }
info->client.ret = ret; info->client.ret = ret;
@@ -1014,29 +1014,29 @@ static int bench_tls_server(info_t* info)
/* set up server */ /* set up server */
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
if (tls13) { if (tls13) {
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfTLSv1_3_server_method_ex, ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfTLSv1_3_server_method_ex,
gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10); gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10);
#else #else
srv_ctx = wolfSSL_CTX_new(wolfTLSv1_3_server_method()); srv_ctx = wolfSSL_CTX_new(wolfTLSv1_3_server_method());
#endif #endif
} }
#endif #endif
if (!tls13) { if (!tls13) {
#if !defined(WOLFSSL_TLS13) #if !defined(WOLFSSL_TLS13)
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfSSLv23_server_method_ex, ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfSSLv23_server_method_ex,
gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10); gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10);
#else #else
srv_ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()); srv_ctx = wolfSSL_CTX_new(wolfSSLv23_server_method());
#endif #endif
#elif !defined(WOLFSSL_NO_TLS12) #elif !defined(WOLFSSL_NO_TLS12)
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfTLSv1_2_server_method_ex, ret = wolfSSL_CTX_load_static_memory(&srv_ctx, wolfTLSv1_2_server_method_ex,
gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10); gWolfCTXSrv, sizeof(gWolfCTXSrv), WOLFMEM_GENERAL , 10);
#else #else
srv_ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method()); srv_ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
#endif #endif
#endif #endif
} }
@@ -1225,7 +1225,7 @@ static int bench_tls_server(info_t* info)
exit: exit:
if (ret != 0 && ret != WOLFSSL_SUCCESS) { if (ret != 0 && ret != WOLFSSL_SUCCESS) {
info->doShutdown = 1; info->doShutdown = 1;
printf("Server Error: %d (%s)\n", ret, printf("Server Error: %d (%s)\n", ret,
wolfSSL_ERR_reason_error_string(ret)); wolfSSL_ERR_reason_error_string(ret));
} }
@@ -1259,7 +1259,7 @@ static void server_thread(const void* args)
/* signal client */ /* signal client */
if (!info->client.done && info->client.threadId != 0) { if (!info->client.done && info->client.threadId != 0) {
#ifdef CMSIS_OS2_H_ #ifdef CMSIS_OS2_H_
osThreadFlagsSet(info->client.threadId, 1); osThreadFlagsSet(info->client.threadId, 1);
#else #else
osSignalSet(info->client.threadId, 1); osSignalSet(info->client.threadId, 1);
#endif #endif
@@ -1813,23 +1813,23 @@ done:
extern RTC_HandleTypeDef hrtc; extern RTC_HandleTypeDef hrtc;
double current_time(void) double current_time(void)
{ {
RTC_TimeTypeDef time; RTC_TimeTypeDef time;
RTC_DateTypeDef date; RTC_DateTypeDef date;
uint32_t subsec = 0; uint32_t subsec = 0;
/* must get time and date here due to STM32 HW bug */ /* must get time and date here due to STM32 HW bug */
HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN); HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN);
/* Not all STM32 RTCs have subseconds in the struct */ /* Not all STM32 RTCs have subseconds in the struct */
#ifdef RTC_ALARMSUBSECONDMASK_ALL #ifdef RTC_ALARMSUBSECONDMASK_ALL
subsec = (255 - time.SubSeconds) * 1000 / 255; subsec = (255 - time.SubSeconds) * 1000 / 255;
#endif #endif
(void) date; (void) date;
/* return seconds.milliseconds */ /* return seconds.milliseconds */
return ((double) time.Hours * 24) + ((double) time.Minutes * 60) return ((double) time.Hours * 24) + ((double) time.Minutes * 60)
+ (double) time.Seconds + ((double) subsec / 1000); + (double) time.Seconds + ((double) subsec / 1000);
} }
#endif /* HAL_RTC_MODULE_ENABLED */ #endif /* HAL_RTC_MODULE_ENABLED */
@@ -1840,8 +1840,8 @@ void wolfCryptDemo(const void* argument)
#endif #endif
{ {
HAL_StatusTypeDef halRet; HAL_StatusTypeDef halRet;
uint8_t buffer[2]; uint8_t buffer[2];
func_args args; func_args args;
#if 0 #if 0
wolfSSL_Debugging_ON(); wolfSSL_Debugging_ON();
@@ -1857,46 +1857,46 @@ void wolfCryptDemo(const void* argument)
#ifdef WOLFSSL_STATIC_MEMORY #ifdef WOLFSSL_STATIC_MEMORY
if (wc_LoadStaticMemory(&HEAP_HINT, gWolfMem, sizeof(gWolfMem), if (wc_LoadStaticMemory(&HEAP_HINT, gWolfMem, sizeof(gWolfMem),
WOLFMEM_GENERAL, 10) != 0) { WOLFMEM_GENERAL, 10) != 0) {
printf("unable to load static memory"); printf("unable to load static memory");
} }
#endif #endif
//wolfSSL_SetAllocators(wolfMallocCb, wolfFreeCb, wolfReallocCb); //wolfSSL_SetAllocators(wolfMallocCb, wolfFreeCb, wolfReallocCb);
while (1) { while (1) {
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
args.return_code = NOT_COMPILED_IN; /* default */ args.return_code = NOT_COMPILED_IN; /* default */
printf("\n\t\t\t\tMENU\n"); printf("\n\t\t\t\tMENU\n");
printf(menu1); printf(menu1);
printf("Please select one of the above options:\n"); printf("Please select one of the above options:\n");
do { do {
halRet = HAL_UART_Receive(&HAL_CONSOLE_UART, buffer, sizeof(buffer), 100); halRet = HAL_UART_Receive(&HAL_CONSOLE_UART, buffer, sizeof(buffer), 100);
} while (halRet != HAL_OK || buffer[0] == '\n' || buffer[0] == '\r'); } while (halRet != HAL_OK || buffer[0] == '\n' || buffer[0] == '\r');
switch (buffer[0]) { switch (buffer[0]) {
case 't': case 't':
printf("Running wolfCrypt Tests...\n"); printf("Running wolfCrypt Tests...\n");
#ifndef NO_CRYPT_TEST #ifndef NO_CRYPT_TEST
args.return_code = 0; args.return_code = 0;
wolfcrypt_test(&args); wolfcrypt_test(&args);
#else #else
args.return_code = NOT_COMPILED_IN; args.return_code = NOT_COMPILED_IN;
#endif #endif
printf("Crypt Test: Return code %d\n", args.return_code); printf("Crypt Test: Return code %d\n", args.return_code);
break; break;
case 'b': case 'b':
printf("Running wolfCrypt Benchmarks...\n"); printf("Running wolfCrypt Benchmarks...\n");
#ifndef NO_CRYPT_BENCHMARK #ifndef NO_CRYPT_BENCHMARK
args.return_code = 0; args.return_code = 0;
benchmark_test(&args); benchmark_test(&args);
#else #else
args.return_code = NOT_COMPILED_IN; args.return_code = NOT_COMPILED_IN;
#endif #endif
printf("Benchmark Test: Return code %d\n", args.return_code); printf("Benchmark Test: Return code %d\n", args.return_code);
break; break;
case 'l': case 'l':
printf("Running TLS Benchmarks...\n"); printf("Running TLS Benchmarks...\n");
@@ -1936,14 +1936,14 @@ void wolfCryptDemo(const void* argument)
printf("TLS 1.3 Client: Return code %d\n", args.return_code); printf("TLS 1.3 Client: Return code %d\n", args.return_code);
break; break;
#endif /* ENABLE_TLS_UART */ #endif /* ENABLE_TLS_UART */
/* All other cases go here */ /* All other cases go here */
default: default:
printf("\nSelection out of range\n"); printf("\nSelection out of range\n");
break; break;
} }
PrintMemStats(); PrintMemStats();
} }
#ifdef WOLFCRYPT_ONLY #ifdef WOLFCRYPT_ONLY
wolfCrypt_Cleanup(); wolfCrypt_Cleanup();

View File

@@ -10797,9 +10797,9 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
int result = 0; int result = 0;
int ret; int ret;
#ifdef WOLFSSL_AES_256 #ifdef WOLFSSL_AES_256
#if !(defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC)) #if !(defined(WOLF_CRYPTO_CB) && defined(HAVE_INTEL_QA_SYNC))
int alen; int alen;
#endif #endif
#if !defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) #if !defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT)
int plen; int plen;
#endif #endif