For MDK5
This commit is contained in:
parent
3ed2085e77
commit
2f98233825
@ -27,15 +27,15 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize RTC
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#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)) ;
|
||||
{
|
||||
/* 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 */
|
||||
@ -51,7 +51,7 @@ static void init_RTC()
|
||||
RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_MINUTE, ENABLE);
|
||||
|
||||
/* Enable rtc (starts increase the tick counter and second counter register) */
|
||||
RTC_Cmd(LPC_RTC, ENABLE);
|
||||
RTC_Cmd(LPC_RTC, ENABLE);
|
||||
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@ static void init_RTC()
|
||||
//#include "lpc43xx_scu.h"
|
||||
//#include "lpc43xx_libcfg.h"
|
||||
//#include "debug_frmwrk.h"
|
||||
|
||||
static void init_TIM()
|
||||
|
||||
static void init_TIM()
|
||||
{
|
||||
TIM_TIMERCFG_Type TIM_ConfigStruct;
|
||||
/* Initialize timer 0, prescale count time of 1uS */
|
||||
@ -78,93 +78,93 @@ static void init_TIM()
|
||||
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") ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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,23 +1,23 @@
|
||||
/* cyassl_KEIL_RL.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
|
||||
*/
|
||||
/* cyassl_MDK_ARM.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
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
@ -28,17 +28,29 @@
|
||||
#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 <rtl.h>
|
||||
#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
|
||||
@ -115,7 +127,7 @@ int Cyassl_recv(int sd, void *buf, size_t len, int flags)
|
||||
while(1) {
|
||||
#undef recv /* Go to KEIL TCPnet recv */
|
||||
ret = recv(sd, buf, len, flags) ;
|
||||
if(ret != SCK_EWOULDBLOCK) break ;
|
||||
if((ret != SCK_EWOULDBLOCK) &&( ret != SCK_ETIMEOUT)) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_CYASSL
|
||||
@ -154,6 +166,8 @@ int Cyassl_send(int sd, const void *buf, size_t len, int flags)
|
||||
|
||||
}
|
||||
|
||||
#endif /* CYASSL_KEIL_TCP_NET */
|
||||
|
||||
#if defined(CYASSL_KEIL_TCP_NET)
|
||||
void Cyassl_sleep(int t)
|
||||
{
|
||||
@ -170,18 +184,52 @@ int Cyassl_tcp_select(int sd, int timeout)
|
||||
}
|
||||
#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) ;
|
||||
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') ;
|
||||
sendchar('\n') ;
|
||||
str[i++] = '\n' ;
|
||||
str[i] = '\0' ;
|
||||
break ;
|
||||
|
@ -263,156 +263,6 @@
|
||||
Des3Crypt(des, out, in, sz, DES_DECRYPTION);
|
||||
}
|
||||
|
||||
|
||||
#elif defined(HAVE_COLDFIRE_SEC)
|
||||
|
||||
#include "sec.h"
|
||||
#include "mcf548x_sec.h"
|
||||
|
||||
#include "memory_pools.h"
|
||||
extern TX_BYTE_POOL mp_ncached; /* Non Cached memory pool */
|
||||
#define DES_BUFFER_SIZE (DES_BLOCK_SIZE * 16)
|
||||
static unsigned char *DesBuffer = NULL ;
|
||||
|
||||
#define SEC_DESC_DES_CBC_ENCRYPT 0x20500010
|
||||
#define SEC_DESC_DES_CBC_DECRYPT 0x20400010
|
||||
#define SEC_DESC_DES3_CBC_ENCRYPT 0x20700010
|
||||
#define SEC_DESC_DES3_CBC_DECRYPT 0x20600010
|
||||
|
||||
extern volatile unsigned char __MBAR[];
|
||||
|
||||
static void Des_Cbc(Des* des, byte* out, const byte* in, word32 sz, word32 desc)
|
||||
{
|
||||
static volatile SECdescriptorType descriptor = { NULL } ;
|
||||
int ret ; int stat1,stat2 ;
|
||||
int i ; int size ;
|
||||
volatile int v ;
|
||||
|
||||
while(sz) {
|
||||
if((sz%DES_BUFFER_SIZE) == sz) {
|
||||
size = sz ;
|
||||
sz = 0 ;
|
||||
} else {
|
||||
size = DES_BUFFER_SIZE ;
|
||||
sz -= DES_BUFFER_SIZE ;
|
||||
}
|
||||
|
||||
descriptor.header = desc ;
|
||||
/*
|
||||
escriptor.length1 = 0x0;
|
||||
descriptor.pointer1 = NULL;
|
||||
*/
|
||||
descriptor.length2 = des->ivlen ;
|
||||
descriptor.pointer2 = (byte *)des->iv ;
|
||||
descriptor.length3 = des->keylen ;
|
||||
descriptor.pointer3 = (byte *)des->key;
|
||||
descriptor.length4 = size;
|
||||
descriptor.pointer4 = (byte *)in ;
|
||||
descriptor.length5 = size;
|
||||
descriptor.pointer5 = DesBuffer ;
|
||||
/*
|
||||
descriptor.length6 = 0;
|
||||
descriptor.pointer6 = NULL;
|
||||
descriptor.length7 = 0x0;
|
||||
descriptor.pointer7 = NULL;
|
||||
descriptor.nextDescriptorPtr = NULL ;
|
||||
*/
|
||||
|
||||
/* Initialize SEC and wait for encryption to complete */
|
||||
MCF_SEC_CCCR0 = 0x0000001A; //enable channel done notification
|
||||
|
||||
/* Point SEC to the location of the descriptor */
|
||||
MCF_SEC_FR0 = (uint32)&descriptor;
|
||||
|
||||
/* poll SISR to determine when channel is complete */
|
||||
while (!(MCF_SEC_SISRL) && !(MCF_SEC_SISRH))
|
||||
;
|
||||
|
||||
for(v=0; v<500; v++) ;
|
||||
|
||||
ret = MCF_SEC_SISRH;
|
||||
stat1 = MCF_SEC_DSR ;
|
||||
stat2 = MCF_SEC_DISR ;
|
||||
if(ret & 0xe0000000)
|
||||
db_printf("Des_Cbc(%x):ISRH=%08x, DSR=%08x, DISR=%08x\n", desc, ret, stat1, stat2) ;
|
||||
|
||||
XMEMCPY(out, DesBuffer, size) ;
|
||||
|
||||
if((desc==SEC_DESC_DES3_CBC_ENCRYPT)||(desc==SEC_DESC_DES_CBC_ENCRYPT)) {
|
||||
XMEMCPY((void*)des->iv, (void*)&(out[size-DES_IVLEN]), DES_IVLEN) ;
|
||||
} else {
|
||||
XMEMCPY((void*)des->iv, (void*)&(in[size-DES_IVLEN]), DES_IVLEN) ;
|
||||
}
|
||||
|
||||
in += size ;
|
||||
out += size ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
Des_Cbc(des, out, in, sz, SEC_DESC_DES_CBC_ENCRYPT) ;
|
||||
}
|
||||
|
||||
void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
Des_Cbc(des, out, in, sz, SEC_DESC_DES_CBC_DECRYPT) ;
|
||||
}
|
||||
|
||||
void Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
Des_Cbc((Des *)des3, out, in, sz, SEC_DESC_DES3_CBC_ENCRYPT) ;
|
||||
}
|
||||
|
||||
void Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
Des_Cbc((Des *)des3, out, in, sz, SEC_DESC_DES3_CBC_DECRYPT) ;
|
||||
}
|
||||
|
||||
|
||||
void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
|
||||
{
|
||||
int i ; int status ;
|
||||
|
||||
if(DesBuffer == NULL) {
|
||||
status = tx_byte_allocate(&mp_ncached,(void *)&DesBuffer,DES_BUFFER_SIZE,TX_NO_WAIT);
|
||||
}
|
||||
|
||||
XMEMCPY(des->key, key, DES_KEYLEN);
|
||||
des->keylen = DES_KEYLEN ;
|
||||
des->ivlen = 0 ;
|
||||
if (iv) {
|
||||
XMEMCPY(des->iv, iv, DES_IVLEN);
|
||||
des->ivlen = DES_IVLEN ;
|
||||
} else {
|
||||
for(i=0; i<DES_IVLEN; i++)
|
||||
des->iv[i] = 0x0 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
{
|
||||
int i ; int status ;
|
||||
|
||||
if(DesBuffer == NULL) {
|
||||
status = tx_byte_allocate(&mp_ncached,(void *)&DesBuffer,DES_BUFFER_SIZE,TX_NO_WAIT);
|
||||
}
|
||||
|
||||
XMEMCPY(des3->key, key, DES3_KEYLEN);
|
||||
des3->keylen = DES3_KEYLEN ;
|
||||
des3->ivlen = 0 ;
|
||||
if (iv) {
|
||||
XMEMCPY(des3->iv, iv, DES3_IVLEN);
|
||||
des3->ivlen = DES3_IVLEN ;
|
||||
} else {
|
||||
for(i=0; i<DES_IVLEN; i++)
|
||||
des3->iv[i] = 0x0 ;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* CTaoCrypt software implementation */
|
||||
|
||||
/* permuted choice table (key) */
|
||||
|
@ -179,28 +179,6 @@ mp_count_bits (mp_int * a)
|
||||
}
|
||||
|
||||
|
||||
int mp_leading_bit (mp_int * a)
|
||||
{
|
||||
int bit = 0;
|
||||
mp_int t;
|
||||
|
||||
if (mp_init_copy(&t, a) != MP_OKAY)
|
||||
return 0;
|
||||
|
||||
while (mp_iszero(&t) == 0) {
|
||||
#ifndef MP_8BIT
|
||||
bit = (t.dp[0] & 0x80) != 0;
|
||||
#else
|
||||
bit = (t.dp[0] | ((t.dp[1] & 0x01) << 7)) & 0x80 != 0;
|
||||
#endif
|
||||
if (mp_div_2d (&t, 8, &t, NULL) != MP_OKAY)
|
||||
break;
|
||||
}
|
||||
mp_clear(&t);
|
||||
return bit;
|
||||
}
|
||||
|
||||
|
||||
/* store in unsigned [big endian] format */
|
||||
int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
|
||||
{
|
||||
@ -3765,7 +3743,7 @@ int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(CYASSL_SNIFFER)
|
||||
#if defined(HAVE_ECC) || !defined(NO_PWDBASED)
|
||||
|
||||
/* single digit addition */
|
||||
int mp_add_d (mp_int* a, mp_digit b, mp_int* c)
|
||||
|
@ -45,12 +45,6 @@ enum {
|
||||
DES_DECRYPTION = 1
|
||||
};
|
||||
|
||||
#define DES_IVLEN 8
|
||||
#define DES_KEYLEN 8
|
||||
#define DES3_IVLEN 8
|
||||
#define DES3_KEYLEN 24
|
||||
|
||||
|
||||
#ifdef STM32F2_CRYPTO
|
||||
enum {
|
||||
DES_CBC = 0,
|
||||
@ -61,20 +55,14 @@ enum {
|
||||
|
||||
/* DES encryption and decryption */
|
||||
typedef struct Des {
|
||||
word32 key[DES_KS_SIZE];
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
byte keylen ; /* for Coldfire SEC */
|
||||
byte ivlen ; /* for Coldfire SEC */
|
||||
byte iv[DES3_IVLEN]; /* for Coldfire SEC */
|
||||
word32 key[DES_KS_SIZE];
|
||||
} Des;
|
||||
|
||||
|
||||
/* DES3 encryption and decryption */
|
||||
typedef struct Des3 {
|
||||
byte keylen ; /* for Coldfire SEC */
|
||||
byte ivlen ; /* for Coldfire SEC */
|
||||
byte iv[DES3_IVLEN]; /* for Coldfire SEC */
|
||||
word32 key[3][DES_KS_SIZE];
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
|
@ -90,7 +90,11 @@
|
||||
#elif defined(FREESCALE_MQX)
|
||||
/* do nothing */
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
#include <rtl.h>
|
||||
#if defined(CYASSL_MDK5)
|
||||
#include "cmsis_os.h"
|
||||
#else
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
#else
|
||||
#ifndef SINGLE_THREADED
|
||||
#define CYASSL_PTHREADS
|
||||
|
@ -208,10 +208,8 @@ static const word16 yasslPort = 11111;
|
||||
static INLINE void err_sys(const char* msg)
|
||||
{
|
||||
printf("yassl error: %s\n", msg);
|
||||
#ifndef CYASSL_MDK_SHELL
|
||||
if (msg)
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
2
src/io.c
2
src/io.c
@ -61,7 +61,7 @@
|
||||
#include "rl_fs.h"
|
||||
#include "rl_net.h"
|
||||
#else
|
||||
#include <rtl.h>
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
#undef RNG
|
||||
#include "CYASSL_MDK_ARM.h"
|
||||
|
@ -370,12 +370,13 @@ static INLINE void c16toa(word16 u16, byte* c)
|
||||
c[1] = u16 & 0xff;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TLS_EXTENSIONS
|
||||
/* convert opaque to 16 bit integer */
|
||||
static INLINE void ato16(const byte* c, word16* u16)
|
||||
{
|
||||
*u16 = (c[0] << 8) | (c[1]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* convert 32 bit integer to opaque */
|
||||
static INLINE void c32toa(word32 u32, byte* c)
|
||||
@ -432,21 +433,19 @@ int CyaSSL_GetHmacType(CYASSL* ssl)
|
||||
{
|
||||
return MD5;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
case sha256_mac:
|
||||
{
|
||||
return SHA256;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef CYASSL_SHA384
|
||||
case sha384_mac:
|
||||
{
|
||||
return SHA384;
|
||||
}
|
||||
break;
|
||||
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
case sha_mac:
|
||||
@ -466,7 +465,6 @@ int CyaSSL_GetHmacType(CYASSL* ssl)
|
||||
{
|
||||
return SSL_FATAL_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user