I would like to implement sending encrypted NUS data to iOS APP from nRF5340 board. Does Nordic provide Zephyr sample code for AES encryption using software and hardware implementations on nRf5340 platform?
I would like to implement sending encrypted NUS data to iOS APP from nRF5340 board. Does Nordic provide Zephyr sample code for AES encryption using software and hardware implementations on nRf5340 platform?
Hi snowuyl,
You can find AES encryption samples here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/nrf/samples/crypto.html.
Most of the samples in NCS are documented in two places,
Hieu
Thanks for your reply! Since there are a lot of AES encryption mode. Which AES encryption mode do you suggest for Nordic UART service (NUS) data?
Thanks for your reply! Since there are a lot of AES encryption mode. Which AES encryption mode do you suggest for Nordic UART service (NUS) data?
Ah, I wanted to mention this but forgot when I last replied. For your purpose (communication over NUS), I don't recommend any AES encryption at all, but recommend you explore the pairing and bonding feature of BLE instead. After two devices are paired (or bonded), the entire connection is encrypted.
We go over pairing and bonding on our free Bluetooth Low Energy online course.
If you cannot support pairing or bonding due to certain requirements, any encryption methods there would work. There is a very highly rated question on the topic on Stack Overflow that you really should go over: https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb.
Thanks for your reply! Does Nordic provide sample code for AES encrypting the pairing and bonding?
Encryption is done automatically by the BLE stack when a connection is in paring or bonding, so you don't need to worry about code.
Thanks for your reply! Do you mean BLE packets are encrypted with nRF5340 hardware acceleration after pairing?
Yes. All BLE packets are encrypted after pairing; and on the nRF5340 (and nRF52 and nRF54 SoCs while we are at it), it will be with hardware acceleration.