ColdFire SEC for aes, des3: Eliminated type mismatch

This commit is contained in:
Takashi Kojo
2014-04-23 20:45:19 +09:00
parent 41199a480d
commit a67cb1207b
2 changed files with 30 additions and 27 deletions

View File

@@ -698,7 +698,7 @@ static int AesCbcCrypt(Aes* aes, byte* po, const byte* pi, word32 sz, word32 des
stat2 = MCF_SEC_AESISR ; stat2 = MCF_SEC_AESISR ;
if(ret & 0xe0000000) if(ret & 0xe0000000)
{ {
db_printf("Aes_Cbc(i=%d):ISRH=%08x, AESSR=%08x, AESISR=%08x\n", i, ret, stat1, stat2) ; /* db_printf("Aes_Cbc(i=%d):ISRH=%08x, AESSR=%08x, AESISR=%08x\n", i, ret, stat1, stat2) ; */
} }
XMEMCPY(po, AESBuffOut, size) ; XMEMCPY(po, AESBuffOut, size) ;
@@ -744,7 +744,7 @@ int AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
#else #else
#error "Allocate non-Cache buffers" #warning "Allocate non-Cache buffers"
#endif #endif
InitMutex(&Mutex_AesSEC) ; InitMutex(&Mutex_AesSEC) ;

View File

@@ -307,13 +307,11 @@ static CyaSSL_Mutex Mutex_DesSEC ;
extern volatile unsigned char __MBAR[]; extern volatile unsigned char __MBAR[];
static int TimeCount = 0 ;
static void Des_Cbc(byte* out, const byte* in, word32 sz, static void Des_Cbc(byte* out, const byte* in, word32 sz,
byte *key, byte *iv, word32 desc) byte *key, byte *iv, word32 desc)
{ {
int ret ; int stat1,stat2 ; int ret ; /* int stat1,stat2 ; */
int i ; int size ; int size ;
volatile int v ; volatile int v ;
LockMutex(&Mutex_DesSEC) ; LockMutex(&Mutex_DesSEC) ;
@@ -364,11 +362,12 @@ static void Des_Cbc(byte* out, const byte* in, word32 sz,
} }
ret = MCF_SEC_SISRH; ret = MCF_SEC_SISRH;
stat1 = MCF_SEC_DSR ; /* stat1 = MCF_SEC_DSR ; */
stat2 = MCF_SEC_DISR ; /* stat2 = MCF_SEC_DISR ; */
if(ret & 0xe0000000) if(ret & 0xe0000000) {
db_printf("Des_Cbc(%x):ISRH=%08x, DSR=%08x, DISR=%08x\n", desc, ret, stat1, stat2) ; /* db_printf("Des_Cbc(%x):ISRH=%08x, DSR=%08x, DISR=%08x\n", desc, ret, stat1, stat2) ; */
}
XMEMCPY(out, desBuffOut, size) ; XMEMCPY(out, desBuffOut, size) ;
if((desc==SEC_DESC_DES3_CBC_ENCRYPT)||(desc==SEC_DESC_DES_CBC_ENCRYPT)) { if((desc==SEC_DESC_DES3_CBC_ENCRYPT)||(desc==SEC_DESC_DES_CBC_ENCRYPT)) {
@@ -383,30 +382,30 @@ static void Des_Cbc(byte* out, const byte* in, word32 sz,
} }
UnLockMutex(&Mutex_DesSEC) ; UnLockMutex(&Mutex_DesSEC) ;
if((TimeCount++ % 6)==0)
tx_thread_sleep(1) ; /* DELAY */
} }
void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz) void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
{ {
Des_Cbc(out, in, sz, des->key, des->reg, SEC_DESC_DES_CBC_ENCRYPT) ; Des_Cbc(out, in, sz, (byte *)des->key, (byte *)des->reg, SEC_DESC_DES_CBC_ENCRYPT) ;
} }
void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz) void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
{ {
Des_Cbc(out, in, sz, des->key, des->reg, SEC_DESC_DES_CBC_DECRYPT) ; Des_Cbc(out, in, sz, (byte *)des->key, (byte *)des->reg, SEC_DESC_DES_CBC_DECRYPT) ;
} }
void Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz) int Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz)
{ {
Des_Cbc(out, in, sz, des3->key, des3->reg, SEC_DESC_DES3_CBC_ENCRYPT) ; Des_Cbc(out, in, sz, (byte *)des3->key, (byte *)des3->reg, SEC_DESC_DES3_CBC_ENCRYPT) ;
return 0;
} }
void Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz) int Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz)
{ {
Des_Cbc(out, in, sz, des3->key, des3->reg, SEC_DESC_DES3_CBC_DECRYPT) ; Des_Cbc(out, in, sz, (byte *)des3->key, (byte *)des3->reg, SEC_DESC_DES3_CBC_DECRYPT) ;
return 0;
} }
static void setParity(byte *buf, int len) static void setParity(byte *buf, int len)
@@ -431,12 +430,11 @@ static void setParity(byte *buf, int len)
} }
void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir) int Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
{ {
int i ; int s1, s2, s3, s4, s5 ;
if(desBuffIn == NULL) { if(desBuffIn == NULL) {
#if defined (HAVE_THREADX) #if defined (HAVE_THREADX)
int s1, s2, s3, s4, s5 ;
s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc, s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc,
sizeof(SECdescriptorType), TX_NO_WAIT); sizeof(SECdescriptorType), TX_NO_WAIT);
s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn, DES_BUFFER_SIZE, TX_NO_WAIT); s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn, DES_BUFFER_SIZE, TX_NO_WAIT);
@@ -445,7 +443,7 @@ void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey, DES3_KEYLEN,TX_NO_WAIT); s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey, DES3_KEYLEN,TX_NO_WAIT);
s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV, DES3_IVLEN, TX_NO_WAIT); s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV, DES3_IVLEN, TX_NO_WAIT);
#else #else
#error "Allocate non-Cache buffers" #warning "Allocate non-Cache buffers"
#endif #endif
InitMutex(&Mutex_DesSEC) ; InitMutex(&Mutex_DesSEC) ;
@@ -457,21 +455,25 @@ void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
} else { } else {
XMEMSET(des->reg, 0x0, DES_IVLEN) ; XMEMSET(des->reg, 0x0, DES_IVLEN) ;
} }
return 0;
} }
void Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir) int Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
{ {
int i ; int s1, s2, s3, s4, s5 ;
if(desBuffIn == NULL) { if(desBuffIn == NULL) {
#if defined (HAVE_THREADX)
int s1, s2, s3, s4, s5 ;
s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc, s5 = tx_byte_allocate(&mp_ncached,(void *)&secDesc,
sizeof(SECdescriptorType), TX_NO_WAIT); sizeof(SECdescriptorType), TX_NO_WAIT);
s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn, DES_BUFFER_SIZE, TX_NO_WAIT); s1 = tx_byte_allocate(&mp_ncached,(void *)&desBuffIn, DES_BUFFER_SIZE, TX_NO_WAIT);
s2 = tx_byte_allocate(&mp_ncached,(void *)&desBuffOut, DES_BUFFER_SIZE, TX_NO_WAIT); s2 = tx_byte_allocate(&mp_ncached,(void *)&desBuffOut, DES_BUFFER_SIZE, TX_NO_WAIT);
s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey, DES3_KEYLEN,TX_NO_WAIT); s3 = tx_byte_allocate(&mp_ncached,(void *)&secKey, DES3_KEYLEN,TX_NO_WAIT);
s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV, DES3_IVLEN, TX_NO_WAIT); s4 = tx_byte_allocate(&mp_ncached,(void *)&secIV, DES3_IVLEN, TX_NO_WAIT);
#else
#warning "Allocate non-Cache buffers"
#endif
InitMutex(&Mutex_DesSEC) ; InitMutex(&Mutex_DesSEC) ;
} }
@@ -482,6 +484,7 @@ void Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
} else { } else {
XMEMSET(des3->reg, 0x0, DES3_IVLEN) ; XMEMSET(des3->reg, 0x0, DES3_IVLEN) ;
} }
return 0;
} }