forked from wolfSSL/wolfssl
Merge branch 'master' of github.com:wolfSSL/wolfssl
This commit is contained in:
@ -89,8 +89,8 @@ static int AesAlign16(Aes* aes, byte* out, const byte* in, word32 sz, word32 di
|
|||||||
ROM_AESReset(AES_BASE);
|
ROM_AESReset(AES_BASE);
|
||||||
ROM_AESConfigSet(AES_BASE, (aes->keylen | dir |
|
ROM_AESConfigSet(AES_BASE, (aes->keylen | dir |
|
||||||
(mode==AES_CFG_MODE_CTR_NOCTR ? AES_CFG_MODE_CTR : mode)));
|
(mode==AES_CFG_MODE_CTR_NOCTR ? AES_CFG_MODE_CTR : mode)));
|
||||||
ROM_AESIVSet(AES_BASE, aes->reg);
|
ROM_AESIVSet(AES_BASE, (uint32_t *)aes->reg);
|
||||||
ROM_AESKey1Set(AES_BASE, aes->key, aes->keylen);
|
ROM_AESKey1Set(AES_BASE, (uint32_t *)aes->key, aes->keylen);
|
||||||
if((dir == AES_CFG_DIR_DECRYPT)&& (mode == AES_CFG_MODE_CBC))
|
if((dir == AES_CFG_DIR_DECRYPT)&& (mode == AES_CFG_MODE_CBC))
|
||||||
/* if input and output same will overwrite input iv */
|
/* if input and output same will overwrite input iv */
|
||||||
XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||||
@ -250,6 +250,7 @@ static int AesAuthArgCheck(Aes* aes, byte* out, const byte* in, word32 inSz,
|
|||||||
const byte* authTag, word32 authTagSz,
|
const byte* authTag, word32 authTagSz,
|
||||||
const byte* authIn, word32 authInSz, word32 *M, word32 *L)
|
const byte* authIn, word32 authInSz, word32 *M, word32 *L)
|
||||||
{
|
{
|
||||||
|
(void) authInSz ;
|
||||||
if((aes == NULL)||(nonce == NULL)||(authTag== NULL)||(authIn == NULL))
|
if((aes == NULL)||(nonce == NULL)||(authTag== NULL)||(authIn == NULL))
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
if((inSz != 0) && ((out == NULL)||(in == NULL)))
|
if((inSz != 0) && ((out == NULL)||(in == NULL)))
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
|
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
|
||||||
|
|
||||||
|
#include "wolfssl/wolfcrypt/port/ti/ti-ccm.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -44,7 +44,7 @@
|
|||||||
#define WAIT(stat) { volatile int i ; for(i=0; i<TIMEOUT; i++)if(stat)break ; if(i==TIMEOUT)return(false) ; }
|
#define WAIT(stat) { volatile int i ; for(i=0; i<TIMEOUT; i++)if(stat)break ; if(i==TIMEOUT)return(false) ; }
|
||||||
|
|
||||||
static bool ccm_init = false ;
|
static bool ccm_init = false ;
|
||||||
bool wolfSSL_TI_CCMInit(void)
|
int wolfSSL_TI_CCMInit(void)
|
||||||
{
|
{
|
||||||
if(ccm_init)return true ;
|
if(ccm_init)return true ;
|
||||||
ccm_init = true ;
|
ccm_init = true ;
|
||||||
@ -63,18 +63,18 @@ bool wolfSSL_TI_CCMInit(void)
|
|||||||
WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0)) ;
|
WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0)) ;
|
||||||
|
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
InitMutex(&TI_CCM_Mutex) ;
|
if(InitMutex(&TI_CCM_Mutex))return false ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
void wolfSSL_TI_lockCCM() {
|
void wolfSSL_TI_lockCCM(void) {
|
||||||
LockMutex(&TI_CCM_Mutex) ;
|
LockMutex(&TI_CCM_Mutex) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wolfSSL_TI_unlockCCM() {
|
void wolfSSL_TI_unlockCCM(void) {
|
||||||
UnLockMutex(&TI_CCM_Mutex) ;
|
UnLockMutex(&TI_CCM_Mutex) ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -74,8 +74,8 @@ static int DesCbcAlign16(Des* des, byte* out, const byte* in, word32 sz, word32
|
|||||||
wolfSSL_TI_lockCCM() ;
|
wolfSSL_TI_lockCCM() ;
|
||||||
ROM_DESReset(DES_BASE);
|
ROM_DESReset(DES_BASE);
|
||||||
ROM_DESConfigSet(DES_BASE, (dir | DES_CFG_MODE_CBC | tri));
|
ROM_DESConfigSet(DES_BASE, (dir | DES_CFG_MODE_CBC | tri));
|
||||||
ROM_DESIVSet(DES_BASE, des->reg);
|
ROM_DESIVSet(DES_BASE, (uint32_t*)des->reg);
|
||||||
ROM_DESKeySet(DES_BASE, des->key);
|
ROM_DESKeySet(DES_BASE,(uint32_t*)des->key);
|
||||||
if(dir == DES_CFG_DIR_DECRYPT)
|
if(dir == DES_CFG_DIR_DECRYPT)
|
||||||
/* if input and output same will overwrite input iv */
|
/* if input and output same will overwrite input iv */
|
||||||
XMEMCPY(des->tmp, in + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
|
XMEMCPY(des->tmp, in + sz - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
|
||||||
@ -159,7 +159,10 @@ WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 s
|
|||||||
|
|
||||||
WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
const byte* key, const byte* iv)
|
const byte* key, const byte* iv)
|
||||||
{ return 0 ;}
|
{
|
||||||
|
(void)out; (void)in; (void)sz; (void)key; (void)iv ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
|
WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
|
||||||
{
|
{
|
||||||
@ -173,7 +176,10 @@ WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32
|
|||||||
|
|
||||||
WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
const byte* key, const byte* iv)
|
const byte* key, const byte* iv)
|
||||||
{ return 0 ; }
|
{
|
||||||
|
(void)out; (void)in; (void)sz; (void)key; (void)iv ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* WOLFSSL_TI_CRYPT */
|
#endif /* WOLFSSL_TI_CRYPT */
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <wolfssl/wolfcrypt/port/ti/ti-hash.h>
|
#include <wolfssl/wolfcrypt/port/ti/ti-hash.h>
|
||||||
#include <wolfssl/wolfcrypt/port/ti/ti-ccm.h>
|
#include <wolfssl/wolfcrypt/port/ti/ti-ccm.h>
|
||||||
#include <wolfssl/wolfcrypt/logging.h>
|
#include <wolfssl/wolfcrypt/logging.h>
|
||||||
|
#include <wolfssl/wolfcrypt/hash.h>
|
||||||
|
|
||||||
#ifndef TI_DUMMY_BUILD
|
#ifndef TI_DUMMY_BUILD
|
||||||
#include "inc/hw_memmap.h"
|
#include "inc/hw_memmap.h"
|
||||||
@ -61,7 +62,7 @@ bool wolfSSL_TI_CCMInit(void) { return true ; }
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int hashInit(wolfssl_TI_Hash *hash) {
|
static int hashInit(wolfssl_TI_Hash *hash) {
|
||||||
if(!wolfSSL_TI_CCMInit())return ;
|
if(!wolfSSL_TI_CCMInit())return 1 ;
|
||||||
hash->used = 0 ;
|
hash->used = 0 ;
|
||||||
hash->msg = 0 ;
|
hash->msg = 0 ;
|
||||||
hash->len = 0 ;
|
hash->len = 0 ;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef WOLF_CRYPT_TI_CCM_H
|
||||||
|
#define WOLF_CRYPT_TI_CCM_H
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
@ -27,14 +30,17 @@
|
|||||||
|
|
||||||
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
|
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
|
||||||
|
|
||||||
bool wolfSSL_TI_CCMInit(void) ;
|
int wolfSSL_TI_CCMInit(void) ;
|
||||||
|
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
void wolfSSL_TI_lockCCM() ;
|
void wolfSSL_TI_lockCCM(void) ;
|
||||||
void wolfSSL_TI_unlockCCM() ;
|
void wolfSSL_TI_unlockCCM(void) ;
|
||||||
#else
|
#else
|
||||||
#define wolfSSL_TI_lockCCM()
|
#define wolfSSL_TI_lockCCM()
|
||||||
#define wolfSSL_TI_unlockCCM()
|
#define wolfSSL_TI_unlockCCM()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user