arch/arm64: AES using the Armv8 Cryptography Extension - #20193
Conversation
274ae4a to
73b652e
Compare
73b652e to
e7a3304
Compare
e7a3304 to
6cea0b5
Compare
|
Closing. @xiaoxiang781216 asked to remove all three files, which is the whole change, and I would rather take that than guess at a third shape for it. No loss on my side: the work this came from uses ChaCha20-Poly1305, so it never needed AES. Happy to reopen if anyone wants arm64 AES later, and the duplicate-symbol clash with |
|
@xiaoxiang781216 one question before I leave this, so I get it right next time: was the objection the location? Every AES backend in the tree is chip-specific ( Or was it that the crypto extension is optional in Armv8-A and arm64 has no runtime detection, so a kernel built with it faults on a core without it? Happy either way, just want the reason rather than a guess. Reopen if it is worth reshaping. |
sorry, I make the comment not clear, I mean remove |
6cea0b5 to
a9239d0
Compare
No problem, thanks for reopening. default n is gone: 9239d05 The two #ifdef CONFIG_ARM64_CRYPTO_AES were already out, the symbol is only in Kconfig, Make.defs and MakeLists now. |
NuttX emits no AES instruction on any arm64 core. There is no runtime feature dispatch in arch/arm64, so every AES goes through crypto/rijndael.c or crypto/aes.c, and the table-driven one indexes memory with key-dependent values, so its timing follows the cache. Provide aes_cypher() for ECB, CBC and CTR built on AESE, AESD and the MixColumns pair, and register it with /dev/crypto as a hardware driver alongside the existing stm32h7, sam34 and esp32 modules. ID_AA64ISAR0_EL1.AES is read on every call, which returns -ENOTSUP rather than trapping on a core without the extension. Verified against the NIST SP 800-38A appendix F vectors for ECB-128, ECB-256, CBC-128, CBC-192 and CTR-128, encrypt and decrypt, in place and out of place. Signed-off-by: Royyan Zahir <royzah@gmail.com>
a9239d0 to
1502f89
Compare
Why
NuttX emits no AES instruction on any core. arm64 has no runtime feature dispatch, so a part that implements the Cryptography Extension still runs https://github.com/apache/nuttx/blob/master/crypto/rijndael.c, which indexes eight 256-entry tables with key-dependent values and so has cache-dependent timing.
How
aes_cypher()for ECB, CBC and CTR onAESE,AESDand the MixColumns pair, registered with/dev/cryptobeside https://github.com/apache/nuttx/blob/master/arch/arm/src/stm32h7/stm32_crypto.c, https://github.com/apache/nuttx/blob/master/arch/arm/src/sam34/sam_crypto.c and https://github.com/apache/nuttx/blob/master/arch/xtensa/src/esp32/esp32_crypto.c.ID_AA64ISAR0_EL1.AESis read on every call, returning-ENOTSUPrather than trapping.crypto/aes.hentry pointsaes_cypher()shape has no such clashAESEwith a zero round keyOpen, and why this is still a draft:
xform.c,gmac.c,cmac.candkey_wrap.creach AES throughAES_CTXand keep the table version. Gatingcrypto/aes.coff when an arch provides those entry points would cover them. Happy to add that here.Tested
NIST SP 800-38A appendix F, executing the instructions under
qemu-aarch64:In-place matters because
/dev/cryptocan pass one buffer as both source and destination.tools/nxstyleclean.