Skip to content

Commit 9273c00

Browse files
authored
Merge pull request #9364 from dgarske/silabs_ecb
Fixed issue with AES ECB offloading to hardware to use full size
2 parents 643cbe1 + c5ae76e commit 9273c00

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

wolfcrypt/src/aes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13036,6 +13036,9 @@ int wc_AesGetKeySize(Aes* aes, word32* keySize)
1303613036
#elif defined(WOLFSSL_RISCV_ASM)
1303713037
/* implemented in wolfcrypt/src/port/riscv/riscv-64-aes.c */
1303813038

13039+
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
13040+
/* implemented in wolfcrypt/src/port/silabs/silabs_aes.c */
13041+
1303913042
#elif defined(MAX3266X_AES)
1304013043

1304113044
int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)

wolfcrypt/src/port/silabs/silabs_aes.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,48 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
8989
return ret;
9090
}
9191

92+
#ifdef HAVE_AES_ECB
93+
int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
94+
{
95+
sl_status_t status;
96+
if ((in == NULL) || (out == NULL) || (aes == NULL)) {
97+
return BAD_FUNC_ARG;
98+
}
99+
if ((sz % WC_AES_BLOCK_SIZE) != 0) {
100+
return BAD_LENGTH_E;
101+
}
102+
103+
status = sl_se_aes_crypt_ecb(
104+
&(aes->ctx.cmd_ctx),
105+
&(aes->ctx.key),
106+
SL_SE_ENCRYPT,
107+
sz,
108+
in,
109+
out);
110+
return (status != SL_STATUS_OK) ? WC_HW_E : 0;
111+
}
112+
113+
int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
114+
{
115+
sl_status_t status;
116+
if ((in == NULL) || (out == NULL) || (aes == NULL)) {
117+
return BAD_FUNC_ARG;
118+
}
119+
if ((sz % WC_AES_BLOCK_SIZE) != 0) {
120+
return BAD_LENGTH_E;
121+
}
122+
123+
status = sl_se_aes_crypt_ecb(
124+
&(aes->ctx.cmd_ctx),
125+
&(aes->ctx.key),
126+
SL_SE_DECRYPT,
127+
sz,
128+
in,
129+
out);
130+
return (status != SL_STATUS_OK) ? WC_HW_E : 0;
131+
}
132+
#endif /* HAVE_AES_ECB */
133+
92134
#ifdef WOLFSSL_AES_DIRECT
93135
int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
94136
{

0 commit comments

Comments
 (0)