Remove some irrelevant CyaSSL files.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\CyaSSL-Lib.ewp</path>
|
||||
</project>
|
||||
<project>
|
||||
<path>$WS_DIR$\wolfCrypt-benchmark.ewp</path>
|
||||
</project>
|
||||
<project>
|
||||
<path>$WS_DIR$\wolfCrypt-test.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
/* benchmark-main.c
|
||||
*
|
||||
* Copyright (C) 2006-2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
func_args args = { 0 } ;
|
||||
|
||||
extern int benchmark_test(void *args) ;
|
||||
|
||||
main(void) {
|
||||
benchmark_test(&args) ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
/* test-main.c
|
||||
*
|
||||
* Copyright (C) 2006-2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
func_args args = { 0 } ;
|
||||
|
||||
extern int ctaocrypt_test(void *args) ;
|
||||
|
||||
main(void) {
|
||||
ctaocrypt_test(&args) ;
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
/*###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__ = 0x0007FFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x2000;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x2000;
|
||||
/**** 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 };
|
||||
//initialize by copy with packing = none { section __DLIB_PERTHREAD }; // Required in a multi-threaded application
|
||||
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 };
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
||||
/*###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__ = 0x0;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x0;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x000FFFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x1FFF0000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x2000;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x3000;
|
||||
/**** 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 };
|
@ -1,49 +0,0 @@
|
||||
CyaSSL IAR Project Files
|
||||
|
||||
This directory contains project files for IAR EWARM IDE. These
|
||||
projects have been set up to generic ARM Cortex-M MPUs.
|
||||
In order to generate project for specific target MPU, take following steps.
|
||||
|
||||
|
||||
Included Project Files
|
||||
-----------------------
|
||||
1. Workspace: CyaSSL-Lib.eww
|
||||
The workspace includes CyaSSL-Lib library and wolfCrypt-test, wolfCrypt-benchmark
|
||||
executable projects. The library project generates full set library of wolfCrypt
|
||||
and CyaSSL functions.
|
||||
|
||||
2. Test suites Project: wolfCrypt-test.ewp
|
||||
generates test.out test suites executable
|
||||
|
||||
3. Benchmark Project: wolfCrypt-benchmark.ewp
|
||||
generates benchmark.out benchmark executable
|
||||
|
||||
Set Up Steps
|
||||
------------
|
||||
0. Default Setting
|
||||
Default Target of the projects are set to Cortex-M3 Simulator.
|
||||
For check the projects, you can build and download to the simulator.
|
||||
Open Terminal I/O window, by "view"->"Terminal I/O", and start execution.
|
||||
|
||||
1. Project option settings
|
||||
For each project,...
|
||||
General Options: Choose appropriate "Target" options
|
||||
|
||||
For executable projects,...
|
||||
Add "SystemInit" and "startup" for your MPU
|
||||
Debugger: Choose your debug "Driver"
|
||||
|
||||
2. For benchmark project,...
|
||||
Write your own "current_time" benchmark timer under "defined(CYASSL_IAR_ARM)" in benchmark.c
|
||||
|
||||
3. settings.h
|
||||
Uncomment the "CYASSL_IAR_ARM" define located in:
|
||||
<cyassl_root>/cyassl/ctaocrypt/settings.
|
||||
|
||||
4. Build and download
|
||||
Go to "Project->Make" and "Download and Debug" in Menu bar for EWARM build and download.
|
||||
|
||||
|
||||
Support
|
||||
-------
|
||||
Please send questions or comments to support@wolfssl.com
|
@ -1,166 +0,0 @@
|
||||
/* time.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 <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize RTC
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include "lpc43xx_rtc.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
|
||||
static void init_RTC()
|
||||
{
|
||||
/* Enable GPIO register interface clock */
|
||||
LPC_CCU1->CLK_M4_GPIO_CFG |= 1;
|
||||
while (!(LPC_CCU1->CLK_M4_GPIO_STAT & 1)) ;
|
||||
|
||||
/* RTC Block section ------------------------------------------------------ */
|
||||
/* Init RTC module */
|
||||
RTC_Init(LPC_RTC);
|
||||
|
||||
/* Set ALARM time for second */
|
||||
RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 30);
|
||||
|
||||
/* Set the AMR for 30s match alarm interrupt */
|
||||
RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
|
||||
|
||||
/* Set the CIIR for minute counter interrupt*/
|
||||
RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_MINUTE, ENABLE);
|
||||
|
||||
/* Enable rtc (starts increase the tick counter and second counter register) */
|
||||
RTC_Cmd(LPC_RTC, ENABLE);
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize TIM
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lpc43xx_timer.h"
|
||||
|
||||
static void init_TIM()
|
||||
{
|
||||
TIM_TIMERCFG_Type TIM_ConfigStruct;
|
||||
/* Initialize timer 0, prescale count time of 1uS */
|
||||
TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_TICKVAL;
|
||||
TIM_ConfigStruct.PrescaleValue = 204; /* 204MHz */
|
||||
/* Set configuration for Tim_config and Tim_MatchConfig */
|
||||
TIM_Init(LPC_TIMER2, TIM_TIMER_MODE,&TIM_ConfigStruct);
|
||||
TIM_ResetCounter(LPC_TIMER2);
|
||||
/* To start timer 2 */
|
||||
TIM_Cmd(LPC_TIMER2,ENABLE);
|
||||
}
|
||||
|
||||
double current_time()
|
||||
{
|
||||
return (double)LPC_TIMER2->TC/1000000.0;
|
||||
}
|
||||
|
||||
|
||||
void init_time(void) {
|
||||
init_RTC() ;
|
||||
init_TIM() ;
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct tm *Cyassl_MDK_gmtime(const time_t *c)
|
||||
{
|
||||
static struct tm date ;
|
||||
|
||||
RTC_TIME_Type RTCFullTime;
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
|
||||
date.tm_year = RTCFullTime.YEAR + 100 ;
|
||||
date.tm_mon = RTCFullTime.MONTH - 1 ;
|
||||
date.tm_mday = RTCFullTime.DOM ;
|
||||
date.tm_hour = RTCFullTime.HOUR ;
|
||||
date.tm_min = RTCFullTime.MIN ;
|
||||
date.tm_sec = RTCFullTime.SEC ;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
{
|
||||
extern void CYASSL_MSG(char *msg) ;
|
||||
char msg[100] ;
|
||||
sprintf(msg, "Debug::Cyassl_KEIL_gmtime(DATE=/%4d/%02d/%02d TIME=%02d:%02d:%02d)\n",
|
||||
RTCFullTime.YEAR+2000, RTCFullTime.MONTH, RTCFullTime.DOM,
|
||||
RTCFullTime.HOUR, RTCFullTime.MIN, RTCFullTime.SEC) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return(&date) ;
|
||||
}
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void time_main(void *args)
|
||||
{
|
||||
char * datetime ;
|
||||
int year ;
|
||||
RTC_TIME_Type RTCFullTime;
|
||||
|
||||
if( args == NULL || ((func_args *)args)->argc == 1) {
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
|
||||
RTCFullTime.MONTH, RTCFullTime.DOM, RTCFullTime.YEAR+2000,
|
||||
RTCFullTime.HOUR, RTCFullTime.MIN, RTCFullTime.SEC) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 'd' ) {
|
||||
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d/%d/%d",
|
||||
(int *)&RTCFullTime.MONTH, (int *)&RTCFullTime.DOM, &year) ;
|
||||
RTCFullTime.YEAR = year - 2000 ;
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MONTH, RTCFullTime.MONTH);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_YEAR, RTCFullTime.YEAR);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH, RTCFullTime.DOM);
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 't' ) {
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d:%d:%d",
|
||||
(int *)&RTCFullTime.HOUR,
|
||||
(int *)&RTCFullTime.MIN,
|
||||
(int *)&RTCFullTime.SEC
|
||||
) ;
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, RTCFullTime.SEC);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MINUTE, RTCFullTime.MIN);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_HOUR, RTCFullTime.HOUR);
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,261 +0,0 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rt_sys.h>
|
||||
|
||||
|
||||
#include <File_Config.h>
|
||||
|
||||
#pragma import(__use_no_semihosting_swi)
|
||||
|
||||
/* The following macro definitions may be used to translate this file:
|
||||
|
||||
STDIO - use standard Input/Output device
|
||||
(default is NOT used)
|
||||
*/
|
||||
|
||||
/* Standard IO device handles. */
|
||||
#define STDIN 0x8001
|
||||
#define STDOUT 0x8002
|
||||
#define STDERR 0x8003
|
||||
|
||||
/* Standard IO device name defines. */
|
||||
const char __stdin_name[] = "STDIN";
|
||||
const char __stdout_name[] = "STDOUT";
|
||||
const char __stderr_name[] = "STDERR";
|
||||
|
||||
struct __FILE { int handle; /* Add whatever you need here */ };
|
||||
|
||||
#ifdef STDIO
|
||||
extern int SER_GetChar (void);
|
||||
extern int SER_PutChar (int ch);
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Write character to the Serial Port
|
||||
*----------------------------------------------------------------------------*/
|
||||
int sendchar (int c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
SER_PutChar ('\r');
|
||||
}
|
||||
SER_PutChar (c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Read character from the Serial Port
|
||||
*----------------------------------------------------------------------------*/
|
||||
int getkey (void)
|
||||
{
|
||||
int ch = SER_GetChar();
|
||||
|
||||
if (ch < 0) {
|
||||
return 0;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------- _ttywrch ---------------------------------------*/
|
||||
|
||||
void _ttywrch (int ch)
|
||||
{
|
||||
#ifdef STDIO
|
||||
sendchar (ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_open --------------------------------------*/
|
||||
#ifndef NO_FILESYSTEM
|
||||
static int KEIL_FS_open(const char *name, int openmode)
|
||||
{
|
||||
int i ; int ret ;
|
||||
#define PATHSIZE 100
|
||||
char path[PATHSIZE] ; char *p ;
|
||||
|
||||
if(strlen(name) > PATHSIZE)return(-1) ;
|
||||
|
||||
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 = __sys_open (p, openmode) ;
|
||||
|
||||
return(ret) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
FILEHANDLE _sys_open (const char *name, int openmode)
|
||||
{
|
||||
/* Register standard Input Output devices. */
|
||||
if (strcmp(name, "STDIN") == 0) {
|
||||
return (STDIN);
|
||||
}
|
||||
if (strcmp(name, "STDOUT") == 0) {
|
||||
return (STDOUT);
|
||||
}
|
||||
if (strcmp(name, "STDERR") == 0) {
|
||||
return (STDERR);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (KEIL_FS_open(name, openmode));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_close -------------------------------------*/
|
||||
|
||||
int _sys_close (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (0);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_close (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_write -------------------------------------*/
|
||||
|
||||
int _sys_write (FILEHANDLE fh, const U8 *buf, U32 len, int mode)
|
||||
{
|
||||
#ifdef STDIO
|
||||
if (fh == STDOUT) {
|
||||
/* Standard Output device. */
|
||||
for ( ; len; len--) {
|
||||
sendchar (*buf++);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_write (fh, buf, len));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_read --------------------------------------*/
|
||||
|
||||
int _sys_read (FILEHANDLE fh, U8 *buf, U32 len, int mode)
|
||||
{
|
||||
#ifdef STDIO
|
||||
if (fh == STDIN) {
|
||||
/* Standard Input device. */
|
||||
int sz ;
|
||||
while((buf[0] = getkey()) == 0) ;
|
||||
;
|
||||
for (sz = 0 ; sz <= len ; sz ++ ) {
|
||||
if(buf[sz] == 0) break ;
|
||||
else sz++ ;
|
||||
buf[sz] = getkey ();
|
||||
}
|
||||
return (sz);
|
||||
}
|
||||
#endif
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_read (fh, buf, len));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_istty -------------------------------------*/
|
||||
|
||||
int _sys_istty (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_seek --------------------------------------*/
|
||||
|
||||
int _sys_seek (FILEHANDLE fh, long pos)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_seek (fh, pos));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_ensure ------------------------------------*/
|
||||
|
||||
int _sys_ensure (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_ensure (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_flen --------------------------------------*/
|
||||
|
||||
long _sys_flen (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (0);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_flen (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _sys_tmpnam ------------------------------------*/
|
||||
|
||||
int _sys_tmpnam (char *name, int sig, unsigned maxlen)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_command_string ----------------------------*/
|
||||
|
||||
char *_sys_command_string (char *cmd, int len)
|
||||
{
|
||||
return (cmd);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_exit --------------------------------------*/
|
||||
|
||||
void _sys_exit (int return_code)
|
||||
{
|
||||
#ifdef CYASSL_MDK_SHELL
|
||||
return ;
|
||||
#else
|
||||
/* Endless loop. */
|
||||
while (1);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* certs_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 <config.h>
|
||||
#endif
|
||||
|
||||
/* Define initial data for cert buffers */
|
||||
#include <cyassl/certs_test.h>
|
||||
|
@ -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
|
||||
|
@ -1,291 +0,0 @@
|
||||
/* config-BEREFOOT.h
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
/**** CyaSSL for KEIL-RL Configuration ****/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define CYASSL_MDK_ARM
|
||||
#define NO_WRITEV
|
||||
#define NO_CYASSL_DIR
|
||||
#define NO_MAIN_DRIVER
|
||||
|
||||
#define CYASSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
|
||||
#define SINGLE_THREADED
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_TLS
|
||||
|
||||
#define NO_ECHOSERVER
|
||||
#define NO_ECHOCLIENT
|
||||
#define NO_SIMPLE_SERVER
|
||||
#define NO_SIMPLE_CLIENT
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Build Target: KEIL-BAREFOOT
|
||||
// <h> Single Threaded, No File System, No TCP-net
|
||||
// </h>
|
||||
// <e>Command Shell
|
||||
#define MDK_CONF_SHELL 1
|
||||
#if MDK_CONF_SHELL == 1
|
||||
#define CYASSL_MDK_SHELL
|
||||
#endif
|
||||
// </e>
|
||||
// <h>CyaSSL Apps
|
||||
// <h>Crypt/Cipher
|
||||
// <o>Cert Storage <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes)
|
||||
#define MDK_CONF_CERT_BUFF 1
|
||||
#if MDK_CONF_CERT_BUFF == 1
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#elif MDK_CONF_CERT_BUFF == 2
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
|
||||
// <e>Crypt/Cipher Test Suite
|
||||
#define MDK_CONF_CTaoCryptTest 1
|
||||
#if MDK_CONF_CTaoCryptTest == 0
|
||||
#define NO_CRYPT_TEST
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Crypt/Cipher Benchmark
|
||||
#define MDK_CONF_CTaoCryptBenchmark 1
|
||||
#if MDK_CONF_CTaoCryptBenchmark == 0
|
||||
#define NO_CRYPT_BENCHMARK
|
||||
#define BENCH_EMBEDDED
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>STM32 Hardware Crypt
|
||||
// <e>STM32F2 Hardware RNG
|
||||
#define MDK_CONF_STM32F2_RNG 0
|
||||
#if MDK_CONF_STM32F2_RNG == 1
|
||||
#define STM32F2_RNG
|
||||
#else
|
||||
#define NO_DEV_RANDOM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>STM32F2 Hardware Crypt
|
||||
#define MDK_CONF_STM32F2_CRYPTO 0
|
||||
#if MDK_CONF_STM32F2_CRYPTO == 1
|
||||
#define STM32F2_CRYPTO
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
|
||||
|
||||
// <h>CTaoCrypt Library
|
||||
|
||||
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
|
||||
// </h>
|
||||
// <e>MD2
|
||||
#define MDK_CONF_MD2 0
|
||||
#if MDK_CONF_MD2 == 1
|
||||
#define CYASSL_MD2
|
||||
#endif
|
||||
// </e>
|
||||
// <e>MD4
|
||||
#define MDK_CONF_MD4 1
|
||||
#if MDK_CONF_MD4 == 0
|
||||
#define NO_MD4
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-384
|
||||
// <i>This has to be with SHA512
|
||||
#define MDK_CONF_SHA384 0
|
||||
#if MDK_CONF_SHA384 == 1
|
||||
#define CYASSL_SHA384
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-512
|
||||
#define MDK_CONF_SHA512 0
|
||||
#if MDK_CONF_SHA512 == 1
|
||||
#define CYASSL_SHA512
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RIPEMD
|
||||
#define MDK_CONF_RIPEMD 0
|
||||
#if MDK_CONF_RIPEMD == 1
|
||||
#define CYASSL_RIPEMD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HMAC
|
||||
#define MDK_CONF_HMAC 1
|
||||
#if MDK_CONF_HMAC == 0
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HC128
|
||||
#define MDK_CONF_HC128 0
|
||||
#if MDK_CONF_HC128 == 1
|
||||
#define HAVE_HC128
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RABBIT
|
||||
#define MDK_CONF_RABBIT 1
|
||||
#if MDK_CONF_RABBI == 0
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>AEAD
|
||||
#define MDK_CONF_AEAD 0
|
||||
#if MDK_CONF_AEAD == 1
|
||||
#define HAVE_AEAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DES3
|
||||
#define MDK_CONF_DES3 1
|
||||
#if MDK_CONF_DES3 == 0
|
||||
#define NO_DES3
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAMELLIA
|
||||
#define MDK_CONF_CAMELLIA 0
|
||||
#if MDK_CONF_CAMELLIA == 1
|
||||
#define HAVE_CAMELLIA
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>DH
|
||||
// <i>need this for CYASSL_SERVER, OPENSSL_EXTRA
|
||||
#define MDK_CONF_DH 1
|
||||
#if MDK_CONF_DH == 0
|
||||
#define NO_DH
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DSA
|
||||
#define MDK_CONF_DSA 1
|
||||
#if MDK_CONF_DSA == 0
|
||||
#define NO_DSA
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PWDBASED
|
||||
#define MDK_CONF_PWDBASED 1
|
||||
#if MDK_CONF_PWDBASED == 0
|
||||
#define NO_PWDBASED
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>ECC
|
||||
#define MDK_CONF_ECC 0
|
||||
#if MDK_CONF_ECC == 1
|
||||
#define HAVE_ECC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PSK
|
||||
#define MDK_CONF_PSK 1
|
||||
#if MDK_CONF_PSK == 0
|
||||
#define NO_PSK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESCCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESCCM 0
|
||||
#if MDK_CONF_AESCCM == 1
|
||||
#define HAVE_AESCCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESGCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESGCM 0
|
||||
#if MDK_CONF_AESGCM == 1
|
||||
#define HAVE_AESGCM
|
||||
#define BUILD_AESGCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>NTRU (need License, "crypto_ntru.h")
|
||||
#define MDK_CONF_NTRU 0
|
||||
#if MDK_CONF_NTRU == 1
|
||||
#define HAVE_NTRU
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>Others
|
||||
|
||||
// <e>Inline
|
||||
#define MDK_CONF_INLINE 0
|
||||
#if MDK_CONF_INLINE == 0
|
||||
#define NO_INLINE
|
||||
#endif
|
||||
// </e>
|
||||
// <h>Debug
|
||||
// <e>Debug Message
|
||||
#define MDK_CONF_DebugMessage 0
|
||||
#if MDK_CONF_DebugMessage == 1
|
||||
#define DEBUG_CYASSL
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Check malloc
|
||||
#define MDK_CONF_CheckMalloc 1
|
||||
#if MDK_CONF_CheckMalloc == 1
|
||||
#define CYASSL_MALLOC_CHECK
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
// <e>ErrNo.h
|
||||
#define MDK_CONF_ErrNo 0
|
||||
#if MDK_CONF_ErrNo == 1
|
||||
#define HAVE_ERRNO
|
||||
#endif
|
||||
// </e>
|
||||
// <e>zlib (need "zlib.h")
|
||||
#define MDK_CONF_LIBZ 0
|
||||
#if MDK_CONF_LIBZ == 1
|
||||
#define HAVE_LIBZ
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAVIUM (need CAVIUM headers)
|
||||
#define MDK_CONF_CAVIUM 0
|
||||
#if MDK_CONF_CAVIUM == 1
|
||||
#define HAVE_CAVIUM
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Error Strings
|
||||
#define MDK_CONF_ErrorStrings 1
|
||||
#if MDK_CONF_ErrorStrings == 0
|
||||
#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Small Stack
|
||||
#define MDK_CONF_SmallStack 1
|
||||
#if MDK_CONF_SmallStack == 0
|
||||
#define NO_CYASSL_SMALL_STACK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Use Fast Math
|
||||
#define MDK_CONF_FASTMATH 0
|
||||
#if MDK_CONF_FASTMATH == 1
|
||||
#define USE_FAST_MATH
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
|
||||
//</h>
|
||||
// <<< end of configuration section >>>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
||||
/* config.h
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
/**** CyaSSL for KEIL-RL Configuration ****/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define CYASSL_MDK_ARM
|
||||
#define NO_WRITEV
|
||||
#define NO_CYASSL_DIR
|
||||
|
||||
/* for Retarget.c */
|
||||
#define STDIO
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
#define CYASSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
|
||||
#if defined(MDK_CONF_RTX_TCP_FS)
|
||||
#include "config-RTX-TCP-FS.h"
|
||||
#elif defined(MDK_CONF_TCP_FS)
|
||||
#include "config-TCP-FS.h"
|
||||
#elif defined(MDK_CONF_FS)
|
||||
#include "config-FS.h"
|
||||
#elif defined(MDK_CONF_BARE_METAL)
|
||||
#include "config-BARE-METAL.h"
|
||||
#endif
|
||||
|
@ -1,249 +0,0 @@
|
||||
/* cyassl_MDK_ARM.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
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/** 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)
|
||||
#if !defined(CYASSL_CMSIS_RTOS)
|
||||
os_tsk_pass ();
|
||||
#else
|
||||
osThreadYield ();
|
||||
#endif
|
||||
#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) ;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/* cyassl_KEIL_RL.h
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
/** 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 */
|
||||
};
|
||||
|
||||
|
||||
/*** #include <unistd.h> **/
|
||||
/*
|
||||
int select(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
fd_set *exceptfds, const struct timeval *timeout);
|
||||
void FD_CLR(int fd, fd_set *set);
|
||||
int FD_ISSET(int fd, fd_set *set);
|
||||
void FD_SET(int fd, fd_set *set);
|
||||
void FD_ZERO(fd_set *set);
|
||||
*/
|
||||
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);
|
||||
|
||||
/* 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,172 +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 <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/visibility.h>
|
||||
#include <cyassl/ctaocrypt/logging.h>
|
||||
|
||||
#include <RTL.h>
|
||||
#include <stdio.h>
|
||||
#include "cyassl_MDK_ARM.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Initialize a Flash Memory Card
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if !defined(NO_FILESYSTEM)
|
||||
static void init_card (void)
|
||||
{
|
||||
U32 retv;
|
||||
|
||||
while ((retv = finit (NULL)) != 0) { /* Wait until the Card is ready */
|
||||
if (retv == 1) {
|
||||
printf ("\nSD/MMC Init Failed");
|
||||
printf ("\nInsert Memory card and press key...\n");
|
||||
} else {
|
||||
printf ("\nSD/MMC Card is Unformatted");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* TCP/IP tasks
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef CYASSL_KEIL_TCP_NET
|
||||
__task void tcp_tick (void)
|
||||
{
|
||||
|
||||
CYASSL_MSG("Time tick started.") ;
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_itv_set (10);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_itv_wait ();
|
||||
#endif
|
||||
/* Timer tick every 100 ms */
|
||||
timer_tick ();
|
||||
}
|
||||
}
|
||||
|
||||
__task void tcp_poll (void)
|
||||
{
|
||||
CYASSL_MSG("TCP polling started.\n") ;
|
||||
while (1) {
|
||||
main_TcpNet ();
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_tsk_pass ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_KEIL_RTX) && defined(CYASSL_MDK_SHELL)
|
||||
#define SHELL_STACKSIZE 1000
|
||||
static unsigned char Shell_stack[SHELL_STACKSIZE] ;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(CYASSL_MDK_SHELL)
|
||||
extern void shell_main(void) ;
|
||||
#endif
|
||||
|
||||
extern void time_main(int) ;
|
||||
extern void benchmark_test(void) ;
|
||||
extern void SER_Init(void) ;
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* mian entry
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*** This is the parent task entry ***/
|
||||
void main_task (void)
|
||||
{
|
||||
#ifdef CYASSL_KEIL_TCP_NET
|
||||
init_TcpNet ();
|
||||
|
||||
os_tsk_create (tcp_tick, 2);
|
||||
os_tsk_create (tcp_poll, 1);
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_MDK_SHELL
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
os_tsk_create_user(shell_main, 1, Shell_stack, SHELL_STACKSIZE) ;
|
||||
#else
|
||||
shell_main() ;
|
||||
#endif
|
||||
#else
|
||||
|
||||
/************************************/
|
||||
/*** USER APPLICATION HERE ***/
|
||||
/************************************/
|
||||
printf("USER LOGIC STARTED\n") ;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
CYASSL_MSG("Terminating tcp_main\n") ;
|
||||
os_tsk_delete_self ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
extern void CyaSSL_Debugging_ON(void) ;
|
||||
#endif
|
||||
|
||||
|
||||
/*** main entry ***/
|
||||
extern void init_time(void) ;
|
||||
extern void SystemInit(void);
|
||||
|
||||
int main() {
|
||||
|
||||
SystemInit();
|
||||
SER_Init() ;
|
||||
#if !defined(NO_FILESYSTEM)
|
||||
init_card () ; /* initializing SD card */
|
||||
#endif
|
||||
|
||||
init_time() ;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
printf("Turning ON Debug message\n") ;
|
||||
CyaSSL_Debugging_ON() ;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
os_sys_init (main_task) ;
|
||||
#else
|
||||
main_task() ;
|
||||
#endif
|
||||
|
||||
return 0 ; /* There should be no return here */
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
||||
/* ssl-dummy.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 <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/internal.h>
|
||||
#include <cyassl/error-ssl.h>
|
||||
#include <cyassl/ctaocrypt/coding.h>
|
||||
|
||||
Signer* GetCA(void* vp, byte* hash)
|
||||
{
|
||||
Signer*s ;
|
||||
return s ;
|
||||
}
|
||||
|
||||
int CyaSSL_dtls(CYASSL* ssl)
|
||||
{
|
||||
return ssl->options.dtls;
|
||||
}
|
||||
|
||||
int CyaSSL_get_using_nonblock(CYASSL* ssl)
|
||||
{
|
||||
CYASSL_ENTER("CyaSSL_get_using_nonblock");
|
||||
CYASSL_LEAVE("CyaSSL_get_using_nonblock", ssl->options.usingNonblock);
|
||||
return ssl->options.usingNonblock;
|
||||
}
|
||||
|
||||
Signer* GetCAByName(void* vp, byte* hash)
|
||||
{
|
||||
Signer * ca ;
|
||||
return(ca) ;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,299 +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 <config.h>
|
||||
#endif
|
||||
|
||||
#include "time.h"
|
||||
|
||||
#define PERIPH_BASE ((uint32_t)0x40000000)
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize RTC
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
#define assert_param(a)
|
||||
|
||||
#define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
|
||||
#define SYNCHRO_TIMEOUT ((uint32_t) 0x00008000)
|
||||
#define Bcd2ToByte(v) \
|
||||
((((uint8_t)(v & (uint8_t)0xF0) >> (uint8_t)0x4) * 10) + (v & (uint8_t)0x0F))
|
||||
#define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
|
||||
#define RTC_TR_MNT ((uint32_t)0x00007000)
|
||||
#define RTC_TR_MNU ((uint32_t)0x00000F00)
|
||||
|
||||
#define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
|
||||
#define CR_OFFSET (PWR_OFFSET + 0x00)
|
||||
#define DBP_BitNumber 0x08
|
||||
#define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
|
||||
#define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
|
||||
#define INITMODE_TIMEOUT ((uint32_t) 0x00010000)
|
||||
|
||||
static void init_RTC()
|
||||
{
|
||||
__IO uint32_t initcounter = 0x00 ;
|
||||
uint32_t initstatus = 0x00; /* Enable the PWR clock : RCC_APB1Periph_PWR */
|
||||
((uint32_t *)RCC)[0x10] |= ((uint32_t)0x10000000) ;
|
||||
|
||||
/* Allow access to RTC */
|
||||
*(__IO uint32_t *) CR_DBP_BB = ENABLE ;
|
||||
/* RCC_LSEConfig(RCC_LSE_ON) */
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x00);
|
||||
/* Reset LSEBYP bit */
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x00);
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x01);
|
||||
/* Wait till LSE is ready */
|
||||
while((RCC->BDCR << 0x2) == 0x0) { }
|
||||
/* Select the RTC clock source: RCC_RTCCLKSource_LSE */
|
||||
((RCC_TypeDef *)RCC)->BDCR |= (uint32_t)0x00000100;
|
||||
|
||||
/* Enable the RTC Clock */
|
||||
*(__IO uint32_t *) (PERIPH_BB_BASE + (((RCC_BASE - PERIPH_BASE)+ 0x70) * 32) + (0x0F* 4)) = (uint32_t)ENABLE;
|
||||
|
||||
*(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
|
||||
RTC->ISR = (uint32_t) RTC_INIT_MASK;
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
|
||||
RTC->CR &= ((uint32_t)~(RTC_CR_FMT)); /* Clear RTC CR FMT Bit */
|
||||
/* Set RTC_CR register */
|
||||
RTC->CR |= ((uint32_t)0x00000000) ; /* RTC_HourFormat_24 */
|
||||
|
||||
/* Configure the RTC PRER */
|
||||
RTC->PRER = 0x7f ;
|
||||
RTC->PRER |= (uint32_t)(0xff << 16);
|
||||
|
||||
/* Exit Initialization mode */
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
/* Enable the write protection for RTC registers */
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize TIM
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
|
||||
|
||||
static void init_TIM()
|
||||
{
|
||||
uint16_t tmpcr1 = 0;
|
||||
|
||||
((uint32_t *)RCC)[0x10] |= RCC_APB1Periph_TIM2 ;
|
||||
|
||||
tmpcr1 = TIM2->CR1 ;
|
||||
tmpcr1 &= (uint16_t) (~(((uint16_t)0x0010) | ((uint16_t)0x0060) ));
|
||||
/* CR1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS) */
|
||||
tmpcr1 |= (uint16_t)0x0000 ; /* CR1 |= TIM_CounterMode_Up */
|
||||
TIM2->CR1= tmpcr1 ;
|
||||
|
||||
TIM2->ARR = 0xffffffff ; /* ARR= TIM_Period */
|
||||
TIM2->PSC = 60 ; /* PSC = TIM_Prescaler */
|
||||
TIM2->EGR = ((uint16_t)0x0001) ; /* EGR = TIM_PSCReloadMode_Immediate */
|
||||
|
||||
*(uint16_t *)(PERIPH_BASE+0x0) |=((uint16_t)0x0001) ;
|
||||
/* TIM_Cmd(TIM2, ENABLE) ; */
|
||||
}
|
||||
|
||||
void init_time(void) {
|
||||
init_RTC() ;
|
||||
init_TIM() ;
|
||||
}
|
||||
|
||||
static void GetTime(uint8_t *h, uint8_t *m, uint8_t *s)
|
||||
{
|
||||
uint32_t tmpreg = 0;
|
||||
tmpreg = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK);
|
||||
*h = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16));
|
||||
*m = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8));
|
||||
*s = (uint8_t)Bcd2ToByte((tmpreg & (RTC_TR_ST | RTC_TR_SU)));
|
||||
}
|
||||
|
||||
static uint32_t ByteToBcd2(uint8_t Value)
|
||||
{
|
||||
uint8_t bcdhigh = 0;
|
||||
while (Value >= 10) {
|
||||
bcdhigh++;
|
||||
Value -= 10;
|
||||
}
|
||||
return ((uint8_t)(bcdhigh << 4) | Value);
|
||||
}
|
||||
|
||||
static void SetTime(uint8_t h, uint8_t m, uint8_t s)
|
||||
{
|
||||
__IO uint32_t synchrocounter = 0;
|
||||
uint32_t synchrostatus = 0x00;
|
||||
__IO uint32_t initcounter = 0;
|
||||
uint32_t initstatus = 0x00;
|
||||
uint32_t tmpreg ;
|
||||
|
||||
tmpreg = ((ByteToBcd2(h) << 16) | (ByteToBcd2(m) << 8) | ByteToBcd2(s)) ;
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
RTC->ISR = (uint32_t)RTC_INIT_MASK;
|
||||
|
||||
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
RTC->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
|
||||
|
||||
RTC->ISR &= (uint32_t)RTC_RSF_MASK;
|
||||
/* Wait the registers to be synchronised */
|
||||
do {
|
||||
synchrostatus = RTC->ISR & RTC_ISR_RSF;
|
||||
synchrocounter++;
|
||||
} while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
|
||||
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
static void GetDate(uint8_t *y, uint8_t *m, uint8_t *d)
|
||||
{
|
||||
uint32_t tmpreg = 0;
|
||||
tmpreg = (uint32_t)(RTC->DR & RTC_TR_RESERVED_MASK);
|
||||
*y = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_DR_YT|RTC_DR_YU)) >>16));
|
||||
*m = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_DR_MT|RTC_DR_MU)) >> 8));
|
||||
*d = (uint8_t)Bcd2ToByte((uint8_t)(tmpreg & (RTC_DR_DT |RTC_DR_DU)));
|
||||
}
|
||||
|
||||
static void SetDate(uint8_t y, uint8_t m, uint8_t d)
|
||||
{
|
||||
__IO uint32_t synchrocounter = 0;
|
||||
uint32_t synchrostatus = 0x00;
|
||||
__IO uint32_t initcounter = 0;
|
||||
uint32_t initstatus = 0x00;
|
||||
uint32_t tmpreg = 0 ;
|
||||
|
||||
tmpreg = ((ByteToBcd2(y) << 16) | (ByteToBcd2(m) << 8) | ByteToBcd2(d)) ;
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
RTC->ISR = (uint32_t)RTC_INIT_MASK;
|
||||
|
||||
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
RTC->DR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
|
||||
|
||||
RTC->ISR &= (uint32_t)RTC_RSF_MASK;
|
||||
/* Wait the registers to be synchronised */
|
||||
do {
|
||||
synchrostatus = RTC->ISR & RTC_ISR_RSF;
|
||||
synchrocounter++;
|
||||
} while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
|
||||
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
void CYASSL_MSG(const char *msg) ;
|
||||
|
||||
struct tm *Cyassl_MDK_gmtime(const time_t *c)
|
||||
{
|
||||
uint8_t h, m, s ;
|
||||
uint8_t y, mo, d ;
|
||||
static struct tm date ;
|
||||
|
||||
GetTime(&h, &m, &s) ;
|
||||
GetDate(&y, &mo, &d) ;
|
||||
|
||||
date.tm_year = y + 100 ;
|
||||
date.tm_mon = mo - 1 ;
|
||||
date.tm_mday = d ;
|
||||
date.tm_hour = h ;
|
||||
date.tm_min = m ;
|
||||
date.tm_sec = s ;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
{
|
||||
char msg[100] ;
|
||||
sprintf(msg,
|
||||
"Debug::Cyassl_KEIL_gmtime(DATE=/%2d/%02d/%04d TIME=%02d:%02d:%02d)\n",
|
||||
d, mo, y+2000, h, m, s) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return(&date) ;
|
||||
}
|
||||
|
||||
double current_time()
|
||||
{
|
||||
return ((double)TIM2->CNT/1000000.0) ;
|
||||
}
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
void time_main(void *args)
|
||||
{
|
||||
char * datetime ;
|
||||
uint8_t h, m, s ;
|
||||
uint8_t y, mo, d ;
|
||||
|
||||
if( args == NULL || ((func_args *)args)->argc == 1) {
|
||||
GetTime(&h, &m, &s) ;
|
||||
GetDate(&y, &mo, &d) ;
|
||||
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
|
||||
mo, d, y+2000, h, m, s) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 'd' ) {
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d/%d/%d", (int *)&mo, (int *)&d, (int *) &y) ;
|
||||
SetDate(y-2000, mo, d) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 't' ) {
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d:%d:%d",
|
||||
(int *)&h, (int *)&m, (int *)&s) ;
|
||||
SetTime(h, m, s) ;
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
time()
|
||||
********************************************************************/
|
||||
time_t time(time_t * t) { return 0 ; }
|
@ -1,185 +0,0 @@
|
||||
/* config-FS.h
|
||||
*
|
||||
* Copyright (C) 2006-2013 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> wolfCrypt Configuration
|
||||
|
||||
// <h>Cert/Key Strage
|
||||
// <o>Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes)
|
||||
#define MDK_CONF_CERT_BUFF 0
|
||||
#if MDK_CONF_CERT_BUFF== 1
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#elif MDK_CONF_CERT_BUFF == 2
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
//</h>
|
||||
|
||||
// <h>Crypt Algrithm
|
||||
|
||||
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
|
||||
// </h>
|
||||
|
||||
// <e>MD2
|
||||
#define MDK_CONF_MD2 0
|
||||
#if MDK_CONF_MD2 == 1
|
||||
#define CYASSL_MD2
|
||||
#endif
|
||||
// </e>
|
||||
// <e>MD4
|
||||
#define MDK_CONF_MD4 1
|
||||
#if MDK_CONF_MD4 == 0
|
||||
#define NO_MD4
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-384
|
||||
// <i>This has to be with SHA512
|
||||
#define MDK_CONF_SHA384 0
|
||||
#if MDK_CONF_SHA384 == 1
|
||||
#define CYASSL_SHA384
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-512
|
||||
#define MDK_CONF_SHA512 0
|
||||
#if MDK_CONF_SHA512 == 1
|
||||
#define CYASSL_SHA512
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RIPEMD
|
||||
#define MDK_CONF_RIPEMD 0
|
||||
#if MDK_CONF_RIPEMD == 1
|
||||
#define CYASSL_RIPEMD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HMAC
|
||||
#define MDK_CONF_HMAC 1
|
||||
#if MDK_CONF_HMAC == 0
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HC128
|
||||
#define MDK_CONF_HC128 0
|
||||
#if MDK_CONF_HC128 == 1
|
||||
#define HAVE_HC128
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RABBIT
|
||||
#define MDK_CONF_RABBIT 1
|
||||
#if MDK_CONF_RABBI == 0
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>AEAD
|
||||
#define MDK_CONF_AEAD 0
|
||||
#if MDK_CONF_AEAD == 1
|
||||
#define HAVE_AEAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DES3
|
||||
#define MDK_CONF_DES3 1
|
||||
#if MDK_CONF_DES3 == 0
|
||||
#define NO_DES3
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAMELLIA
|
||||
#define MDK_CONF_CAMELLIA 0
|
||||
#if MDK_CONF_CAMELLIA == 1
|
||||
#define HAVE_CAMELLIA
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>DH
|
||||
// <i>need this for CYASSL_SERVER, OPENSSL_EXTRA
|
||||
#define MDK_CONF_DH 1
|
||||
#if MDK_CONF_DH == 0
|
||||
#define NO_DH
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DSA
|
||||
#define MDK_CONF_DSA 1
|
||||
#if MDK_CONF_DSA == 0
|
||||
#define NO_DSA
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PWDBASED
|
||||
#define MDK_CONF_PWDBASED 1
|
||||
#if MDK_CONF_PWDBASED == 0
|
||||
#define NO_PWDBASED
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>ECC
|
||||
#define MDK_CONF_ECC 0
|
||||
#if MDK_CONF_ECC == 1
|
||||
#define HAVE_ECC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PSK
|
||||
#define MDK_CONF_PSK 1
|
||||
#if MDK_CONF_PSK == 0
|
||||
#define NO_PSK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESCCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESCCM 0
|
||||
#if MDK_CONF_AESCCM == 1
|
||||
#define HAVE_AESCCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESGCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESGCM 0
|
||||
#if MDK_CONF_AESGCM == 1
|
||||
#define HAVE_AESGCM
|
||||
#define BUILD_AESGCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>NTRU (need License, "crypto_ntru.h")
|
||||
#define MDK_CONF_NTRU 0
|
||||
#if MDK_CONF_NTRU == 1
|
||||
#define HAVE_NTRU
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>Hardware Crypt (See document for usage)
|
||||
// <e>Hardware RNG
|
||||
#define MDK_CONF_STM32F2_RNG 0
|
||||
#if MDK_CONF_STM32F2_RNG == 1
|
||||
#define STM32F2_RNG
|
||||
#else
|
||||
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Hardware Crypt
|
||||
#define MDK_CONF_STM32F2_CRYPTO 0
|
||||
#if MDK_CONF_STM32F2_CRYPTO == 1
|
||||
#define STM32F2_CRYPTO
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
|
||||
|
||||
|
||||
//</h>
|
||||
// <<< end of configuration section >>>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user