Files
wolfssl/IDE/MDK5-ARM/Projects/CryptTest/main.c

155 lines
3.6 KiB
C
Raw Normal View History

2013-11-07 10:29:01 +09:00
/* main.c
*
* Copyright (C) 2006-2017 wolfSSL Inc.
2013-11-07 10:29:01 +09:00
*
2016-03-17 16:02:13 -06:00
* This file is part of wolfSSL.
2013-11-07 10:29:01 +09:00
*
2015-01-06 12:14:15 -07:00
* wolfSSL is free software; you can redistribute it and/or modify
2013-11-07 10:29:01 +09:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
2015-01-06 12:14:15 -07:00
* wolfSSL is distributed in the hope that it will be useful,
2013-11-07 10:29:01 +09:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2016-03-17 16:02:13 -06:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2013-11-07 10:29:01 +09:00
*/
2013-11-07 10:29:01 +09:00
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
2013-11-07 10:29:01 +09:00
#include <stdio.h>
2018-01-01 12:18:08 +09:00
#include <time.h>
/* Dummy definition for test RTC */
#define RTC_YEAR 2018
#define RTC_MONTH 1
#define RTC_DAY 1
#if defined(STM32F7xx)
#include "stm32f7xx_hal.h"
#elif defined(STM32F4xx)
2018-01-02 06:41:47 +09:00
#include "stm32f4xx_hal.h"
2018-01-01 12:18:08 +09:00
#elif defined(STM32F2xx)
#include "stm32f2xx_hal.h"
#endif
#warning "write MPU specific Set ups\n"
static void SystemClock_Config (void) {
2017-12-24 14:59:49 +09:00
}
static void MPU_Config (void) {
2017-12-24 14:59:49 +09:00
}
static void CPU_CACHE_Enable (void) {
2017-12-24 14:59:49 +09:00
}
2013-11-07 10:29:01 +09:00
2018-01-01 12:18:08 +09:00
#ifdef RTE_CMSIS_RTOS_RTX
extern uint32_t os_time;
static time_t epochTime;
2018-01-18 07:00:51 +09:00
uint32_t HAL_GetTick(void) {
return os_time;
2018-01-01 12:18:08 +09:00
}
time_t time(time_t *t){
return epochTime ;
}
void setTime(time_t t){
epochTime = t;
}
#endif
#ifdef WOLFSSL_CURRTIME_OSTICK
#include <stdint.h>
extern uint32_t os_time;
double current_time(int reset)
{
if(reset) os_time = 0 ;
return (double)os_time /1000.0;
}
#else
#include <stdint.h>
#define DWT ((DWT_Type *) (0xE0001000UL) )
typedef struct
{
uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */
uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */
} DWT_Type;
extern uint32_t SystemCoreClock ;
double current_time(int reset)
{
if(reset) DWT->CYCCNT = 0 ;
return ((double)DWT->CYCCNT/SystemCoreClock) ;
}
#endif
2013-11-07 10:29:01 +09:00
/*-----------------------------------------------------------------------------
* Initialize a Flash Memory Card
*----------------------------------------------------------------------------*/
2014-05-12 08:57:38 +09:00
#if !defined(NO_FILESYSTEM)
#include "rl_fs.h" /* FileSystem definitions */
2014-05-12 08:57:38 +09:00
2013-11-07 10:29:01 +09:00
static void init_filesystem (void) {
int32_t retv;
retv = finit ("M0:");
2017-12-24 14:59:49 +09:00
if (retv == fsOK) {
2013-11-07 10:29:01 +09:00
retv = fmount ("M0:");
2017-12-24 14:59:49 +09:00
if (retv == fsOK) {
2013-11-07 10:29:01 +09:00
printf ("Drive M0 ready!\n");
}
else {
2017-12-24 14:59:49 +09:00
printf ("Drive M0 mount failed(%d)!\n", retv);
2013-11-07 10:29:01 +09:00
}
}
else {
printf ("Drive M0 initialization failed!\n");
}
}
2014-05-12 08:57:38 +09:00
#endif
2018-01-01 12:18:08 +09:00
2013-11-07 10:29:01 +09:00
/*-----------------------------------------------------------------------------
* mian entry
2013-11-07 10:29:01 +09:00
*----------------------------------------------------------------------------*/
2018-01-18 07:00:51 +09:00
void wolfcrypt_test(void *arg) ;
int main()
2013-11-07 10:29:01 +09:00
{
void * arg = NULL ;
2018-01-01 12:18:08 +09:00
2017-12-24 14:59:49 +09:00
MPU_Config();
CPU_CACHE_Enable();
HAL_Init(); /* Initialize the HAL Library */
SystemClock_Config(); /* Configure the System Clock */
2013-11-07 10:29:01 +09:00
2017-12-24 14:59:49 +09:00
#if !defined(NO_FILESYSTEM)
2013-11-07 10:29:01 +09:00
init_filesystem ();
2017-12-24 14:59:49 +09:00
#endif
2018-01-01 12:18:08 +09:00
setTime((RTC_YEAR-1970)*365*24*60*60 + RTC_MONTH*30*24*60*60 + RTC_DAY*24*60*60);
printf("=== Start: Crypt test === \n") ;
wolfcrypt_test(arg) ;
printf("=== End: Crypt test ===\n") ;
2013-11-07 10:29:01 +09:00
}