mirror of https://github.com/wolfSSL/wolfssl.git
Fixed compile issues with example server/client. Fixed issue with using XMALLOC/XFREE being used in examples. Fixed issue with "int select_ret" declaration scope. Fixed issue with test.h HAVE_SESSION_TICKET "static rng" name.
parent
d3584979a0
commit
10eab5047a
|
@ -191,8 +191,8 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
||||||
conn_time = current_time() - start;
|
conn_time = current_time() - start;
|
||||||
|
|
||||||
/* Allocate TX/RX buffers */
|
/* Allocate TX/RX buffers */
|
||||||
tx_buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
tx_buffer = (char*)malloc(TEST_BUFFER_SIZE);
|
||||||
rx_buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
rx_buffer = (char*)malloc(TEST_BUFFER_SIZE);
|
||||||
if(tx_buffer && rx_buffer) {
|
if(tx_buffer && rx_buffer) {
|
||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
||||||
/* Perform TX and RX of bytes */
|
/* Perform TX and RX of bytes */
|
||||||
xfer_bytes = 0;
|
xfer_bytes = 0;
|
||||||
while(throughput > xfer_bytes) {
|
while(throughput > xfer_bytes) {
|
||||||
int len, rx_pos;
|
int len, rx_pos, select_ret;
|
||||||
|
|
||||||
/* Determine packet size */
|
/* Determine packet size */
|
||||||
len = min(TEST_BUFFER_SIZE, throughput - xfer_bytes);
|
len = min(TEST_BUFFER_SIZE, throughput - xfer_bytes);
|
||||||
|
@ -226,7 +226,7 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
||||||
tx_time += current_time() - start;
|
tx_time += current_time() - start;
|
||||||
|
|
||||||
/* Perform RX */
|
/* Perform RX */
|
||||||
int select_ret = tcp_select(sockfd, 1); /* Timeout=1 second */
|
select_ret = tcp_select(sockfd, 1); /* Timeout=1 second */
|
||||||
if (select_ret == TEST_RECV_READY) {
|
if (select_ret == TEST_RECV_READY) {
|
||||||
start = current_time();
|
start = current_time();
|
||||||
rx_pos = 0;
|
rx_pos = 0;
|
||||||
|
@ -260,10 +260,10 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err_sys("Buffer alloc failed");
|
err_sys("Client buffer malloc failed");
|
||||||
}
|
}
|
||||||
if(tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
if(tx_buffer) free(tx_buffer);
|
||||||
if(rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
if(rx_buffer) free(rx_buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err_sys("wolfSSL_connect failed");
|
err_sys("wolfSSL_connect failed");
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void NonBlockingSSL_Accept(SSL* ssl)
|
||||||
int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
|
int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char* buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
char* buffer = (char*)malloc(TEST_BUFFER_SIZE);
|
||||||
if(buffer) {
|
if(buffer) {
|
||||||
double start, rx_time = 0, tx_time = 0;
|
double start, rx_time = 0, tx_time = 0;
|
||||||
int xfer_bytes = 0;
|
int xfer_bytes = 0;
|
||||||
|
@ -162,7 +162,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
|
||||||
xfer_bytes += len;
|
xfer_bytes += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
free(buffer);
|
||||||
|
|
||||||
if(throughput) {
|
if(throughput) {
|
||||||
printf("wolfSSL Server Benchmark %d bytes\n"
|
printf("wolfSSL Server Benchmark %d bytes\n"
|
||||||
|
@ -175,7 +175,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err_sys("Server buffer XMALLOC failed");
|
err_sys("Server buffer malloc failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -1938,17 +1938,17 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
|
||||||
} key_ctx;
|
} key_ctx;
|
||||||
|
|
||||||
static key_ctx myKey_ctx;
|
static key_ctx myKey_ctx;
|
||||||
static WC_RNG rng;
|
static WC_RNG myKey_rng;
|
||||||
|
|
||||||
static INLINE int TicketInit(void)
|
static INLINE int TicketInit(void)
|
||||||
{
|
{
|
||||||
int ret = wc_InitRng(&rng);
|
int ret = wc_InitRng(&myKey_rng);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.key, sizeof(myKey_ctx.key));
|
ret = wc_RNG_GenerateBlock(&myKey_rng, myKey_ctx.key, sizeof(myKey_ctx.key));
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.name,sizeof(myKey_ctx.name));
|
ret = wc_RNG_GenerateBlock(&myKey_rng, myKey_ctx.name,sizeof(myKey_ctx.name));
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1956,7 +1956,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
|
||||||
|
|
||||||
static INLINE void TicketCleanup(void)
|
static INLINE void TicketCleanup(void)
|
||||||
{
|
{
|
||||||
wc_FreeRng(&rng);
|
wc_FreeRng(&myKey_rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE int myTicketEncCb(WOLFSSL* ssl,
|
static INLINE int myTicketEncCb(WOLFSSL* ssl,
|
||||||
|
@ -1978,7 +1978,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
|
||||||
if (enc) {
|
if (enc) {
|
||||||
XMEMCPY(key_name, myKey_ctx.name, WOLFSSL_TICKET_NAME_SZ);
|
XMEMCPY(key_name, myKey_ctx.name, WOLFSSL_TICKET_NAME_SZ);
|
||||||
|
|
||||||
ret = wc_RNG_GenerateBlock(&rng, iv, WOLFSSL_TICKET_IV_SZ);
|
ret = wc_RNG_GenerateBlock(&myKey_rng, iv, WOLFSSL_TICKET_IV_SZ);
|
||||||
if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
|
if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
|
||||||
|
|
||||||
/* build aad from key name, iv, and length */
|
/* build aad from key name, iv, and length */
|
||||||
|
|
Loading…
Reference in New Issue