mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Merge pull request #2524 from cconlon/cau_iar
mmCAU Classic AES key alignment, IAR warnings fixes
This commit is contained in:
@@ -1917,7 +1917,9 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
const byte* iv, int dir)
|
const byte* iv, int dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
byte *rk = (byte*)aes->key;
|
byte* rk = (byte*)aes->key;
|
||||||
|
byte* tmpKey = (byte*)userKey;
|
||||||
|
int tmpKeyDynamic = 0;
|
||||||
|
|
||||||
(void)dir;
|
(void)dir;
|
||||||
|
|
||||||
@@ -1933,18 +1935,41 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
|
|
||||||
aes->rounds = keylen/4 + 6;
|
aes->rounds = keylen/4 + 6;
|
||||||
|
|
||||||
|
#ifdef FREESCALE_MMCAU_CLASSIC
|
||||||
|
if ((wolfssl_word)userKey % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||||
|
#ifndef NO_WOLFSSL_ALLOC_ALIGN
|
||||||
|
byte* tmp = (byte*)XMALLOC(keylen + WOLFSSL_MMCAU_ALIGNMENT,
|
||||||
|
aes->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
return MEMORY_E;
|
||||||
|
}
|
||||||
|
tmpKey = tmp + (WOLFSSL_MMCAU_ALIGNMENT -
|
||||||
|
((wolfssl_word)tmp % WOLFSSL_MMCAU_ALIGNMENT));
|
||||||
|
XMEMCPY(tmpKey, userKey, keylen);
|
||||||
|
tmpKeyDynamic = 1;
|
||||||
|
#else
|
||||||
|
WOLFSSL_MSG("Bad cau_aes_set_key alignment");
|
||||||
|
return BAD_ALIGN_E;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = wolfSSL_CryptHwMutexLock();
|
ret = wolfSSL_CryptHwMutexLock();
|
||||||
if(ret == 0) {
|
if(ret == 0) {
|
||||||
#ifdef FREESCALE_MMCAU_CLASSIC
|
#ifdef FREESCALE_MMCAU_CLASSIC
|
||||||
cau_aes_set_key(userKey, keylen*8, rk);
|
cau_aes_set_key(tmpKey, keylen*8, rk);
|
||||||
#else
|
#else
|
||||||
MMCAU_AES_SetKey(userKey, keylen, rk);
|
MMCAU_AES_SetKey(tmpKey, keylen, rk);
|
||||||
#endif
|
#endif
|
||||||
wolfSSL_CryptHwMutexUnLock();
|
wolfSSL_CryptHwMutexUnLock();
|
||||||
|
|
||||||
ret = wc_AesSetIV(aes, iv);
|
ret = wc_AesSetIV(aes, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tmpKeyDynamic == 1) {
|
||||||
|
XFREE(tmpKey, aes->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2768,7 +2768,7 @@ int fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp)
|
|||||||
fp_digit *c;
|
fp_digit *c;
|
||||||
#endif
|
#endif
|
||||||
fp_digit *_c, *tmpm, mu = 0;
|
fp_digit *_c, *tmpm, mu = 0;
|
||||||
int oldused, x, y, pa, err;
|
int oldused, x, y, pa, err = 0;
|
||||||
|
|
||||||
IF_HAVE_INTEL_MULX(err = fp_montgomery_reduce_mulx(a, m, mp), return err) ;
|
IF_HAVE_INTEL_MULX(err = fp_montgomery_reduce_mulx(a, m, mp), return err) ;
|
||||||
(void)err;
|
(void)err;
|
||||||
|
@@ -862,7 +862,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
|
#if (defined(__IAR_SYSTEMS_ICC__) && (__IAR_SYSTEMS_ICC__ > 8)) || \
|
||||||
|
defined(__GNUC__)
|
||||||
#define WOLFSSL_PACK __attribute__ ((packed))
|
#define WOLFSSL_PACK __attribute__ ((packed))
|
||||||
#else
|
#else
|
||||||
#define WOLFSSL_PACK
|
#define WOLFSSL_PACK
|
||||||
|
Reference in New Issue
Block a user