# [Implement post-quantum cryptography on Arm Cortex-M4](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/pqc_pqm4/)

## 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 [GitHub](https://github.com/akashmalik19973) [LinkedIn](https://linkedin.com/in/akash-malik-a65bab219)
- Odin Shen, Arm [GitHub](https://github.com/odincodeshen) [LinkedIn](https://linkedin.com/in/odin-shen-lmshen)

### Arm IP:
[Cortex-M](https://support.arm.com/?tab=compute-ip&Product%20Type=Microcontrollers)

### Tags:
- [Security](/tag/security)
- [Linux](/tag/linux)
- [macOS](/tag/macos)
- [C](/tag/c)
- [Python](/tag/python)
- [GCC](/tag/gcc)
- [stlink](/tag/stlink)
- [QEMU](/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?
Upon completion of this Learning Path, you will be able to:
- 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 will need the following:
- Computer with Python 3.8 or higher
- Arm GNU Toolchain [installed](/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

<details>
<summary>Which target should I use: a physical Cortex-M4 board or QEMU?</summary>
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.
</details>

<details>
<summary>How do I know the pqm4 build completed successfully?</summary>
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.
</details>

<details>
<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.
</details>

<details>
<summary>What results should I expect when running tests and benchmarks?</summary>
The test harness validates correctness against known test vectors. Benchmarks report standardized metrics, including cycle counts, stack usage, and code size.
</details>

<details>
<summary>How do I add a new KEM and verify it's picked up by pqm4?</summary>
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.
</details>
