Added aes.c/des3.c

pull/73/head
Takashi Kojo 2015-05-22 09:55:49 +09:00
parent 5bcce85de4
commit aaa1fe813a
4 changed files with 41 additions and 11 deletions

View File

@ -1846,9 +1846,9 @@ void bench_ed25519KeySign(void)
return ( ns / CLOCK * 2.0); return ( ns / CLOCK * 2.0);
} }
#elif defined(WOLFSSL_IAR_ARM) || defined (WOLFSSL_MDK_ARM) #elif defined(WOLFSSL_IAR_ARM_TIME) || defined (WOLFSSL_MDK_ARM)
#warning "Write your current_time()" extern double current_time(int reset);
double current_time(int reset) { return 0.0 ; }
#elif defined FREERTOS #elif defined FREERTOS

View File

@ -230,6 +230,10 @@ void wc_AesFreeCavium(Aes* aes)
word32 length); word32 length);
static int wc_AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in, static int wc_AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
word32 length); word32 length);
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti_aes.c */
#else #else
/* using CTaoCrypt software AES implementation */ /* using CTaoCrypt software AES implementation */
#define NEED_AES_TABLES #define NEED_AES_TABLES
@ -1505,6 +1509,11 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
{ {
return wc_AesSetKey(aes, userKey, keylen, iv, dir); return wc_AesSetKey(aes, userKey, keylen, iv, dir);
} }
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti_md5.c */
#else #else
static int wc_AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen, static int wc_AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen,
const byte* iv, int dir) const byte* iv, int dir)
@ -1775,17 +1784,21 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
#elif defined(WOLFSSL_PIC32MZ_CRYPT) #elif defined(WOLFSSL_PIC32MZ_CRYPT)
#error "PIC32MZ doesn't yet support AES direct" #error "PIC32MZ doesn't yet support AES direct"
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti_aes.c */
#else #else
/* Allow direct access to one block encrypt */ /* Allow direct access to one block encrypt */
void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
{ {
return wc_AesEncrypt(aes, in, out); wc_AesEncrypt(aes, in, out);
} }
/* Allow direct access to one block decrypt */ /* Allow direct access to one block decrypt */
void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in) void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
{ {
return wc_AesDecrypt(aes, in, out); wc_AesDecrypt(aes, in, out);
} }
#endif /* FREESCALE_MMCAU, AES direct block */ #endif /* FREESCALE_MMCAU, AES direct block */
@ -2309,6 +2322,10 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
return 0 ; return 0 ;
} }
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti_aes.c */
#else #else
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{ {
@ -2589,7 +2606,10 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
#elif defined(FREESCALE_MMCAU) #elif defined(FREESCALE_MMCAU)
#error "Freescale mmCAU doesn't currently support AES-CTR mode" #error "Freescale mmCAU doesn't currently support AES-CTR mode"
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti/ti_aes.c */
#else #else
/* Increment AES counter */ /* Increment AES counter */
static INLINE void IncrementAesCounter(byte* inOutCtr) static INLINE void IncrementAesCounter(byte* inOutCtr)
@ -2671,7 +2691,7 @@ enum {
CTR_SZ = 4 CTR_SZ = 4
}; };
#if !defined(WOLFSSL_TI_CRYPT)
static INLINE void InitGcmCounter(byte* inOutCtr) static INLINE void InitGcmCounter(byte* inOutCtr)
{ {
inOutCtr[AES_BLOCK_SIZE - 4] = 0; inOutCtr[AES_BLOCK_SIZE - 4] = 0;
@ -2776,6 +2796,10 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
if (ret == 0) { if (ret == 0) {
#ifdef FREESCALE_MMCAU #ifdef FREESCALE_MMCAU
cau_aes_encrypt(iv, rk, aes->rounds, aes->H); cau_aes_encrypt(iv, rk, aes->rounds, aes->H);
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti/ti_aes.c */
#else #else
wc_AesEncrypt(aes, iv, aes->H); wc_AesEncrypt(aes, iv, aes->H);
#endif #endif
@ -3289,8 +3313,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz,
} }
#endif /* end GCM_WORD32 */ #endif /* end GCM_WORD32 */
int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz, int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz, const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz, byte* authTag, word32 authTagSz,
@ -3445,8 +3468,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
} }
return 0; return 0;
} }
#endif
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len) WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
{ {
@ -3478,6 +3500,7 @@ WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
#endif #endif
#if !defined(WOLFSSL_TI_CRYPT)
void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz) void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
{ {
byte nonce[AES_BLOCK_SIZE]; byte nonce[AES_BLOCK_SIZE];
@ -3758,6 +3781,7 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
return result; return result;
} }
#endif /* WOLFCRYPT_TI_CRYPT */
#endif /* HAVE_AESCCM */ #endif /* HAVE_AESCCM */

View File

@ -944,6 +944,9 @@ int wc_Des3_SetIV(Des3* des, const byte* iv);
return 0; return 0;
} }
#elif defined(WOLFSSL_TI_CRYPT)
/* defined in port/ti/ti-des3.c */
#else /* CTaoCrypt software implementation */ #else /* CTaoCrypt software implementation */
/* permuted choice table (key) */ /* permuted choice table (key) */

View File

@ -113,6 +113,9 @@ typedef struct Aes {
word32 iv_ce [AES_BLOCK_SIZE /sizeof(word32)] ; word32 iv_ce [AES_BLOCK_SIZE /sizeof(word32)] ;
int keylen ; int keylen ;
#endif #endif
#ifdef WOLFSSL_TI_CRYPT
int keylen ;
#endif
} Aes; } Aes;