Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10855,7 +10855,7 @@ then
# Replace all options and just use WOLFSSL_USER_SETTINGS and
# WOLFSSL_USER_SETTINGS_ASM.
AM_CFLAGS="-DWOLFSSL_USER_SETTINGS -DWOLFSSL_USER_SETTINGS_ASM"
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_USER_SETTINGS -DWOLFSSL_USER_SETTINGS_ASM"
AM_CCASFLAGS="-DWOLFSSL_USER_SETTINGS -DWOLFSSL_USER_SETTINGS_ASM"

# Generate assembly-safe user_settings_asm.h (just preprocessor directives
# from user_settings.h).
Expand Down
3 changes: 3 additions & 0 deletions examples/benchmark/tls_bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ static struct group_info groups[] = {
{ WOLFSSL_ECC_BRAINPOOLP512R1, "ECC_BRAINPOOLP512R1" },
{ WOLFSSL_ECC_X25519, "ECC_X25519" },
{ WOLFSSL_ECC_X448, "ECC_X448" },
{ WOLFSSL_ECC_BRAINPOOLP256R1TLS13, "ECC_BRAINPOOLP256R1TLS13" },
{ WOLFSSL_ECC_BRAINPOOLP384R1TLS13, "ECC_BRAINPOOLP384R1TLS13" },
{ WOLFSSL_ECC_BRAINPOOLP512R1TLS13, "ECC_BRAINPOOLP512R1TLS13" },
{ WOLFSSL_FFDHE_2048, "FFDHE_2048" },
{ WOLFSSL_FFDHE_3072, "FFDHE_3072" },
{ WOLFSSL_FFDHE_4096, "FFDHE_4096" },
Expand Down
100 changes: 88 additions & 12 deletions examples/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,16 @@ static void ShowVersions(void)
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
#define MAX_GROUP_NUMBER 4
static void SetKeyShare(WOLFSSL* ssl, int onlyKeyShare, int useX25519,
int useX448, int usePqc, char* pqcAlg, int setGroups)
int useX448, int useBp, int usePqc, char* pqcAlg,
int setGroups)
{
int ret;
int groups[MAX_GROUP_NUMBER] = {0};
int count = 0;

(void)useX25519;
(void)useX448;
(void)useBp;
(void)usePqc;
(void)pqcAlg;

Expand Down Expand Up @@ -349,6 +351,23 @@ static void SetKeyShare(WOLFSSL* ssl, int onlyKeyShare, int useX25519,
else
err_sys("unable to use curve x448");
} while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
#endif
}
else if (useBp) {
#if defined(HAVE_ECC) && defined(HAVE_ECC_BRAINPOOL)
#if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256
do {
ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_ECC_BRAINPOOLP256R1TLS13);
if (ret == WOLFSSL_SUCCESS)
groups[count++] = WOLFSSL_ECC_BRAINPOOLP256R1TLS13;
#ifdef WOLFSSL_ASYNC_CRYPT
else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
#endif
else
err_sys("unable to use curve brainpoolp256r1");
} while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
#endif
#endif
}
else {
Expand Down Expand Up @@ -587,7 +606,7 @@ static const char* client_bench_conmsg[][5] = {
static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
int dtlsUDP, int dtlsSCTP, int benchmark, int resumeSession, int useX25519,
int useX448, int usePqc, char* pqcAlg, int helloRetry, int onlyKeyShare,
int version, int earlyData)
int version, int earlyData, int useBp)
{
/* time passed in number of connects give average */
int times = benchmark, skip = (int)((double)times * 0.1);
Expand All @@ -610,6 +629,7 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
(void)onlyKeyShare;
(void)version;
(void)earlyData;
(void)useBp;

while (loops--) {
#ifndef NO_SESSION_CACHE
Expand All @@ -636,7 +656,7 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
else if (version >= 4) {
if (!helloRetry)
SetKeyShare(ssl, onlyKeyShare, useX25519, useX448,
usePqc, pqcAlg, 1);
useBp, usePqc, pqcAlg, 1);
else
wolfSSL_NoKeyShares(ssl);
}
Expand Down Expand Up @@ -717,7 +737,7 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
int dtlsUDP, int dtlsSCTP, int block, size_t throughput, int useX25519,
int useX448, int usePqc, char* pqcAlg, int exitWithRet, int version,
int onlyKeyShare)
int onlyKeyShare, int useBp)
{
double start, conn_time = 0, tx_time = 0, rx_time = 0;
SOCKET_T sockfd = WOLFSSL_SOCKET_INVALID;
Expand All @@ -738,11 +758,12 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
(void)useX448;
(void)usePqc;
(void)pqcAlg;
(void)useBp;
(void)version;
(void)onlyKeyShare;
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
if (version >= 4) {
SetKeyShare(ssl, onlyKeyShare, useX25519, useX448, usePqc,
SetKeyShare(ssl, onlyKeyShare, useX25519, useX448, useBp, usePqc,
pqcAlg, 1);
}
#endif
Expand Down Expand Up @@ -1150,7 +1171,7 @@ static int ClientWriteRead(WOLFSSL* ssl, const char* msg, int msgSz,
/* 4. add the same message into Japanese section */
/* (will be translated later) */
/* 5. add printf() into suitable position of Usage() */
static const char* client_usage_msg[][78] = {
static const char* client_usage_msg[][79] = {
/* English */
{
" NOTE: All files relative to wolfSSL home dir\n", /* 0 */
Expand Down Expand Up @@ -1398,10 +1419,13 @@ static const char* client_usage_msg[][78] = {
"--files-are-der Specified files are in DER, not PEM format\n", /* 75 */
#ifdef WOLFSSL_SYS_CRYPTO_POLICY
"--crypto-policy <path to crypto policy file>\n", /* 76 */
#endif
#ifdef HAVE_ECC_BRAINPOOL
"--bpKs Use Brainpool ECC group for key share\n", /* 77 */
#endif
"\n"
"For simpler wolfSSL TLS client examples, visit\n"
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 77 */
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 78 */
NULL,
},
#ifndef NO_MULTIBYTE_PRINT
Expand Down Expand Up @@ -1653,11 +1677,14 @@ static const char* client_usage_msg[][78] = {
"--files-are-der Specified files are in DER, not PEM format\n", /* 75 */
#ifdef WOLFSSL_SYS_CRYPTO_POLICY
"--crypto-policy <path to crypto policy file>\n", /* 76 */
#endif
#ifdef HAVE_ECC_BRAINPOOL
"--bpKs Use Brainpool ECC group for key share\n", /* 77 */
#endif
"\n"
"より簡単なwolfSSL TLS クライアントの例については"
"下記にアクセスしてください\n"
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 77 */
"https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n", /* 78 */
NULL,
},
#endif
Expand Down Expand Up @@ -1892,6 +1919,9 @@ static void Usage(void)
#endif
#ifdef HAVE_RPK
printf("%s", msg[++msgid]); /* --rpk */
#endif
#ifdef HAVE_ECC_BRAINPOOL
printf("%s", msg[++msgid]); /* --bpKs */
#endif
printf("%s", msg[++msgid]); /* --files-are-der */
printf("%s", msg[++msgid]); /* Documentation Hint */
Expand Down Expand Up @@ -2078,6 +2108,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#if defined(WOLFSSL_SYS_CRYPTO_POLICY)
{ "crypto-policy", 1, 269 },
#endif /* WOLFSSL_SYS_CRYPTO_POLICY */
#ifdef HAVE_ECC_BRAINPOOL
{ "bpKs", 0, 270 },
#endif
{ 0, 0, 0 }
};
#endif
Expand Down Expand Up @@ -2187,6 +2220,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#endif
int useX25519 = 0;
int useX448 = 0;
int useBrainpool = 0;
int usePqc = 0;
char* pqcAlg = NULL;
int exitWithRet = 0;
Expand Down Expand Up @@ -2311,6 +2345,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
(void)earlyData;
(void)useX25519;
(void)useX448;
(void)useBrainpool;
(void)helloRetry;
(void)onlyKeyShare;
(void)useSupCurve;
Expand Down Expand Up @@ -2959,6 +2994,15 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
policy = myoptarg;
#endif /* WOLFSSL_SYS_CRYPTO_POLICY */
break;
#ifdef HAVE_ECC_BRAINPOOL
case 270:
useBrainpool = 1;
#if defined(HAVE_ECC) && defined(WOLFSSL_TLS13) && \
defined(HAVE_SUPPORTED_CURVES)
onlyKeyShare = 2;
#endif
break;
#endif

default:
Usage();
Expand Down Expand Up @@ -3680,6 +3724,37 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
}
#endif /* HAVE_CURVE448 */
#ifdef HAVE_ECC
#ifdef HAVE_ECC_BRAINPOOL
if (useBrainpool) {
if (version == 4) {
if (wolfSSL_CTX_UseSupportedCurve(ctx,
WOLFSSL_ECC_BRAINPOOLP256R1TLS13)
!= WOLFSSL_SUCCESS) {
err_sys("unable to support brainpoolp256r1tls13");
}
}
else if (version == CLIENT_DOWNGRADE_VERSION) {
if (wolfSSL_CTX_UseSupportedCurve(ctx,
WOLFSSL_ECC_BRAINPOOLP256R1TLS13)
!= WOLFSSL_SUCCESS) {
err_sys("unable to support brainpoolp256r1tls13");
}
if (minVersion <= 3) {
if (wolfSSL_CTX_UseSupportedCurve(ctx,
WOLFSSL_ECC_BRAINPOOLP256R1)
!= WOLFSSL_SUCCESS) {
err_sys("unable to support brainpoolp256r1");
}
}
}
else {
if (wolfSSL_CTX_UseSupportedCurve(ctx, WOLFSSL_ECC_BRAINPOOLP256R1)
!= WOLFSSL_SUCCESS) {
err_sys("unable to support brainpoolp256r1");
}
}
}
#endif /* HAVE_ECC_BRAINPOOL */
if (useSupCurve) {
#if !defined(NO_ECC_SECP) && \
(defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES))
Expand Down Expand Up @@ -3728,7 +3803,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
ClientBenchmarkConnections(ctx, host, port, dtlsUDP, dtlsSCTP,
benchmark, resumeSession, useX25519,
useX448, usePqc, pqcAlg, helloRetry,
onlyKeyShare, version, earlyData);
onlyKeyShare, version, earlyData,
useBrainpool);
wolfSSL_CTX_free(ctx); ctx = NULL;
XEXIT_T(EXIT_SUCCESS);
}
Expand All @@ -3738,7 +3814,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
ClientBenchmarkThroughput(ctx, host, port, dtlsUDP, dtlsSCTP,
block, throughput, useX25519, useX448,
usePqc, pqcAlg, exitWithRet, version,
onlyKeyShare);
onlyKeyShare, useBrainpool);
wolfSSL_CTX_free(ctx); ctx = NULL;
if (((func_args*)args)->return_code != EXIT_SUCCESS && !exitWithRet)
XEXIT_T(EXIT_SUCCESS);
Expand Down Expand Up @@ -3872,8 +3948,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)

#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
if (!helloRetry && (version >= 4 || version <= -4)) {
SetKeyShare(ssl, onlyKeyShare, useX25519, useX448, usePqc,
pqcAlg, 0);
SetKeyShare(ssl, onlyKeyShare, useX25519, useX448,
useBrainpool, usePqc, pqcAlg, 0);
}
else {
wolfSSL_NoKeyShares(ssl);
Expand Down
3 changes: 3 additions & 0 deletions examples/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ static struct group_info group_id_to_text[] = {
{ WOLFSSL_ECC_BRAINPOOLP256R1, "BRAINPOOLP256R1" },
{ WOLFSSL_ECC_BRAINPOOLP384R1, "BRAINPOOLP384R1" },
{ WOLFSSL_ECC_BRAINPOOLP512R1, "BRAINPOOLP512R1" },
{ WOLFSSL_ECC_BRAINPOOLP256R1TLS13, "BRAINPOOLP256R1TLS13" },
{ WOLFSSL_ECC_BRAINPOOLP384R1TLS13, "BRAINPOOLP384R1TLS13" },
{ WOLFSSL_ECC_BRAINPOOLP512R1TLS13, "BRAINPOOLP512R1TLS13" },
{ 0, NULL }
};
#endif /* CAN_FORCE_CURVE && HAVE_ECC */
Expand Down
Loading