Merge pull request #761 from dgarske/stm32_fixes

Fix for AES-GCM with STM32 and CubeMX HAL
pull/766/head
toddouska 2017-02-22 14:31:36 -08:00 committed by GitHub
commit 6425a654be
1 changed files with 11 additions and 18 deletions

View File

@ -210,6 +210,7 @@ void wc_AesAsyncFree(Aes* aes)
int ret = 0;
#ifdef WOLFSSL_STM32_CUBEMX
CRYP_HandleTypeDef hcryp;
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
/* load key into correct registers */
switch(aes->rounds) {
@ -225,8 +226,6 @@ void wc_AesAsyncFree(Aes* aes)
default:
break;
}
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
hcryp.Instance = CRYP;
hcryp.Init.DataType = CRYP_DATATYPE_8B;
hcryp.Init.pKey = (uint8_t*)aes->key;
@ -330,7 +329,7 @@ void wc_AesAsyncFree(Aes* aes)
int ret = 0;
#ifdef WOLFSSL_STM32_CUBEMX
CRYP_HandleTypeDef hcryp;
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
/* load key into correct registers */
switch(aes->rounds) {
case 10: /* 128-bit key */
@ -345,8 +344,6 @@ void wc_AesAsyncFree(Aes* aes)
default:
break;
}
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
hcryp.Instance = CRYP;
hcryp.Init.DataType = CRYP_DATATYPE_8B;
hcryp.Init.pKey = (uint8_t*)aes->key;
@ -2086,7 +2083,7 @@ int wc_InitAes_h(Aes* aes, void* h)
{
int ret = 0;
CRYP_HandleTypeDef hcryp;
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
/* load key into correct registers */
switch(aes->rounds) {
case 10: /* 128-bit key */
@ -2101,8 +2098,6 @@ int wc_InitAes_h(Aes* aes, void* h)
default:
break;
}
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
hcryp.Instance = CRYP;
hcryp.Init.DataType = CRYP_DATATYPE_8B;
hcryp.Init.pKey = (uint8_t*)aes->key;
@ -2886,7 +2881,7 @@ int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
CRYP_HandleTypeDef hcryp;
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
/* load key into correct registers */
switch(aes->rounds) {
case 10: /* 128-bit key */
@ -2901,8 +2896,6 @@ int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
default:
break;
}
XMEMSET(&hcryp, 0, sizeof(CRYP_HandleTypeDef));
hcryp.Instance = CRYP;
hcryp.Init.DataType = CRYP_DATATYPE_8B;
hcryp.Init.pKey = aes->key;