-
-#ifndef NO_MAIN_DRIVER
- #define ECHO_OUT
-#endif
-
-#include "examples/echoserver/echoserver.h"
-
-
-#ifdef SESSION_STATS
- CYASSL_API void PrintSessionStats(void);
-#endif
-
-#define SVR_COMMAND_SIZE 256
-
-static void SignalReady(void* args, word16 port)
-{
-#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
- /* 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;
- ready->port = port;
- pthread_cond_signal(&ready->cond);
- pthread_mutex_unlock(&ready->mutex);
-#endif
- (void)args;
- (void)port;
-}
-
-
-THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
-{
- SOCKET_T sockfd = 0;
- CYASSL_METHOD* method = 0;
- CYASSL_CTX* ctx = 0;
-
- int doDTLS = 0;
- int doPSK = 0;
- int outCreated = 0;
- int shutDown = 0;
- int useAnyAddr = 0;
- word16 port = yasslPort;
- int argc = ((func_args*)args)->argc;
- char** argv = ((func_args*)args)->argv;
-
-#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
- (void)outCreated;
- (void)argc;
- (void)argv;
-
- ((func_args*)args)->return_code = -1; /* error state */
-
-#ifdef CYASSL_DTLS
- doDTLS = 1;
-#endif
-
-#ifdef CYASSL_LEANPSK
- doPSK = 1;
-#endif
-
-#if defined(NO_RSA) && !defined(HAVE_ECC)
- doPSK = 1;
-#endif
-
- #if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
- !defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL)
- port = 0;
- #endif
- #if defined(USE_ANY_ADDR)
- useAnyAddr = 1;
- #endif
- tcp_listen(&sockfd, &port, useAnyAddr, doDTLS);
-
-#if defined(CYASSL_DTLS)
- method = CyaDTLSv1_server_method();
-#elif !defined(NO_TLS)
- method = CyaSSLv23_server_method();
-#else
- method = CyaSSLv3_server_method();
-#endif
- ctx = CyaSSL_CTX_new(method);
- /* CyaSSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); */
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
- CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-#ifndef NO_FILESYSTEM
- if (doPSK == 0) {
- #ifdef HAVE_NTRU
- /* ntru */
- if (CyaSSL_CTX_use_certificate_file(ctx, ntruCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load ntru cert file, "
- "Please run from CyaSSL home dir");
-
- if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ntruKey)
- != SSL_SUCCESS)
- err_sys("can't load ntru key file, "
- "Please run from CyaSSL home dir");
- #elif defined(HAVE_ECC)
- /* ecc */
- if (CyaSSL_CTX_use_certificate_file(ctx, eccCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server cert file, "
- "Please run from CyaSSL home dir");
-
- if (CyaSSL_CTX_use_PrivateKey_file(ctx, eccKey, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server key file, "
- "Please run from CyaSSL home dir");
- #elif defined(NO_CERTS)
- /* do nothing, just don't load cert files */
- #else
- /* normal */
- if (CyaSSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server cert file, "
- "Please run from CyaSSL home dir");
-
- if (CyaSSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server key file, "
- "Please run from CyaSSL home dir");
- #endif
- } /* doPSK */
-#elif !defined(NO_CERTS)
- if (!doPSK) {
- load_buffer(ctx, svrCert, CYASSL_CERT);
- load_buffer(ctx, svrKey, CYASSL_KEY);
- }
-#endif
-
-#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
- /* don't use EDH, can't sniff tmp keys */
- CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA");
-#endif
-
- if (doPSK) {
-#ifndef NO_PSK
- const char *defaultCipherList;
-
- CyaSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
- CyaSSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
- #ifdef HAVE_NULL_CIPHER
- defaultCipherList = "PSK-NULL-SHA256";
- #else
- defaultCipherList = "PSK-AES128-CBC-SHA256";
- #endif
- if (CyaSSL_CTX_set_cipher_list(ctx, defaultCipherList) != SSL_SUCCESS)
- err_sys("server can't set cipher list 2");
-#endif
- }
-
- SignalReady(args, port);
-
- while (!shutDown) {
- CYASSL* ssl = 0;
- char command[SVR_COMMAND_SIZE+1];
- int echoSz = 0;
- int clientfd;
- int firstRead = 1;
- int gotFirstG = 0;
-
-#ifndef CYASSL_DTLS
- SOCKADDR_IN_T client;
- socklen_t client_len = sizeof(client);
- clientfd = accept(sockfd, (struct sockaddr*)&client,
- (ACCEPT_THIRD_T)&client_len);
-#else
- clientfd = udp_read_connect(sockfd);
-#endif
- if (clientfd == -1) err_sys("tcp accept failed");
-
- ssl = CyaSSL_new(ctx);
- if (ssl == NULL) err_sys("SSL_new failed");
- CyaSSL_set_fd(ssl, clientfd);
- #if !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA)
- CyaSSL_SetTmpDH_file(ssl, dhParam, SSL_FILETYPE_PEM);
- #elif !defined(NO_CERTS)
- SetDH(ssl); /* will repick suites with DHE, higher than PSK */
- #endif
- if (CyaSSL_accept(ssl) != SSL_SUCCESS) {
- printf("SSL_accept failed\n");
- CyaSSL_free(ssl);
- CloseSocket(clientfd);
- continue;
- }
-#if defined(PEER_INFO)
- showPeer(ssl);
-#endif
-
- while ( (echoSz = CyaSSL_read(ssl, command, sizeof(command)-1)) > 0) {
-
- 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 */
- }
-
- if ( strncmp(command, "quit", 4) == 0) {
- printf("client sent quit command: shutting down!\n");
- shutDown = 1;
- break;
- }
- if ( strncmp(command, "break", 5) == 0) {
- printf("client sent break command: closing session!\n");
- break;
- }
-#ifdef SESSION_STATS
- if ( strncmp(command, "printstats", 10) == 0) {
- PrintSessionStats();
- break;
- }
-#endif
- if ( strncmp(command, "GET", 3) == 0) {
- char type[] = "HTTP/1.0 200 ok\r\nContent-type:"
- " text/html\r\n\r\n";
- char header[] = "\n\n";
- char body[] = "greetings from CyaSSL\n";
- char footer[] = "\r\n\r\n";
-
- strncpy(command, type, sizeof(type));
- echoSz = sizeof(type) - 1;
-
- strncpy(&command[echoSz], header, sizeof(header));
- echoSz += (int)sizeof(header) - 1;
- strncpy(&command[echoSz], body, sizeof(body));
- echoSz += (int)sizeof(body) - 1;
- strncpy(&command[echoSz], footer, sizeof(footer));
- echoSz += (int)sizeof(footer);
-
- if (CyaSSL_write(ssl, command, echoSz) != echoSz)
- err_sys("SSL_write failed");
- break;
- }
- command[echoSz] = 0;
-
- #ifdef ECHO_OUT
- fputs(command, fout);
- #endif
-
- if (CyaSSL_write(ssl, command, echoSz) != echoSz)
- err_sys("SSL_write failed");
- }
-#ifndef CYASSL_DTLS
- CyaSSL_shutdown(ssl);
-#endif
- CyaSSL_free(ssl);
- CloseSocket(clientfd);
-#ifdef CYASSL_DTLS
- tcp_listen(&sockfd, &port, useAnyAddr, doDTLS);
- SignalReady(args, port);
-#endif
- }
-
- CloseSocket(sockfd);
- CyaSSL_CTX_free(ctx);
-
-#ifdef ECHO_OUT
- if (outCreated)
- fclose(fout);
-#endif
-
- ((func_args*)args)->return_code = 0;
- return 0;
-}
-
-
-/* so overall tests can pull in test function */
-#ifndef NO_MAIN_DRIVER
-
- int main(int argc, char** argv)
- {
- func_args args;
-
-#ifdef HAVE_CAVIUM
- int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
- if (ret != 0)
- err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
- StartTCP();
-
- args.argc = argc;
- args.argv = argv;
-
- CyaSSL_Init();
-#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
- CyaSSL_Debugging_ON();
-#endif
- if (CurrentDir("echoserver"))
- ChangeDirBack(2);
- else if (CurrentDir("Debug") || CurrentDir("Release"))
- ChangeDirBack(3);
- echoserver_test(&args);
- CyaSSL_Cleanup();
-
-#ifdef HAVE_CAVIUM
- CspShutdown(CAVIUM_DEV_ID);
-#endif
- return args.return_code;
- }
-
-
-#endif /* NO_MAIN_DRIVER */
-
-
-
-
diff --git a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/main.c b/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/main.c
deleted file mode 100644
index dc7941f72..000000000
--- a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/main.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* main.c
- *
- * Copyright (C) 2006-2014 wolfSSL Inc.
- *
- * This file is part of CyaSSL.
- *
- * CyaSSL is free software; you can redistribute it and/or modify
- * 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.
- *
- * CyaSSL is distributed in the hope that it will be useful,
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
- #include
-#endif
-
-#include
-#include
-
-#include "cmsis_os.h"
-#if !defined(NO_FILESYSTEM)
-#include "rl_fs.h"
-#endif
-#include "rl_net.h"
-#include
-#include "cyassl_MDK_ARM.h"
-#include
-
-/*-----------------------------------------------------------------------------
- * Initialize a Flash Memory Card
- *----------------------------------------------------------------------------*/
-#if !defined(NO_FILESYSTEM)
-static void init_filesystem (void) {
- int32_t retv;
-
- retv = finit ("M0:");
- if (retv == 0) {
- retv = fmount ("M0:");
- if (retv == 0) {
- printf ("Drive M0 ready!\n");
- }
- else {
- printf ("Drive M0 mount failed!\n");
- }
- }
- else {
- printf ("Drive M0 initialization failed!\n");
- }
-}
-#endif
-
-/*-----------------------------------------------------------------------------
- * TCP/IP tasks
- *----------------------------------------------------------------------------*/
-void tcp_poll (void const *arg)
-{
- CYASSL_MSG("TCP polling started.\n") ;
- while (1) {
- net_main ();
- osDelay(1) ;
- }
-}
-
-extern void shell_main(void * args) ;
-extern void init_time(void) ;
-
-osThreadDef (tcp_poll, osPriorityHigh, 1, 0) ;
-/*-----------------------------------------------------------------------------
- * mian entry
- *----------------------------------------------------------------------------*/
-int myoptind = 0;
-char* myoptarg = NULL;
-
-int main()
-{
- void *arg = NULL ;
-
- #if !defined(NO_FILESYSTEM)
- init_filesystem ();
- #endif
-
- net_initialize() ;
-
- osThreadCreate (osThread (tcp_poll), NULL);
- osDelay(10000) ; /* wait for DHCP */
- #if defined(DEBUG_CYASSL)
- printf("Turning ON Debug message\n") ;
- CyaSSL_Debugging_ON() ;
- #endif
-
- shell_main(arg) ;
-
-}
diff --git a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/server.c b/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/server.c
deleted file mode 100644
index 440dd1d03..000000000
--- a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/server.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/* server.c
- *
- * Copyright (C) 2006-2014 wolfSSL Inc.
- *
- * This file is part of CyaSSL.
- *
- * CyaSSL is free software; you can redistribute it and/or modify
- * 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.
- *
- * CyaSSL is distributed in the hope that it will be useful,
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
- #include
-#endif
-
-#include
-
-#if !defined(CYASSL_TRACK_MEMORY) && !defined(NO_MAIN_DRIVER)
- /* in case memory tracker wants stats */
- #define CYASSL_TRACK_MEMORY
-#endif
-
-#if defined(CYASSL_MDK_ARM)
- #include
- #include
-
- #if defined(CYASSL_MDK5)
- #include "cmsis_os.h"
- #include "rl_fs.h"
- #include "rl_net.h"
- #else
- #include "rtl.h"
- #endif
-
- #include "cyassl_MDK_ARM.h"
-#endif
-#include
-#include
-
-#include "examples/server/server.h"
-
-
-#ifdef CYASSL_CALLBACKS
- int srvHandShakeCB(HandShakeInfo*);
- int srvTimeoutCB(TimeoutInfo*);
- Timeval srvTo;
-#endif
-
-static void NonBlockingSSL_Accept(SSL* ssl)
-{
-#ifndef CYASSL_CALLBACKS
- int ret = SSL_accept(ssl);
-#else
- int ret = CyaSSL_accept_ex(ssl, srvHandShakeCB, srvTimeoutCB, srvTo);
-#endif
- int error = SSL_get_error(ssl, 0);
- SOCKET_T sockfd = (SOCKET_T)CyaSSL_get_fd(ssl);
- int select_ret;
-
- while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ ||
- error == SSL_ERROR_WANT_WRITE)) {
- int currTimeout = 1;
-
- if (error == SSL_ERROR_WANT_READ)
- printf("... server would read block\n");
- else
- printf("... server would write block\n");
-
-#ifdef CYASSL_DTLS
- currTimeout = CyaSSL_dtls_get_current_timeout(ssl);
-#endif
- select_ret = tcp_select(sockfd, currTimeout);
-
- if ((select_ret == TEST_RECV_READY) ||
- (select_ret == TEST_ERROR_READY)) {
- #ifndef CYASSL_CALLBACKS
- ret = SSL_accept(ssl);
- #else
- ret = CyaSSL_accept_ex(ssl,
- srvHandShakeCB, srvTimeoutCB, srvTo);
- #endif
- error = SSL_get_error(ssl, 0);
- }
- else if (select_ret == TEST_TIMEOUT && !CyaSSL_dtls(ssl)) {
- error = SSL_ERROR_WANT_READ;
- }
-#ifdef CYASSL_DTLS
- else if (select_ret == TEST_TIMEOUT && CyaSSL_dtls(ssl) &&
- CyaSSL_dtls_got_timeout(ssl) >= 0) {
- error = SSL_ERROR_WANT_READ;
- }
-#endif
- else {
- error = SSL_FATAL_ERROR;
- }
- }
- if (ret != SSL_SUCCESS)
- err_sys("SSL_accept failed");
-}
-
-
-static void Usage(void)
-{
- printf("server " LIBCYASSL_VERSION_STRING
- " NOTE: All files relative to CyaSSL home dir\n");
- printf("-? Help, print this usage\n");
- printf("-p Port to listen on, not 0, default %d\n", yasslPort);
- printf("-v SSL version [0-3], SSLv3(0) - TLS1.2(3)), default %d\n",
- SERVER_DEFAULT_VERSION);
- printf("-l Cipher list\n");
- printf("-c Certificate file, default %s\n", svrCert);
- printf("-k Key file, default %s\n", svrKey);
- printf("-A Certificate Authority file, default %s\n", cliCert);
- printf("-d Disable client cert check\n");
- printf("-b Bind to any interface instead of localhost only\n");
- printf("-s Use pre Shared keys\n");
- printf("-t Track CyaSSL memory use\n");
- printf("-u Use UDP DTLS,"
- " add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
- printf("-f Fewer packets/group messages\n");
- printf("-N Use Non-blocking sockets\n");
- printf("-S Use Host Name Indication\n");
-#ifdef HAVE_OCSP
- printf("-o Perform OCSP lookup on peer certificate\n");
- printf("-O Perform OCSP lookup using as responder\n");
-#endif
-#ifdef HAVE_PK_CALLBACKS
- printf("-P Public Key Callbacks\n");
-#endif
-}
-
-THREAD_RETURN CYASSL_THREAD server_test(void* args)
-{
- SOCKET_T sockfd = 0;
- SOCKET_T clientfd = 0;
-
- SSL_METHOD* method = 0;
- SSL_CTX* ctx = 0;
- SSL* ssl = 0;
-
- char msg[] = "I hear you fa shizzle!";
- char input[80];
- int idx;
- int ch;
- int version = SERVER_DEFAULT_VERSION;
- int doCliCertCheck = 0; /* = 0 for no Realtime Clock environment */
- int useAnyAddr = 0;
- word16 port = yasslPort;
- int usePsk = 0;
- int doDTLS = 0;
- int useNtruKey = 0;
- int nonBlocking = 0;
- int trackMemory = 0;
- int fewerPackets = 0;
- int pkCallbacks = 0;
- char* cipherList = NULL;
- char* verifyCert = (char*)cliCert;
- char* ourCert = (char*)svrCert;
- char* ourKey = (char*)svrKey;
- int argc = ((func_args*)args)->argc;
- char** argv = ((func_args*)args)->argv;
-
-#ifdef HAVE_SNI
- char* sniHostName = NULL;
-#endif
-
-#ifdef HAVE_OCSP
- int useOcsp = 0;
- char* ocspUrl = NULL;
-#endif
-
- ((func_args*)args)->return_code = -1; /* error state */
-
-#ifdef NO_RSA
- verifyCert = (char*)cliEccCert;
- ourCert = (char*)eccCert;
- ourKey = (char*)eccKey;
-#endif
- (void)trackMemory;
- (void)pkCallbacks;
-
- while ((ch = mygetopt(argc, argv, "?dbstnNufPp:v:l:A:c:k:S:oO:")) != -1) {
- switch (ch) {
- case '?' :
- Usage();
- exit(EXIT_SUCCESS);
-
- case 'd' :
- doCliCertCheck = 0;
- break;
-
- case 'b' :
- useAnyAddr = 1;
- break;
-
- case 's' :
- usePsk = 1;
- break;
-
- case 't' :
- #ifdef USE_CYASSL_MEMORY
- trackMemory = 1;
- #endif
- break;
-
- case 'n' :
- useNtruKey = 1;
- break;
-
- case 'u' :
- doDTLS = 1;
- break;
-
- case 'f' :
- fewerPackets = 1;
- break;
-
- case 'P' :
- #ifdef HAVE_PK_CALLBACKS
- pkCallbacks = 1;
- #endif
- break;
-
- case 'p' :
- port = (word16)atoi(myoptarg);
- #if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
- if (port == 0)
- err_sys("port number cannot be 0");
- #endif
- break;
-
- case 'v' :
- version = atoi(myoptarg);
- if (version < 0 || version > 3) {
- Usage();
- exit(MY_EX_USAGE);
- }
- break;
-
- case 'l' :
- cipherList = myoptarg;
- break;
-
- case 'A' :
- verifyCert = myoptarg;
- break;
-
- case 'c' :
- ourCert = myoptarg;
- break;
-
- case 'k' :
- ourKey = myoptarg;
- break;
-
- case 'N':
- nonBlocking = 1;
- break;
-
- case 'S' :
- #ifdef HAVE_SNI
- sniHostName = myoptarg;
- #endif
- break;
-
- case 'o' :
- #ifdef HAVE_OCSP
- useOcsp = 1;
- #endif
- break;
-
- case 'O' :
- #ifdef HAVE_OCSP
- useOcsp = 1;
- ocspUrl = myoptarg;
- #endif
- break;
-
- default:
- Usage();
- exit(MY_EX_USAGE);
- }
- }
-
- myoptind = 0; /* reset for test cases */
-
- /* sort out DTLS versus TLS versions */
- if (version == CLIENT_INVALID_VERSION) {
- if (doDTLS)
- version = CLIENT_DTLS_DEFAULT_VERSION;
- else
- version = CLIENT_DEFAULT_VERSION;
- }
- else {
- if (doDTLS) {
- if (version == 3)
- version = -2;
- else
- version = -1;
- }
- }
-
-#ifdef USE_CYASSL_MEMORY
- if (trackMemory)
- InitMemoryTracker();
-#endif
-
- switch (version) {
-#ifndef NO_OLD_TLS
- case 0:
- method = SSLv3_server_method();
- break;
-
- #ifndef NO_TLS
- case 1:
- method = TLSv1_server_method();
- break;
-
-
- case 2:
- method = TLSv1_1_server_method();
- break;
-
- #endif
-#endif
-
-#ifndef NO_TLS
- case 3:
- method = TLSv1_2_server_method();
- break;
-#endif
-
-#ifdef CYASSL_DTLS
- case -1:
- method = DTLSv1_server_method();
- break;
-
- case -2:
- method = DTLSv1_2_server_method();
- break;
-#endif
-
- default:
- err_sys("Bad SSL version");
- }
-
- if (method == NULL)
- err_sys("unable to get method");
-
- ctx = SSL_CTX_new(method);
- if (ctx == NULL)
- err_sys("unable to get ctx");
-
- if (cipherList)
- if (SSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
- err_sys("server can't set cipher list 1");
-
-#ifdef CYASSL_LEANPSK
- usePsk = 1;
-#endif
-
-#if defined(NO_RSA) && !defined(HAVE_ECC)
- usePsk = 1;
-#endif
-
- if (fewerPackets)
- CyaSSL_CTX_set_group_messages(ctx);
-
-#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
- SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-#endif
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
- if (!usePsk) {
- if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server cert file, check file and run from"
- " CyaSSL home dir");
- }
-#endif
-
-#ifdef HAVE_NTRU
- if (useNtruKey) {
- if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ourKey)
- != SSL_SUCCESS)
- err_sys("can't load ntru key file, "
- "Please run from CyaSSL home dir");
- }
-#endif
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
- if (!useNtruKey && !usePsk) {
- if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("can't load server private key file, check file and run "
- "from CyaSSL home dir");
- }
-#endif
-
- if (usePsk) {
-#ifndef NO_PSK
- SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
- SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
- if (cipherList == NULL) {
- const char *defaultCipherList;
- #ifdef HAVE_NULL_CIPHER
- defaultCipherList = "PSK-NULL-SHA256";
- #else
- defaultCipherList = "PSK-AES128-CBC-SHA256";
- #endif
- if (SSL_CTX_set_cipher_list(ctx, defaultCipherList) != SSL_SUCCESS)
- err_sys("server can't set cipher list 2");
- }
-#endif
- }
-
-#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
- /* if not using PSK, verify peer with certs */
- if (doCliCertCheck && usePsk == 0) {
- SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER |
- SSL_VERIFY_FAIL_IF_NO_PEER_CERT,0);
- if (SSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS)
- err_sys("can't load ca file, Please run from CyaSSL home dir");
- }
-#endif
-
-#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
- /* don't use EDH, can't sniff tmp keys */
- if (cipherList == NULL) {
- if (SSL_CTX_set_cipher_list(ctx, "AES256-SHA256") != SSL_SUCCESS)
- err_sys("server can't set cipher list 3");
- }
-#endif
-
-#ifdef HAVE_SNI
- if (sniHostName)
- if (CyaSSL_CTX_UseSNI(ctx, CYASSL_SNI_HOST_NAME, sniHostName,
- XSTRLEN(sniHostName)) != SSL_SUCCESS)
- err_sys("UseSNI failed");
-#endif
-
- ssl = SSL_new(ctx);
- if (ssl == NULL)
- err_sys("unable to get SSL");
-
-#ifdef HAVE_CRL
- CyaSSL_EnableCRL(ssl, 0);
- CyaSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, CYASSL_CRL_MONITOR |
- CYASSL_CRL_START_MON);
- CyaSSL_SetCRL_Cb(ssl, CRL_CallBack);
-#endif
-#ifdef HAVE_OCSP
- if (useOcsp) {
- if (ocspUrl != NULL) {
- CyaSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl);
- CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE
- | CYASSL_OCSP_URL_OVERRIDE);
- }
- else
- CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE);
- }
-#endif
-#ifdef HAVE_PK_CALLBACKS
- if (pkCallbacks)
- SetupPkCallbacks(ctx, ssl);
-#endif
-
- tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr, doDTLS);
- if (!doDTLS)
- CloseSocket(sockfd);
-
- SSL_set_fd(ssl, clientfd);
- if (usePsk == 0) {
- #if !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA)
- CyaSSL_SetTmpDH_file(ssl, dhParam, SSL_FILETYPE_PEM);
- #elif !defined(NO_CERTS)
- SetDH(ssl); /* repick suites with DHE, higher priority than PSK */
- #endif
- }
-
-#ifndef CYASSL_CALLBACKS
- if (nonBlocking) {
- CyaSSL_set_using_nonblock(ssl, 1);
- tcp_set_nonblocking(&clientfd);
- NonBlockingSSL_Accept(ssl);
- } else if (SSL_accept(ssl) != SSL_SUCCESS) {
- int err = SSL_get_error(ssl, 0);
- char buffer[CYASSL_MAX_ERROR_SZ];
- printf("error = %d, %s\n", err, ERR_error_string(err, buffer));
- err_sys("SSL_accept failed");
- }
-#else
- NonBlockingSSL_Accept(ssl);
-#endif
- showPeer(ssl);
-
- idx = SSL_read(ssl, input, sizeof(input)-1);
- if (idx > 0) {
- input[idx] = 0;
- printf("Client message: %s\n", input);
-
- }
- else if (idx < 0) {
- int readErr = SSL_get_error(ssl, 0);
- if (readErr != SSL_ERROR_WANT_READ)
- err_sys("SSL_read failed");
- }
-
- if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
- err_sys("SSL_write failed");
-
- #if defined(CYASSL_MDK_SHELL) && defined(HAVE_MDK_RTX)
- os_dly_wait(500) ;
- #endif
-
- SSL_shutdown(ssl);
- SSL_free(ssl);
- SSL_CTX_free(ctx);
-
- CloseSocket(clientfd);
- ((func_args*)args)->return_code = 0;
-
-#ifdef USE_CYASSL_MEMORY
- if (trackMemory)
- ShowMemoryTracker();
-#endif /* USE_CYASSL_MEMORY */
-
- return 0;
-}
-
-
-/* so overall tests can pull in test function */
-#ifndef NO_MAIN_DRIVER
-
- int main(int argc, char** argv)
- {
- func_args args;
-
-#ifdef HAVE_CAVIUM
- int ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
- if (ret != 0)
- err_sys("Cavium OpenNitroxDevice failed");
-#endif /* HAVE_CAVIUM */
-
- StartTCP();
-
- args.argc = argc;
- args.argv = argv;
-
- CyaSSL_Init();
-#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
- CyaSSL_Debugging_ON();
-#endif
- if (CurrentDir("server"))
- ChangeDirBack(2);
- else if (CurrentDir("Debug") || CurrentDir("Release"))
- ChangeDirBack(3);
-
-#ifdef HAVE_STACK_SIZE
- StackSizeCheck(&args, server_test);
-#else
- server_test(&args);
-#endif
- CyaSSL_Cleanup();
-
-#ifdef HAVE_CAVIUM
- CspShutdown(CAVIUM_DEV_ID);
-#endif
- return args.return_code;
- }
-
- int myoptind = 0;
- char* myoptarg = NULL;
-
-#endif /* NO_MAIN_DRIVER */
-
-
-#ifdef CYASSL_CALLBACKS
-
- int srvHandShakeCB(HandShakeInfo* info)
- {
- (void)info;
- return 0;
- }
-
-
- int srvTimeoutCB(TimeoutInfo* info)
- {
- (void)info;
- return 0;
- }
-
-#endif
-
diff --git a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/shell.c b/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/shell.c
deleted file mode 100644
index 1ada297cf..000000000
--- a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/shell.c
+++ /dev/null
@@ -1,657 +0,0 @@
-/*shell.c
- *
- * Copyright (C) 2006-2014 wolfSSL Inc.
- *
- * This file is part of CyaSSL.
- *
- * CyaSSL is free software; you can redistribute it and/or modify
- * 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.
- *
- * CyaSSL is distributed in the hope that it will be useful,
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
- /*** tiny Shell for CyaSSL apps ***/
-
- #ifdef HAVE_CONFIG_H
- #include
-#endif
-
-#include "cyassl/internal.h"
-#undef RNG
-#include
-
-#if defined(CYASSL_MDK_ARM)
- #include
- #include
- #include
- #if defined(CYASSL_MDK5)
- #include "cmsis_os.h"
- #include "rl_fs.h"
- #else
- #include
- #endif
- #include "cyassl_MDK_ARM.h"
-#endif
-
-#ifdef CYASSL_KEIL_NET
-#include "cyassl/test.h"
-#else
-typedef struct func_args {
- int argc;
- char** argv;
- int return_code;
-} func_args;
-#endif
-
-#ifdef NO_ECHOCLIENT
-#define echoclient_test command_not_found
-#endif
-#ifdef NO_ECHOSERVER
-#define echoserver_test command_not_found
-#endif
-#ifdef NO_SIMPLE_CLIENT
-#define client_test command_not_found
-#endif
-#ifdef NO_SIMPLE_SERVER
-#define server_test command_not_found
-#endif
-#ifdef NO_CRYPT_BENCHMARK
-#define benchmark_test command_not_found
-#endif
-#ifdef NO_CRYPT_TEST
-#define ctaocrypt_test command_not_found
-#endif
-
-#ifndef CYASSL_KEIL_NET
-#define ipaddr_comm command_not_found
-#endif
-
-#if !defined(HAVE_KEIL_RTX)
-#define stack_comm command_not_found
-#endif
-
-
-#if !defined(DEBUG_CYASSL)
-#define dbg_comm command_not_found
-#endif
-
-
-void command_not_found(void *argv) {
- printf("Command not found\n") ;
-}
-
-extern void echoclient_test(void *args) ;
-extern void echoserver_test(void *args) ;
-extern void benchmark_test(void *args) ;
-extern void ctaocrypt_test(void *args) ;
-extern void client_test(void *args) ;
-extern void server_test(void *args) ;
-extern void kill_task(void *args) ;
-extern void ipaddr_comm(void *args) ;
-extern void stack_comm(void *args) ;
-extern void for_command(void *args) ;
-extern void dbg_comm(void *arg) ;
-extern void help_comm(void *arg) ;
-
-#if !defined(NO_CRYPT_TEST)
-
-#ifndef NO_MD5
-extern void md5_test(void *arg) ;
-#endif
-#ifdef CYASSL_MD2
-extern void md2_test(void *arg) ;
-#endif
-#ifndef NO_MD4
-extern void md4_test(void *arg) ;
-#endif
-
-extern void sha_test(void *arg) ;
-
-#ifndef NO_SHA256
-extern void sha256_test(void *arg) ;
-#endif
-#ifdef CYASSL_SHA384
-extern void sha384_test(void *arg) ;
-#endif
-
-#ifdef CYASSL_SHA512
-extern void sha512_test(void *arg) ;
-#endif
-
-#ifdef CYASSL_RIPEMD
-extern void ripemd_test(void *arg) ;
-#endif
-#ifndef NO_HMAC
- #ifndef NO_MD5
-extern void hmac_md5_test(void *arg) ;
- #endif
-extern void hmac_sha_test(void *arg) ;
-
- #ifndef NO_SHA256
-extern void hmac_sha256_test(void *arg) ;
- #endif
-
- #ifdef CYASSL_SHA384
-extern void hmac_sha384_test(void *arg) ;
- #endif
-#endif
-#ifndef NO_RC4
-extern void arc4_test(void *arg) ;
-#endif
-
-#ifndef NO_HC128
-extern void hc128_test(void *arg) ;
-#endif
-
-#ifndef NO_RABBIT
-extern void rabbit_test(void *arg) ;
-#endif
-
-#ifndef NO_DES3
-extern void des_test(void *arg) ;
-extern void des3_test(void *arg) ;
-#endif
-
-#ifndef NO_AES
-extern void aes_test(void *arg) ;
-#ifdef HAVE_AESGCM
-extern void aesgcm_test(void *arg) ;
-#endif
-
-#ifdef HAVE_AESCCM
-extern void aesccm_test(void *arg) ;
-#endif
-#endif
-
-#ifdef HAVE_CAMELLIA
-extern void camellia_test(void *arg) ;
-#endif
-extern void random_test(void *arg) ;
-
-#ifndef NO_RSA
-extern void rsa_test(void *arg) ;
-#endif
-
-#ifndef NO_DH
-extern void dh_test(void *arg) ;
-#endif
-
-#ifndef NO_DSA
-extern void dsa_test(void *arg) ;
-#endif
-
-#ifndef NO_PWDBASED
-extern void pwdbased_test(void *arg) ;
-#endif
-
-#ifdef OPENSSL_EXTRA
-extern void openssl_test(void *arg) ;
-#endif
-
-#ifdef HAVE_ECC
-extern void ecc_test(void *arg) ;
-#endif
-
-#endif /* NO_CRYPT_TEST */
-
-static struct {
- const char *command ;
- void (*func)(void *args) ;
-} commandTable[] = {
- "echoclient", echoclient_test,
- "echoserver", echoserver_test,
- "benchmark", benchmark_test,
- "test", ctaocrypt_test,
- "client", client_test,
- "server", server_test,
- "ipaddr", ipaddr_comm, /* TBD */
- "stack", stack_comm, /* On/Off check stack size */
- "for", for_command, /* iterate next command X times */
- "debug", dbg_comm, /* On/Off debug message */
- "help", help_comm, /* Breif description about the commands */
-
- /** short name **/
- "ec", echoclient_test,
- "es", echoserver_test,
- "bm", benchmark_test,
- "te", ctaocrypt_test,
- "cl", client_test,
- "sv", server_test,
- "ip", ipaddr_comm,
- "st", stack_comm,
- "dbg", dbg_comm,
- "?", help_comm,
-
-/*** test suites ****/
-#if !defined(NO_CRYPT_TEST)
-#ifndef NO_MD5
- "md5", md5_test,
-#endif
-#ifdef CYASSL_MD2
- "md2", md2_test,
-#endif
-#ifndef NO_MD4
- "md4", md4_test,
-#endif
- "sha", sha_test,
-#ifndef NO_SHA256
- "sha256", sha256_test,
-#endif
-#ifdef CYASSL_SHA384
- "sha384", sha384_test,
-#endif
-#ifdef CYASSL_SHA512
- "sha512", sha512_test,
-#endif
-#ifdef CYASSL_RIPEMD
- "ripemd", ripemd_test,
-#endif
-#ifndef NO_HMAC
- #ifndef NO_MD5
- "hmac_md5", hmac_md5_test,
- #endif
- "hmac_sha", hmac_sha_test,
- #ifndef NO_SHA256
- "hmac_sha256", hmac_sha256_test,
- #endif
- #ifdef CYASSL_SHA384
- "hmac_sha384", hmac_sha384_test,
- #endif
-#endif
-#ifndef NO_RC4
- "arc4", arc4_test,
-#endif
-#ifndef NO_HC128
- "hc128", hc128_test,
-#endif
-#ifndef NO_RABBIT
- "rabbit", rabbit_test,
-#endif
-#ifndef NO_DES3
- "des", des_test,
- "des3", des3_test,
-#endif
-#ifndef NO_AES
- "aes", aes_test,
- #ifdef HAVE_AESGCM
- "aesgcm", aesgcm_test,
- #endif
- #ifdef HAVE_AESCCM
- "aesccm", aesccm_test,
- #endif
-#endif
-
-#ifdef HAVE_CAMELLIA
- "camellia", camellia_test,
-#endif
- "random", random_test,
-#ifndef NO_RSA
- "rsa", rsa_test,
-#endif
-#ifndef NO_DH
- "dh", dh_test,
-#endif
-#ifndef NO_DSA
- "dsa", dsa_test,
-#endif
-#ifndef NO_PWDBASED
- "pwdbased", pwdbased_test,
-#endif
-#ifdef OPENSSL_EXTRA
- "openssl", openssl_test,
-#endif
-#ifdef HAVE_ECC
- "ecc", ecc_test,
-#endif
-
-#endif /* NO_CRYPT_TEST */
-
- "", NULL
-} ;
-
-enum jobtype { FORGROUND, BACKGROUND } ;
-
-#define IF_DELIMITER(ch) ((ch) == ' ' || (ch) == '\n')
-
-static int BackGround = 0 ; /* 1: background job is running */
-
-/******* Get Command Line *****************************/
-static int getline(char * line, int sz, func_args *args, int*bf_flg)
-{
- char * ret ;
- int i ;
-
- #define MAXARGS 10
- #define MAXARGLEN 30
- static char *argv[MAXARGS] ;
- args->argv = argv ;
-
- putchar('>') ;
- fflush(stdout) ;
- ret = fgets(line, sz, stdin) ;
-
- #define SHELL_ERROR_FGETS -102
- if(ret != line) return(SHELL_ERROR_FGETS) ;
-
- if(line[strlen(line)-2] == '&') {
- (*bf_flg) = BACKGROUND ;
- line[strlen(line)-2] = '\n' ;
- } else {
- (*bf_flg) = FORGROUND ;
- }
- args->argc = 0 ;
- for(i=0; iargv[args->argc] = &(line[i]) ;
- while(!IF_DELIMITER(line[i])) i++ ;
- args->argc++ ;
- if(line[i] == '\n') {
- line[i] = '\0' ;
- break ;
- } else {
- line[i] = '\0' ;
- }
- }
- return i ;
-}
-
-
-/************* Embedded Shell Commands **********************************/
-#define IP_SIZE 16
-
-#ifdef CYASSL_KEIL_NET
-static void ipaddr_comm(void *args)
-{
- if(((func_args *)args)->argc == 1) {
- printf("IP addr: %s, port %d\n", yasslIP, yasslPort) ;
- } else {
- if(BackGround != 0) {
- printf("Cannot change IP addr while background server is running\n") ;
- } else if(((func_args *)args)->argc == 3 &&
- ((func_args *)args)->argv[1][0] == '-'&&
- ((func_args *)args)->argv[1][1] == 'a' ) {
-/* strcpy(yasslIP, ((func_args *)args)->argv[2]) ; */
- } else if(((func_args *)args)->argc == 3 &&
- ((func_args *)args)->argv[1][0] == '-' &&
- ((func_args *)args)->argv[1][1] == 'p' ) {
-/* yasslPort = atoi(((func_args *)args)->argv[2]) ; */
- } else printf("Invalid argument\n") ;
- }
-}
-
-#endif
-
-
-
-#if defined(HAVE_KEIL_RTX)
-static int stack_ck = 0 ;
-
-void stack_comm(void *args)
-{
- if(stack_ck) {
- printf("Stack Check: Off\n") ;
- stack_ck = 0 ;
- } else {
- printf("Stack Check: On\n") ;
- stack_ck = 1 ;
- }
-}
-
-#define FILL_PATTERN 0xa596695a
-void stack_fill(char * stack, int size)
-{
- int i ;
-
- if(stack_ck == 0)return ;
- for(i=1; iargc == 1) {
- printf("For %d times\n", for_iteration) ;
- } else if( args == NULL || ((func_args *)args)->argc == 2) {
- for_iteration = atoi(((func_args *)args)->argv[1]) ;
- } else printf("Invalid argument\n") ;
-}
-
-
-#if defined(DEBUG_CYASSL)
-
-static int CyasslDebug = 1 ;
-
-static void dbg_comm(void *args)
-{
- if(CyasslDebug == 1) {
- CyasslDebug = 0 ;
- printf("Turning OFF Debug message\n") ;
- CyaSSL_Debugging_OFF() ;
- } else {
- CyasslDebug = 1 ;
- printf("Turning ON Debug message\n") ;
- CyaSSL_Debugging_ON() ;
- }
-}
-#endif
-
-static void help_comm(void *args)
-{
- static char *commands[] = {
- "test",
- "benchmark",
- "echoserver& : simple echo server in background mode",
- "echoclient : simple echo client followed by any input string, or \"quit\", \"break\"",
- "server& : simple server in background mode",
- "client : simple client",
- "client -g -v [0123] -h xxx.xxx.xxx.xxx -p 443 : usage example",
- "server/client -h : help for server/client command",
- "help",
- ""
- } ;
-
- int i ;
- printf("Commands:\n") ;
- for(i=0; commands[i][0] ; i++)
- printf(" %s\n", commands[i]) ;
-
-}
-
-
-
-#define BG_JOB_STACK_SIZE 8000
-#if (!defined(NO_SIMPLE_SERVER) && !defined(NO_ECHOSERVER)) && \
- defined(HAVE_KEIL_RTX)
-#if !defined(CYASSL_CMSIS_RTOS)
-static char bg_job_stack[BG_JOB_STACK_SIZE] ;
-#endif
-
-#endif
-
-#define COMMAND_STACK_SIZE 10000
-#if defined(HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
-static char command_stack[COMMAND_STACK_SIZE] ;
-#endif
-
-
-#ifdef HAVE_KEIL_RTX
-static CyaSSL_Mutex command_mutex ;
-#endif
-
-void exit_command(void) {
- printf("Command Aborted\n") ;
- #ifdef CYASSL_CMSIS_RTOS
- osThreadTerminate(osThreadGetId()) ;
- #else
- os_tsk_delete_self() ;
- #endif
-}
-
-
-/*********** Invoke Forground Command *********************/
-static void command_invoke(void const *args)
-{
- void (*func)(void const * ) ;
- int i,iteration ;
-
- func = (void(*)(void const *))((func_args *)args)->argv[0] ;
- #ifdef HAVE_KEIL_RTX
- LockMutex((CyaSSL_Mutex *)&command_mutex) ;
- #endif
- iteration = for_iteration ;
- for(i=0; i< iteration; i++) {
- if(iteration > 1) printf("--- Start for %d ---->\n", i) ;
- #if defined(HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
- stack_fill(command_stack, COMMAND_STACK_SIZE) ;
- #endif
-
- func(args) ; /* invoke command */
-
- #if defined(HAVE_KEIL_RTX)&& !defined(CYASSL_CMSIS_RTOS)
- stack_check(command_stack, COMMAND_STACK_SIZE) ;
- #endif
- }
-
- if(iteration > 1)
- for_iteration = 1 ;
- osDelay(20000) ;
- #ifdef HAVE_KEIL_RTX
- UnLockMutex((CyaSSL_Mutex *)&command_mutex) ;
- #ifdef CYASSL_CMSIS_RTOS
- osThreadTerminate(osThreadGetId()) ;
- #else
- os_tsk_delete_self() ;
- #endif
- #endif
-}
-
-#if defined(HAVE_KEIL_RTX)
-/******* Invoke Background Job *******************************/
-static void bg_job_invoke(void const *args)
-{
- void (*func)(void const * ) ;
- BackGround = 1 ;
- #if defined(HAVE_KEIL_RTX)&& !defined(CYASSL_CMSIS_RTOS)
- stack_fill(bg_job_stack, BG_JOB_STACK_SIZE) ;
- #endif
-
- func = (void(*)(void const *))((func_args *)args)->argv[0] ;
- func(args) ; /* invoke command */
- #if defined(HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
- stack_check(bg_job_stack, BG_JOB_STACK_SIZE) ;
- #endif
-
- osDelay(20000) ;
- BackGround = 0 ;
-
- #ifdef CYASSL_CMSIS_RTOS
- osThreadTerminate(osThreadGetId()) ;
- #else
- os_tsk_delete_self() ; ;
- #endif
-}
-#endif
-
-#define LINESIZE 100
-static char line[LINESIZE] ;
-
-#if defined(CYASSL_CMSIS_RTOS)
- osThreadDef (command_invoke, osPriorityAboveNormal , 1, COMMAND_STACK_SIZE) ;
- osThreadDef (bg_job_invoke, osPriorityNormal , 1 , BG_JOB_STACK_SIZE) ;
-#endif
-/********* SHEULL MAIN LOOP ***********************************/
-void shell_main(void *arg) {
- int i ;
- func_args args ;
- int bf_flg ;
-
- i = BackGround ;
- /* Dummy for avoiding warning: BackGround is defined but not used. */
-
- #if defined(HAVE_KEIL_RTX)
- InitMutex(&command_mutex) ;
-#endif
- help_comm(NULL) ;
-
- printf("Starting Shell\n") ;
- while(1) {
- if(getline(line, LINESIZE, &args, &bf_flg) > 0) {
- for(i=0; commandTable[i].func != NULL; i++) {
- if(strcmp(commandTable[i].command, args.argv[0]) == 0) {
- args.argv[0] = (char *) commandTable[i].func ;
- if(bf_flg == FORGROUND) {
- #if defined(HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
- UnLockMutex((CyaSSL_Mutex *)&command_mutex) ;
- os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7,
- command_stack, COMMAND_STACK_SIZE, &args) ;
- #else
- #if defined(CYASSL_CMSIS_RTOS)
- UnLockMutex((CyaSSL_Mutex *)&command_mutex) ;
- osThreadCreate (osThread (command_invoke) , &args);
- #else
- command_invoke(&args) ;
- #endif
- #endif
- #ifdef HAVE_KEIL_RTX
- LockMutex((CyaSSL_Mutex *)&command_mutex) ;
- #endif
- } else {
- #if (!defined(NO_SIMPLE_SERVER) && \
- !defined(NO_ECHOSERVER)) && \
- defined(HAVE_KEIL_RTX)
- if(BackGround != 0) {
- printf("Multiple background servers not supported.\n") ;
- } else {
- printf("\"%s\" is running with the background mode.\n",
- commandTable[i].command) ;
- #if defined(HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
- os_tsk_create_user_ex( (void(*)(void *))&bg_job_invoke,
- 6, bg_job_stack, BG_JOB_STACK_SIZE, &args) ;
- #else
- osThreadCreate (osThread (bg_job_invoke), &args);
- osDelay (500) ;
- #endif
- }
- #else
- printf("Invalid Command: no background job\n") ;
- #endif
- }
- break ;
- }
- }
- if(commandTable[i].func == NULL)
- printf("Command not found\n") ;
- }
- }
-}
-
diff --git a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/test.c b/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/test.c
deleted file mode 100644
index e19675bd9..000000000
--- a/FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/CyaSSL-Full/test.c
+++ /dev/null
@@ -1,4758 +0,0 @@
-/* test.c
- *
- * Copyright (C) 2006-2014 wolfSSL Inc.
- *
- * This file is part of CyaSSL.
- *
- * CyaSSL is free software; you can redistribute it and/or modify
- * 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.
- *
- * CyaSSL is distributed in the hope that it will be useful,
- * 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
- #include
-#endif
-
-#include
-
-#ifdef XMALLOC_USER
- #include /* we're using malloc / free direct here */
-#endif
-
-#ifndef NO_CRYPT_TEST
-
-#ifdef CYASSL_TEST_CERT
- #include
-#else
- #include
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#ifdef HAVE_ECC
- #include
-#endif
-#ifdef HAVE_BLAKE2
- #include
-#endif
-#ifdef HAVE_LIBZ
- #include
-#endif
-#ifdef HAVE_PKCS7
- #include
-#endif
-
-#ifdef _MSC_VER
- /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
- #pragma warning(disable: 4996)
-#endif
-
-#ifdef OPENSSL_EXTRA
- #include