← Back to Blog

PQC on ARM Cortex-M: Performance and Memory Numbers

PQC on ARM Cortex-M: Performance and Memory Numbers - QNSQY post-quantum encryption guide

ARM Cortex-M is the most successful microcontroller architecture in the history of embedded systems. From smart locks to industrial sensors to insulin pumps, billions of devices ship every year running Cortex-M cores. Cryptography on these devices used to be straightforward: a small ECC library, a dab of AES, maybe a TLS stack tuned down to fit in 32 KB of flash. Post-quantum cryptography changes the math.

Lattice-based and hash-based schemes use bigger keys, bigger signatures, and more memory than ECC ever asked for. The question every embedded engineer is asking right now is: can NIST's standardized PQC algorithms actually run on the constrained microcontrollers we ship in real products? The answer, mostly, is yes. But the details matter, and not all algorithms are equal on a Cortex-M target.

This article walks through what Cortex-M is, what the cores look like, and what the actual numbers say about ML-KEM, ML-DSA, and SLH-DSA performance and memory footprint. The numbers come primarily from pqm4 (github.com/mupq/pqm4), the well-known benchmarking project for post-quantum cryptography on the Cortex-M4.

Cortex-M In Brief

ARM's Cortex-M family covers small 32-bit processors designed for embedded control. The lineup ranges from the tiny Cortex-M0 (no DSP, no FPU, slim instruction set) up through the Cortex-M7 (high-performance with DSP and double-precision FPU) and the Cortex-M33/M55/M85 with TrustZone security extensions. The most studied target for post-quantum cryptography is the Cortex-M4, which has DSP extensions including single-cycle multiply-accumulate, useful for the polynomial arithmetic in lattice schemes.

Memory on Cortex-M targets is small. A common STM32F4 part has 192 KB of SRAM and 1 MB of flash. Smaller parts have 16 to 64 KB of SRAM. Newer parts with TrustZone (M33-based STM32L5 or NXP RT500 series) have 256 KB or more, but Cortex-M memory is always tighter than what a desktop or even a smartphone has.

The pqm4 benchmark project standardizes PQC measurements on the STM32F407 development board, which carries a Cortex-M4 at 168 MHz with 192 KB SRAM and 1 MB flash. Numbers from pqm4 are widely cited in the literature and are a good baseline for what to expect on similar Cortex-M4 hardware.

ML-KEM on Cortex-M4

ML-KEM (FIPS 203, formerly Kyber) is the NIST-standardized post-quantum key encapsulation mechanism. It comes in three parameter sets:

  • ML-KEM-512 (NIST security level 1, comparable to AES-128)
  • ML-KEM-768 (security level 3, comparable to AES-192)
  • ML-KEM-1024 (security level 5, comparable to AES-256)

For a deeper dive into the algorithm itself, see our ML-KEM explained article.

Approximate cycle counts on Cortex-M4 (pqm4 numbers):

  • ML-KEM-512 keygen: ~520,000 cycles
  • ML-KEM-512 encapsulate: ~620,000 cycles
  • ML-KEM-512 decapsulate: ~600,000 cycles

At 168 MHz, that is roughly 3 to 4 milliseconds per operation for ML-KEM-512. ML-KEM-768 takes roughly 1.6x longer than ML-KEM-512 (~1 million cycles per operation, ~6 ms at 168 MHz). ML-KEM-1024 takes roughly 2.4x longer than ML-KEM-512 (~1.5 million cycles, ~9 ms at 168 MHz).

Stack memory:

  • ML-KEM-512: ~3 KB
  • ML-KEM-768: ~3.5 KB
  • ML-KEM-1024: ~4 KB

Public key sizes: 800, 1184, 1568 bytes for the three levels. Ciphertexts: 768, 1088, 1568 bytes. Secret keys: 1632, 2400, 3168 bytes.

These numbers are practical. ML-KEM-768 fits comfortably on a Cortex-M4 with as little as 32 KB of SRAM, leaving plenty of room for the application. The main constraint is flash: keeping pre-computed twiddle factors and the NTT lookup tables takes a few kilobytes of code. A clean implementation comes in around 14 to 18 KB of flash for any single security level.

ML-DSA on Cortex-M4

ML-DSA (FIPS 204, formerly Dilithium) is the NIST-standardized post-quantum signature scheme based on lattices. It comes in three parameter sets: ML-DSA-44, ML-DSA-65, and ML-DSA-87.

Approximate cycle counts on Cortex-M4:

  • ML-DSA-44 keygen: ~1.6 million cycles
  • ML-DSA-44 sign: ~4 million cycles (median; rejection sampling adds variance)
  • ML-DSA-44 verify: ~1.5 million cycles

At 168 MHz, that is roughly 10 ms for keygen, 24 ms median for signing, 9 ms for verification. ML-DSA-65 is about 1.5x slower; ML-DSA-87 is about 2.5x slower.

Stack memory is the headline:

  • ML-DSA-44: ~10 KB
  • ML-DSA-65: ~14 KB
  • ML-DSA-87: ~17 KB

Signature sizes: 2420, 3309, 4627 bytes for the three levels. Public keys: 1312, 1952, 2592 bytes.

The 10 KB stack for ML-DSA-44 is manageable on most Cortex-M4 parts but not all. A small part with 16 KB of total SRAM cannot run ML-DSA without some restructuring (out-of-stack allocation, heap-based polynomial arrays, or careful sequencing). Most STM32F4 and NXP K66 parts have 64-256 KB of SRAM, so they handle ML-DSA fine.

The signing operation has variance because ML-DSA uses rejection sampling. The median is 4 million cycles, but worst-case can be 2-3x higher. Real-time systems need to budget for the worst case, not the median.

For the comparison with hash-based signatures, see our ML-DSA versus SLH-DSA article.

SLH-DSA on Cortex-M4

SLH-DSA (FIPS 205, formerly SPHINCS+) is the hash-based post-quantum signature standard. Hash-based signatures are conceptually simpler than lattice-based ones: there is no NTT, no rejection sampling, just a tree of hashes. The catch is that they are slow, and signatures are large.

Approximate cycle counts on Cortex-M4 for SLH-DSA-128s (the small variant at NIST security level 1):

  • SLH-DSA-128s keygen: ~1.5 billion cycles
  • SLH-DSA-128s sign: ~9.5 billion cycles
  • SLH-DSA-128s verify: ~1.5 billion cycles

At 168 MHz, that is 9 seconds for keygen, 56 seconds for signing, 9 seconds for verification. These are not typos.

The "f" (fast) variants improve signing time at the cost of larger signatures. SLH-DSA-128f signs in roughly 0.5 billion cycles (~3 seconds at 168 MHz), but signatures balloon from 7856 to 17,088 bytes.

Stack memory:

  • SLH-DSA-128s: ~7 KB
  • SLH-DSA-128f: ~7 KB

The stack is manageable, but the runtime is the issue. SLH-DSA on a Cortex-M4 is workable for occasional firmware update verification (where the verify-side overhead can be amortized) or other low-frequency operations. It is not workable for per-message signing in any real-time system.

If you need a hash-based signature for stateful contexts, NIST SP 800-208 covers the LMS/HSS family, which can be much faster than SLH-DSA. We compare these in our ML-DSA versus SLH-DSA article.

Hashing Speed Affects Everything

All three NIST PQC schemes lean heavily on hashing. ML-KEM and ML-DSA use SHAKE-128 and SHAKE-256 (Keccak-based extendable-output functions). SLH-DSA can use either SHAKE or SHA-256.

On Cortex-M4 without hardware acceleration, Keccak runs at roughly 70 to 90 cycles per byte for SHAKE-128. SHA-256 is around 30 to 40 cycles per byte for the optimized assembly implementations. So a Cortex-M4 with no hash accelerator spends a large fraction of its PQC time inside hash functions.

Many modern Cortex-M parts include a hash accelerator (the STM32 HASH peripheral, or a custom Keccak unit). When present, these accelerators dramatically speed up SLH-DSA and meaningfully speed up ML-KEM and ML-DSA. Embedded engineers should check whether their target chip has this peripheral and whether their PQC library uses it.

The Real Constraint: Flash

Cortex-M parts often have more SRAM than the algorithms strictly need, but flash is finite. A complete TLS or secure boot implementation with PQC support has to fit:

  • The PQC algorithm code (12-20 KB per algorithm)
  • A TLS or secure-channel state machine (40-60 KB)
  • Driver code, boot code, application logic (varies)

Adding ML-KEM and ML-DSA support to an existing TLS stack typically adds 30-50 KB of flash. This eats into the budget for application code on smaller parts. On 256 KB or 512 KB flash parts, this is not an issue. On 64 KB or 128 KB parts, it is a real constraint.

For more on memory budgets, see our PQC stack memory analysis article.

Cortex-M0 and Cortex-M33

Most published benchmarks focus on Cortex-M4 because it is the most common target with DSP extensions. Cortex-M0 is more constrained: no single-cycle multiply-accumulate, fewer registers, smaller code density. Lattice-based PQC on M0 is slower (rough estimates suggest 3-5x slower than M4 for ML-KEM) and tighter on flash.

Cortex-M33 (the security-enabled successor with TrustZone) typically has similar performance to M4 (or better, depending on the implementation). The TrustZone-M extensions allow PQC implementations to run inside the secure world, with the application running in the non-secure world. This is the right architecture for products that need to protect signing keys: the keys never leave the secure world, and the non-secure application only sees signature outputs.

Cortex-M55 and Cortex-M85 add Helium (M-profile vector extension) for SIMD operations, which speeds up lattice arithmetic substantially. These parts are still rolling out in production silicon, so benchmark numbers are emerging gradually.

Cortex-M7 sits between the M4 and the application-class M-profile cores in performance. M7 typically runs at 200-480 MHz with optional double-precision FPU and dual-issue capability. For PQC on M7, expect 2-3x speedup over M4 for the same algorithms, mostly from higher clock speed and the dual-issue advantage on independent instructions. STM32H7 series (Cortex-M7 at 480 MHz) handles ML-KEM-1024 in roughly 3 ms per operation and ML-DSA-87 signing in roughly 8 ms median, both fast enough for almost any embedded use case.

The biggest M7 advantage for PQC is RAM. STM32H7 parts ship with 1 MB of internal SRAM, far more than the smaller M4 parts. The full ML-DSA-87 working set (about 17 KB) is barely 2 percent of available RAM. This headroom matters for designs that need to run multiple PQC operations concurrently, or for designs that use heavily-optimized implementations that trade extra RAM for speed.

Constant-Time Considerations

Implementing PQC on Cortex-M correctly requires constant-time arithmetic at the inner loops. Branch-on-data, table lookups indexed by secret values, and variable-time arithmetic operations all leak secret information through cache and timing channels.

The pqm4 implementations are written carefully to avoid these issues. They use bit-twiddling tricks to convert what would naively be branches into branchless arithmetic, they ensure all rejection-sampling decisions ultimately produce constant-time outputs, and they avoid memory access patterns that depend on secrets.

Even with careful implementation, the compiler can reintroduce timing leaks. Modern GCC and LLVM optimizers sometimes generate branches from what looked like branchless code in C. For high-stakes deployments, post-compile inspection of the generated assembly is essential. Some teams freeze the toolchain version and validate that the generated code is constant-time per their threat model.

What This Means in Practice

For most embedded products that do TLS or secure boot today, ML-KEM-512 and ML-DSA-44 are deployable now on Cortex-M4 and above. The flash and stack overhead is manageable, the runtime is acceptable for most use cases (a few milliseconds per operation), and the algorithms are NIST-standardized.

For tiny Cortex-M0 parts (16-32 KB flash, 4-8 KB SRAM), PQC is harder. ML-KEM-512 might fit, but it leaves little room for anything else. Designs targeting these parts might have to wait for further code-size optimizations or move to a slightly larger MCU.

For high-frequency signing (per-packet TLS signatures, real-time CAN bus authentication), ML-DSA is the right choice. SLH-DSA's signing time (seconds, not milliseconds) is a non-starter for these workloads.

For secure boot, where you sign a firmware image once and verify it many times, SLH-DSA is acceptable. The signer is offline (build server with infinite resources), and the verifier on the device runs the verify function once per boot, which pqm4 measures at about 7.5 to 70 million cycles on a Cortex-M4 at the 128-bit level, depending on the parameter set (SPHINCS+ figures): roughly 0.3 to 3 seconds at its 24 MHz test clock.

QNSQY does not run on Cortex-M directly. It is a desktop tool. But the underlying algorithms (ML-KEM, ML-DSA) are exactly the ones embedded engineers will be deploying for years. If a device only stores or relays files, encrypting them with QNSQY on a Linux or Windows computer first gives them NIST-standardized post-quantum confidentiality while they are on the device, without the device running any cryptography. Decrypting them again needs QNSQY on a computer.

FAQ

Can I run ML-KEM on a Cortex-M0? Probably yes, but it will be slow (tens of milliseconds per operation) and tight on flash. Most production designs targeting Cortex-M0 are reserving these parts for ECC-class workloads and using Cortex-M4 or above for PQC.

What stack size do I need for ML-DSA-44? About 10 KB minimum, on a Cortex-M4 with the standard pqm4 implementation. Highly optimized implementations can shrink this somewhat, but reserve 12-16 KB for headroom.

Is SLH-DSA viable for embedded? For low-frequency operations (firmware update verification once per boot), yes. For per-message signing, no. The signing time on a Cortex-M4 is measured in seconds, not milliseconds.

Should I use a hardware crypto accelerator? If your part has one, yes. Hash accelerators speed up all three NIST PQC schemes meaningfully. Some newer parts also have Keccak-specific accelerators that target SHAKE-based PQC explicitly.

Can I migrate from ECC to ML-KEM in the same flash budget? Roughly, but expect to add 20-40 KB of flash for full PQC support. ECC can fit in 8-12 KB; ML-KEM plus ML-DSA together typically takes 25-35 KB.

Sources

  1. NIST FIPS 203 (ML-KEM): https://csrc.nist.gov/pubs/fips/203/final
  2. NIST FIPS 204 (ML-DSA): https://csrc.nist.gov/pubs/fips/204/final
  3. NIST FIPS 205 (SLH-DSA): https://csrc.nist.gov/pubs/fips/205/final
  4. ARM Cortex-M Series Documentation: https://developer.arm.com/Processors/Cortex-M
  5. ARMv7-M Architecture Reference Manual: https://developer.arm.com/documentation/ddi0403/latest
  6. NIST SP 800-208 (Stateful Hash-Based Signatures): https://csrc.nist.gov/pubs/sp/800/208/final

Related Articles

Protect Your Data Before Q-Day Arrives

QNSQY's NIST-standardized post-quantum encryption protects files against both current and quantum-era threats.

Try QNSQY