mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 04:34:41 +02:00
refactor options in test.h, eliminate cyassl_MDK_ARM.[ch] coupler functions, cert_data.[ch]
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
#ifndef CYASSL_CERT_DATA_H
|
||||
#define CYASSL_CERT_DATA_H
|
||||
|
||||
#ifdef USE_CERT_BUFFERS_1024
|
||||
extern const unsigned char client_key_der_1024[] ;
|
||||
extern int sizeof_client_key_der_1024 ;
|
||||
/* ./certs/1024/client-cert.der, 1024-bit */
|
||||
extern const unsigned char client_cert_der_1024[] ;
|
||||
extern int sizeof_client_cert_der_1024 ;
|
||||
/* ./certs/1024/dh1024.der, 1024-bit */
|
||||
extern const unsigned char dh_key_der_1024[] ;
|
||||
extern int sizeof_dh_key_der_1024 ;
|
||||
/* ./certs/1024/dsa1024.der, 1024-bit */
|
||||
extern const unsigned char dsa_key_der_1024[] ;
|
||||
extern int sizeof_dsa_key_der_1024 ;
|
||||
/* ./certs/1024/rsa1024.der, 1024-bit */
|
||||
extern const unsigned char rsa_key_der_1024[] ;
|
||||
extern int sizeof_rsa_key_der_1024 ;
|
||||
|
||||
#elif defined(USE_CERT_BUFFERS_2048)
|
||||
/* ./certs/client-key.der, 2048-bit */
|
||||
extern const unsigned char client_key_der_2048[] ;
|
||||
extern int sizeof_client_key_der_2048 ;
|
||||
/* ./certs/client-cert.der, 2048-bit */
|
||||
extern const unsigned char client_cert_der_2048[] ;
|
||||
extern int sizeof_client_cert_der_2048 ;
|
||||
/* ./certs/dh2048.der, 2048-bit */
|
||||
extern const unsigned char dh_key_der_2048[] ;
|
||||
extern int sizeof_dh_key_der_2048 ;
|
||||
/* ./certs/dsa2048.der, 2048-bit */
|
||||
extern const unsigned char dsa_key_der_2048[] ;
|
||||
extern int sizeof_dsa_key_der_2048;
|
||||
/* ./certs/rsa2048.der, 2048-bit */
|
||||
extern const unsigned char rsa_key_der_2048[] ;
|
||||
extern int sizeof_rsa_key_der_2048 ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -20,43 +20,38 @@
|
||||
*/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define CYASSL_MDK_ARM
|
||||
#define CYASSL_MDK5
|
||||
#define CYASSL_CMSIS_RTOS
|
||||
|
||||
#define NO_WRITEV
|
||||
#define NO_CYASSL_DIR
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
#define CYASSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
#define NO_MAIN_DRIVER
|
||||
|
||||
#if defined(MDK_CONF_CYASSL)
|
||||
#define CYASSL_MDK_SHELL
|
||||
#if defined(MDK_CONF_full)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-CyaSSL.h"
|
||||
#include "config-wolfSSL.h"
|
||||
|
||||
#elif defined(MDK_CONF_SimpleClient)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-CyaSSL.h"
|
||||
#include "config-wolfSSL.h"
|
||||
|
||||
#elif defined(MDK_CONF_SimpleServer)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-CyaSSL.h"
|
||||
#include "config-wolfSSL.h"
|
||||
|
||||
#elif defined(MDK_CONF_EchoClient)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-CyaSSL.h"
|
||||
#include "config-wolfSSL.h"
|
||||
|
||||
#elif defined(MDK_CONF_EchoServer)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-CyaSSL.h"
|
||||
#include "config-wolfSSL.h"
|
||||
|
||||
#elif defined(MDK_CONF_Benchmark)
|
||||
#define SINGLE_THREADED
|
||||
#define NO_INLINE
|
||||
#include "config-Crypt.h"
|
||||
#elif defined(MDK_CONF_CryptTest)
|
||||
#define SINGLE_THREADED
|
||||
#define NO_INLINE
|
||||
#include "config-Crypt.h"
|
||||
|
||||
#elif defined(MDK_CONF_CryptTest)
|
||||
#define SINGLE_THREADED
|
||||
#include "config-Crypt.h"
|
||||
|
||||
#elif defined(MDK_CONF_wolfSSL_lib)
|
||||
#include "config-Crypt.h"
|
||||
#include "config-wolfSSL.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -1,106 +0,0 @@
|
||||
/* cyassl_KEIL_RL.h
|
||||
*
|
||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
/** This file is for defining types, values for specific to KEIL-MDK-ARM. **/
|
||||
/******************************************************************************/
|
||||
#ifndef CYASSL_KEIL_RL_H
|
||||
#define CYASSL_KEIL_RL_H
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Go to STDIN */
|
||||
#define fgets(buff, sz, fd) Cyassl_fgets(buff, sz, fd)
|
||||
extern char * Cyassl_fgets ( char * str, int num, FILE * f ) ;
|
||||
|
||||
#define SOCKET_T int
|
||||
|
||||
/*** #include <socket.h> ***/
|
||||
#define NUMBITSPERBYTE 8
|
||||
#define FD_SETSIZE 10
|
||||
|
||||
typedef long fd_mask;
|
||||
#define NFDBITS (sizeof(fd_mask) * NUMBITSPERBYTE) /* bits per mask */
|
||||
|
||||
typedef struct fd_set {
|
||||
fd_mask fds_bits[(FD_SETSIZE + NFDBITS - 1) / NFDBITS];
|
||||
} fd_set;
|
||||
|
||||
/*** #include <sys/types.h> ***/
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
|
||||
|
||||
#if defined(CYASSL_MDK5)
|
||||
#define SCK_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
|
||||
#define SCK_ETIMEOUT BSD_ERROR_TIMEOUT
|
||||
#include "rl_net.h"
|
||||
#endif
|
||||
|
||||
typedef int socklen_t ;
|
||||
|
||||
/* for avoiding conflict with KEIL-TCPnet BSD socket */
|
||||
/* Bodies are in cyassl_KEIL_RL.c */
|
||||
#define connect Cyassl_connect
|
||||
#define accept Cyassl_accept
|
||||
#define recv Cyassl_recv
|
||||
#define send Cyassl_send
|
||||
#define sleep Cyassl_sleep
|
||||
|
||||
/* for avoiding conflicting with KEIL-TCPnet TCP socket */
|
||||
/* Bodies are in test.h */
|
||||
#define tcp_connect Cyassl_tcp_connect
|
||||
#define tcp_socket Cyassl_tcp_soket
|
||||
#define tcp_listen Cyassl_tcp_listen
|
||||
#define tcp_select Cyassl_tcp_select
|
||||
|
||||
extern int Cyassl_connect(int sd, const struct sockaddr * sa, int sz) ;
|
||||
extern int Cyassl_accept(int sd, struct sockaddr *addr, socklen_t *addrlen);
|
||||
extern int Cyassl_recv(int sd, void *buf, size_t len, int flags);
|
||||
extern int Cyassl_send(int sd, const void *buf, size_t len, int flags);
|
||||
extern void Cyassl_sleep(int sec) ;
|
||||
extern int Cyassl_tcp_select(int sd, int timeout) ;
|
||||
|
||||
/** KEIL-RL TCPnet ****/
|
||||
/* TCPnet BSD socket does not have following functions. */
|
||||
extern char *inet_ntoa(struct in_addr in);
|
||||
extern unsigned long inet_addr(const char *cp);
|
||||
extern int setsockopt(int sockfd, int level, int optname,
|
||||
const void *optval, socklen_t optlen);
|
||||
extern int select(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
fd_set *exceptfds, const struct timeval *timeout);
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
|
||||
|
||||
/* CyaSSL MDK-ARM time functions */
|
||||
#include <time.h>
|
||||
struct tm *Cyassl_MDK_gmtime(const time_t *c) ;
|
||||
extern double current_time(void) ;
|
||||
|
||||
#endif /* CYASSL_KEIL_RL_H */
|
@@ -1,28 +0,0 @@
|
||||
/* certs_test.c
|
||||
*
|
||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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 <config.h>
|
||||
#endif
|
||||
|
||||
/* Define initial data for cert buffers */
|
||||
#include <cyassl/certs_test.h>
|
||||
|
@@ -1,28 +0,0 @@
|
||||
/* certs_test.c
|
||||
*
|
||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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 <config.h>
|
||||
#endif
|
||||
|
||||
/* Define initial data for cert buffers */
|
||||
#include <cyassl/certs_test.h>
|
||||
|
@@ -1,28 +0,0 @@
|
||||
/* certs_test.c
|
||||
*
|
||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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 <config.h>
|
||||
#endif
|
||||
|
||||
/* Define initial data for cert buffers */
|
||||
#include <cyassl/certs_test.h>
|
||||
|
@@ -1,247 +0,0 @@
|
||||
/* cyassl_KEIL_RL.c
|
||||
*
|
||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/** This file is for defining functions for specific to KEIL-RL. **/
|
||||
/***************************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined (CYASSL_MDK5)
|
||||
#include "cmsis_os.h"
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
#include "rl_net.h"
|
||||
#endif
|
||||
#else
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
|
||||
#include "cyassl_MDK_ARM.h"
|
||||
|
||||
#include <cyassl/ctaocrypt/visibility.h>
|
||||
#include <cyassl/ctaocrypt/logging.h>
|
||||
|
||||
#if defined (CYASSL_CMSIS_RTOS)
|
||||
#define os_dly_wait(t) osDelay(10*t)
|
||||
#endif
|
||||
|
||||
|
||||
/** KEIL-RL TCPnet ****/
|
||||
/** TCPnet BSD socket does not have following functions. **/
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
char *inet_ntoa(struct in_addr in)
|
||||
{
|
||||
#define NAMESIZE 16
|
||||
static char name[NAMESIZE] ;
|
||||
sprintf(name, "%d.%d.%d.%d", (in.s_addr>>24)&0xff, (in.s_addr>>16)&0xff, (in.s_addr>>8)&0xff, in.s_addr&0xff) ;
|
||||
return name ;
|
||||
}
|
||||
|
||||
unsigned long inet_addr(const char *cp)
|
||||
{
|
||||
unsigned int a[4] ; unsigned long ret ;
|
||||
sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]) ;
|
||||
ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
|
||||
return(ret) ;
|
||||
}
|
||||
|
||||
|
||||
/*** tcp_connect is actually associated with following syassl_tcp_connect. ***/
|
||||
int Cyassl_connect(int sd, const struct sockaddr* sa, int sz)
|
||||
{
|
||||
int ret = 0 ;
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
|
||||
SOCKADDR_IN addr ;
|
||||
|
||||
addr = *(SOCKADDR_IN *)sa ;
|
||||
|
||||
do {
|
||||
#undef connect /* Go to KEIL TCPnet connect */
|
||||
ret = connect(sd, (SOCKADDR *)&addr, sizeof(addr)) ;
|
||||
os_dly_wait(50);
|
||||
} while(ret == SCK_EWOULDBLOCK) ;
|
||||
#ifdef DEBUG_CYASSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Connect return code: %d\n", ret) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
}
|
||||
|
||||
|
||||
int Cyassl_accept(int sd, struct sockaddr *addr, int *addrlen)
|
||||
{
|
||||
int ret = 0 ;
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef accept /* Go to KEIL TCPnet accept */
|
||||
ret = accept(sd, addr, addrlen) ;
|
||||
if(ret != SCK_EWOULDBLOCK) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_CYASSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Accept return code: %d\n", ret) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
|
||||
}
|
||||
|
||||
int Cyassl_recv(int sd, void *buf, size_t len, int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef recv /* Go to KEIL TCPnet recv */
|
||||
ret = recv(sd, buf, len, flags) ;
|
||||
if((ret != SCK_EWOULDBLOCK) &&( ret != SCK_ETIMEOUT)) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_CYASSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Recv return code: %d\n", ret) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
}
|
||||
|
||||
int Cyassl_send(int sd, const void *buf, size_t len, int flags)
|
||||
{
|
||||
int ret = 0 ;
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef send /* Go to KEIL TCPnet send */
|
||||
ret = send(sd, buf, len, flags) ;
|
||||
if(ret != SCK_EWOULDBLOCK) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_CYASSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Send return code: %d\n", ret) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
return(ret) ;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
void Cyassl_sleep(int t)
|
||||
{
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
os_dly_wait(t/1000+1) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
int Cyassl_tcp_select(int sd, int timeout)
|
||||
{
|
||||
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int strlen(const char *s) ;
|
||||
|
||||
FILE * CyaSSL_fopen(const char *name, const char *openmode)
|
||||
{
|
||||
int i ; FILE * ret ;
|
||||
#define PATHSIZE 100
|
||||
char path[PATHSIZE] ; char *p ;
|
||||
|
||||
if(strlen(name) > PATHSIZE)return(NULL) ;
|
||||
|
||||
for(i = 0; i<= strlen(name); i++) {
|
||||
if(name[i] == '/')path[i] = '\\' ;
|
||||
else path[i] = name[i] ;
|
||||
}
|
||||
if(path[0] == '.' && path[1] == '\\') p = path + 2 ;
|
||||
else p = path ;
|
||||
|
||||
ret = fopen (p, openmode) ;
|
||||
|
||||
return(ret) ;
|
||||
}
|
||||
|
||||
#if defined (CYASSL_MDK5)
|
||||
#define getkey getchar
|
||||
#define sendchar putchar
|
||||
#else
|
||||
extern int getkey(void) ;
|
||||
extern int sendchar(int c) ;
|
||||
#endif
|
||||
|
||||
char * Cyassl_fgets ( char * str, int num, FILE * f )
|
||||
{
|
||||
int i ;
|
||||
|
||||
for(i = 0 ; i< num ; i++) {
|
||||
while((str[i] = getkey()) == 0) {
|
||||
#if defined (HAVE_KEIL_RTX) && !defined(CYASSL_CMSIS_RTOS)
|
||||
os_tsk_pass ();
|
||||
#else
|
||||
osThreadYield ();
|
||||
#endif
|
||||
}
|
||||
if(str[i] == '\n' || str[i] == '\012' || str[i] == '\015') {
|
||||
sendchar('\n') ;
|
||||
str[i++] = '\n' ;
|
||||
str[i] = '\0' ;
|
||||
break ;
|
||||
} else if(str[i] == '\010') { /* BS */
|
||||
if(i) { /* erace one char */
|
||||
sendchar('\010') ; sendchar(' ') ; sendchar('\010') ;
|
||||
i = (i>0 ? (i-2) : -1 ) ;
|
||||
continue ;
|
||||
}
|
||||
} else if(str[i] == '\033' || str[i] == '\004' ) { /* ESC or ^D */
|
||||
str[i] = '\0' ;
|
||||
return(0) ;
|
||||
}
|
||||
sendchar(str[i]) ;
|
||||
}
|
||||
return(str) ;
|
||||
}
|
@@ -32,8 +32,27 @@
|
||||
#endif
|
||||
#define SOCKET_T SOCKET
|
||||
#define SNPRINTF _snprintf
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
||||
#include <string.h>
|
||||
#include "rl_net.h"
|
||||
#define SOCKET_T int
|
||||
typedef int socklen_t ;
|
||||
static unsigned long inet_addr(const char *cp)
|
||||
{
|
||||
unsigned int a[4] ; unsigned long ret ;
|
||||
sscanf(cp, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]) ;
|
||||
ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
|
||||
return(ret) ;
|
||||
}
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
#define sleep(t) os_dly_wait(t/1000+1) ;
|
||||
#elif defined (WOLFSSL_CMSIS_RTOS)
|
||||
#define sleep(t) osDelay(t/1000+1) ;
|
||||
#endif
|
||||
|
||||
static int wolfssl_tcp_select(int sd, int timeout)
|
||||
{ return 0 ; }
|
||||
#define tcp_select(sd,t) wolfssl_tcp_select(sd, t) /* avoid conflicting Keil TCP tcp_select */
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
@@ -109,8 +128,8 @@
|
||||
|
||||
/* HPUX doesn't use socklent_t for third parameter to accept, unless
|
||||
_XOPEN_SOURCE_EXTENDED is defined */
|
||||
#if !defined(__hpux__) && !defined(WOLFSSL_MDK_ARM) && \
|
||||
!defined(WOLFSSL_IAR_ARM) && !defined(WOLFSSL_ROWLEY_ARM)
|
||||
#if !defined(__hpux__) && !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM)\
|
||||
&& !defined(WOLFSSL_ROWLEY_ARM) && !defined(WOLFSSL_KEIL_TCP_NET)
|
||||
typedef socklen_t* ACCEPT_THIRD_T;
|
||||
#else
|
||||
#if defined _XOPEN_SOURCE_EXTENDED
|
||||
@@ -124,12 +143,12 @@
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define CloseSocket(s) closesocket(s)
|
||||
#define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
||||
#define CloseSocket(s) closesocket(s)
|
||||
#define StartTCP()
|
||||
#define StartTCP()
|
||||
#else
|
||||
#define CloseSocket(s) close(s)
|
||||
#define StartTCP()
|
||||
#define StartTCP()
|
||||
#endif
|
||||
|
||||
|
||||
@@ -144,7 +163,7 @@
|
||||
#define WOLFSSL_THREAD
|
||||
#define INFINITE -1
|
||||
#define WAIT_OBJECT_0 0L
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_KEIL_TCP_NET)
|
||||
typedef unsigned int THREAD_RETURN;
|
||||
typedef int THREAD_TYPE;
|
||||
#define WOLFSSL_THREAD
|
||||
@@ -182,6 +201,21 @@
|
||||
#endif
|
||||
|
||||
/* all certs relative to wolfSSL home directory now */
|
||||
#if defined(WOLFSSL_NO_CURRDIR) || defined(WOLFSSL_MDK_SHELL)
|
||||
#define caCert "certs/ca-cert.pem"
|
||||
#define eccCert "certs/server-ecc.pem"
|
||||
#define eccKey "certs/ecc-key.pem"
|
||||
#define svrCert "certs/server-cert.pem"
|
||||
#define svrKey "certs/server-key.pem"
|
||||
#define cliCert "certs/client-cert.pem"
|
||||
#define cliKey "certs/client-key.pem"
|
||||
#define ntruCert "certs/ntru-cert.pem"
|
||||
#define ntruKey "certs/ntru-key.raw"
|
||||
#define dhParam "certs/dh2048.pem"
|
||||
#define cliEccKey "certs/ecc-client-key.pem"
|
||||
#define cliEccCert "certs/client-ecc-cert.pem"
|
||||
#define crlPemDir "certs/crl"
|
||||
#else
|
||||
#define caCert "./certs/ca-cert.pem"
|
||||
#define eccCert "./certs/server-ecc.pem"
|
||||
#define eccKey "./certs/ecc-key.pem"
|
||||
@@ -195,6 +229,7 @@
|
||||
#define cliEccKey "./certs/ecc-client-key.pem"
|
||||
#define cliEccCert "./certs/client-ecc-cert.pem"
|
||||
#define crlPemDir "./certs/crl"
|
||||
#endif
|
||||
|
||||
typedef struct tcp_ready {
|
||||
word16 ready; /* predicate */
|
||||
@@ -429,7 +464,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
||||
#ifndef TEST_IPV6
|
||||
/* peer could be in human readable form */
|
||||
if ( (peer != INADDR_ANY) && isalpha((int)peer[0])) {
|
||||
#ifdef WOLFSSL_MDK_ARM
|
||||
#if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
||||
int err;
|
||||
struct hostent* entry = gethostbyname(peer, &err);
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
@@ -452,7 +487,7 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
||||
|
||||
|
||||
#ifndef TEST_IPV6
|
||||
#if defined(WOLFSSL_MDK_ARM)
|
||||
#if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
||||
addr->sin_family = PF_INET;
|
||||
#else
|
||||
addr->sin_family = AF_INET_V;
|
||||
@@ -527,7 +562,8 @@ static INLINE void tcp_socket(SOCKET_T* sockfd, int udp)
|
||||
if (res < 0)
|
||||
err_sys("setsockopt SO_NOSIGPIPE failed\n");
|
||||
}
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS)
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS) ||\
|
||||
defined(WOLFSSL_KEIL_TCP_NET)
|
||||
/* nothing to define */
|
||||
#else /* no S_NOSIGPIPE */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@@ -575,7 +611,8 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_TIRTOS)
|
||||
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET) && \
|
||||
!defined(WOLFSSL_TIRTOS)
|
||||
static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
||||
{
|
||||
fd_set recvfds, errfds;
|
||||
@@ -619,7 +656,8 @@ static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
|
||||
build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfSSLIP), *port, udp);
|
||||
tcp_socket(sockfd, udp);
|
||||
|
||||
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)
|
||||
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)\
|
||||
&& !defined(WOLFSSL_KEIL_TCP_NET)
|
||||
{
|
||||
int res, on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
@@ -682,7 +720,8 @@ static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
||||
tcp_socket(sockfd, 1);
|
||||
|
||||
|
||||
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)
|
||||
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM) \
|
||||
&& !defined(WOLFSSL_KEIL_TCP_NET)
|
||||
{
|
||||
int res, on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
@@ -788,14 +827,14 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
||||
|
||||
static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
|
||||
{
|
||||
#ifdef USE_WINDOWS_API
|
||||
#ifdef USE_WINDOWS_API
|
||||
unsigned long blocking = 1;
|
||||
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
|
||||
if (ret == SOCKET_ERROR)
|
||||
err_sys("ioctlsocket failed");
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined (WOLFSSL_TIRTOS) \
|
||||
|| defined(WOLFSSL_VXWORKS)
|
||||
/* non blocking not suppported, for now */
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) \
|
||||
|| defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS)
|
||||
/* non blocking not suppported, for now */
|
||||
#else
|
||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
@@ -881,7 +920,7 @@ static INLINE unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
|
||||
extern double current_time();
|
||||
#else
|
||||
|
||||
#if !defined(WOLFSSL_MDK_ARM)
|
||||
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET)
|
||||
#include <sys/time.h>
|
||||
|
||||
static INLINE double current_time(void)
|
||||
@@ -1134,7 +1173,7 @@ static INLINE int CurrentDir(const char* str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_FS)
|
||||
/* KEIL-RL File System does not support relative directry */
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
#else
|
||||
|
Reference in New Issue
Block a user