Encrypted IoT Networking via RF24Gateway with nRF24, nRF52x and nRF54x. Coming soon

To start, for anybody not familiar, I’ve developed a library, nrf_to_nrf that allows direct radio communication using the XIAO nRF52840 and nRF54L15 based boards. This library doesn’t use Bluetooth, Zigbee, etc, it uses the Enhanced Shockburst (ESB) protocol and direct radio access.

Along with that basic communication functionality, it also includes AES/CCM encryption, which I’ve now enabled for both nRF52x and nRF54x devices in the nrf_to_nrf library.

Now I have that in place, and am working to include encryption in my RF24Gateway library. The Gateway allows usage of nRF24, nRF52x and nRF54x devices as standard wireless Ethernet adapters (NOT WiFi), utilizing TCP/IP and UDP protocols. This allows usage of protocols like MQTT, HTTP, etc over the secure radio network. The Gateway requires a GPIO/SPI capable Linux device like Raspberry Pi.

The code is written, the PRs are in place, its just a matter of getting the code fully released over the next day or two.

For anybody who is familiar with RF24Gateway, or anybody interested in expanding their existing IoT networks using XIAO nRF devices, feel free to check out the project.

https://tmrh20.blogspot.com/2026/10/supporting-encryption-on-rf24gateway.html

Docs:

nice one, CCM right on the nrf radio is a great fit for this :ok_hand:

couple of qs (been fighting with key storage on the esp32-s3 lately so this stuff is on my mind)

what happens to the nonce/counter after a reboot? if a node comes back up and reuses a counter with the same key, CCM is basically toast for those packets. you saving it to flash, or rolling a fresh session key on boot?

also where’s the key actually sitting on the xiao, plain flash or behind APPROTECT? asking cause the nrf52840 approtect got glitched open a while back, so kinda curious what threat model you’re going for

anyway looking fwd to the release

Well I’m not an encryption expert, so had to get some help from AI in answering your question:

Neither:

Nothing is saved to flash and there’s no session key. The counter isn’t what keeps the
nonce unique.

  • Nonce construction: every packet gets a fresh 5-byte IV from the hardware RNG (bias correction
    on), combined with a 3-byte packet counter. Both are sent in the clear ahead of the ciphertext,
    and the receiver takes the nonce from the packet.
  • Why: it keeps receivers stateless. Any node can reboot, or talk to any other node in a mesh,
    with no handshake and no counter sync.
  • On reboot: the counter restarts at 0 (it also wraps at 200,000). Reusing a counter value alone
    doesn’t repeat a nonce; you’d also need a collision on the 40-bit random IV at that same
    counter value.

Case:

  1. Node that reboots constantly, so always sending at counter around 0 :

Packets under one key for ~50% chance of a repeated nonce = ~1.2 million

  1. Counters spread evenly over the 0–200,000 range:

Packets under one key for ~50% chance of a repeated nonce = ~470 million

All nodes sharing a key share that budget. A collision leaks the XOR of those two plaintexts, but
unlike GCM it doesn’t hand over the authentication key. If that margin is too thin, the sizes
are configurable up to an 8-byte IV and 4-byte counter, or call setCounter() at boot from a
persisted value.

Two related limits:

  • Replay: there is no replay protection in the library. The docs say so, and the application has
    to carry its own timestamp or sequence number.
  • MIC: it is 4 bytes, so a forgery attempt succeeds 1 in 2^32 times.

Threat model

This is over-the-air only: it stops passive sniffing and casual injection by someone without the
key. It is not meant to survive physical capture of a node. Since the key is typically
network-wide, extracting it from one device gives you the whole network. There is no forward
secrecy and no key rotation.

wow thanks for the super detailed answer, random 40-bit IV + counter in the clear is a neat way to keep receivers stateless :ok_hand:

the bit that stuck with me is the threat model: network-wide key + no protection vs physical capture = one stolen node opens the whole mesh. that’s literally the rabbit hole I’ve been in lately on the esp32-s3 side (flash encryption + key in efuse so a dumped flash is useless). ever thought about per-node keys derived from a master + node id, so a captured node only burns itself? prob breaks the any-node-talks-to-any-node thing tho

The other option with my existing system is to use old school nRF24 modules mostly, the nRF52s and nRF54s can do it I think, but with ESP32, you can handle SSL, TLS encryption, using available libraries like GitHub - govorox/SSLClient: SSLClient - generic secure client Arduino library using mbedtls · GitHub or GitHub - arduino-libraries/ArduinoBearSSL: Port of BearSSL to Arduino · GitHub and they allow a client cert and client key. The time can be synced over NTP or by using simple RF24Mesh/RF24Network messages.

If I knew more about this stuff, and I hope to learn more, I could look more into things like per-node keys etc, but right now just finished getting everything into place and am trying to make sure there is an actual level of security to be had.

It seems that in most modes of operation, especially in a sensor network, the nodes only need to communicate with the master node, sending in data to a central point, and potentially receiving commands and information back.

oh nice, if it’s mostly star (nodes → master) then per-node keys get way easier actually: master keeps a master secret and derives each node key as HKDF(master, node_id). nodes only ever hold their own key, so a captured node burns just itself, and the master doesn’t even need a key table

on the esp32 TLS route, one thing to watch: the client key usually ends up in plain flash. on the s3 you can lock it down with flash encryption + NVS encryption, or go one step further with the DS (digital signature) peripheral, where the private key is wrapped by an eFuse HMAC key and software never sees it in clear

if you ever want a second pair of eyes on the per-node key stuff, ping me, been deep in this lately :slightly_smiling_face:

Hi there,

AND… YOUR approach is the right one…
Trying to kill a fly with a shotgun is the other… IMO. :face_with_hand_over_mouth:

No point, keep your code safe the rest is on the silicon.

GL :slight_smile: PJ :v: