# Implement post-quantum cryptography on Arm Cortex-M4

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/)
- [Understand pqm4 and post-quantum cryptography](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/introduction/)
- [Set up the pqm4 development environment](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/setup-installation/)
- [Run pqm4 tests and benchmarks](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/running-tests-and-benchmarks/)
- [Add a KEM implementation to pqm4](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/adding-new-schemes/)
- [Next Steps](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/_next-steps/)

## About this Learning Path

|  |  |
| --- | --- |
| Skill level: | Advanced |
| Reading time: | 2 hrs |
| Last updated: | 13 Aug 2026 |

|  |  |
| --- | --- |
| Authors: | Akash Malik , Arm<br>[GitHub](https://github.com/akashmalik19973)<br>[LinkedIn](https://linkedin.com/in/akash-malik-a65bab219)<br>Odin Shen , Arm<br>[GitHub](https://github.com/odincodeshen)<br>[LinkedIn](https://linkedin.com/in/odin-shen-lmshen) |
| Arm IP: | [Cortex-M](https://support.arm.com/?tab=compute-ip&Product%20Type=Microcontrollers) |
| Tags: | [Security](https://learn.arm.com/tag/security) [Linux](https://learn.arm.com/tag/linux) [macOS](https://learn.arm.com/tag/macos) [C](https://learn.arm.com/tag/c) [Python](https://learn.arm.com/tag/python) [GCC](https://learn.arm.com/tag/gcc) [stlink](https://learn.arm.com/tag/stlink) [QEMU](https://learn.arm.com/tag/qemu) |
| [Security](https://learn.arm.com/tag/security) [Linux](https://learn.arm.com/tag/linux) [macOS](https://learn.arm.com/tag/macos) [C](https://learn.arm.com/tag/c) [Python](https://learn.arm.com/tag/python) [GCC](https://learn.arm.com/tag/gcc) [stlink](https://learn.arm.com/tag/stlink) [QEMU](https://learn.arm.com/tag/qemu) |

| Tags:        |
|--------------|
| [Security](https://learn.arm.com/tag/security), [Linux](https://learn.arm.com/tag/linux), [macOS](https://learn.arm.com/tag/macos), [C](https://learn.arm.com/tag/c), [Python](https://learn.arm.com/tag/python), [GCC](https://learn.arm.com/tag/gcc), [stlink](https://learn.arm.com/tag/stlink), [QEMU](https://learn.arm.com/tag/qemu) |

### Who is this for?
This is an advanced topic for software developers and cryptography enthusiasts interested in implementing and testing post-quantum cryptographic algorithms on Arm Cortex-M4 microcontrollers.

### What will you learn?
After completing this Learning Path, you'll be able to perform the following tasks:
- Describe the design goals and supported algorithms of the pqm4 library.
- Set up the development environment for Arm Cortex-M4.
- Implement and test post-quantum cryptographic algorithms.
- Benchmark and profile cryptographic implementations.
- Integrate new cryptographic schemes into the pqm4 framework.

### Prerequisites
Before starting, you'll need the following prerequisites:
- Computer with Python 3.8 or higher
- Arm GNU Toolchain [installed](https://learn.arm.com/install-guides/gcc/arm-gnu/)
- An Arm Cortex-M4 development board such as NUCLEO-L4R5ZI, NUCLEO-L476RG, or STM32F4 Discovery, with stlink or OpenOCD for flashing. Alternatively, install QEMU to simulate the hardware without a physical board.

### Summary
You’ll use `pqm4` to test and benchmark post-quantum cryptography on Arm Cortex-M4. First, you’ll set up hardware or QEMU, build scheme binaries, and validate implementations against test vectors. Then, you’ll measure cycles, stack usage, and code size. You’ll add a key encapsulation mechanism under `crypto_kem/` so the build system discovers and compiles it.

### Frequently asked questions

**Which target should I use: a physical Cortex-M4 board or QEMU?**

Use a physical board if you have supported hardware and a flashing tool (`stlink` or OpenOCD). Choose QEMU to simulate a Cortex-M4 using the `mps2-an386` platform when hardware isn’t available.

**How do I know the pqm4 build completed successfully?**

You’ll see binaries under `bin/` for each scheme you built. The filenames follow a pattern such as `bin/crypto_kem_ml-kem-768_<impl>_<type>.bin`, indicating the scheme and implementation variant.

<summary>What do implementation variants such as `m4fspeed` and `m4fstack` indicate?</summary>
The `<impl>` field identifies each scheme’s variant. For example, `m4fspeed` is optimized for speed and is used by ML-KEM, while `m4fstack` is another Cortex-M4F variant. The exact suffix depends on the scheme.

**What results should I expect when running tests and benchmarks?**

The test harness validates correctness against known test vectors. Benchmarks report standardized metrics, including cycle counts, stack usage, and code size.

**How do I add a new KEM and verify it's picked up by pqm4?**

Place the new scheme in its own directory under `crypto_kem/`. pqm4’s build system automatically discovers and compiles it. Verify by checking for generated binaries for the new scheme and running the tests and benchmarks.
