Drop a function brace and WOLFSSL_TLS13.

This commit is contained in:
Anthony Hu
2021-10-04 13:56:01 -04:00
parent 2fa0114d54
commit 310ab6692a

View File

@@ -963,6 +963,7 @@ static int bench_tls_client(info_t* info)
goto exit; goto exit;
} }
#ifdef WOLFSSL_TLS13
if (info->group != 0) { if (info->group != 0) {
ret = wolfSSL_UseKeyShare(cli_ssl, info->group); ret = wolfSSL_UseKeyShare(cli_ssl, info->group);
if (ret != WOLFSSL_SUCCESS) { if (ret != WOLFSSL_SUCCESS) {
@@ -970,6 +971,7 @@ static int bench_tls_client(info_t* info)
goto exit; goto exit;
} }
} }
#endif
#ifdef WOLFSSL_DTLS #ifdef WOLFSSL_DTLS
if (info->doDTLS) { if (info->doDTLS) {
@@ -1387,6 +1389,7 @@ static int bench_tls_server(info_t* info)
ret = MEMORY_E; goto exit; ret = MEMORY_E; goto exit;
} }
#ifdef WOLFSSL_TLS13
if (info->group != 0) { if (info->group != 0) {
ret = wolfSSL_UseKeyShare(srv_ssl, info->group); ret = wolfSSL_UseKeyShare(srv_ssl, info->group);
if (ret != WOLFSSL_SUCCESS) { if (ret != WOLFSSL_SUCCESS) {
@@ -1394,6 +1397,7 @@ static int bench_tls_server(info_t* info)
goto exit; goto exit;
} }
} }
#endif
#ifdef WOLFSSL_DTLS #ifdef WOLFSSL_DTLS
if (info->doDTLS) { if (info->doDTLS) {
@@ -1605,7 +1609,9 @@ static void Usage(void)
fprintf(stderr, "-P Port (default %d)\n", BENCH_DEFAULT_PORT); fprintf(stderr, "-P Port (default %d)\n", BENCH_DEFAULT_PORT);
fprintf(stderr, "-e List Every cipher suite available\n"); fprintf(stderr, "-e List Every cipher suite available\n");
fprintf(stderr, "-i Show peer info\n"); fprintf(stderr, "-i Show peer info\n");
#ifdef WOLFSSL_TLS13
fprintf(stderr, "-g Run through each of the TLS 1.3 groups that are available\n"); fprintf(stderr, "-g Run through each of the TLS 1.3 groups that are available\n");
#endif
fprintf(stderr, "-l <str> Cipher suite list (: delimited)\n"); fprintf(stderr, "-l <str> Cipher suite list (: delimited)\n");
fprintf(stderr, "-t <num> Time <num> (seconds) to run each test (default %d)\n", BENCH_RUNTIME_SEC); fprintf(stderr, "-t <num> Time <num> (seconds) to run each test (default %d)\n", BENCH_RUNTIME_SEC);
fprintf(stderr, "-p <num> The packet size <num> in bytes [1-16kB] (default %d)\n", TEST_PACKET_SIZE); fprintf(stderr, "-p <num> The packet size <num> in bytes [1-16kB] (default %d)\n", TEST_PACKET_SIZE);
@@ -1636,7 +1642,9 @@ static void ShowCiphers(void)
fprintf(stderr, "%s\n", ciphers); fprintf(stderr, "%s\n", ciphers);
} }
static int SetupSupportedGroups(int verbose) { #ifdef WOLFSSL_TLS13
static int SetupSupportedGroups(int verbose)
{
int i; int i;
WOLFSSL_CTX* ctx = NULL; WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL; WOLFSSL* ssl = NULL;
@@ -1683,6 +1691,7 @@ static int SetupSupportedGroups(int verbose) {
wolfSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx);
return ret; return ret;
} }
#endif
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@@ -1725,7 +1734,9 @@ int bench_tls(void* args)
#ifdef WOLFSSL_DTLS #ifdef WOLFSSL_DTLS
int doDTLS = 0; int doDTLS = 0;
#endif #endif
#ifdef WOLFSSL_TLS13
int argDoGroups = 0; int argDoGroups = 0;
#endif
if (args != NULL) { if (args != NULL) {
argc = ((func_args*)args)->argc; argc = ((func_args*)args)->argc;
@@ -1770,9 +1781,14 @@ int bench_tls(void* args)
goto exit; goto exit;
case 'g' : case 'g' :
#ifdef WOLFSSL_TLS13
argDoGroups = 1; argDoGroups = 1;
break; break;
#else
fprintf(stderr, "There are only groups in TLS 1.3\n");
Usage();
ret = MY_EX_USAGE; goto exit;
#endif
case 'i' : case 'i' :
argShowPeerInfo = 1; argShowPeerInfo = 1;
break; break;
@@ -1850,11 +1866,13 @@ int bench_tls(void* args)
cipher = ciphers; cipher = ciphers;
} }
#ifdef WOLFSSL_TLS13
if (argDoGroups) { if (argDoGroups) {
if (SetupSupportedGroups(argShowVerbose) != 0) { if (SetupSupportedGroups(argShowVerbose) != 0) {
goto exit; goto exit;
} }
} }
#endif
/* for server or client side only, only 1 thread is allowed */ /* for server or client side only, only 1 thread is allowed */
if (argServerOnly || argClientOnly) { if (argServerOnly || argClientOnly) {
@@ -1919,13 +1937,14 @@ int bench_tls(void* args)
fprintf(stderr, "Cipher: %s\n", cipher); fprintf(stderr, "Cipher: %s\n", cipher);
} }
#ifdef WOLFSSL_TLS13
for (group_index = 0; groups[group_index].name != NULL; group_index++) { for (group_index = 0; groups[group_index].name != NULL; group_index++) {
if (argDoGroups && groups[group_index].group == 0) { if (argDoGroups && groups[group_index].group == 0) {
/* Skip unsupported group. */ /* Skip unsupported group. */
continue; continue;
} }
#endif
for (i=0; i<argThreadPairs; i++) { for (i=0; i<argThreadPairs; i++) {
info = &theadInfo[i]; info = &theadInfo[i];
XMEMSET(info, 0, sizeof(info_t)); XMEMSET(info, 0, sizeof(info_t));
@@ -1934,9 +1953,11 @@ int bench_tls(void* args)
info->port = argPort + i; /* threads must have separate ports */ info->port = argPort + i; /* threads must have separate ports */
info->cipher = cipher; info->cipher = cipher;
#ifdef WOLFSSL_TLS13
if (argDoGroups && XSTRNCMP(theadInfo[0].cipher, "TLS13", 5) == 0) if (argDoGroups && XSTRNCMP(theadInfo[0].cipher, "TLS13", 5) == 0)
info->group = groups[group_index].group; info->group = groups[group_index].group;
else else
#endif
info->group = 0; info->group = 0;
info->packetSize = argTestPacketSize; info->packetSize = argTestPacketSize;
@@ -2078,13 +2099,14 @@ int bench_tls(void* args)
#endif #endif
} }
#ifdef WOLFSSL_TLS13
if (!argDoGroups || theadInfo[0].group == 0) { if (!argDoGroups || theadInfo[0].group == 0) {
/* We only needed to do this once because they don't want to /* We only needed to do this once because they don't want to
* benchmarks groups or this isn't a TLS 1.3 cipher. */ * benchmarks groups or this isn't a TLS 1.3 cipher. */
break; break;
} }
} }
#endif
/* target next cipher */ /* target next cipher */
cipher = (next_cipher != NULL) ? (next_cipher + 1) : NULL; cipher = (next_cipher != NULL) ? (next_cipher + 1) : NULL;
} /* while */ } /* while */