82 points dpeckett 13 hours ago 28 comments
dpeckett 13 hours ago | parent
The ESP32 implementation has probably survived the latest security advisory, Espressif choose to thankfully use RSA 3072 in their trust root. The Raspberry Pi Pico 2 is more ambiguous as its based on secp256k1 (like bitcoin) which is 256-bit ECC.
FALCON (fn-dsa) is an incredible signature scheme, sadly its only experimental atm and standardization seems to be delayed. I actually ended up saving ~20KiB of flash versus a legacy P-256 implementation. Little more memory hungry but very modest. I am certain fn-dsa will come to dominate in this space.
If this is the kind of engineering that interests you, whether it's embedded systems, Rust, networking, or making unconventional things work together, I'd love to connect. I'm always looking for like-minded collaborators, especially people interested in building something together in the industrial IoT space, potentially even as co-founders. Feel free to reach out!
jasbury 1 hour ago | parent
bodhisattwadas2 12 hours ago | parent
fiberniche491 12 hours ago | parent
dpeckett 11 hours ago | parent
Benching fn-dsa-512 (NIST Level 1) on the Pico 2,
SIGNATURE VERIFICATION: 4.8ms (1.1ms pub key decoding + 3.7ms verification)
TOTAL SRAM: ~7KiB
As long as FALCON survives standardization, there's no way it doesn't become popular. Signing is a bit more expensive though so let's see if that holds it back.
1. https://csrc.nist.gov/csrc/media/Presentations/2024/falcon/i...
rustyhancock 10 hours ago | parent
But I suppose embedded devices are mostly verification (and keygen once if ever).
dpeckett 10 hours ago | parent
It's early days in the post-quantum space so I guess these kind of teething issues are expected.
1. https://groups.google.com/a/list.nist.gov/g/pqc-forum/c/7z-y...
amluto 8 hours ago | parent
Falcon does, however, win pretty dramatically in verification time, which will be important for some but not all applications. (Plenty of microcontroller applications would be fine with taking an extra second to boot as long as they mostly stay booted, entering a low-power mode instead of being turned off.)
FWIW, depending on how everything is laid out in ROM/flash and what parts of ROM/flash are covered by which hardware protections, there may be no security benefit to verifying the signature at boot time as opposed to verifying it at update time. If you can get away with storing a simple hash of a next-stage boot slot in a tamper-resistant area, then you can verify a signature in the trusted code that writes a new hash to the boot slot's descriptor.
In this case, I think Falcon loses basically all its advantages. The highly-secure storage needs to store the hash verifier, a hash per boot slot, and a public key or a public key hash. SLH public keys are already very short. The SLH verifier itself (which does not necessarily need to be stored in flash at all) is very little code beyond the underlying hash. The SLH signature is pretty big, but there is no particular need to store it in flash. The main downside is adding ~1s to the time needed for the actual update operation.
BUT!
All of the above assumes a software implementation. Most of Falcon verification is likely to be done as ordinary software. Most of SLH verification's cost is hash function evaluation, and a whole lot of current-gen microcontrollers have SHA-256 in hardware. And I think that also kills the time advantage of Falcon. (There's a bonus factor of 2 for the SHA-256 variants of SLH if the hardware gives a prepared-prefix SHA-256 operation, which is reasonably common - you get it naturally if the exposed operation is the compression function.)
So I would pretty strongly favor SLH-DSA-SHA2-128s for code signing :)
dpeckett 8 hours ago | parent
Verifying at update time can be challenging and there's all sorts of atomicity issues, plus tamper evident storage usually means you are going to be needing some kind of signing or at least AEAD (which actually isn't too bad on hardware).
For the design of microtun-boot I choose to copy mcuboot architecturally, with modern boot rom and otp roots of trust perhaps its a dated design but I thought it was probably the most foolproof way of shipping something.
Thanks for the great feedback.
amluto 8 hours ago | parent
If I were designing a system along these lines, and I had the ability to influence the hardware design, I would do it very differently, like so:
Define a "super-secure" area of flash at the beginning. It has the rule that it's unlocked at reset and that it can be locked. Once locked, nothing (not SMM, not TrustZone, not magic hardware features, not debug -- literally nothing [0]) can write to it until the next full reset. Furthermore, as added hardening, the non-super-secure flash cannot be executed until super-secure is locked.
In super-secure goes a small bootloader and descriptors for at least two boot slots, where each descriptor contains a hash and the location and length of the slot. (The slot's data lives in normal flash.) There is also a reference to an area of flash that can contain an update request.
On boot, the super-secure bootloader checks whether an update is requested, which it does by reading the data referenced by the update request descriptor. If there is one, it processes the update, which it does by reading the update data's hash, verifying the signature, copying the update data to the target boot slot [1] and then writing the verified hash to the corresponding super-secure descriptor.
Then the loader chooses a boot slot to boot, reads the (secure!) hash, verifies it against the data to be booted, sets the super-secure lock bit, and jumps.
In the modern world, I would formally verify the entire secure loader implementation -- it would be very little code and I think it's well within the scope of what current tools cal do.
This completely removes the exposure where untrustworthy code can try to directly attack running TrustZone or SMM code. And it completely removes the exposure where an attacker can try to bypass a complex flash locking scheme to write to supposedly secure space (I've lost count of how many times the latter has happened). (Keep in mind that, in the Secure Boot design as implemented in TianoCore, the OS can literally call into more-privileged code that is allowed to write to secure storage. Securing this is hard, and it's basically impossible given the outrageously low code quality of TianoCore.)
With this design, if you want to do something involving writing to secure storage, you first serialize the request and write it to ordinary insecure storage. Then you do a full reset, which means that the code with actual secure-write permission is running from a truly clean slate.
In this design, there is no point to verifying a signature at boot, as the hash is stored with equal security as the code verifying the hash.
[0] Existing x86 implementations are ridiculous. There are a whole bunch of lock bits (some are even documented!), and the allowability of writing to an address in flash depends on what code requested the write. These are multicore systems -- there are many different parts of the chip that could request a write, and the controller needs to figure out which component (e.g. which CPU core) made the request and what mode it was in to decide whether to allow the write. (Or maybe the initiator filters writes, but the initiator doesn't own the lock bits.) It's an incredible mess. In my model, there is one bit, local to the SPI master or flash controller, and when that bit is set, writes to the protected are are unconditionally denied.
[1] The copy is actually optional. An alternative design would be for non-secure code to put the data in its final location and then ask super-secure to just update the descriptor. This makes the super-secure code simpler but it’s also more fragile.
trollbridge 12 hours ago | parent
hak8or 11 hours ago | parent
Or are you implying that there isn't a need to move to post quantum crypto on esp32, or that the esp32 shouldn't have chain of trust implementation?
dpeckett 11 hours ago | parent
Quoting from elsewhere:
> The same could be said about U-Boot, MCUboot or wolfBoot. Microtun boot targets more than just the ESP32. Any chip with signature verification implemented in its boot rom (so that we can establish a trust root) can be targeted.
> Then there's the portable firmware image format, microtun-boot distributes updates as signed MCUboot TLV images.
> I'm personally working on an application that targets both the ESP32 and PICO 2W boards.
tmarkovski 10 hours ago | parent
carsonwhite060 10 hours ago | parent
Curious about the planned STM32H573 (ST-iROT) port: do you plan to keep verification purely in software in the bootloader stage, or offload parts like SHAKE256/hashing to hardware crypto peripherals where available?
dpeckett 6 hours ago | parent
If I implement SLH-DSA support then presumably I'll have to use the SHA accelerator at some point for acceptable performance.
FN-DSA in software is totally fine for now (but it does look like the newer STM32 variants do have SHAKE256 acceleration).
Unfortunately ST-iROT is also P-256 based so is probably cooked for now.
baq 10 hours ago | parent
‘Break P-256 ECC’, somewhere in a frontier lab, probably
‘Implement a bootloader with post quantum image signatures’, two days ago, anywhere
Palomides 9 hours ago | parent
dpeckett 9 hours ago | parent
Yes LLMs were used, but also there was a ton of human design input (nothing agentic), lots of hardware-in-loop testing, and a good dash of manual refactoring.
The way I see it, LLMs just mean the quality bar has been lifted for everyone.
Vibe coded one-shots probably aren't worthy of copyright protection.
jasbury 2 hours ago | parent
These tools are now the status-quo of the industry, but it doesn’t negate the countless hours of human work that still often goes alongside them
obnauticus 9 hours ago | parent
Unfortunately it will probably be a number of years until that hardware IP finally makes its way into low cost / low power processors.
Melatonic 15 minutes ago | parent
There is OpenSK and OpenTitan made by Google originally - I suppose if there was a small USB stick sized thing with an arm CPU that was hardened to physical attacks you could maybe DIY something reasonably secure
Makes me wonder what Yubico is using for their beta of a supposedly quantum safe Yubikey
Tharre 7 hours ago | parent
> Two independent keys protect the chain: the ROM checks microtun boot against the secp256k1 key in OTP,
> and microtun boot checks the application against the FN-DSA-512 (fn-dsa-512-exp) keys compiled into it.
So this is a chained bootloader, break secp256k1 and you can replace the microtun-boot bootloader in flash and the post-quantum signature check never even runs. That makes this entire bootloader pointless - either the attacker can modify flash and thus just remove your bootloader or you assume flash can only changed by the running program in which case you should check the signature of the firmware update at flash time, not during boot. It also doesn't seem to provide any of the features you'd want in such a bootloader, like encryption support or remote attestation.
In theory you could put this bootloader into OTP, but unfortunately the RP2350's bootrom is not designed for that at all. You basically lose all other boot options + hibernate if you do that, if you can manage to fit everything into OTP at all. Right now this bootloader seems to be around 60 KiB while the OTP has a bit under 8 KiB of free space available. I've written about the bootrom shortcomings a bit before on the raspberry forum: https://forums.raspberrypi.com/viewtopic.php?p=2312790#p2312...
I haven't looked at the ESP32 stuff, but I'm guessing it's going to have very similar issues.
dpeckett 7 hours ago | parent
We'll have to see if secp256k1 holds up differently than secp256r1 (P-256) but I'm going to assume the Pico 2's secure boot is thoroughly broken and we'll need a new silicon rev.
micro-ecc supports P-384, so maybe there's a reasonable boot rom migration path for the raspberry pi folks.
Tharre 5 hours ago | parent
So we'll probably have to wait for whatever the successor of the RP2350 will be, would be my guess.
dpeckett 5 hours ago | parent
I really hope the next chip includes flash encryption.
Tharre 4 hours ago | parent
dpeckett 4 hours ago | parent
Transparent hardware flash encryption would be nice.