pkg/pqm4: add ML-DSA-44 (FIPS 204) post-quantum signature package#22268
pkg/pqm4: add ML-DSA-44 (FIPS 204) post-quantum signature package#22268cakirmert wants to merge 3 commits into
Conversation
|
Hello, thank you for your contribution to RIOT, we always appreciate that. I want to be quite blunt because the PR description did not follow the standard template for RIOT which felt a bit weird and a small review of the code supported it, is this AI generated? Please switch to the default PR template description and properly declare your AI usage. |
c43666a to
ac3fcaa
Compare
ac3fcaa to
6899874
Compare
|
@AnnsAnns You're right, sorry about that. I've rewritten the description to follow The pqm4 wrapper, the UART fixes (#22269) and the periph_timer driver (#22270) all came out of getting a post-quantum mutual-attestation firmware to run on real Pi Pico 2 H boards. I made the substantive decisions (which pqm4 variant, which features to gate on, what to fix in the PL011 driver); Claude helped me draft, debug, and write up. Every register-level claim was checked against the RP2350 datasheet and PL011 TRM, and the firmware was hardware-tested on Pico 2 H boards before each PR was opened. I should have used the template and declared the tool from the start; sorry for the friction. Happy to take any further changes you'd like to see. |
crasbe
left a comment
There was a problem hiding this comment.
I don't like reviewing AI code...
6899874 to
d6dceb9
Compare
|
@crasbe thanks for the careful review. All 19 threads have been addressed |
Add a RIOT package wrapper for the pqm4 post-quantum crypto library (Kannwischer et al.). The upstream pqm4 sources are unmodified; the package provides fetch/build Makefiles and two glue source files (riot-hal.c, riot-randombytes.c) compiled directly into the pqm4 module via vpath. Currently wired for the ML-DSA-44 m4f (speed-optimised) variant. The m4fstack (memory-optimised, ~7 KiB signing stack) variant can be selected by changing the source paths in Makefile.pqm4. The Cortex-M4F assembly in pqm4 runs unmodified on Cortex-M33 (ARMv8-M Mainline + DSP is a superset of ARMv7E-M + DSP). The package gates on the cortexm_fpu RIOT feature, which restricts it to cortex-m4f, cortex-m7, and cortex-m33 - pre-Thumb-2 and FPU-less cores are skipped at feature resolution. Tested on: Raspberry Pi Pico 2 H (RP2350, Cortex-M33 @ 125 MHz).
Basic round-trip test for the pqm4 package: generates a keypair, signs a test message, verifies the signature, and checks the recovered message matches the original. Includes tests/01-run.py so the test plugs into the standard RIOT testrunner.
d6dceb9 to
da1050d
Compare
|
Please do not squash / force push unless asked to https://github.com/RIOT-OS/RIOT/blob/master/CONTRIBUTING.md#squash-commits-after-review This makes it extremely hard for reviewers to understand changes and breaks any references to existing files on outstanding reviews! |
There was a problem hiding this comment.
Did you actually run this test?
- Switch the copyright header to SPDX format (see #21515) - Reduce double blank lines around testfunc and __main__ guard per reviewer suggestion
|
Hello, once again thank you for being wilful to contribute to RIOT, we do appreciate it. Due to various reasons, such as the currently unresolved legal issues around AI code combined with the very high degree of AI assistance, among other things, we have decided that we can not accept this PR as of now. This is not meant to stop you from contributing to RIOT. For example, if you want to PR code written by yourself, we are open to review and help you. |
Contribution description
Adds
pkg/pqm4as a new RIOT external package, exposing theML-DSA-44 (FIPS 204) post-quantum signature scheme via the upstream
pqm4 library (Kannwischer, Rijneveld,
Schwabe, Stoffelen et al.).
The upstream pqm4 sources are unmodified. The package consists of:
Makefile: fetches pqm4 at a pinned commit, hooksgit submodule update --init mupqintoPKG_PREPAREDso themupq/pqcleansubmodule is in place before consumers buildMakefile.pqm4: explicit SRC list for the m4f (speed-optimised)variant; the m4fstack (memory-optimised, ~7 KiB signing stack)
variant is a one-line edit away
Makefile.include: exports header search paths and CFLAGSMakefile.dep: gates the package on thecortexm_fpufeature(provided by Cortex-M4F / Cortex-M7 / Cortex-M33 with FPU), so
pre-Thumb-2 ARM (e.g. msba2 / LPC23xx) and Cortex-M0/M3/M23 are
skipped at feature-resolution rather than failing in the assembler
glue/riot-hal.c: implements pqm4'smupq/common/hal.hcontract(six functions) over RIOT primitives, replacing upstream
hal-opencm3/hal-mps2glue/riot-randombytes.c: implementsPQCLEAN_randombytes()over RIOT's
random_bytes()The Cortex-M4F assembly in pqm4 runs unmodified on Cortex-M33
(ARMv8-M Mainline + DSP is a strict superset of ARMv7E-M + DSP).
A previous attempt at integrating pqm4 was made in PR #9897 (closed
unmerged in 2019, on the policy concern that ML-DSA was experimental
at the time). ML-DSA was standardised by NIST as FIPS 204 in
August 2024; this PR is the post-standardisation revisit.
Testing procedure
tests/pkg/pqm4performs a keygen / sign / verify round-trip on afixed message. Build and run on a Cortex-M4F-or-later board:
Expected serial output:
Before this PR is applied,
tests/pkg/pqm4does not exist in thetree and no pqm4 integration is available at all. With the PR
applied:
tests/pkg/pqm4builds, flashes, and prints the output above;the package becomes available to any RIOT application via
USEPKG += pqm4(then#include "api.h"to accesscrypto_sign_keypair(),crypto_sign(),crypto_sign_open(),and the matching ML-DSA-44 size constants);
cortexm_fpu(msba2, Cortex-M0/M3/M23 etc.),the build skips at feature-resolution time, reporting
There are unsatisfied feature requirements: cortexm_fpu.Hardware-tested on Raspberry Pi Pico 2 H (RP2350, Cortex-M33 @ 125 MHz).
Issues/PRs references
Supersedes the long-stale PR #9897 (2019 pqm4 integration attempt,
closed because ML-DSA was experimental, but that policy concern is
now obsolete with FIPS 204).
Companion PRs from the same investigation, independent merge order:
cpu/rp2350_common/periph/uart: PL011 FIFO/ISR fixescpu/rp2350_common:periph_timerdriverDeclaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are:
review for code drafting, package layout, PR description authoring,
debugging assistance, and hardware test orchestration. All commits
are authored by me; every code change was reviewed before commit;
the
cortexm_fpugate, thehal.hglue layout, and the testMakefile path were iteratively adjusted in response to maintainer
feedback and CI errors.