Merge branch 'master' of https://github.com/tisb/cyassl into ti
This commit is contained in:
commit
ec5f3cc681
@ -783,7 +783,7 @@ static RNG rng;
|
||||
static char *certRSAname = "certs/rsa2048.der" ;
|
||||
static void set_Bench_RSA_File(char * cert) { certRSAname = cert ; }
|
||||
/* set by shell command */
|
||||
#elif defined(CYASSL_MDK_SHELL)
|
||||
#elif defined(CYASSL_MDK_SHELL) || defined(TIRTOS)
|
||||
/* nothing */
|
||||
#else
|
||||
static const char *certRSAname = "certs/rsa2048.der" ;
|
||||
@ -888,7 +888,7 @@ void bench_rsa(void)
|
||||
static char *certDHname = "certs/dh2048.der" ;
|
||||
void set_Bench_DH_File(char * cert) { certDHname = cert ; }
|
||||
/* set by shell command */
|
||||
#elif defined(CYASSL_MDK_SHELL)
|
||||
#elif defined(CYASSL_MDK_SHELL) || defined(TIRTOS)
|
||||
/* nothing */
|
||||
#else
|
||||
static const char *certDHname = "certs/dh2048.der" ;
|
||||
@ -1204,6 +1204,10 @@ void bench_eccKeyAgree(void)
|
||||
return (double)tickCount / 1000;
|
||||
}
|
||||
|
||||
#elif defined (TIRTOS)
|
||||
|
||||
extern double current_time(int reset);
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -320,6 +320,21 @@ time_t mqx_time(time_t* timer)
|
||||
|
||||
#endif /* FREESCALE_MQX */
|
||||
|
||||
#ifdef TIRTOS
|
||||
|
||||
time_t XTIME(time_t * timer)
|
||||
{
|
||||
time_t sec = 0;
|
||||
|
||||
sec = (time_t) MYTIME_gettime();
|
||||
|
||||
if (timer != NULL)
|
||||
*timer = sec;
|
||||
|
||||
return sec;
|
||||
}
|
||||
|
||||
#endif /* TIRTOS */
|
||||
|
||||
static INLINE word32 btoi(byte b)
|
||||
{
|
||||
|
@ -351,7 +351,42 @@ int UnLockMutex(CyaSSL_Mutex *m)
|
||||
else
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
|
||||
|
||||
#elif defined (TIRTOS)
|
||||
|
||||
int InitMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
Semaphore_Params params;
|
||||
|
||||
Semaphore_Params_init(¶ms);
|
||||
params.mode = Semaphore_Mode_BINARY;
|
||||
|
||||
*m = Semaphore_create(1, ¶ms, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FreeMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
Semaphore_delete(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
Semaphore_pend(*m, BIOS_WAIT_FOREVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UnLockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
Semaphore_post(*m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(CYASSL_MDK_ARM)|| defined(CYASSL_CMSIS_RTOS)
|
||||
|
||||
#if defined(CYASSL_CMSIS_RTOS)
|
||||
|
@ -756,6 +756,25 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(TIRTOS)
|
||||
|
||||
#include <xdc/runtime/Timestamp.h>
|
||||
#include <stdlib.h>
|
||||
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
{
|
||||
int i;
|
||||
srand(xdc_runtime_Timestamp_get32());
|
||||
|
||||
for (i = 0; i < sz; i++ ) {
|
||||
output[i] = rand() % 256;
|
||||
if ((i % 8) == 7) {
|
||||
srand(xdc_runtime_Timestamp_get32());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(CUSTOM_RAND_GENERATE)
|
||||
|
||||
/* Implement your own random generation function
|
||||
|
@ -241,7 +241,7 @@ enum ExtKeyUsage_Sum { /* From RFC 5280 */
|
||||
EKU_ANY_OID = 151, /* 2.5.29.37.0, anyExtendedKeyUsage */
|
||||
EKU_SERVER_AUTH_OID = 71, /* 1.3.6.1.5.5.7.3.1, id-kp-serverAuth */
|
||||
EKU_CLIENT_AUTH_OID = 72, /* 1.3.6.1.5.5.7.3.2, id-kp-clientAuth */
|
||||
EKU_OCSP_SIGN_OID = 79, /* 1.3.6.1.5.5.7.3.9, OCSPSigning */
|
||||
EKU_OCSP_SIGN_OID = 79 /* 1.3.6.1.5.5.7.3.9, OCSPSigning */
|
||||
};
|
||||
|
||||
|
||||
|
@ -62,6 +62,9 @@
|
||||
#endif
|
||||
#elif defined(CYASSL_CMSIS_RTOS)
|
||||
#include "cmsis_os.h"
|
||||
#elif defined(TIRTOS)
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/sysbios/knl/Semaphore.h>
|
||||
#else
|
||||
#ifndef SINGLE_THREADED
|
||||
#define CYASSL_PTHREADS
|
||||
@ -104,6 +107,8 @@
|
||||
#endif
|
||||
#elif defined(CYASSL_CMSIS_RTOS)
|
||||
typedef osMutexId CyaSSL_Mutex;
|
||||
#elif defined(TIRTOS)
|
||||
typedef ti_sysbios_knl_Semaphore_Handle CyaSSL_Mutex;
|
||||
#else
|
||||
#error Need a mutex type in multithreaded mode
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
@ -90,6 +90,9 @@
|
||||
/* Uncomment next line if building for EROAD */
|
||||
/* #define CYASSL_EROAD */
|
||||
|
||||
/* Uncomment next line if using TI-RTOS settings */
|
||||
/* #define TIRTOS */
|
||||
|
||||
#include <cyassl/ctaocrypt/visibility.h>
|
||||
|
||||
#ifdef IPHONE
|
||||
@ -267,6 +270,32 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TIRTOS
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define NO_WRITEV
|
||||
#define NO_CYASSL_DIR
|
||||
#define NO_SHA512
|
||||
#define NO_DH
|
||||
#define NO_HC128
|
||||
#define NO_RABBIT
|
||||
#define USE_FAST_MATH
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#define NO_DEV_RANDOM
|
||||
#define NO_FILESYSTEM
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#define NO_ERROR_STRINGS
|
||||
#define USER_TIME
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#pragma diag_suppress=Pa089
|
||||
#elif !defined(__GNUC__)
|
||||
/* Suppress the sslpro warning */
|
||||
#pragma diag_suppress=11
|
||||
#endif
|
||||
|
||||
#include <ti/ndk/nettools/mytime/mytime.h>
|
||||
#endif
|
||||
|
||||
#ifdef EBSNET
|
||||
#include "rtip.h"
|
||||
|
||||
|
@ -96,7 +96,8 @@
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
#elif defined(MBED)
|
||||
|
||||
#elif defined(TIRTOS)
|
||||
/* do nothing */
|
||||
#else
|
||||
#ifndef SINGLE_THREADED
|
||||
#define CYASSL_PTHREADS
|
||||
|
@ -34,6 +34,14 @@
|
||||
#define SNPRINTF _snprintf
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
#include <string.h>
|
||||
#elif defined(TIRTOS)
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <ti/sysbios/knl/Task.h>
|
||||
#define SOCKET_T int
|
||||
#else
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
@ -119,6 +127,10 @@
|
||||
typedef unsigned int THREAD_RETURN;
|
||||
typedef int THREAD_TYPE;
|
||||
#define CYASSL_THREAD
|
||||
#elif defined(TIRTOS)
|
||||
typedef void THREAD_RETURN;
|
||||
typedef Task_Handle THREAD_TYPE;
|
||||
#define CYASSL_THREAD
|
||||
#else
|
||||
typedef unsigned int THREAD_RETURN;
|
||||
typedef intptr_t THREAD_TYPE;
|
||||
@ -467,6 +479,9 @@ static INLINE void tcp_socket(SOCKET_T* sockfd, int udp)
|
||||
#ifdef USE_WINDOWS_API
|
||||
if (*sockfd == INVALID_SOCKET)
|
||||
err_sys("socket failed\n");
|
||||
#elif defined(TIRTOS)
|
||||
if (*sockfd == -1)
|
||||
err_sys("socket failed\n");
|
||||
#else
|
||||
if (*sockfd < 0)
|
||||
err_sys("socket failed\n");
|
||||
@ -481,7 +496,7 @@ static INLINE void tcp_socket(SOCKET_T* sockfd, int udp)
|
||||
if (res < 0)
|
||||
err_sys("setsockopt SO_NOSIGPIPE failed\n");
|
||||
}
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
#elif defined(CYASSL_MDK_ARM) || defined (TIRTOS)
|
||||
/* nothing to define */
|
||||
#else /* no S_NOSIGPIPE */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@ -529,7 +544,7 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
#if !defined(CYASSL_MDK_ARM)
|
||||
#if !defined(CYASSL_MDK_ARM) && !defined(TIRTOS)
|
||||
static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
||||
{
|
||||
fd_set recvfds, errfds;
|
||||
@ -555,6 +570,11 @@ static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
||||
|
||||
return TEST_SELECT_FAIL;
|
||||
}
|
||||
#elif defined(TIRTOS)
|
||||
static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
||||
{
|
||||
return TEST_RECV_READY;
|
||||
}
|
||||
#endif /* !CYASSL_MDK_ARM */
|
||||
|
||||
|
||||
@ -665,6 +685,11 @@ static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
}
|
||||
#elif defined (TIRTOS)
|
||||
/* Need mutex? */
|
||||
tcp_ready* ready = args->signal;
|
||||
ready->ready = 1;
|
||||
ready->port = port;
|
||||
#endif
|
||||
|
||||
*clientfd = udp_read_connect(*sockfd);
|
||||
@ -694,6 +719,11 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
}
|
||||
#elif defined (TIRTOS)
|
||||
/* Need mutex? */
|
||||
tcp_ready* ready = args->signal;
|
||||
ready->ready = 1;
|
||||
ready->port = port;
|
||||
#endif
|
||||
|
||||
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
|
||||
@ -715,7 +745,7 @@ static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
|
||||
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
|
||||
if (ret == SOCKET_ERROR)
|
||||
err_sys("ioctlsocket failed");
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
#elif defined(CYASSL_MDK_ARM) || defined (TIRTOS)
|
||||
/* non blocking not suppported, for now */
|
||||
#else
|
||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
||||
@ -798,6 +828,8 @@ static INLINE unsigned int my_psk_server_cb(CYASSL* ssl, const char* identity,
|
||||
return (double)count.QuadPart / freq.QuadPart;
|
||||
}
|
||||
|
||||
#elif defined(TIRTOS)
|
||||
extern double current_time();
|
||||
#else
|
||||
|
||||
#if !defined(CYASSL_MDK_ARM)
|
||||
@ -1035,6 +1067,7 @@ static INLINE int CurrentDir(const char* str)
|
||||
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
/* KEIL-RL File System does not support relative directry */
|
||||
#elif defined(TIRTOS)
|
||||
#else
|
||||
|
||||
#ifndef MAX_PATH
|
||||
@ -1702,7 +1735,7 @@ static INLINE void SetupPkCallbacks(CYASSL_CTX* ctx, CYASSL* ssl)
|
||||
|
||||
|
||||
|
||||
#if defined(__hpux__) || defined(__MINGW32__)
|
||||
#if defined(__hpux__) || defined(__MINGW32__) || defined (TIRTOS)
|
||||
|
||||
/* HP/UX doesn't have strsep, needed by test/suites.c */
|
||||
static INLINE char* strsep(char **stringp, const char *delim)
|
||||
|
@ -712,6 +712,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
SOCKADDR_IN_T addr;
|
||||
#ifdef USE_WINDOWS_API
|
||||
Sleep(500);
|
||||
#elif defined(TIRTOS)
|
||||
Task_sleep(1);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
@ -752,6 +754,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
/* give server a chance to bounce a message back to client */
|
||||
#ifdef USE_WINDOWS_API
|
||||
Sleep(500);
|
||||
#elif defined(TIRTOS)
|
||||
Task_sleep(1);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
@ -781,7 +785,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
ShowMemoryTracker();
|
||||
#endif /* USE_CYASSL_MEMORY */
|
||||
|
||||
#if !defined(TIRTOS)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,11 +254,12 @@ void echoclient_test(void* args)
|
||||
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL)
|
||||
CyaSSL_Debugging_ON();
|
||||
#endif
|
||||
|
||||
#ifndef TIRTOS
|
||||
if (CurrentDir("echoclient"))
|
||||
ChangeDirBack(2);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
#endif
|
||||
echoclient_test(&args);
|
||||
|
||||
CyaSSL_Cleanup();
|
||||
|
@ -107,12 +107,18 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
||||
#endif
|
||||
|
||||
#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL)
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL) && \
|
||||
!defined(TIRTOS)
|
||||
port = 0;
|
||||
#endif
|
||||
#if defined(USE_ANY_ADDR)
|
||||
useAnyAddr = 1;
|
||||
#endif
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
tcp_listen(&sockfd, &port, useAnyAddr, doDTLS);
|
||||
|
||||
#if defined(CYASSL_DTLS)
|
||||
@ -313,7 +319,14 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
||||
#endif
|
||||
|
||||
((func_args*)args)->return_code = 0;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
#ifndef TIRTOS
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +187,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
(void)trackMemory;
|
||||
(void)pkCallbacks;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
while ((ch = mygetopt(argc, argv, "?dbstnNufPp:v:l:A:c:k:S:oO:")) != -1) {
|
||||
switch (ch) {
|
||||
case '?' :
|
||||
@ -519,6 +523,8 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
|
||||
#if defined(CYASSL_MDK_SHELL) && defined(HAVE_MDK_RTX)
|
||||
os_dly_wait(500) ;
|
||||
#elif defined (TIRTOS)
|
||||
Task_yield();
|
||||
#endif
|
||||
|
||||
SSL_shutdown(ssl);
|
||||
@ -533,7 +539,13 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
ShowMemoryTracker();
|
||||
#endif /* USE_CYASSL_MEMORY */
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
#ifndef TIRTOS
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -2352,6 +2352,12 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
return (word32) mqxTime.SECONDS;
|
||||
}
|
||||
|
||||
#elif defined(TIRTOS)
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
return (word32) MYTIME_gettime();
|
||||
}
|
||||
|
||||
#elif defined(USER_TICKS)
|
||||
#if 0
|
||||
|
2
src/io.c
2
src/io.c
@ -69,6 +69,8 @@
|
||||
#define RNG CyaSSL_RNG
|
||||
/* for avoiding name conflict in "stm32f2xx.h" */
|
||||
static int errno;
|
||||
#elif defined(TIRTOS)
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
69
tests/api.c
69
tests/api.c
@ -738,8 +738,10 @@ int test_CyaSSL_CTX_load_verify_locations(void)
|
||||
"CyaSSL_CTX_load_verify_locations(ctx, NULL, NULL)");
|
||||
test_lvl(NULL, caCert, NULL, SSL_FAILURE,
|
||||
"CyaSSL_CTX_load_verify_locations(ctx, NULL, NULL)");
|
||||
#ifndef TIRTOS
|
||||
test_lvl(ctx, caCert, bogusFile, SSL_FAILURE,
|
||||
"CyaSSL_CTX_load_verify_locations(ctx, caCert, bogusFile)");
|
||||
#endif
|
||||
/* Add a test for the certs directory path loading. */
|
||||
/* There is a leak here. If you load a second cert, the first one
|
||||
is lost. */
|
||||
@ -925,6 +927,10 @@ static int test_CyaSSL_read_write(void)
|
||||
func_args server_args;
|
||||
THREAD_TYPE serverThread;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
StartTCP();
|
||||
|
||||
InitTcpReady(&ready);
|
||||
@ -948,6 +954,9 @@ static int test_CyaSSL_read_write(void)
|
||||
|
||||
FreeTcpReady(&ready);
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
return test_result;
|
||||
}
|
||||
|
||||
@ -966,13 +975,17 @@ THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args)
|
||||
char msg[] = "I hear you fa shizzle!";
|
||||
char input[1024];
|
||||
int idx;
|
||||
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
((func_args*)args)->return_code = TEST_FAIL;
|
||||
method = CyaSSLv23_server_method();
|
||||
ctx = CyaSSL_CTX_new(method);
|
||||
|
||||
#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL)
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL) && \
|
||||
!defined(TIRTOS)
|
||||
port = 0;
|
||||
#endif
|
||||
|
||||
@ -1033,9 +1046,17 @@ THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args)
|
||||
if (CyaSSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
|
||||
{
|
||||
/*err_sys("SSL_write failed");*/
|
||||
#ifdef TIRTOS
|
||||
return;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TIRTOS
|
||||
Task_yield();
|
||||
#endif
|
||||
|
||||
done:
|
||||
CyaSSL_shutdown(ssl);
|
||||
CyaSSL_free(ssl);
|
||||
@ -1043,7 +1064,13 @@ done:
|
||||
|
||||
CloseSocket(clientfd);
|
||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
#ifndef TIRTOS
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_client_nofail(void* args)
|
||||
@ -1059,6 +1086,10 @@ void test_client_nofail(void* args)
|
||||
int input;
|
||||
int msgSz = (int)strlen(msg);
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
((func_args*)args)->return_code = TEST_FAIL;
|
||||
method = CyaSSLv23_client_method();
|
||||
ctx = CyaSSL_CTX_new(method);
|
||||
@ -1119,6 +1150,10 @@ done2:
|
||||
|
||||
CloseSocket(sockfd);
|
||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1135,6 +1170,10 @@ void run_cyassl_client(void* args)
|
||||
char input[1024];
|
||||
int idx;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
((func_args*)args)->return_code = TEST_FAIL;
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
@ -1181,6 +1220,10 @@ void run_cyassl_client(void* args)
|
||||
CyaSSL_CTX_free(ctx);
|
||||
CloseSocket(sfd);
|
||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
}
|
||||
|
||||
THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
|
||||
@ -1198,10 +1241,14 @@ THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
|
||||
char input[1024];
|
||||
int idx;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
((func_args*)args)->return_code = TEST_FAIL;
|
||||
|
||||
#if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && \
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL)
|
||||
!defined(CYASSL_SNIFFER) && !defined(CYASSL_MDK_SHELL) && \
|
||||
!defined(TIRTOS)
|
||||
port = 0;
|
||||
#endif
|
||||
|
||||
@ -1255,7 +1302,9 @@ THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
|
||||
}
|
||||
|
||||
AssertIntEQ(len, CyaSSL_write(ssl, msg, len));
|
||||
|
||||
#ifdef TIRTOS
|
||||
Task_yield();
|
||||
#endif
|
||||
CyaSSL_shutdown(ssl);
|
||||
}
|
||||
|
||||
@ -1268,7 +1317,12 @@ THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
|
||||
|
||||
((func_args*)args)->return_code = TEST_SUCCESS;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
#ifndef TIRTOS
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_CyaSSL_client_server(callback_functions* client_callbacks,
|
||||
@ -1284,6 +1338,10 @@ void test_CyaSSL_client_server(callback_functions* client_callbacks,
|
||||
client_args.callbacks = client_callbacks;
|
||||
server_args.callbacks = server_callbacks;
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
/* RUN Server side */
|
||||
InitTcpReady(&ready);
|
||||
server_args.signal = &ready;
|
||||
@ -1296,6 +1354,9 @@ void test_CyaSSL_client_server(callback_functions* client_callbacks,
|
||||
join_thread(serverThread);
|
||||
|
||||
FreeTcpReady(&ready);
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SINGLE_THREADED*/
|
||||
|
@ -121,8 +121,17 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
int cli_argc, char** cli_argv,
|
||||
int addNoVerify, int addNonBlocking)
|
||||
{
|
||||
#ifdef TIRTOS
|
||||
func_args cliArgs = {0};
|
||||
func_args svrArgs = {0};
|
||||
cliArgs.argc = cli_argc;
|
||||
cliArgs.argv = cli_argv;
|
||||
svrArgs.argc = svr_argc;
|
||||
svrArgs.argv = svr_argv;
|
||||
#else
|
||||
func_args cliArgs = {cli_argc, cli_argv, 0, NULL, NULL};
|
||||
func_args svrArgs = {svr_argc, svr_argv, 0, NULL, NULL};
|
||||
#endif
|
||||
|
||||
tcp_ready ready;
|
||||
THREAD_TYPE serverThread;
|
||||
@ -183,7 +192,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
strcat(commandLine, flagSep);
|
||||
}
|
||||
}
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if !defined(USE_WINDOWS_API) && !defined(TIRTOS)
|
||||
/* add port 0 */
|
||||
if (svr_argc + 2 > MAX_ARGS)
|
||||
printf("cannot add the magic port number flag to server\n");
|
||||
@ -222,11 +231,15 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
|
||||
InitTcpReady(&ready);
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
/* start server */
|
||||
svrArgs.signal = &ready;
|
||||
start_thread(server_test, &svrArgs, &serverThread);
|
||||
wait_tcp_ready(&svrArgs);
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if !defined(USE_WINDOWS_API) && !defined(TIRTOS)
|
||||
if (ready.port != 0)
|
||||
{
|
||||
if (cli_argc + 2 > MAX_ARGS)
|
||||
@ -255,6 +268,9 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
FreeTcpReady(&ready);
|
||||
|
||||
return 0;
|
||||
|
30
tests/unit.c
30
tests/unit.c
@ -11,9 +11,16 @@
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
int unit_test(int argc, char** argv);
|
||||
|
||||
|
||||
#ifndef NO_TESTSUITE_MAIN_DRIVER
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return unit_test(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
int unit_test(int argc, char** argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -27,10 +34,12 @@ int main(int argc, char** argv)
|
||||
err_sys("Cavium OpenNitroxDevice failed");
|
||||
#endif /* HAVE_CAVIUM */
|
||||
|
||||
#ifndef TIRTOS
|
||||
if (CurrentDir("tests") || CurrentDir("_build"))
|
||||
ChangeDirBack(1);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
ChangeDirBack(3);
|
||||
#endif
|
||||
|
||||
if ( (ret = ApiTest()) != 0) {
|
||||
printf("api test failed with %d\n", ret);
|
||||
@ -85,6 +94,17 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
|
||||
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||
pthread_create(thread, 0, fun, args);
|
||||
return;
|
||||
#elif defined (TIRTOS)
|
||||
/* Initialize the defaults and set the parameters. */
|
||||
Task_Params taskParams;
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.arg0 = (UArg)args;
|
||||
taskParams.stackSize = 65535;
|
||||
*thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL);
|
||||
if (*thread == NULL) {
|
||||
printf("Failed to create new Task\n");
|
||||
}
|
||||
Task_yield();
|
||||
#else
|
||||
*thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0);
|
||||
#endif
|
||||
@ -97,6 +117,14 @@ void join_thread(THREAD_TYPE thread)
|
||||
(void)thread;
|
||||
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||
pthread_join(thread, 0);
|
||||
#elif defined (TIRTOS)
|
||||
while(1) {
|
||||
if (Task_getMode(thread) == Task_Mode_TERMINATED) {
|
||||
Task_sleep(5);
|
||||
break;
|
||||
}
|
||||
Task_yield();
|
||||
}
|
||||
#else
|
||||
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
|
||||
assert(res == WAIT_OBJECT_0);
|
||||
|
@ -57,7 +57,14 @@ enum {
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#ifndef NO_TESTSUITE_MAIN_DRIVER
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return testsuite_test(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
int testsuite_test(int argc, char** argv)
|
||||
{
|
||||
func_args server_args;
|
||||
|
||||
@ -80,6 +87,7 @@ int main(int argc, char** argv)
|
||||
CyaSSL_Debugging_ON();
|
||||
#endif
|
||||
|
||||
#if !defined(TIRTOS)
|
||||
if (CurrentDir("testsuite") || CurrentDir("_build"))
|
||||
ChangeDirBack(1);
|
||||
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||
@ -87,6 +95,12 @@ int main(int argc, char** argv)
|
||||
/* Derived Data Advanced -> Custom */
|
||||
/* Relative to Workspace, Build/Products */
|
||||
/* Debug or Release */
|
||||
#endif
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdOpenSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
server_args.signal = &ready;
|
||||
InitTcpReady(&ready);
|
||||
|
||||
@ -155,6 +169,10 @@ int main(int argc, char** argv)
|
||||
CyaSSL_Cleanup();
|
||||
FreeTcpReady(&ready);
|
||||
|
||||
#ifdef TIRTOS
|
||||
fdCloseSession(TaskSelf());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAVIUM
|
||||
CspShutdown(CAVIUM_DEV_ID);
|
||||
#endif
|
||||
@ -205,7 +223,8 @@ void simple_test(func_args* args)
|
||||
cliArgs.return_code = 0;
|
||||
|
||||
strcpy(svrArgs.argv[0], "SimpleServer");
|
||||
#if !defined(USE_WINDOWS_API) && !defined(CYASSL_SNIFFER)
|
||||
#if !defined(USE_WINDOWS_API) && !defined(CYASSL_SNIFFER) && \
|
||||
!defined(TIRTOS)
|
||||
strcpy(svrArgs.argv[svrArgs.argc++], "-p");
|
||||
strcpy(svrArgs.argv[svrArgs.argc++], "0");
|
||||
#endif
|
||||
@ -263,6 +282,17 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
|
||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||
pthread_create(thread, 0, fun, args);
|
||||
return;
|
||||
#elif defined(TIRTOS)
|
||||
/* Initialize the defaults and set the parameters. */
|
||||
Task_Params taskParams;
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.arg0 = (UArg)args;
|
||||
taskParams.stackSize = 65535;
|
||||
*thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL);
|
||||
if (*thread == NULL) {
|
||||
printf("Failed to create new Task\n");
|
||||
}
|
||||
Task_yield();
|
||||
#else
|
||||
*thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0);
|
||||
#endif
|
||||
@ -273,6 +303,14 @@ void join_thread(THREAD_TYPE thread)
|
||||
{
|
||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||
pthread_join(thread, 0);
|
||||
#elif defined(TIRTOS)
|
||||
while(1) {
|
||||
if (Task_getMode(thread) == Task_Mode_TERMINATED) {
|
||||
Task_sleep(5);
|
||||
break;
|
||||
}
|
||||
Task_yield();
|
||||
}
|
||||
#else
|
||||
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
|
||||
assert(res == WAIT_OBJECT_0);
|
||||
|
36
tirtos/README
Normal file
36
tirtos/README
Normal file
@ -0,0 +1,36 @@
|
||||
CyaSSL library for TI-RTOS
|
||||
|
||||
This directory contains the files that build CyaSSL library for TI-RTOS.
|
||||
Please follow the instructions in TI-RTOS user guide (www.ti.com/tool/ti-rtos)
|
||||
to build the CyaSSL library and the example applications.
|
||||
|
||||
Included Files
|
||||
---------------
|
||||
|
||||
1. CyaSSL library build files (packages/ti/net/cyassl)
|
||||
|
||||
Build instructions provided in TI-RTOS user guide (www.ti.com/tool/ti-rtos)
|
||||
|
||||
2. CTaoCrypt test application (packages/ti/net/cyassl/tests/ctaocrypt/test)
|
||||
|
||||
This application is the standard CTaoCrypt test application provided with
|
||||
CyaSSL.
|
||||
|
||||
It will be built along with the CyaSSL library. Load the built executable
|
||||
on the target and make sure the CyaSSL library works as expected.
|
||||
|
||||
3. CTaoCrypt benchmark application
|
||||
(packages/ti/net/cyassl/tests/ctaocrypt/benchmark)
|
||||
|
||||
This application is the standard CTaoCrypt benchmark application provided
|
||||
with CyaSSL.
|
||||
|
||||
It will be built along with the CyaSSL library. Load the built executable
|
||||
on the target and run to get the benchmark results for the configured
|
||||
CyaSSL library.
|
||||
|
||||
Examples Application
|
||||
--------------------
|
||||
|
||||
A simple 'TCP echo server with SSL' example application is provided with TI-RTOS
|
||||
product. Look in the TI-RTOS user guide for instructions to build examples.
|
86
tirtos/cyassl.bld
Normal file
86
tirtos/cyassl.bld
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Generally there is no need to edit this file!
|
||||
*
|
||||
* This file controls which libraries are built, as well as compiler options
|
||||
* to use.
|
||||
*
|
||||
* The contents of this file usually don't change, but having it in your
|
||||
* ownership allows you to tweak your compiler options. If you do change
|
||||
* this file, however, on the next upgrade of the product we recommend
|
||||
* that you take "cyassl.bld" file as supplied by the upgrade and then merge
|
||||
* your changes with it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ======== cyassl.bld ========
|
||||
* This script is run prior to all build scripts. It sets host-system-
|
||||
* independent values for targets and platforms, then it attempts to
|
||||
* find the host-system-specific user.bld script that sets rootDirs.
|
||||
*
|
||||
* These settings may be a function of the following global variables:
|
||||
*
|
||||
* environment a hash table of environment strings
|
||||
*
|
||||
* arguments an array of string arguments to the _config.bld script
|
||||
* initialized as follows:
|
||||
* arguments[0] - the file name of the _config.bld script
|
||||
* arguments[1] - the first argument specified in XDCARGS
|
||||
* :
|
||||
* arguments[n] - the n'th argument in XDCARGS
|
||||
*
|
||||
* Build an alias for xdc.om.xdc.bld.BuildEnvironment
|
||||
*/
|
||||
|
||||
var armOpts = " -ms ";
|
||||
var gnuOpts = "";
|
||||
var iarOpts = "";
|
||||
|
||||
/* Uncomment the following lines to build libraries for debug mode: */
|
||||
// Pkg.attrs.profile = "debug";
|
||||
// armOpts += " -g -o0 ";
|
||||
// gnuOpts += " -g ";
|
||||
// iarOpts += " --debug ";
|
||||
|
||||
var ccOpts = {
|
||||
"ti.targets.arm.elf.M4F" : armOpts,
|
||||
|
||||
"gnu.targets.arm.M4F" : gnuOpts,
|
||||
|
||||
"iar.targets.arm.M4F" : iarOpts,
|
||||
};
|
||||
|
||||
/* initialize local vars with those set in xdcpaths.mak (via XDCARGS) */
|
||||
for (arg = 0; arg < arguments.length; arg++) {
|
||||
/*
|
||||
* Get the compiler's installation directory.
|
||||
* For "ti.targets.arm.elf.M4F=/vendors/arm/6.1.0",
|
||||
* we get "/vendors/arm/6.1.0"
|
||||
*/
|
||||
var targetName = arguments[arg].split("=")[0];
|
||||
var rootDir = arguments[arg].split("=")[1];
|
||||
|
||||
/* only build for the specified compilers */
|
||||
if (rootDir == "" || rootDir == undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetName.match(/^TivaWareDir/) ) {
|
||||
TivaWareDir = rootDir;
|
||||
continue;
|
||||
}
|
||||
|
||||
var target = xdc.useModule(targetName);
|
||||
target.rootDir = rootDir;
|
||||
target.ccOpts.suffix += ccOpts[targetName];
|
||||
|
||||
Build.targets.$add(target);
|
||||
}
|
||||
|
||||
/* Include Path (needed to find NDK headers) */
|
||||
var ndkPath = "$(NDK_INSTALL_DIR)/packages/ti/ndk/";
|
||||
var cyasslPathInclude = " -I" + ndkPath + "/inc" + " -I" + ndkPath
|
||||
+ "/inc/bsd -DTIRTOS ";
|
||||
|
||||
/* lib/ is a generated directory that 'xdc clean' should remove */
|
||||
var Pkg = xdc.useModule('xdc.bld.PackageContents');
|
||||
Pkg.generatedFiles.$add("lib/");
|
74
tirtos/cyassl.mak
Normal file
74
tirtos/cyassl.mak
Normal file
@ -0,0 +1,74 @@
|
||||
#
|
||||
# ======== cyassl.mak ========
|
||||
#
|
||||
|
||||
# USER OPTIONAL STEP: These variables are set when building cyassl
|
||||
# through the tirtos.mak
|
||||
# Set up dependencies
|
||||
XDC_INSTALL_DIR ?= C:/ti/xdctools_3_24_02_30
|
||||
SYSBIOS_INSTALL_DIR ?= C:/ti/bios_6_34_01_14
|
||||
NDK_INSTALL_DIR ?= C:/ti/ndk_2_24_00_02
|
||||
TIRTOS_INSTALLATION_DIR ?= C:/ti/tirtos_tivac_2_00_00_22
|
||||
TivaWareDir ?= C:/ti/tivaware
|
||||
CYASSL_INSTALL_DIR ?= C:/cyassl/cyassl-2.9.4
|
||||
|
||||
#
|
||||
# Set location of various cgtools
|
||||
# These variables can be set here or on the command line. These
|
||||
# variables are set when building cyassl through tirtos.mak
|
||||
# USER OPTIONAL STEP: user can define below paths to compilers
|
||||
ti.targets.arm.elf.M4F ?=
|
||||
|
||||
gnu.targets.arm.M4F ?=
|
||||
|
||||
iar.targets.arm.M4F ?=
|
||||
|
||||
#
|
||||
# Set XDCARGS to some of the variables above. XDCARGS are passed
|
||||
# to the XDC build engine... which will load cyassl.bld... which will
|
||||
# extract these variables and use them to determine what to build and which
|
||||
# toolchains to use.
|
||||
#
|
||||
# Note that not all of these variables need to be set to something valid.
|
||||
# Unfortunately, since these vars are unconditionally assigned, your build line
|
||||
# will be longer and more noisy than necessary.
|
||||
#
|
||||
# Some background is here:
|
||||
# http://rtsc.eclipse.org/docs-tip/Command_-_xdc#Environment_Variables
|
||||
#
|
||||
XDCARGS= \
|
||||
ti.targets.arm.elf.M4F=\"$(ti.targets.arm.elf.M4F)\" \
|
||||
gnu.targets.arm.M4F=\"$(gnu.targets.arm.M4F)\" \
|
||||
iar.targets.arm.M4F=\"$(iar.targets.arm.M4F)\" \
|
||||
TivaWareDir=\"$(TivaWareDir)\"
|
||||
|
||||
#
|
||||
# Set XDCPATH to contain necessary repositories.
|
||||
#
|
||||
XDCPATH = $(SYSBIOS_INSTALL_DIR)/packages;$(NDK_INSTALL_DIR)/packages;$(CYASSL_INSTALL_DIR);$(TIRTOS_INSTALLATION_DIR)/packages;$(TivaWareDir);
|
||||
export XDCPATH
|
||||
|
||||
#
|
||||
# Set XDCOPTIONS. Use -v for a verbose build.
|
||||
#
|
||||
#XDCOPTIONS=v
|
||||
export XDCOPTIONS
|
||||
|
||||
#
|
||||
# Set XDC executable command
|
||||
# Note that XDCBUILDCFG points to the cyassl.bld file which uses
|
||||
# the arguments specified by XDCARGS
|
||||
#
|
||||
XDC = $(XDC_INSTALL_DIR)/xdc XDCARGS="$(XDCARGS)" XDCBUILDCFG=./cyassl.bld
|
||||
|
||||
######################################################
|
||||
## Shouldnt have to modify anything below this line ##
|
||||
######################################################
|
||||
|
||||
all:
|
||||
@ echo building cyassl packages ...
|
||||
@ $(XDC) -Pr ./packages
|
||||
|
||||
clean:
|
||||
@ echo cleaning cyassl packages ...
|
||||
@ $(XDC) clean -Pr ./packages
|
43
tirtos/packages/ti/net/cyassl/package.bld
Normal file
43
tirtos/packages/ti/net/cyassl/package.bld
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* ======== package.bld ========
|
||||
* Build script for CyaSSL library
|
||||
*/
|
||||
var Build = xdc.useModule('xdc.bld.BuildEnvironment');
|
||||
var Pkg = xdc.useModule('xdc.bld.PackageContents');
|
||||
|
||||
/* make command to search for the srcs */
|
||||
Pkg.makePrologue = "vpath %.c $(subst ;, ,$(XPKGPATH))";
|
||||
|
||||
/* CYASSL sources */
|
||||
var cyaSSLObjList = [
|
||||
"ctaocrypt/src/aes.c",
|
||||
"ctaocrypt/src/arc4.c",
|
||||
"ctaocrypt/src/asn.c",
|
||||
"ctaocrypt/src/coding.c",
|
||||
"ctaocrypt/src/des3.c",
|
||||
"ctaocrypt/src/dsa.c",
|
||||
"ctaocrypt/src/error.c",
|
||||
"ctaocrypt/src/hmac.c",
|
||||
"ctaocrypt/src/logging.c",
|
||||
"ctaocrypt/src/md4.c",
|
||||
"ctaocrypt/src/md5.c",
|
||||
"ctaocrypt/src/memory.c",
|
||||
"ctaocrypt/src/port.c",
|
||||
"ctaocrypt/src/pwdbased.c",
|
||||
"ctaocrypt/src/random.c",
|
||||
"ctaocrypt/src/rsa.c",
|
||||
"ctaocrypt/src/sha.c",
|
||||
"ctaocrypt/src/sha256.c",
|
||||
"ctaocrypt/src/tfm.c",
|
||||
"src/internal.c",
|
||||
"src/io.c",
|
||||
"src/keys.c",
|
||||
"src/ssl.c",
|
||||
"src/tls.c",
|
||||
];
|
||||
|
||||
for each (var targ in Build.targets) {
|
||||
var libOptions = {incs: cyasslPathInclude};
|
||||
var lib = Pkg.addLibrary("lib/" + Pkg.name, targ, libOptions);
|
||||
lib.addObjects(cyaSSLObjList);
|
||||
}
|
7
tirtos/packages/ti/net/cyassl/package.xdc
Normal file
7
tirtos/packages/ti/net/cyassl/package.xdc
Normal file
@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* ======== ti.net.cyassl ========
|
||||
* CyaSSL library for TI-RTOS
|
||||
*
|
||||
*/
|
||||
package ti.net.cyassl {
|
||||
}
|
12
tirtos/packages/ti/net/cyassl/package.xs
Normal file
12
tirtos/packages/ti/net/cyassl/package.xs
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* ======== package.xs ========
|
||||
*/
|
||||
|
||||
/*
|
||||
* ======== getLibs ========
|
||||
* Contribute CyaSSL library.
|
||||
*/
|
||||
function getLibs(prog)
|
||||
{
|
||||
return ("lib/" + this.$name + ".a" + prog.build.target.suffix);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x000FFFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2003FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x8000;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x10000;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* ======== benchmark.cfg ========
|
||||
*/
|
||||
|
||||
/* ================ General configuration ================ */
|
||||
var Defaults = xdc.useModule('xdc.runtime.Defaults');
|
||||
var Diags = xdc.useModule('xdc.runtime.Diags');
|
||||
var Error = xdc.useModule('xdc.runtime.Error');
|
||||
var Log = xdc.useModule('xdc.runtime.Log');
|
||||
var Main = xdc.useModule('xdc.runtime.Main');
|
||||
var Memory = xdc.useModule('xdc.runtime.Memory');
|
||||
var System = xdc.useModule('xdc.runtime.System');
|
||||
var Text = xdc.useModule('xdc.runtime.Text');
|
||||
var TimeStamp = xdc.useModule('xdc.runtime.Timestamp');
|
||||
|
||||
var BIOS = xdc.useModule('ti.sysbios.BIOS');
|
||||
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
|
||||
var Task = xdc.useModule('ti.sysbios.knl.Task');
|
||||
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
|
||||
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
|
||||
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
|
||||
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
|
||||
|
||||
BIOS.heapSize = 100000;
|
||||
Task.idleTaskStackSize = 768;
|
||||
Program.stack = 2048;
|
||||
|
||||
/* ================ System configuration ================ */
|
||||
var SysMin = xdc.useModule('xdc.runtime.SysMin');
|
||||
SysMin.bufSize = 128;
|
||||
System.SupportProxy = SysMin;
|
||||
|
||||
/* Enable Semihosting for GNU targets to print to CCS console */
|
||||
if (Program.build.target.$name.match(/gnu/)) {
|
||||
var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
|
||||
}
|
||||
|
||||
/* ================ NDK configuration ================ */
|
||||
var Ndk = xdc.loadPackage('ti.ndk.config');
|
||||
var Global = xdc.useModule('ti.ndk.config.Global');
|
||||
var Ip = xdc.useModule('ti.ndk.config.Ip');
|
||||
var Udp = xdc.useModule('ti.ndk.config.Udp');
|
||||
var Tcp = xdc.useModule('ti.ndk.config.Tcp');
|
||||
|
||||
Global.IPv6 = false;
|
||||
Global.stackLibType = Global.MIN;
|
||||
|
||||
Global.pktNumFrameBufs = 10;
|
||||
Global.memRawPageCount = 6;
|
||||
Global.ndkThreadStackSize = 1536;
|
||||
Global.lowTaskStackSize = 1024;
|
||||
Global.normTaskStackSize = 1024;
|
||||
Global.highTaskStackSize = 1024;
|
||||
Tcp.transmitBufSize = 1024;
|
||||
Tcp.receiveBufSize = 1024;
|
||||
|
||||
|
||||
/* ================ Driver configuration ================ */
|
||||
var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS');
|
||||
|
||||
var EMAC = xdc.useModule('ti.drivers.EMAC');
|
||||
EMAC.libType = EMAC.LibType_NonInstrumented;
|
||||
var GPIO = xdc.useModule('ti.drivers.GPIO');
|
||||
GPIO.libType = GPIO.LibType_NonInstrumented;
|
||||
|
||||
/* ================ CyaSSL configuration ================ */
|
||||
try {
|
||||
var CyaSSL = xdc.loadPackage('ti.net.cyassl');
|
||||
}
|
||||
catch (e) {
|
||||
print("Error: Could not find CyaSSL library! Make sure the CyaSSL library"
|
||||
+ " is built and package path is updated for the build tool"
|
||||
+ " to find the library. More detailed CyaSSL build instructions"
|
||||
+ " can be found in the TI-RTOS user guide.");
|
||||
}
|
106
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/benchmark/main.c
Normal file
106
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/benchmark/main.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* ======== main.c ========
|
||||
* Entry point for Benchmark application
|
||||
*/
|
||||
/* BIOS Header files */
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/sysbios/knl/Swi.h>
|
||||
#include <xdc/runtime/System.h>
|
||||
#include <ti/sysbios/knl/Task.h>
|
||||
#include <ti/sysbios/hal/Timer.h>
|
||||
|
||||
static int initialized = 0;
|
||||
static double msTicks = 0;
|
||||
static Timer_Handle hdl = NULL;
|
||||
|
||||
double current_time(int reset);
|
||||
static void tick(unsigned int arg0);
|
||||
void msTimer_init(void);
|
||||
void runBenchmarks(UArg arg0, UArg arg1);
|
||||
extern int benchmark_test(void* args);
|
||||
|
||||
/*
|
||||
* ======== runBenchmarks ========
|
||||
* Run the CyaSSL benchmark application
|
||||
*/
|
||||
void runBenchmarks(UArg arg0, UArg arg1)
|
||||
{
|
||||
void *args = NULL;
|
||||
msTimer_init();
|
||||
|
||||
System_printf("Running benchmarks...\n");
|
||||
System_flush();
|
||||
benchmark_test(args);
|
||||
System_printf("Benchmarks completed.\n");
|
||||
|
||||
BIOS_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== ticks ========
|
||||
* Keeps track of time in millisec
|
||||
*/
|
||||
static void tick(unsigned int arg0)
|
||||
{
|
||||
Swi_disable();
|
||||
msTicks++;
|
||||
Swi_enable();
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== current_time ========
|
||||
* Returns the time in sec (double precision)
|
||||
*/
|
||||
double current_time(int reset)
|
||||
{
|
||||
if (reset) {
|
||||
msTicks = 0;
|
||||
}
|
||||
|
||||
return (msTicks/1000);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== msTimer_init ========
|
||||
* Sets up a BIOS timer with millisec period
|
||||
*/
|
||||
void msTimer_init(void)
|
||||
{
|
||||
Timer_Params params;
|
||||
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
Timer_Params_init(¶ms);
|
||||
params.period = 1000;
|
||||
params.periodType = Timer_PeriodType_MICROSECS;
|
||||
params.runMode = Timer_RunMode_CONTINUOUS;
|
||||
params.startMode = Timer_StartMode_AUTO;
|
||||
hdl = Timer_create(-1, (ti_sysbios_hal_Timer_FuncPtr)tick,
|
||||
¶ms, NULL);
|
||||
if (!hdl) {
|
||||
System_abort("msTimer_init: Timer creation failed.\n");
|
||||
}
|
||||
|
||||
/* Set flag indicating that initialization has completed */
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== main ========
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
/* Initialize the defaults and set the parameters. */
|
||||
Task_Handle handle;
|
||||
Task_Params taskParams;
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.stackSize = 65535;
|
||||
handle = Task_create(runBenchmarks, &taskParams, NULL);
|
||||
if (handle == NULL) {
|
||||
System_printf("main: Failed to create new Task.\n");
|
||||
}
|
||||
|
||||
BIOS_start();
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* ======== package.bld ========
|
||||
* Build script for benchmark application
|
||||
*/
|
||||
|
||||
if ((typeof(TivaWareDir) == undefined) || (TivaWareDir == "")) {
|
||||
throw("ERROR: NO VALID TIVAWARE PATH DEFINED!!!");
|
||||
}
|
||||
|
||||
var Build = xdc.useModule('xdc.bld.BuildEnvironment');
|
||||
var Pkg = xdc.useModule('xdc.bld.PackageContents');
|
||||
|
||||
/* make command to search for the srcs */
|
||||
Pkg.makePrologue = "vpath %.c $(subst ;, ,$(XPKGPATH))";
|
||||
|
||||
var srcs = [
|
||||
"main.c",
|
||||
"ctaocrypt/benchmark/benchmark.c",
|
||||
"examples/EK_TM4C1294XL/EK_TM4C1294XL.c",
|
||||
];
|
||||
|
||||
for each (var targ in Build.targets) {
|
||||
|
||||
var lnkOpts = " -l" + TivaWareDir + "/driverlib/ccs/Debug/driverlib.lib";
|
||||
var platform = "ti.platforms.tiva:TM4C1294NCPDT:1";
|
||||
if (targ.$name.match(/^ti/)) {
|
||||
lnkOpts += " -x ";
|
||||
}
|
||||
else if (targ.$name.match(/^iar/)) {
|
||||
lnkOpts = TivaWareDir + "/driverlib/ccs/Debug/driverlib.lib"
|
||||
+ " --config TM4C1294NC.icf";
|
||||
platform = "ti.platforms.tiva:TM4C1294NCPDT";
|
||||
|
||||
/* Floating point print support */
|
||||
var suffix = targ.$orig.lnkOpts.suffix;
|
||||
targ.$orig.lnkOpts.suffix = suffix.replace(/PrintfSmall/, "PrintfFull");
|
||||
}
|
||||
|
||||
var exeOptions = {incs: cyasslPathInclude
|
||||
+ " -DNO_MAIN_DRIVER -D_INCLUDE_NIMU_CODE -DBENCH_EMBEDDED "
|
||||
+ " -DTIVAWARE -DPART_TM4C1294NCPDT",
|
||||
lopts: lnkOpts
|
||||
};
|
||||
|
||||
var exe = Pkg.addExecutable("benchmark", targ,
|
||||
platform, exeOptions);
|
||||
exe.addObjects(srcs);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* ======== ti.net.cyassl.tests.ctaocrypt.benchmark ========
|
||||
* CTaoCrypt Benchmark Application
|
||||
*/
|
||||
package ti.net.cyassl.tests.ctaocrypt.benchmark {
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x000FFFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2003FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x8000;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x10000;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
56
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/test/main.c
Normal file
56
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/test/main.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* ======== main.c ========
|
||||
* Entry point to Ctaocrypt Test Application
|
||||
*/
|
||||
|
||||
/* XDCtools Header files */
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/sysbios/knl/Task.h>
|
||||
#include <xdc/runtime/System.h>
|
||||
|
||||
/* func_args from test.h, so don't have to pull in other junk */
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
extern int ctaocrypt_test(void* args);
|
||||
|
||||
/*
|
||||
* ======== testCtaocrypt ========
|
||||
* Run the Ctaocrypt test
|
||||
*/
|
||||
void testCtaocrypt(UArg arg0, UArg arg1)
|
||||
{
|
||||
System_printf("Running ctaocrypt tests...\n");
|
||||
System_flush();
|
||||
ctaocrypt_test((void *)arg0);
|
||||
System_printf("Tests completed.\n");
|
||||
|
||||
BIOS_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== main ========
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
func_args args;
|
||||
args.argc = argc;
|
||||
args.argv = argv;
|
||||
/* Initialize the defaults and set the parameters. */
|
||||
Task_Handle handle;
|
||||
Task_Params taskParams;
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.arg0 = (UArg)&args;
|
||||
taskParams.stackSize = 65535;
|
||||
handle =Task_create(testCtaocrypt, &taskParams, NULL);
|
||||
if (handle == NULL) {
|
||||
System_printf("main: Failed to create new Task.\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
BIOS_start();
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* ======== package.bld ========
|
||||
* Build script for Ctaocrypt Test
|
||||
*/
|
||||
|
||||
if ((typeof(TivaWareDir) == undefined) || (TivaWareDir == "")) {
|
||||
throw("ERROR: NO VALID TIVAWARE PATH DEFINED!!!");
|
||||
}
|
||||
|
||||
var Build = xdc.useModule('xdc.bld.BuildEnvironment');
|
||||
var Pkg = xdc.useModule('xdc.bld.PackageContents');
|
||||
|
||||
/* make command to search for the srcs */
|
||||
Pkg.makePrologue = "vpath %.c $(subst ;, ,$(XPKGPATH))";
|
||||
|
||||
var srcs = [
|
||||
"main.c",
|
||||
"ctaocrypt/test/test.c",
|
||||
"examples/EK_TM4C1294XL/EK_TM4C1294XL.c",
|
||||
];
|
||||
|
||||
for each (var targ in Build.targets) {
|
||||
var lnkOpts = " -l" + TivaWareDir + "/driverlib/ccs/Debug/driverlib.lib"
|
||||
var platform = "ti.platforms.tiva:TM4C1294NCPDT:1";
|
||||
if (targ.$name.match(/^ti/)) {
|
||||
lnkOpts += " -x ";
|
||||
}
|
||||
else if (targ.$name.match(/^iar/)) {
|
||||
lnkOpts = TivaWareDir + "/driverlib/ccs/Debug/driverlib.lib"
|
||||
+ " --config TM4C1294NC.icf";
|
||||
platform = "ti.platforms.tiva:TM4C1294NCPDT";
|
||||
}
|
||||
|
||||
var exeOptions = {incs: cyasslPathInclude
|
||||
+ " -DNO_MAIN_DRIVER -D_INCLUDE_NIMU_CODE -DBENCH_EMBEDDED "
|
||||
+ " -DTIVAWARE -DPART_TM4C1294NCPDT",
|
||||
lopts: lnkOpts,
|
||||
};
|
||||
|
||||
var exe = Pkg.addExecutable("test", targ,
|
||||
platform, exeOptions);
|
||||
exe.addObjects(srcs);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* ======== ti.net.cyassl.tests.ctaocrypt.test ========
|
||||
* Ctaocrypt Test Application
|
||||
*/
|
||||
package ti.net.cyassl.tests.ctaocrypt.test {
|
||||
}
|
75
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/test/test.cfg
Normal file
75
tirtos/packages/ti/net/cyassl/tests/ctaocrypt/test/test.cfg
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* ======== test.cfg ========
|
||||
*/
|
||||
|
||||
/* ================ General configuration ================ */
|
||||
var Defaults = xdc.useModule('xdc.runtime.Defaults');
|
||||
var Diags = xdc.useModule('xdc.runtime.Diags');
|
||||
var Error = xdc.useModule('xdc.runtime.Error');
|
||||
var Log = xdc.useModule('xdc.runtime.Log');
|
||||
var Main = xdc.useModule('xdc.runtime.Main');
|
||||
var Memory = xdc.useModule('xdc.runtime.Memory');
|
||||
var System = xdc.useModule('xdc.runtime.System');
|
||||
var Text = xdc.useModule('xdc.runtime.Text');
|
||||
var TimeStamp = xdc.useModule('xdc.runtime.Timestamp');
|
||||
|
||||
var BIOS = xdc.useModule('ti.sysbios.BIOS');
|
||||
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
|
||||
var Task = xdc.useModule('ti.sysbios.knl.Task');
|
||||
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
|
||||
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
|
||||
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
|
||||
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
|
||||
|
||||
BIOS.heapSize = 100000;
|
||||
Task.idleTaskStackSize = 768;
|
||||
Program.stack = 2048;
|
||||
|
||||
/* ================ System configuration ================ */
|
||||
var SysMin = xdc.useModule('xdc.runtime.SysMin');
|
||||
SysMin.bufSize = 128;
|
||||
System.SupportProxy = SysMin;
|
||||
|
||||
/* Enable Semihosting for GNU targets to print to CCS console */
|
||||
if (Program.build.target.$name.match(/gnu/)) {
|
||||
var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
|
||||
}
|
||||
|
||||
/* ================ NDK configuration ================ */
|
||||
var Ndk = xdc.loadPackage('ti.ndk.config');
|
||||
var Global = xdc.useModule('ti.ndk.config.Global');
|
||||
var Ip = xdc.useModule('ti.ndk.config.Ip');
|
||||
var Udp = xdc.useModule('ti.ndk.config.Udp');
|
||||
var Tcp = xdc.useModule('ti.ndk.config.Tcp');
|
||||
|
||||
Global.IPv6 = false;
|
||||
Global.stackLibType = Global.MIN;
|
||||
|
||||
Global.pktNumFrameBufs = 10;
|
||||
Global.memRawPageCount = 6;
|
||||
Global.ndkThreadStackSize = 1536;
|
||||
Global.lowTaskStackSize = 1024;
|
||||
Global.normTaskStackSize = 1024;
|
||||
Global.highTaskStackSize = 1024;
|
||||
Tcp.transmitBufSize = 1024;
|
||||
Tcp.receiveBufSize = 1024;
|
||||
|
||||
|
||||
/* ================ Driver configuration ================ */
|
||||
var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS');
|
||||
|
||||
var EMAC = xdc.useModule('ti.drivers.EMAC');
|
||||
EMAC.libType = EMAC.LibType_NonInstrumented;
|
||||
var GPIO = xdc.useModule('ti.drivers.GPIO');
|
||||
GPIO.libType = GPIO.LibType_NonInstrumented;
|
||||
|
||||
/* ================ CyaSSL configuration ================ */
|
||||
try {
|
||||
var CyaSSL = xdc.loadPackage('ti.net.cyassl');
|
||||
}
|
||||
catch (e) {
|
||||
print("Error: Could not find CyaSSL library! Make sure the CyaSSL library"
|
||||
+ " is built and package path is updated for the build tool"
|
||||
+ " to find the library. More detailed CyaSSL build instructions"
|
||||
+ " can be found in the TI-RTOS user guide.");
|
||||
}
|
Loading…
Reference in New Issue
Block a user