FelipeMdeO commented on PR #19319:
URL: https://github.com/apache/nuttx/pull/19319#issuecomment-4897369579

   Hello @xiaoxiang781216 I was able to "integrate" chacha into /dev/crypto 
using enviroments different than espressif.
   
   When I enable `CRYPTO_SW_AES` required by the /dev/crypto software backend
   (`CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO` depends on it, even though 
chacha20-poly1305
   itself does not use AES), I got a conflict with the Espressif HAL, because 
`aes_encrypt` and `aes_decrypt` are defined on both sides.
   
   On the NuttX side they are in `crypto/aes.c`:958 and 963.
   On the Espressif side they are in
   
`esp-hal-3rdparty/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c`:515
 and 530, which is always linked when WiFi is enabled:
   
   ```
       riscv-none-elf-ld: staging/libcrypto.a(aes.o): in function `aes_encrypt':
       aes.c:(.text.aes_encrypt+0x0): multiple definition of `aes_encrypt';
       
staging/libarch.a(crypto_mbedtls.o):crypto_mbedtls.c:(.text.aes_encrypt+0x0): 
first defined here
   ```
   
   Note that `CRYPTO_SW_AES` alone links fine, `aes.c` is compiled but nothing 
references it. The crash only happens once the software cryptodev backend 
(`xform.c`) pulls `aes.o` into the link. The same config links fine on 
`sim:nsh`, so this is a namespace clash between the esp-hal WiFi stack and 
`CRYPTO_SW_AES`, not something specific to Dropbear.
   
   ### How to reproduce on master
   
   Using a plain WiFi defconfig, no Dropbear and no extra patches:
   
   ```
       ./tools/configure.sh esp32c3-devkit:wifi
       make menuconfig
   
   ```
   In menuconfig, enable:
   
   ```
       CONFIG_ALLOW_BSD_COMPONENTS
       CONFIG_CRYPTO
       CONFIG_CRYPTO_SW_AES
       CONFIG_CRYPTO_CRYPTODEV
       CONFIG_CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO
   ```
   
   Then run `make`. The build fails at the final link with the `multiple 
definition of 'aes_encrypt' / 'aes_decrypt'` errors above. Enabling only 
`CONFIG_CRYPTO_SW_AES` (without the cryptodev software backend) still links 
fine.
   
   @acassis , @tmedicci can you take a look too, please?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to