2011-07-26 13:27:22 -07:00
|
|
|
/* echoserver.c
|
|
|
|
*
|
2021-03-11 13:42:46 +07:00
|
|
|
* Copyright (C) 2006-2021 wolfSSL Inc.
|
2011-07-26 13:27:22 -07:00
|
|
|
*
|
2016-03-17 16:02:13 -06:00
|
|
|
* This file is part of wolfSSL.
|
2011-07-26 13:27:22 -07:00
|
|
|
*
|
2015-01-06 12:14:15 -07:00
|
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
2011-07-26 13:27:22 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2015-01-06 12:14:15 -07:00
|
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
2011-07-26 13:27:22 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2016-03-17 16:02:13 -06:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
2011-07-26 13:27:22 -07:00
|
|
|
*/
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-03-17 16:02:13 -06:00
|
|
|
|
2011-08-24 16:37:16 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2011-08-04 16:42:55 -06:00
|
|
|
|
2014-12-18 15:40:09 -07:00
|
|
|
#include <cyassl/ssl.h> /* name change portability layer */
|
2013-04-10 12:17:23 -07:00
|
|
|
#include <cyassl/ctaocrypt/settings.h>
|
2014-09-09 10:14:32 -07:00
|
|
|
#ifdef HAVE_ECC
|
|
|
|
#include <cyassl/ctaocrypt/ecc.h> /* ecc_fp_free */
|
|
|
|
#endif
|
2013-04-10 12:17:23 -07:00
|
|
|
|
2015-11-27 11:31:12 +09:00
|
|
|
#if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
2014-04-11 16:20:12 +09:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2018-01-01 11:57:31 +09:00
|
|
|
#include "cmsis_os.h"
|
|
|
|
#include "rl_fs.h"
|
|
|
|
#include "rl_net.h"
|
|
|
|
#include "wolfssl_MDK_ARM.h"
|
2013-05-16 09:47:27 -07:00
|
|
|
#endif
|
|
|
|
|
2011-11-03 10:56:15 -07:00
|
|
|
#include <cyassl/ssl.h>
|
2011-08-25 14:28:57 -07:00
|
|
|
#include <cyassl/test.h>
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
#ifndef NO_MAIN_DRIVER
|
|
|
|
#define ECHO_OUT
|
|
|
|
#endif
|
|
|
|
|
2012-09-19 23:38:41 -07:00
|
|
|
#include "examples/echoserver/echoserver.h"
|
|
|
|
|
2017-06-26 23:05:32 -07:00
|
|
|
#ifndef NO_WOLFSSL_SERVER
|
|
|
|
|
2020-10-09 09:45:00 -07:00
|
|
|
#ifdef NO_FILESYSTEM
|
|
|
|
#ifdef NO_RSA
|
|
|
|
#error currently the example only tries to load in a RSA buffer
|
|
|
|
#endif
|
|
|
|
#undef USE_CERT_BUFFERS_2048
|
|
|
|
#define USE_CERT_BUFFERS_2048
|
|
|
|
#include <wolfssl/certs_test.h>
|
|
|
|
#endif
|
|
|
|
|
2016-08-15 13:59:41 -06:00
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
static int devId = INVALID_DEVID;
|
|
|
|
#endif
|
|
|
|
|
2013-05-16 09:47:27 -07:00
|
|
|
#define SVR_COMMAND_SIZE 256
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-03-03 16:46:48 -08:00
|
|
|
static void SignalReady(void* args, word16 port)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2013-05-01 14:17:11 -06:00
|
|
|
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
|
2011-02-05 11:14:47 -08:00
|
|
|
/* signal ready to tcp_accept */
|
|
|
|
func_args* server_args = (func_args*)args;
|
|
|
|
tcp_ready* ready = server_args->signal;
|
|
|
|
pthread_mutex_lock(&ready->mutex);
|
|
|
|
ready->ready = 1;
|
2013-03-26 22:00:39 -07:00
|
|
|
ready->port = port;
|
2011-02-05 11:14:47 -08:00
|
|
|
pthread_cond_signal(&ready->cond);
|
|
|
|
pthread_mutex_unlock(&ready->mutex);
|
|
|
|
#endif
|
2012-09-20 15:39:15 -07:00
|
|
|
(void)args;
|
2013-03-26 22:00:39 -07:00
|
|
|
(void)port;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-26 15:41:16 -07:00
|
|
|
THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2011-11-03 10:56:15 -07:00
|
|
|
SOCKET_T sockfd = 0;
|
|
|
|
CYASSL_METHOD* method = 0;
|
|
|
|
CYASSL_CTX* ctx = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-03-04 10:05:22 -08:00
|
|
|
int ret = 0;
|
2012-08-02 11:54:49 -07:00
|
|
|
int doDTLS = 0;
|
2020-01-15 22:15:38 +10:00
|
|
|
int doPSK;
|
2011-02-05 11:14:47 -08:00
|
|
|
int outCreated = 0;
|
2012-09-20 15:39:15 -07:00
|
|
|
int shutDown = 0;
|
2012-07-30 11:58:57 -07:00
|
|
|
int useAnyAddr = 0;
|
2016-04-01 15:45:53 -07:00
|
|
|
word16 port;
|
2011-02-05 11:14:47 -08:00
|
|
|
int argc = ((func_args*)args)->argc;
|
|
|
|
char** argv = ((func_args*)args)->argv;
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
char buffer[CYASSL_MAX_ERROR_SZ];
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
#ifdef ECHO_OUT
|
|
|
|
FILE* fout = stdout;
|
|
|
|
if (argc >= 2) {
|
|
|
|
fout = fopen(argv[1], "w");
|
|
|
|
outCreated = 1;
|
|
|
|
}
|
|
|
|
if (!fout) err_sys("can't open output file");
|
|
|
|
#endif
|
2012-09-20 15:39:15 -07:00
|
|
|
(void)outCreated;
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
((func_args*)args)->return_code = -1; /* error state */
|
|
|
|
|
2012-08-02 11:54:49 -07:00
|
|
|
#ifdef CYASSL_DTLS
|
|
|
|
doDTLS = 1;
|
|
|
|
#endif
|
|
|
|
|
2020-02-19 18:07:45 +10:00
|
|
|
#if (defined(NO_RSA) && !defined(HAVE_ECC) && !defined(HAVE_ED25519) && \
|
|
|
|
!defined(HAVE_ED448)) || defined(CYASSL_LEANPSK)
|
2013-03-11 13:19:43 -07:00
|
|
|
doPSK = 1;
|
2020-01-15 22:15:38 +10:00
|
|
|
#else
|
|
|
|
doPSK = 0;
|
2012-10-30 12:51:14 -07:00
|
|
|
#endif
|
|
|
|
|
2016-06-16 16:39:18 -06:00
|
|
|
#if defined(NO_MAIN_DRIVER) && !defined(CYASSL_SNIFFER) && \
|
|
|
|
!defined(WOLFSSL_MDK_SHELL) && !defined(CYASSL_TIRTOS) && \
|
|
|
|
!defined(USE_WINDOWS_API)
|
2016-04-01 15:45:53 -07:00
|
|
|
/* Let tcp_listen assign port */
|
|
|
|
port = 0;
|
|
|
|
#else
|
|
|
|
/* Use default port */
|
|
|
|
port = wolfSSLPort;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(USE_ANY_ADDR)
|
|
|
|
useAnyAddr = 1;
|
|
|
|
#endif
|
2014-05-08 15:52:20 -07:00
|
|
|
|
2014-09-08 19:40:03 -07:00
|
|
|
#ifdef CYASSL_TIRTOS
|
|
|
|
fdOpenSession(Task_self());
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
|
|
|
|
2016-08-25 22:20:35 -07:00
|
|
|
tcp_listen(&sockfd, &port, useAnyAddr, doDTLS, 0);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
#if defined(CYASSL_DTLS)
|
2015-04-08 13:29:25 -07:00
|
|
|
method = CyaDTLSv1_2_server_method();
|
2017-11-14 13:55:48 -08:00
|
|
|
#elif !defined(NO_TLS)
|
2020-08-19 10:46:03 -07:00
|
|
|
#if (defined(WOLFSSL_TLS13) && defined(WOLFSSL_SNIFFER)) || \
|
|
|
|
defined(HAVE_NTRU)
|
2020-06-04 16:42:40 -07:00
|
|
|
method = CyaTLSv1_2_server_method();
|
|
|
|
#else
|
2011-11-03 10:56:15 -07:00
|
|
|
method = CyaSSLv23_server_method();
|
2020-06-04 16:42:40 -07:00
|
|
|
#endif
|
2015-08-12 16:39:13 -07:00
|
|
|
#elif defined(WOLFSSL_ALLOW_SSLV3)
|
2011-11-03 10:56:15 -07:00
|
|
|
method = CyaSSLv3_server_method();
|
2015-08-12 16:39:13 -07:00
|
|
|
#else
|
|
|
|
#error "no valid server method built in"
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
2011-11-03 10:56:15 -07:00
|
|
|
ctx = CyaSSL_CTX_new(method);
|
2017-10-11 09:09:52 -07:00
|
|
|
/* CyaSSL_CTX_set_session_cache_mode(ctx, WOLFSSL_SESS_CACHE_OFF); */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2018-03-30 15:48:15 -07:00
|
|
|
#ifdef WOLFSSL_ENCRYPTED_KEYS
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
|
|
|
|
2021-02-03 13:30:38 +10:00
|
|
|
#if defined(HAVE_SESSION_TICKET) && defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && \
|
|
|
|
((defined(HAVE_CHACHA) && defined(HAVE_POLY1305)) || defined(HAVE_AESGCM))
|
2015-05-18 09:13:34 -07:00
|
|
|
if (TicketInit() != 0)
|
|
|
|
err_sys("unable to setup Session Ticket Key context");
|
|
|
|
wolfSSL_CTX_set_TicketEncCb(ctx, myTicketEncCb);
|
|
|
|
#endif
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifndef NO_FILESYSTEM
|
2013-03-11 13:19:43 -07:00
|
|
|
if (doPSK == 0) {
|
2015-12-22 15:19:11 -07:00
|
|
|
#if defined(HAVE_NTRU) && defined(WOLFSSL_STATIC_RSA)
|
2015-07-11 12:52:22 -06:00
|
|
|
/* ntru */
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_use_certificate_file(ctx, ntruCertFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
2015-07-11 12:52:22 -06:00
|
|
|
err_sys("can't load ntru cert file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
|
|
|
|
2017-04-06 15:54:59 -07:00
|
|
|
if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ntruKeyFile)
|
2017-10-11 09:09:52 -07:00
|
|
|
!= WOLFSSL_SUCCESS)
|
2015-07-11 12:52:22 -06:00
|
|
|
err_sys("can't load ntru key file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
|
|
|
#elif defined(HAVE_ECC) && !defined(CYASSL_SNIFFER)
|
2011-02-05 11:14:47 -08:00
|
|
|
/* ecc */
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_use_certificate_file(ctx, eccCertFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
2011-08-24 15:54:58 -07:00
|
|
|
err_sys("can't load server cert file, "
|
2015-01-20 12:36:20 -07:00
|
|
|
"Please run from wolfSSL home dir");
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_use_PrivateKey_file(ctx, eccKeyFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
2011-08-24 15:54:58 -07:00
|
|
|
err_sys("can't load server key file, "
|
2015-01-20 12:36:20 -07:00
|
|
|
"Please run from wolfSSL home dir");
|
2018-07-23 10:20:18 +10:00
|
|
|
#elif defined(HAVE_ED25519) && !defined(CYASSL_SNIFFER)
|
|
|
|
/* ed25519 */
|
|
|
|
if (CyaSSL_CTX_use_certificate_chain_file(ctx, edCertFile)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server cert file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
|
|
|
|
|
|
|
if (CyaSSL_CTX_use_PrivateKey_file(ctx, edKeyFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server key file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
2020-02-19 18:07:45 +10:00
|
|
|
#elif defined(HAVE_ED448) && !defined(CYASSL_SNIFFER)
|
|
|
|
/* ed448 */
|
|
|
|
if (CyaSSL_CTX_use_certificate_chain_file(ctx, ed448CertFile)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server cert file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
|
|
|
|
|
|
|
if (CyaSSL_CTX_use_PrivateKey_file(ctx, ed448KeyFile,
|
|
|
|
WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server key file, "
|
|
|
|
"Please run from wolfSSL home dir");
|
2013-03-11 16:07:46 -07:00
|
|
|
#elif defined(NO_CERTS)
|
|
|
|
/* do nothing, just don't load cert files */
|
2011-02-05 11:14:47 -08:00
|
|
|
#else
|
|
|
|
/* normal */
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
2011-08-24 15:54:58 -07:00
|
|
|
err_sys("can't load server cert file, "
|
2015-01-20 12:36:20 -07:00
|
|
|
"Please run from wolfSSL home dir");
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
2011-08-24 15:54:58 -07:00
|
|
|
err_sys("can't load server key file, "
|
2015-01-20 12:36:20 -07:00
|
|
|
"Please run from wolfSSL home dir");
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
2013-03-11 13:19:43 -07:00
|
|
|
} /* doPSK */
|
2012-11-01 12:36:47 -07:00
|
|
|
#elif !defined(NO_CERTS)
|
2013-03-11 13:19:43 -07:00
|
|
|
if (!doPSK) {
|
2020-10-09 09:45:00 -07:00
|
|
|
if (CyaSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048,
|
|
|
|
sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server cert buffer");
|
|
|
|
|
|
|
|
if (CyaSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048,
|
|
|
|
sizeof_server_key_der_2048, WOLFSSL_FILETYPE_ASN1)
|
|
|
|
!= WOLFSSL_SUCCESS)
|
|
|
|
err_sys("can't load server key buffer");
|
2012-10-30 12:51:14 -07:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
|
|
|
|
2015-04-01 12:14:48 -07:00
|
|
|
#if defined(CYASSL_SNIFFER)
|
2020-05-12 09:51:20 -07:00
|
|
|
/* Only set if not running testsuite */
|
2020-06-04 16:42:40 -07:00
|
|
|
if (XSTRSTR(argv[0], "testsuite") != 0) {
|
2020-05-12 09:51:20 -07:00
|
|
|
/* don't use EDH, can't sniff tmp keys */
|
|
|
|
CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA");
|
|
|
|
}
|
2012-06-29 10:59:48 -07:00
|
|
|
#endif
|
|
|
|
|
2013-03-11 13:19:43 -07:00
|
|
|
if (doPSK) {
|
|
|
|
#ifndef NO_PSK
|
|
|
|
const char *defaultCipherList;
|
|
|
|
|
2012-10-30 12:51:14 -07:00
|
|
|
CyaSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
2013-03-11 13:19:43 -07:00
|
|
|
CyaSSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
|
|
|
#ifdef HAVE_NULL_CIPHER
|
|
|
|
defaultCipherList = "PSK-NULL-SHA256";
|
2015-08-14 12:49:30 -07:00
|
|
|
#elif defined(HAVE_AESGCM) && !defined(NO_DH)
|
2020-05-15 15:08:17 -07:00
|
|
|
#ifdef WOLFSSL_TLS13
|
2020-10-28 11:47:31 +10:00
|
|
|
defaultCipherList = "TLS13-AES128-GCM-SHA256"
|
|
|
|
#ifndef WOLFSSL_NO_TLS12
|
|
|
|
":DHE-PSK-AES128-GCM-SHA256"
|
|
|
|
#endif
|
|
|
|
;
|
2020-05-15 15:08:17 -07:00
|
|
|
#else
|
2015-08-14 12:49:30 -07:00
|
|
|
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
|
2020-05-15 15:08:17 -07:00
|
|
|
#endif
|
2020-10-28 11:47:31 +10:00
|
|
|
#elif defined(HAVE_AESGCM) && defined(WOLFSSL_TLS13)
|
|
|
|
defaultCipherList = "TLS13-AES128-GCM-SHA256"
|
|
|
|
#ifndef WOLFSSL_NO_TLS12
|
|
|
|
":PSK-AES128-GCM-SHA256"
|
|
|
|
#endif
|
|
|
|
;
|
2013-03-11 13:19:43 -07:00
|
|
|
#else
|
|
|
|
defaultCipherList = "PSK-AES128-CBC-SHA256";
|
|
|
|
#endif
|
2017-10-11 09:09:52 -07:00
|
|
|
if (CyaSSL_CTX_set_cipher_list(ctx, defaultCipherList) != WOLFSSL_SUCCESS)
|
2013-03-11 13:19:43 -07:00
|
|
|
err_sys("server can't set cipher list 2");
|
2020-05-15 15:08:17 -07:00
|
|
|
wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
|
2012-10-30 12:51:14 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-08-15 13:59:41 -06:00
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
ret = wolfAsync_DevOpen(&devId);
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (ret < 0) {
|
|
|
|
printf("Async device open failed\nRunning without async\n");
|
2016-08-15 13:59:41 -06:00
|
|
|
}
|
|
|
|
wolfSSL_CTX_UseAsync(ctx, devId);
|
|
|
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
|
|
|
|
2013-03-26 22:00:39 -07:00
|
|
|
SignalReady(args, port);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2012-09-20 15:39:15 -07:00
|
|
|
while (!shutDown) {
|
2017-03-20 15:08:34 -07:00
|
|
|
CYASSL* ssl = NULL;
|
|
|
|
CYASSL* write_ssl = NULL; /* may have separate w/ HAVE_WRITE_DUP */
|
2013-05-16 09:47:27 -07:00
|
|
|
char command[SVR_COMMAND_SIZE+1];
|
2011-11-03 10:56:15 -07:00
|
|
|
int echoSz = 0;
|
|
|
|
int clientfd;
|
2012-01-27 11:55:23 -08:00
|
|
|
int firstRead = 1;
|
|
|
|
int gotFirstG = 0;
|
2016-03-04 10:05:22 -08:00
|
|
|
int err = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
SOCKADDR_IN_T client;
|
|
|
|
socklen_t client_len = sizeof(client);
|
2015-09-15 17:23:52 -07:00
|
|
|
#ifndef CYASSL_DTLS
|
2011-02-05 11:14:47 -08:00
|
|
|
clientfd = accept(sockfd, (struct sockaddr*)&client,
|
|
|
|
(ACCEPT_THIRD_T)&client_len);
|
|
|
|
#else
|
2015-09-15 17:23:52 -07:00
|
|
|
clientfd = sockfd;
|
|
|
|
{
|
|
|
|
/* For DTLS, peek at the next datagram so we can get the client's
|
|
|
|
* address and set it into the ssl object later to generate the
|
|
|
|
* cookie. */
|
|
|
|
int n;
|
|
|
|
byte b[1500];
|
|
|
|
n = (int)recvfrom(clientfd, (char*)b, sizeof(b), MSG_PEEK,
|
|
|
|
(struct sockaddr*)&client, &client_len);
|
|
|
|
if (n <= 0)
|
|
|
|
err_sys("recvfrom failed");
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
2015-10-14 19:13:45 -07:00
|
|
|
if (WOLFSSL_SOCKET_IS_INVALID(clientfd)) err_sys("tcp accept failed");
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2011-11-03 10:56:15 -07:00
|
|
|
ssl = CyaSSL_new(ctx);
|
2011-02-05 11:14:47 -08:00
|
|
|
if (ssl == NULL) err_sys("SSL_new failed");
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_set_fd(ssl, clientfd);
|
2015-09-15 17:23:52 -07:00
|
|
|
#ifdef CYASSL_DTLS
|
|
|
|
wolfSSL_dtls_set_peer(ssl, &client, client_len);
|
|
|
|
#endif
|
2015-03-27 14:28:05 -07:00
|
|
|
#if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN)
|
2017-10-11 09:09:52 -07:00
|
|
|
CyaSSL_SetTmpDH_file(ssl, dhParamFile, WOLFSSL_FILETYPE_PEM);
|
2014-07-03 11:32:24 -07:00
|
|
|
#elif !defined(NO_DH)
|
2011-11-01 16:17:45 -07:00
|
|
|
SetDH(ssl); /* will repick suites with DHE, higher than PSK */
|
2011-11-01 14:05:14 -07:00
|
|
|
#endif
|
2016-03-04 10:05:22 -08:00
|
|
|
|
|
|
|
do {
|
|
|
|
err = 0; /* Reset error */
|
|
|
|
ret = CyaSSL_accept(ssl);
|
2017-10-11 09:09:52 -07:00
|
|
|
if (ret != WOLFSSL_SUCCESS) {
|
2016-03-04 10:05:22 -08:00
|
|
|
err = CyaSSL_get_error(ssl, 0);
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
if (err == WC_PENDING_E) {
|
|
|
|
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
|
|
|
if (ret < 0) break;
|
|
|
|
}
|
|
|
|
#endif
|
2016-03-04 10:05:22 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
} while (err == WC_PENDING_E);
|
2017-10-11 09:09:52 -07:00
|
|
|
if (ret != WOLFSSL_SUCCESS) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
printf("SSL_accept error = %d, %s\n", err,
|
|
|
|
CyaSSL_ERR_error_string(err, buffer));
|
2011-04-25 15:49:30 -07:00
|
|
|
printf("SSL_accept failed\n");
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_free(ssl);
|
2011-02-05 11:14:47 -08:00
|
|
|
CloseSocket(clientfd);
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-29 10:41:21 -07:00
|
|
|
#if defined(PEER_INFO)
|
2011-04-25 15:49:30 -07:00
|
|
|
showPeer(ssl);
|
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2017-03-20 15:08:34 -07:00
|
|
|
#ifdef HAVE_WRITE_DUP
|
|
|
|
write_ssl = wolfSSL_write_dup(ssl);
|
|
|
|
if (write_ssl == NULL) {
|
|
|
|
printf("wolfSSL_write_dup failed\n");
|
|
|
|
CyaSSL_free(ssl);
|
|
|
|
CloseSocket(clientfd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
write_ssl = ssl;
|
|
|
|
#endif
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
while (1) {
|
|
|
|
do {
|
|
|
|
err = 0; /* reset error */
|
|
|
|
ret = CyaSSL_read(ssl, command, sizeof(command)-1);
|
|
|
|
if (ret <= 0) {
|
|
|
|
err = CyaSSL_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 <= 0) {
|
2017-10-11 09:09:52 -07:00
|
|
|
if (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_ZERO_RETURN){
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
printf("SSL_read echo error %d, %s!\n", err,
|
|
|
|
CyaSSL_ERR_error_string(err, buffer));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echoSz = ret;
|
2012-01-27 11:55:23 -08:00
|
|
|
|
|
|
|
if (firstRead == 1) {
|
|
|
|
firstRead = 0; /* browser may send 1 byte 'G' to start */
|
|
|
|
if (echoSz == 1 && command[0] == 'G') {
|
|
|
|
gotFirstG = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gotFirstG == 1 && strncmp(command, "ET /", 4) == 0) {
|
|
|
|
strncpy(command, "GET", 4);
|
|
|
|
/* fall through to normal GET */
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
if ( strncmp(command, "quit", 4) == 0) {
|
|
|
|
printf("client sent quit command: shutting down!\n");
|
2012-09-20 15:39:15 -07:00
|
|
|
shutDown = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( strncmp(command, "break", 5) == 0) {
|
|
|
|
printf("client sent break command: closing session!\n");
|
|
|
|
break;
|
|
|
|
}
|
2015-04-14 12:35:24 -07:00
|
|
|
#ifdef PRINT_SESSION_STATS
|
2011-02-05 11:14:47 -08:00
|
|
|
if ( strncmp(command, "printstats", 10) == 0) {
|
2015-04-14 12:35:24 -07:00
|
|
|
CyaSSL_PrintSessionStats();
|
2011-02-05 11:14:47 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2018-06-11 13:39:49 -07:00
|
|
|
if (strncmp(command, "GET", 3) == 0) {
|
|
|
|
const char resp[] =
|
|
|
|
"HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n"
|
|
|
|
"<html><body BGCOLOR=\"#ffffff\"><pre>\r\n"
|
2020-01-22 16:23:46 -08:00
|
|
|
"greetings from wolfSSL\r\n</pre></body></html>\r\n\r\n";
|
2018-06-11 13:39:49 -07:00
|
|
|
|
|
|
|
echoSz = (int)strlen(resp) + 1;
|
|
|
|
if (echoSz > (int)sizeof(command)) {
|
|
|
|
/* Internal error. */
|
|
|
|
err_sys("HTTP response greater than buffer.");
|
|
|
|
}
|
|
|
|
strncpy(command, resp, sizeof(command));
|
2011-02-05 11:14:47 -08:00
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
do {
|
|
|
|
err = 0; /* reset error */
|
|
|
|
ret = CyaSSL_write(write_ssl, command, echoSz);
|
|
|
|
if (ret <= 0) {
|
2017-05-08 12:49:38 -07:00
|
|
|
err = CyaSSL_get_error(write_ssl, 0);
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
if (err == WC_PENDING_E) {
|
|
|
|
ret = wolfSSL_AsyncPoll(write_ssl, WOLF_POLL_FLAG_CHECK_HW);
|
|
|
|
if (ret < 0) break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
} while (err == WC_PENDING_E);
|
|
|
|
if (ret != echoSz) {
|
|
|
|
printf("SSL_write get error = %d, %s\n", err,
|
|
|
|
CyaSSL_ERR_error_string(err, buffer));
|
|
|
|
err_sys("SSL_write get failed");
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
command[echoSz] = 0;
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#ifdef ECHO_OUT
|
|
|
|
fputs(command, fout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
do {
|
|
|
|
err = 0; /* reset error */
|
|
|
|
ret = CyaSSL_write(write_ssl, command, echoSz);
|
|
|
|
if (ret <= 0) {
|
|
|
|
err = CyaSSL_get_error(write_ssl, 0);
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
if (err == WC_PENDING_E) {
|
|
|
|
ret = wolfSSL_AsyncPoll(write_ssl, WOLF_POLL_FLAG_CHECK_HW);
|
|
|
|
if (ret < 0) break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
} while (err == WC_PENDING_E);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (ret != echoSz) {
|
|
|
|
printf("SSL_write echo error = %d, %s\n", err,
|
|
|
|
CyaSSL_ERR_error_string(err, buffer));
|
|
|
|
err_sys("SSL_write echo failed");
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
#ifndef CYASSL_DTLS
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_shutdown(ssl);
|
2017-03-20 15:08:34 -07:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_WRITE_DUP
|
|
|
|
CyaSSL_free(write_ssl);
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_free(ssl);
|
2011-02-05 11:14:47 -08:00
|
|
|
CloseSocket(clientfd);
|
|
|
|
#ifdef CYASSL_DTLS
|
2016-08-25 22:20:35 -07:00
|
|
|
tcp_listen(&sockfd, &port, useAnyAddr, doDTLS, 0);
|
2013-03-26 22:00:39 -07:00
|
|
|
SignalReady(args, port);
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseSocket(sockfd);
|
2011-11-03 10:56:15 -07:00
|
|
|
CyaSSL_CTX_free(ctx);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
#ifdef ECHO_OUT
|
|
|
|
if (outCreated)
|
|
|
|
fclose(fout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
((func_args*)args)->return_code = 0;
|
2014-05-08 15:52:20 -07:00
|
|
|
|
2014-09-09 10:14:32 -07:00
|
|
|
#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
|
|
|
|
&& defined(HAVE_THREAD_LS)
|
|
|
|
ecc_fp_free(); /* free per thread cache */
|
|
|
|
#endif
|
|
|
|
|
2014-09-08 19:40:03 -07:00
|
|
|
#ifdef CYASSL_TIRTOS
|
|
|
|
fdCloseSession(Task_self());
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
|
|
|
|
2021-02-03 13:30:38 +10:00
|
|
|
#if defined(HAVE_SESSION_TICKET) && defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && \
|
|
|
|
((defined(HAVE_CHACHA) && defined(HAVE_POLY1305)) || defined(HAVE_AESGCM))
|
2015-05-18 09:13:34 -07:00
|
|
|
TicketCleanup();
|
|
|
|
#endif
|
|
|
|
|
2016-08-15 13:59:41 -06:00
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
wolfAsync_DevClose(&devId);
|
|
|
|
#endif
|
|
|
|
|
2014-09-08 19:40:03 -07:00
|
|
|
#ifndef CYASSL_TIRTOS
|
2011-02-05 11:14:47 -08:00
|
|
|
return 0;
|
2014-05-08 15:52:20 -07:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
2017-06-26 23:05:32 -07:00
|
|
|
#endif /* !NO_WOLFSSL_SERVER */
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
/* so overall tests can pull in test function */
|
|
|
|
#ifndef NO_MAIN_DRIVER
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
func_args args;
|
|
|
|
|
2016-05-05 15:31:25 -06:00
|
|
|
#ifdef HAVE_WNR
|
|
|
|
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0)
|
|
|
|
err_sys("Whitewood netRandom global config failed");
|
|
|
|
#endif
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
StartTCP();
|
|
|
|
|
|
|
|
args.argc = argc;
|
|
|
|
args.argv = argv;
|
2018-06-13 11:42:16 +10:00
|
|
|
args.return_code = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2011-06-08 13:19:39 -07:00
|
|
|
CyaSSL_Init();
|
2013-05-16 09:47:27 -07:00
|
|
|
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
|
2011-02-05 11:14:47 -08:00
|
|
|
CyaSSL_Debugging_ON();
|
|
|
|
#endif
|
2015-10-28 23:54:08 -07:00
|
|
|
ChangeToWolfRoot();
|
2017-06-26 23:05:32 -07:00
|
|
|
#ifndef NO_WOLFSSL_SERVER
|
2011-02-05 11:14:47 -08:00
|
|
|
echoserver_test(&args);
|
2017-06-26 23:05:32 -07:00
|
|
|
#endif
|
2011-06-08 13:19:39 -07:00
|
|
|
CyaSSL_Cleanup();
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-05-05 15:31:25 -06:00
|
|
|
#ifdef HAVE_WNR
|
|
|
|
if (wc_FreeNetRandom() < 0)
|
|
|
|
err_sys("Failed to free netRandom context");
|
|
|
|
#endif /* HAVE_WNR */
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
return args.return_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NO_MAIN_DRIVER */
|