From 7114cc2978eb9334292e752dfdd5619c6a0d0e4b Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Thu, 15 Dec 2022 19:09:06 -0300 Subject: [PATCH] risc-v/esp32c3: Revert aes_cypher name change introduced in #6920 "aes_cypher" is a function from NuttX crypto, so better use instead of defining a new interface in the driver. Signed-off-by: Gustavo Henrique Nihei --- arch/risc-v/src/esp32c3/esp32c3_aes.c | 10 +++++++--- arch/risc-v/src/esp32c3/esp32c3_aes.h | 8 -------- arch/risc-v/src/esp32c3/esp32c3_crypto.c | 17 ++++++----------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/arch/risc-v/src/esp32c3/esp32c3_aes.c b/arch/risc-v/src/esp32c3/esp32c3_aes.c index 15041012f1..93e409a8af 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_aes.c +++ b/arch/risc-v/src/esp32c3/esp32c3_aes.c @@ -585,9 +585,11 @@ int esp32c3_aes_init(void) * Name: aes_cypher ****************************************************************************/ -int esp32c3_aes_cypher(void *out, const void *in, size_t size, - const void *iv, const void *key, size_t keysize, - int mode, int encrypt) +#ifdef CONFIG_CRYPTO_AES + +int aes_cypher(void *out, const void *in, size_t size, + const void *iv, const void *key, size_t keysize, + int mode, int encrypt) { int ret; uint8_t iv_buf[AES_BLK_SIZE]; @@ -651,3 +653,5 @@ int esp32c3_aes_cypher(void *out, const void *in, size_t size, return ret; } + +#endif diff --git a/arch/risc-v/src/esp32c3/esp32c3_aes.h b/arch/risc-v/src/esp32c3/esp32c3_aes.h index 3dd2a276e6..6ed25f17c0 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_aes.h +++ b/arch/risc-v/src/esp32c3/esp32c3_aes.h @@ -208,14 +208,6 @@ int esp32c3_aes_xts_setkey(struct esp32c3_aes_xts_s *aes, const void *keyptr, int esp32c3_aes_init(void); -/**************************************************************************** - * Name: aes_cypher - ****************************************************************************/ - -int esp32c3_aes_cypher(void *out, const void *in, size_t size, - const void *iv, const void *key, size_t keysize, - int mode, int encrypt); - #ifdef __cplusplus } #endif diff --git a/arch/risc-v/src/esp32c3/esp32c3_crypto.c b/arch/risc-v/src/esp32c3/esp32c3_crypto.c index 41b942771e..71f3495d9b 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_crypto.c +++ b/arch/risc-v/src/esp32c3/esp32c3_crypto.c @@ -445,11 +445,9 @@ static int esp32c3_process(struct cryptop *crp) switch (data->alg) { case CRYPTO_AES_CBC: - err = esp32c3_aes_cypher(crp->crp_dst, crp->crp_buf, - crd->crd_len, - crd->crd_iv, crd->crd_key, 16, - AES_MODE_CBC, - crd->crd_flags & CRD_F_ENCRYPT); + err = aes_cypher(crp->crp_dst, crp->crp_buf, crd->crd_len, + crd->crd_iv, crd->crd_key, 16, AES_MODE_CBC, + crd->crd_flags & CRD_F_ENCRYPT); if (err < 0) { return err; @@ -460,12 +458,9 @@ static int esp32c3_process(struct cryptop *crp) memcpy(iv, crd->crd_key + crd->crd_klen / 8 - 4, 4); memcpy(iv + 4, crd->crd_iv, 8); iv[15] = 0x1; - err = esp32c3_aes_cypher(crp->crp_dst, crp->crp_buf, - crd->crd_len, - iv, crd->crd_key, - crd->crd_klen / 8 - 4, - AES_MODE_CTR , - crd->crd_flags & CRD_F_ENCRYPT); + err = aes_cypher(crp->crp_dst, crp->crp_buf, crd->crd_len, iv, + crd->crd_key, crd->crd_klen / 8 - 4, + AES_MODE_CTR, crd->crd_flags & CRD_F_ENCRYPT); if (err < 0) { return err;