Tests: Add AVR baremetal tests#1158
Open
mkannwischer wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
The ACVP tests for verification require the return value of the main function to properly test invalid signatures. Currently the AVR harness does not propagate the return codes. That needs to be fixed first. |
971c25c to
346b78d
Compare
Contributor
CBMC Results (ML-DSA-87, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-65, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-44, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-44)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-65)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-87)Full Results (205 proofs)
|
Contributor
Author
That is now added in. Also the UBSan tests were ported from mlkem-native |
b706360 to
76b822c
Compare
On platforms with 16-bit int, several shift and conversion idioms relied on int being at least 32 bits: - Shift constants exceeding 16-bit int need explicit int32_t (reduce.h, rounding.h, MLDSA_GAMMA1 in params.h) - The ghost bound parameter of mld_ntt_butterfly_block reaches up to 9 * MLD_FQMUL_BOUND and does not fit unsigned int; use uint32_t - Use unsigned for the Keccak rate in fips202x4.c (as in mlkem-native) - Keep the nonce computation in mld_yvec_get_poly_lazy unsigned to avoid signed/unsigned conversion when uint16_t does not promote to int Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
Decode the hex values of ACVP command line arguments in place inside the argument strings instead of into separate stack buffers. This reduces peak RAM usage by up to ~13KB, which is required to fit ML-DSA-87 sigGen into the 64KB data address space of AVR. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
Port the AVR baremetal build and test environment from mlkem-native, using avr-gcc and a patched simavr (ATmega128rfr2 with RAM bumped to the maximal 63.5K of the 16-bit data address space, 32K EEPROM). Unlike mlkem-native, the argc/argv block is placed at the top of RAM at a per-invocation address chosen by the exec wrapper and passed via EEPROM; startup code points the stack directly below it. This is needed because ML-DSA test binaries have conflicting demands: the functional and RNG-failure tests carry up to ~24K of .data test vectors, while the ACVP binaries receive up to ~31K of hex-encoded arguments. Test exit codes are propagated through simavr's exit-code commands (buserror/simavr@c9354b3, not yet in a release, backported as a patch): the firmware declares a command register via AVR_MCU_SIMAVR_COMMAND, and an exit() override forwards the return value of main(). The .mmcu section holding the register declaration must be placed outside the flash address range: the linker otherwise places it between the .text and .data load segments, and simavr then loads .data at the wrong address, breaking the firmware. The tests are built with -fno-wrapv -fsanitize=undefined -fsanitize-trap=undefined to detect UB (such as signed-shift overflow on 16-bit int) at runtime; avr-gcc otherwise defaults to -fwrapv, hiding such UB. On a trap, the abort() override in the test wrapper prints an error and exits nonzero. Builds use MLD_CONFIG_REDUCE_RAM and a single test iteration. Functional, RNG-failure, and ACVP tests pass in simavr for all parameter sets. Unit tests exceed avr-gcc's per-function stack frame limit and are disabled. In CI, only the ACVP tests are run to keep the runtime manageable. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.