mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Added EarlyData support to benchmark loop
This commit is contained in:
@@ -260,6 +260,56 @@ static void SetKeyShare(WOLFSSL* ssl, int onlyKeyShare, int useX25519)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_EARLY_DATA
|
||||||
|
static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
|
||||||
|
int msgSz, char* buffer)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
err = 0; /* reset error */
|
||||||
|
ret = wolfSSL_write_early_data(ssl, msg, msgSz, &msgSz);
|
||||||
|
if (ret <= 0) {
|
||||||
|
err = wolfSSL_get_error(ssl, 0);
|
||||||
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
|
if (err == WC_PENDING_E) {
|
||||||
|
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||||
|
if (ret < 0) break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} while (err == WC_PENDING_E);
|
||||||
|
if (ret != msgSz) {
|
||||||
|
printf("SSL_write_early_data msg error %d, %s\n", err,
|
||||||
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
|
err_sys("SSL_write_early_data failed");
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
err = 0; /* reset error */
|
||||||
|
ret = wolfSSL_write_early_data(ssl, msg, msgSz, &msgSz);
|
||||||
|
if (ret <= 0) {
|
||||||
|
err = wolfSSL_get_error(ssl, 0);
|
||||||
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
|
if (err == WC_PENDING_E) {
|
||||||
|
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||||
|
if (ret < 0) break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} while (err == WC_PENDING_E);
|
||||||
|
if (ret != msgSz) {
|
||||||
|
printf("SSL_write_early_data msg error %d, %s\n", err,
|
||||||
|
wolfSSL_ERR_error_string(err, buffer));
|
||||||
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
|
err_sys("SSL_write_early_data failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Measures average time to create, connect and disconnect a connection (TPS).
|
/* Measures average time to create, connect and disconnect a connection (TPS).
|
||||||
Benchmark = number of connections. */
|
Benchmark = number of connections. */
|
||||||
static const char* client_bench_conmsg[][5] = {
|
static const char* client_bench_conmsg[][5] = {
|
||||||
@@ -280,7 +330,7 @@ static const char* client_bench_conmsg[][5] = {
|
|||||||
|
|
||||||
static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
|
static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
|
||||||
int dtlsUDP, int dtlsSCTP, int benchmark, int resumeSession, int useX25519,
|
int dtlsUDP, int dtlsSCTP, int benchmark, int resumeSession, int useX25519,
|
||||||
int helloRetry, int onlyKeyShare, int version)
|
int helloRetry, int onlyKeyShare, int version, int earlyData)
|
||||||
{
|
{
|
||||||
/* time passed in number of connects give average */
|
/* time passed in number of connects give average */
|
||||||
int times = benchmark, skip = times * 0.1;
|
int times = benchmark, skip = times * 0.1;
|
||||||
@@ -292,6 +342,9 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
#ifdef WOLFSSL_TLS13
|
#ifdef WOLFSSL_TLS13
|
||||||
byte* reply[80];
|
byte* reply[80];
|
||||||
static const char msg[] = "GET /index.html HTTP/1.0\r\n\r\n";
|
static const char msg[] = "GET /index.html HTTP/1.0\r\n\r\n";
|
||||||
|
#ifdef WOLFSSL_EARLY_DATA
|
||||||
|
static const char earlyMsg[] = "A drop of info";
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
const char** words = client_bench_conmsg[lng_index];
|
const char** words = client_bench_conmsg[lng_index];
|
||||||
|
|
||||||
@@ -300,6 +353,7 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
(void)helloRetry;
|
(void)helloRetry;
|
||||||
(void)onlyKeyShare;
|
(void)onlyKeyShare;
|
||||||
(void)version;
|
(void)version;
|
||||||
|
(void)earlyData;
|
||||||
|
|
||||||
while (loops--) {
|
while (loops--) {
|
||||||
#ifndef NO_SESSION_CACHE
|
#ifndef NO_SESSION_CACHE
|
||||||
@@ -337,6 +391,13 @@ static int ClientBenchmarkConnections(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
err_sys("error in setting fd");
|
err_sys("error in setting fd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WOLFSSL_TLS13) && !defined(NO_SESSION_CACHE) && \
|
||||||
|
defined(WOLFSSL_EARLY_DATA)
|
||||||
|
if (version >= 4 && benchResume && earlyData) {
|
||||||
|
char buffer[WOLFSSL_MAX_ERROR_SZ];
|
||||||
|
EarlyData(ctx, ssl, earlyMsg, sizeof(earlyMsg)-1, buffer);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
err = 0; /* reset error */
|
err = 0; /* reset error */
|
||||||
ret = wolfSSL_connect(ssl);
|
ret = wolfSSL_connect(ssl);
|
||||||
@@ -764,55 +825,6 @@ static void ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_EARLY_DATA
|
|
||||||
static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, char* msg, int msgSz,
|
|
||||||
char* buffer)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
do {
|
|
||||||
err = 0; /* reset error */
|
|
||||||
ret = wolfSSL_write_early_data(ssl, msg, msgSz, &msgSz);
|
|
||||||
if (ret <= 0) {
|
|
||||||
err = wolfSSL_get_error(ssl, 0);
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
||||||
if (err == WC_PENDING_E) {
|
|
||||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
|
||||||
if (ret < 0) break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} while (err == WC_PENDING_E);
|
|
||||||
if (ret != msgSz) {
|
|
||||||
printf("SSL_write_early_data msg error %d, %s\n", err,
|
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
|
||||||
wolfSSL_free(ssl); ssl = NULL;
|
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
|
||||||
err_sys("SSL_write_early_data failed");
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
err = 0; /* reset error */
|
|
||||||
ret = wolfSSL_write_early_data(ssl, msg, msgSz, &msgSz);
|
|
||||||
if (ret <= 0) {
|
|
||||||
err = wolfSSL_get_error(ssl, 0);
|
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
||||||
if (err == WC_PENDING_E) {
|
|
||||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
|
||||||
if (ret < 0) break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} while (err == WC_PENDING_E);
|
|
||||||
if (ret != msgSz) {
|
|
||||||
printf("SSL_write_early_data msg error %d, %s\n", err,
|
|
||||||
wolfSSL_ERR_error_string(err, buffer));
|
|
||||||
wolfSSL_free(ssl); ssl = NULL;
|
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
|
||||||
err_sys("SSL_write_early_data failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* when adding new option, please follow the steps below: */
|
/* when adding new option, please follow the steps below: */
|
||||||
/* 1. add new option message in English section */
|
/* 1. add new option message in English section */
|
||||||
@@ -1370,9 +1382,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
int postHandAuth = 0;
|
int postHandAuth = 0;
|
||||||
#endif
|
#endif
|
||||||
int updateKeysIVs = 0;
|
int updateKeysIVs = 0;
|
||||||
#ifdef WOLFSSL_EARLY_DATA
|
|
||||||
int earlyData = 0;
|
int earlyData = 0;
|
||||||
#endif
|
|
||||||
#ifdef WOLFSSL_MULTICAST
|
#ifdef WOLFSSL_MULTICAST
|
||||||
byte mcastID = 0;
|
byte mcastID = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -1442,6 +1452,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
(void)alpnList;
|
(void)alpnList;
|
||||||
(void)alpn_opt;
|
(void)alpn_opt;
|
||||||
(void)updateKeysIVs;
|
(void)updateKeysIVs;
|
||||||
|
(void)earlyData;
|
||||||
(void)useX25519;
|
(void)useX25519;
|
||||||
(void)helloRetry;
|
(void)helloRetry;
|
||||||
(void)onlyKeyShare;
|
(void)onlyKeyShare;
|
||||||
@@ -2389,7 +2400,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
((func_args*)args)->return_code =
|
((func_args*)args)->return_code =
|
||||||
ClientBenchmarkConnections(ctx, host, port, dtlsUDP, dtlsSCTP,
|
ClientBenchmarkConnections(ctx, host, port, dtlsUDP, dtlsSCTP,
|
||||||
benchmark, resumeSession, useX25519,
|
benchmark, resumeSession, useX25519,
|
||||||
helloRetry, onlyKeyShare, version);
|
helloRetry, onlyKeyShare, version,
|
||||||
|
earlyData);
|
||||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||||
XEXIT_T(EXIT_SUCCESS);
|
XEXIT_T(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user