Skip to content

Commit 500d830

Browse files
committed
Fixed issue with SiLibs AES Direct (required by DTLS v1.3). ZD 20695
1 parent a28e107 commit 500d830

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

wolfcrypt/benchmark/benchmark.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15758,6 +15758,7 @@ void bench_sphincsKeySign(byte level, byte optim)
1575815758
#else
1575915759
return (double)tickCount / 1000;
1576015760
#endif
15761+
(void)reset;
1576115762
}
1576215763
#endif
1576315764

wolfcrypt/src/aes.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,9 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(Aes* aes, const byte* inBlock,
11111111
#elif defined(WOLFSSL_RISCV_ASM)
11121112
/* implemented in wolfcrypt/src/port/risc-v/riscv-64-aes.c */
11131113

1114+
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
1115+
/* implemented in wolfcrypt/src/port/silabs/silabs_aes.c */
1116+
11141117
#else
11151118

11161119
/* using wolfCrypt software implementation */
@@ -1127,8 +1130,7 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(Aes* aes, const byte* inBlock,
11271130

11281131
#ifndef WC_AES_BITSLICED
11291132
#if defined(__aarch64__) || !defined(WOLFSSL_ARMASM)
1130-
#if !defined(WOLFSSL_SILABS_SE_ACCEL) || \
1131-
defined(NO_ESP32_CRYPT) || defined(NO_WOLFSSL_ESP32_CRYPT_AES) || \
1133+
#if defined(NO_ESP32_CRYPT) || defined(NO_WOLFSSL_ESP32_CRYPT_AES) || \
11321134
defined(NEED_AES_HW_FALLBACK)
11331135
static const FLASH_QUALIFIER word32 rcon[] = {
11341136
0x01000000, 0x02000000, 0x04000000, 0x08000000,
@@ -1410,7 +1412,7 @@ static const FLASH_QUALIFIER word32 Te[4][256] = {
14101412
}
14111413
};
14121414

1413-
#if defined(HAVE_AES_DECRYPT) && !defined(WOLFSSL_SILABS_SE_ACCEL)
1415+
#ifdef HAVE_AES_DECRYPT
14141416
#if defined(__aarch64__) || !defined(WOLFSSL_ARMASM)
14151417
static const FLASH_QUALIFIER word32 Td[4][256] = {
14161418
{
@@ -1679,14 +1681,13 @@ static const FLASH_QUALIFIER word32 Td[4][256] = {
16791681
0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
16801682
}
16811683
};
1682-
#endif
1684+
#endif /* __aarch64__ || !WOLFSSL_ARMASM */
16831685
#endif /* HAVE_AES_DECRYPT */
16841686
#endif /* WOLFSSL_AES_SMALL_TABLES */
16851687

16861688
#ifdef HAVE_AES_DECRYPT
1687-
#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC) && \
1688-
!defined(WOLFSSL_SILABS_SE_ACCEL)) || \
1689-
defined(HAVE_AES_ECB) || defined(WOLFSSL_AES_DIRECT)
1689+
#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC)) || \
1690+
defined(HAVE_AES_ECB) || defined(WOLFSSL_AES_DIRECT)
16901691
#if defined(__aarch64__) || !defined(WOLFSSL_ARMASM)
16911692
static const FLASH_QUALIFIER byte Td4[256] =
16921693
{
@@ -3091,8 +3092,7 @@ static WARN_UNUSED_RESULT int wc_AesEncrypt(
30913092
#endif /* HAVE_AES_CBC || WOLFSSL_AES_DIRECT || HAVE_AESGCM */
30923093

30933094
#if defined(HAVE_AES_DECRYPT)
3094-
#if ((defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC) && \
3095-
!defined(WOLFSSL_SILABS_SE_ACCEL)) || \
3095+
#if ((defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC)) || \
30963096
defined(HAVE_AES_ECB) || defined(WOLFSSL_AES_DIRECT)) && \
30973097
(defined(__aarch64__) || !defined(WOLFSSL_ARMASM))
30983098

@@ -3731,8 +3731,7 @@ static void AesDecryptBlocks_C(Aes* aes, const byte* in, byte* out, word32 sz)
37313731
#endif /* !WC_AES_BITSLICED */
37323732
#endif
37333733

3734-
#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC) && \
3735-
!defined(WOLFSSL_SILABS_SE_ACCEL)) || \
3734+
#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC)) || \
37363735
defined(WOLFSSL_AES_DIRECT)
37373736
#if defined(__aarch64__) || !defined(WOLFSSL_ARMASM)
37383737
#if !defined(WC_AES_BITSLICED) || defined(WOLFSSL_AES_DIRECT)

wolfcrypt/src/port/silabs/silabs_aes.c

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

92+
#ifdef WOLFSSL_AES_DIRECT
93+
int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
94+
{
95+
sl_status_t status = sl_se_aes_crypt_ecb(
96+
&(aes->ctx.cmd_ctx),
97+
&(aes->ctx.key),
98+
SL_SE_ENCRYPT,
99+
WC_AES_BLOCK_SIZE,
100+
inBlock,
101+
outBlock);
102+
return (status != SL_STATUS_OK) ? WC_HW_E : 0;
103+
}
104+
105+
int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
106+
{
107+
sl_status_t status = sl_se_aes_crypt_ecb(
108+
&(aes->ctx.cmd_ctx),
109+
&(aes->ctx.key),
110+
SL_SE_DECRYPT,
111+
WC_AES_BLOCK_SIZE,
112+
inBlock,
113+
outBlock);
114+
return (status != SL_STATUS_OK) ? WC_HW_E : 0;
115+
}
116+
#endif /* WOLFSSL_AES_DIRECT */
117+
92118
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
93119
{
94120
sl_status_t status = sl_se_aes_crypt_cbc(

wolfssl/wolfcrypt/port/silabs/silabs_aes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ typedef struct {
3838

3939
typedef struct Aes Aes;
4040

41+
#ifdef WOLFSSL_AES_DIRECT
42+
int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock);
43+
int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock);
44+
#endif
45+
4146
#ifdef HAVE_AESGCM
4247
int wc_AesGcmEncrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
4348
const byte* iv, word32 ivSz,

0 commit comments

Comments
 (0)