SiLabs: add AES-CCM hardware acceleration support

pull/3497/head
Elms 2020-11-17 14:40:33 -08:00
parent 79c31a5f2c
commit e501346047
4 changed files with 92 additions and 1 deletions

View File

@ -7079,6 +7079,33 @@ int wc_AesCcmCheckTagSize(int sz)
#elif defined(WOLFSSL_IMX6_CAAM) && !defined(NO_IMX6_CAAM_AES)
/* implemented in wolfcrypt/src/port/caam_aes.c */
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
/* implemented in wolfcrypt/src/port/silabs/silabs_hash.c */
int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
return wc_AesCcmEncrypt_silabs(
aes, out, in, inSz,
nonce, nonceSz,
authTag, authTagSz,
authIn, authInSz);
}
#ifdef HAVE_AES_DECRYPT
int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
return wc_AesCcmDecrypt_silabs(
aes, out, in, inSz,
nonce, nonceSz,
authTag, authTagSz,
authIn, authInSz);
}
#endif
#elif defined(FREESCALE_LTC)
/* return 0 on success */

View File

@ -27,6 +27,10 @@ recommend defining `WOLFSSL_USER_SETTINGS` and adding your own
`user_settings.h` file. You can find a good reference for this in
`IDE/GCC-ARM/Header/user_settings.h`.
### Caveats
* AES GCM tags of some lengths do not pass tests.
### Benchmarks

View File

@ -161,4 +161,51 @@ int wc_AesGcmDecrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
#endif /* HAVE_AESGCM */
#ifdef HAVE_AESCCM
int wc_AesCcmEncrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
sl_status_t status = sl_se_ccm_encrypt_and_tag(
&(aes->ctx.cmd_ctx),
&(aes->ctx.key),
sz,
iv,
ivSz,
authIn,
authInSz,
in,
out,
authTag,
authTagSz
);
return (status != SL_STATUS_OK) ? AES_GCM_AUTH_E : 0;
}
int wc_AesCcmDecrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
sl_status_t status = sl_se_ccm_auth_decrypt(
&(aes->ctx.cmd_ctx),
&(aes->ctx.key),
sz,
iv,
ivSz,
authIn,
authInSz,
in,
out,
(byte*)authTag,
authTagSz);
return (status != SL_STATUS_OK) ? AES_GCM_AUTH_E : 0;
}
#endif /* HAVE_AESGCM */
#endif /* WOLFSSL_SILABS_SE_ACCEL */

View File

@ -36,8 +36,9 @@ typedef struct {
sl_se_key_descriptor_t key;
} silabs_aes_t;
#ifdef HAVE_AESGCM
typedef struct Aes Aes;
#ifdef HAVE_AESGCM
int wc_AesGcmEncrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
@ -49,6 +50,18 @@ int wc_AesGcmDecrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
#endif /* HAVE_AESGCM */
#ifdef HAVE_AESCCM
int wc_AesCcmEncrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
int wc_AesCcmDecrypt_silabs (Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
#endif /* HAVE_AESCCM */
#endif /* defined(WOLFSSL_SILABS_SE_ACCEL) */
#endif /* _SILABS_AES_H_ */