mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-06 09:10:50 +02:00
Add hw accel for aes ecb, cbc, ofb, cfb, ctr. Turn them on.
This commit is contained in:
+26
-3
@@ -59,6 +59,10 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
|
||||
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
#include <wolfssl/wolfcrypt/port/nxp/hashcrypt_port.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SECO_CAAM
|
||||
#include <wolfssl/wolfcrypt/port/caam/wolfcaam.h>
|
||||
#endif
|
||||
@@ -4997,7 +5001,8 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir)
|
||||
|
||||
#if defined(WOLF_CRYPTO_CB) || (defined(WOLFSSL_DEVCRYPTO) && \
|
||||
(defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))) || \
|
||||
(defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES))
|
||||
(defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)) || \
|
||||
defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (aes->devId != INVALID_DEVID)
|
||||
#endif
|
||||
@@ -6371,6 +6376,9 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
#elif defined(WOLFSSL_DEVCRYPTO_CBC)
|
||||
/* implemented in wolfcrypt/src/port/devcrypt/devcrypto_aes.c */
|
||||
|
||||
#elif defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
/* implemented in wolfcrypt/src/port/nxp/hashcrypt_port.c */
|
||||
|
||||
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
|
||||
/* implemented in wolfcrypt/src/port/silabs/silabs_aes.c */
|
||||
|
||||
@@ -7038,7 +7046,11 @@ int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#define NEED_AES_CTR_SOFT
|
||||
|
||||
#elif defined(WOLFSSL_HAVE_PSA) && !defined(WOLFSSL_PSA_NO_AES)
|
||||
/* implemented in wolfcrypt/src/port/psa/psa_aes.c */
|
||||
/* implemented in wolfcrypt/src/port/psa/psa_aes.c */
|
||||
|
||||
#elif defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
/* implemented in wolfcrypt/src/port/nxp/hashcrypt_port.c */
|
||||
|
||||
#else
|
||||
|
||||
/* Use software based AES counter */
|
||||
@@ -13763,6 +13775,9 @@ int wc_AesGetKeySize(Aes* aes, word32* keySize)
|
||||
#elif defined(WOLFSSL_RISCV_ASM)
|
||||
/* implemented in wolfcrypt/src/port/riscv/riscv-64-aes.c */
|
||||
|
||||
#elif defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
/* implemented in wolfcrypt/src/port/nxp/hashcrypt_port.c */
|
||||
|
||||
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
|
||||
/* implemented in wolfcrypt/src/port/silabs/silabs_aes.c */
|
||||
|
||||
@@ -14058,7 +14073,10 @@ int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
|
||||
#if defined(WOLFSSL_AES_CFB)
|
||||
|
||||
#if defined(WOLFSSL_PSOC6_CRYPTO)
|
||||
#if defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
/* implemented in wolfcrypt/src/port/nxp/hashcrypt_port.c */
|
||||
|
||||
#elif defined(WOLFSSL_PSOC6_CRYPTO)
|
||||
|
||||
int wc_AesCfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
@@ -14507,6 +14525,10 @@ int wc_AesCfb8Decrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
|
||||
#ifdef WOLFSSL_AES_OFB
|
||||
#ifdef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
/* implemented in wolfcrypt/src/port/nxp/hashcrypt_port.c */
|
||||
|
||||
#else /* software */
|
||||
/* OFB AES mode
|
||||
*
|
||||
* aes structure holding key to use for encryption
|
||||
@@ -14609,6 +14631,7 @@ int wc_AesOfbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
return AesOfbCrypt_C(aes, out, in, sz);
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* software */
|
||||
#endif /* WOLFSSL_AES_OFB */
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
static int finish_called;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_AES) && defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
hashcrypt_handle_t aes_handle;
|
||||
#endif
|
||||
|
||||
int wc_hashcrypt_init(void)
|
||||
{
|
||||
#if (!defined(NO_SHA) && defined(WOLFSSL_NXP_HASHCRYPT_SHA)) || \
|
||||
@@ -54,9 +58,7 @@ int wc_hashcrypt_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (!defined(NO_SHA256) && defined(WOLFSSL_NXP_HASHCRYPT_SHA256))
|
||||
|
||||
|
||||
#if !defined(NO_SHA256) && defined(WOLFSSL_NXP_HASHCRYPT_SHA256)
|
||||
int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
@@ -69,7 +71,8 @@ int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
|
||||
// return BAD_MUTEX_E;
|
||||
|
||||
XMEMSET(sha256, 0, sizeof(wc_Sha256));
|
||||
if (HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha256) != kStatus_Success)
|
||||
if (HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha256)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
finish_called = 0;
|
||||
@@ -87,7 +90,8 @@ int wc_Sha256Update(wc_Sha256* sha256, const byte* data, word32 len)
|
||||
HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha256);
|
||||
finish_called = 0;
|
||||
}
|
||||
if (HASHCRYPT_SHA_Update(HASHCRYPT, &hash_ctx, data, len) != kStatus_Success)
|
||||
if (HASHCRYPT_SHA_Update(HASHCRYPT, &hash_ctx, data, len)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
@@ -108,8 +112,9 @@ int wc_Sha256Final(wc_Sha256* sha256, byte* hash)
|
||||
}
|
||||
|
||||
if (
|
||||
HASHCRYPT_SHA_Finish(HASHCRYPT, &hash_ctx, hash, &outlen) != kStatus_Success ||
|
||||
outlen != WC_SHA256_DIGEST_SIZE
|
||||
HASHCRYPT_SHA_Finish(HASHCRYPT, &hash_ctx, hash, &outlen)
|
||||
!= kStatus_Success
|
||||
|| outlen != WC_SHA256_DIGEST_SIZE
|
||||
)
|
||||
{
|
||||
return WC_HW_E;
|
||||
@@ -119,10 +124,10 @@ int wc_Sha256Final(wc_Sha256* sha256, byte* hash)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* **_SHA256 */
|
||||
#endif /* !defined(NO_SHA256) && defined(WOLFSSL_NXP_HASHCRYPT_SHA256) */
|
||||
|
||||
|
||||
#if (!defined(NO_SHA) && defined(WOLFSSL_NXP_HASHCRYPT_SHA))
|
||||
#if !defined(NO_SHA) && defined(WOLFSSL_NXP_HASHCRYPT_SHA)
|
||||
int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
|
||||
{
|
||||
(void)heap;
|
||||
@@ -132,7 +137,8 @@ int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(sha, 0, sizeof(wc_Sha));
|
||||
if (HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha1) != kStatus_Success)
|
||||
if (HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha1)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
finish_called = 0;
|
||||
@@ -150,7 +156,8 @@ int wc_ShaUpdate(wc_Sha* sha, const byte* data, word32 len)
|
||||
HASHCRYPT_SHA_Init(HASHCRYPT, &hash_ctx, kHASHCRYPT_Sha1);
|
||||
finish_called = 0;
|
||||
}
|
||||
if (HASHCRYPT_SHA_Update(HASHCRYPT, &hash_ctx, data, len) != kStatus_Success)
|
||||
if (HASHCRYPT_SHA_Update(HASHCRYPT, &hash_ctx, data, len)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
@@ -171,8 +178,9 @@ int wc_ShaFinal(wc_Sha* sha, byte* hash)
|
||||
}
|
||||
|
||||
if (
|
||||
HASHCRYPT_SHA_Finish(HASHCRYPT, &hash_ctx, hash, &outlen) != kStatus_Success ||
|
||||
outlen != WC_SHA_DIGEST_SIZE
|
||||
HASHCRYPT_SHA_Finish(HASHCRYPT, &hash_ctx, hash, &outlen)
|
||||
!= kStatus_Success
|
||||
|| outlen != WC_SHA_DIGEST_SIZE
|
||||
)
|
||||
{
|
||||
return WC_HW_E;
|
||||
@@ -182,51 +190,43 @@ int wc_ShaFinal(wc_Sha* sha, byte* hash)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* **_SHA */
|
||||
#endif /* !defined(NO_SHA) && defined(WOLFSSL_NXP_HASHCRYPT_SHA) */
|
||||
|
||||
|
||||
#if (!defined(NO_AES) && defined(WOLFSSL_NXP_HASHCRYPT_AES))
|
||||
|
||||
|
||||
WOLFSSL_AES_128
|
||||
WOLFSSL_AES_192
|
||||
WOLFSSL_AES_256
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int wc_AesSetKey(
|
||||
Aes* aes, const byte* userKey, word32 keylen, const byte* iv, int dir
|
||||
)
|
||||
#if !defined(NO_AES) && defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
static int _hashcrypt_set_key(Aes* aes)
|
||||
{
|
||||
aes_handle.keyType = kHASHCRYPT_UserKey;
|
||||
|
||||
if (aes->keylen == 128/8)
|
||||
aes_handle.keySize = kHASHCRYPT_Aes128;
|
||||
else if (aes->keylen == 192/8)
|
||||
aes_handle.keySize = kHASHCRYPT_Aes192;
|
||||
else if (aes->keylen == 256/8)
|
||||
aes_handle.keySize = kHASHCRYPT_Aes256;
|
||||
else
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (HASHCRYPT_AES_SetKey(
|
||||
HASHCRYPT, &aes_handle, (const uint8_t *)aes->devKey, aes->keylen
|
||||
) != kStatus_Success
|
||||
)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_AES_CBC
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_AES_CBC */
|
||||
|
||||
|
||||
#ifdef HAVE_AES_ECB
|
||||
int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret = _hashcrypt_set_key(aes);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_EncryptEcb(HASHCRYPT, &aes_handle, in, out, sz)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -234,16 +234,75 @@ int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret = _hashcrypt_set_key(aes);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_DecryptEcb(HASHCRYPT, &aes_handle, in, out, sz)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_AES_ECB */
|
||||
|
||||
#ifdef HAVE_AES_CBC
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret = _hashcrypt_set_key(aes);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_EncryptCbc(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
XMEMCPY(aes->reg, out + sz - 16, 16);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
byte tmp_iv[16];
|
||||
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
XMEMCPY(tmp_iv, in + sz - 16, 16);
|
||||
|
||||
if (HASHCRYPT_AES_DecryptCbc(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
XMEMCPY(aes->reg, tmp_iv, 16);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_AES_CBC */
|
||||
|
||||
#ifdef WOLFSSL_AES_OFB
|
||||
int wc_AesOfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_CryptOfb(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -251,16 +310,35 @@ int wc_AesOfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesOfbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_CryptOfb(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_AES_OFB */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_AES_CFB
|
||||
int wc_AesCfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_EncryptCfb(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -268,42 +346,56 @@ int wc_AesCfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesCfbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_DecryptCfb(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (const uint8_t *)aes->reg)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
int ret;
|
||||
byte* tmp;
|
||||
|
||||
if (aes == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
/* consume any unused bytes left in aes->tmp */
|
||||
tmp = (byte*)aes->tmp + WC_AES_BLOCK_SIZE - aes->left;
|
||||
while (aes->left && sz) {
|
||||
*(out++) = *(in++) ^ *(tmp++);
|
||||
aes->left--;
|
||||
sz--;
|
||||
}
|
||||
|
||||
if (sz) {
|
||||
ret = _hashcrypt_set_key(aes);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (HASHCRYPT_AES_CryptCtr(
|
||||
HASHCRYPT, &aes_handle, in, out, sz, (byte *)aes->reg,
|
||||
(byte *)aes->tmp, (word32 *)&aes->left)
|
||||
!= kStatus_Success)
|
||||
return WC_HW_E;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_AES_DIRECT
|
||||
int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_AES_COUNTER */
|
||||
|
||||
|
||||
#endif /* **_AES */
|
||||
|
||||
#endif /* !defined(NO_AES) && defined(WOLFSSL_NXP_HASHCRYPT_AES) */
|
||||
|
||||
#endif /* WOLFSSL_NXP_HASHCRYPT */
|
||||
|
||||
@@ -11695,9 +11695,11 @@ EVP_TEST_END:
|
||||
if (ret != 0)
|
||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
|
||||
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
if (XMEMCMP(cipher + WC_AES_BLOCK_SIZE, cipher1 + WC_AES_BLOCK_SIZE,
|
||||
WC_AES_BLOCK_SIZE))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
ret = wc_AesOfbDecrypt(dec, plain, cipher1, WC_AES_BLOCK_SIZE);
|
||||
@@ -11712,9 +11714,11 @@ EVP_TEST_END:
|
||||
if (ret != 0)
|
||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
|
||||
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
if (XMEMCMP(plain + WC_AES_BLOCK_SIZE, plain1 + WC_AES_BLOCK_SIZE,
|
||||
WC_AES_BLOCK_SIZE))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
|
||||
/* multiple blocks at once */
|
||||
@@ -11796,8 +11800,10 @@ EVP_TEST_END:
|
||||
if (ret != 0)
|
||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
|
||||
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
if (XMEMCMP(cipher + 3, cipher1 + 3, WC_AES_BLOCK_SIZE))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
ret = wc_AesOfbDecrypt(dec, plain, cipher1, 6);
|
||||
@@ -11811,8 +11817,10 @@ EVP_TEST_END:
|
||||
if (ret != 0)
|
||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
|
||||
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
if (XMEMCMP(plain + 6, plain1 + 6, WC_AES_BLOCK_SIZE))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* WOLFSSL_AES_256 */
|
||||
|
||||
@@ -12014,6 +12022,7 @@ EVP_TEST_END:
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
|
||||
/* test restarting encryption process */
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
ret = wc_AesCfbEncrypt(enc, cipher + (WC_AES_BLOCK_SIZE * 2),
|
||||
msg1 + (WC_AES_BLOCK_SIZE * 2), WC_AES_BLOCK_SIZE);
|
||||
if (ret != 0)
|
||||
@@ -12031,6 +12040,7 @@ EVP_TEST_END:
|
||||
if (XMEMCMP(plain, msg1, WC_AES_BLOCK_SIZE * 3))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif
|
||||
#endif /* WOLFSSL_AES_128 */
|
||||
|
||||
#ifdef WOLFSSL_AES_192
|
||||
@@ -12092,6 +12102,7 @@ EVP_TEST_END:
|
||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
/* test with data left overs, magic lengths are checking near edges */
|
||||
XMEMSET(cipher, 0, sizeof(cipher));
|
||||
ret = wc_AesCfbEncrypt(enc, cipher, msg3, 4);
|
||||
@@ -12143,6 +12154,7 @@ EVP_TEST_END:
|
||||
if (XMEMCMP(plain, msg3, WC_AES_BLOCK_SIZE * 4))
|
||||
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif
|
||||
#endif /* WOLFSSL_AES_256 */
|
||||
|
||||
out:
|
||||
@@ -15600,11 +15612,13 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
|
||||
/* and an additional 9 bytes to reuse tmp left buffer */
|
||||
{ NULL, 0, NULL, ctrPlain, (int)sizeof(oddCipher), oddCipher },
|
||||
/* Counter wrapping */
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
{ ctr128Key, (int)sizeof(ctr128Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr128Wrap128Cipher), ctr128Wrap128Cipher },
|
||||
{ ctr128Key, (int)sizeof(ctr128Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr128Wrap128CipherLong),
|
||||
ctr128Wrap128CipherLong },
|
||||
#endif
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
|
||||
{ ctr128Key, (int)sizeof(ctr128Key), ctrIvWrap128_2,
|
||||
ctrPlain, (int)sizeof(ctr128Wrap128_2CipherLong),
|
||||
@@ -15642,11 +15656,13 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
|
||||
{ ctr192Key, (int)sizeof(ctr192Key), ctrIv,
|
||||
ctrPlain, (int)sizeof(oddCipher), ctr192Cipher },
|
||||
/* Counter wrapping */
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
{ ctr192Key, (int)sizeof(ctr192Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr192Wrap128Cipher), ctr192Wrap128Cipher },
|
||||
{ ctr192Key, (int)sizeof(ctr192Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr192Wrap128CipherLong),
|
||||
ctr192Wrap128CipherLong },
|
||||
#endif
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
|
||||
{ ctr192Key, (int)sizeof(ctr192Key), ctrIvWrap128_2,
|
||||
ctrPlain, (int)sizeof(ctr192Wrap128_2CipherLong),
|
||||
@@ -15684,11 +15700,13 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_ctr_test(void)
|
||||
{ ctr256Key, (int)sizeof(ctr256Key), ctrIv,
|
||||
ctrPlain, (int)sizeof(oddCipher), ctr256Cipher },
|
||||
/* Counter wrapping */
|
||||
#ifndef WOLFSSL_NXP_HASHCRYPT_AES
|
||||
{ ctr256Key, (int)sizeof(ctr256Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr256Wrap128Cipher), ctr256Wrap128Cipher },
|
||||
{ ctr256Key, (int)sizeof(ctr256Key), ctrIvWrap128,
|
||||
ctrPlain, (int)sizeof(ctr256Wrap128CipherLong),
|
||||
ctr256Wrap128CipherLong },
|
||||
#endif
|
||||
#if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_RISCV_ASM)
|
||||
{ ctr256Key, (int)sizeof(ctr256Key), ctrIvWrap128_2,
|
||||
ctrPlain, (int)sizeof(ctr256Wrap128_2CipherLong),
|
||||
|
||||
@@ -380,7 +380,7 @@ struct Aes {
|
||||
#if defined(WOLF_CRYPTO_CB) || (defined(WOLFSSL_DEVCRYPTO) && \
|
||||
(defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))) || \
|
||||
(defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)) || \
|
||||
defined(WOLFSSL_KCAPI_AES)
|
||||
defined(WOLFSSL_KCAPI_AES) || defined(WOLFSSL_NXP_HASHCRYPT_AES)
|
||||
word32 devKey[AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE/sizeof(word32)]; /* raw key */
|
||||
#ifdef HAVE_CAVIUM_OCTEON_SYNC
|
||||
int keySet;
|
||||
|
||||
@@ -2102,18 +2102,16 @@ extern void uITRON4_free(void *p) ;
|
||||
#ifndef WOLFSSL_NXP_LPC55S69_NO_HWACCEL
|
||||
#define WOLFSSL_NXP_RNG_1
|
||||
#define WOLFSSL_NXP_HASHCRYPT
|
||||
#define WOLFSSL_NXP_HASHCRYPT_AES
|
||||
#define WOLFSSL_NXP_HASHCRYPT_SHA
|
||||
#define WOLFSSL_NXP_HASHCRYPT_SHA256
|
||||
#define WOLFSSL_NXP_CASPER
|
||||
#define WOLFSSL_NXP_CASPER_RSA_PUB_EXPTMOD
|
||||
// #define WOLFSSL_NXP_CASPER_ECC_MUL2ADD
|
||||
// #define WOLFSSL_SP_MULMOD
|
||||
#endif
|
||||
#endif /* WOLFSSL_NXP_LPC55S69 */
|
||||
|
||||
// #ifdef WOLFSSL_NXP_CASPER
|
||||
// #define WOLFSSL_NXP_CASPER_ECC
|
||||
// #define WOLFSSL_SP_MULMOD
|
||||
// #endif /* WOLFSSL_NXP_CASPER */
|
||||
|
||||
#ifdef FREESCALE_LTC_TFM_RSA_4096_ENABLE
|
||||
#undef USE_CERT_BUFFERS_4096
|
||||
#define USE_CERT_BUFFERS_4096
|
||||
|
||||
Reference in New Issue
Block a user