Skip to content

Commit

Permalink
risc-v/esp32c3: Revert aes_cypher name change introduced in apache#6920
Browse files Browse the repository at this point in the history
"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 <gustavo.nihei@espressif.com>
  • Loading branch information
gustavonihei committed Dec 16, 2022
1 parent 19ca5ec commit 5057d37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
10 changes: 7 additions & 3 deletions arch/risc-v/src/esp32c3/esp32c3_aes.c
Expand Up @@ -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];
Expand Down Expand Up @@ -651,3 +653,5 @@ int esp32c3_aes_cypher(void *out, const void *in, size_t size,

return ret;
}

#endif
8 changes: 0 additions & 8 deletions arch/risc-v/src/esp32c3/esp32c3_aes.h
Expand Up @@ -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
Expand Down
17 changes: 6 additions & 11 deletions arch/risc-v/src/esp32c3/esp32c3_crypto.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 5057d37

Please sign in to comment.