Skip to content

Commit b1ea5fe

Browse files
authored
Merge pull request #489 from pq-code-package/ci-config-variation
CI: Port config-variation action from mlkem-native
2 parents 614529e + d6a3d6f commit b1ea5fe

File tree

3 files changed

+131
-78
lines changed

3 files changed

+131
-78
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
2+
3+
name: 'Custom config tests'
4+
description: 'Build and test mldsa-native with various custom configs'
5+
inputs:
6+
gh_token:
7+
description: 'GitHub token'
8+
required: true
9+
tests:
10+
description: 'List of tests to run (space-separated IDs) or "all" for all tests. Available IDs: pct-enabled, pct-enabled-broken, custom-zeroize, no-asm, custom-randombytes, custom-memcpy, custom-memset, custom-stdlib'
11+
required: false
12+
default: 'all'
13+
opt:
14+
description: 'Optimization level to pass to multi-functest'
15+
required: false
16+
default: 'all'
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: "PCT enabled"
21+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'pct-enabled') }}
22+
uses: ./.github/actions/multi-functest
23+
with:
24+
gh_token: ${{ inputs.gh_token }}
25+
compile_mode: native
26+
cflags: "-DMLD_CONFIG_KEYGEN_PCT -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
27+
func: true
28+
kat: true
29+
acvp: true
30+
opt: ${{ inputs.opt }}
31+
examples: true
32+
- name: "PCT enabled + broken"
33+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'pct-enabled-broken') }}
34+
shell: bash
35+
run: |
36+
make clean
37+
CFLAGS='-DMLD_CONFIG_FILE=\"../test/break_pct_config.h\"' make func -j4
38+
# PCT breakage is done at runtime via MLD_BREAK_PCT
39+
make run_func # Should be OK
40+
MLD_BREAK_PCT=0 make run_func # Should be OK
41+
if (MLD_BREAK_PCT=1 make run_func 2>&1 >/dev/null); then
42+
echo "PCT failure expected"
43+
exit 1
44+
else
45+
echo "PCT failed as expected"
46+
fi
47+
- name: "Custom zeroization (explicit_bzero)"
48+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'custom-zeroize') }}
49+
uses: ./.github/actions/multi-functest
50+
with:
51+
gh_token: ${{ inputs.gh_token }}
52+
compile_mode: native
53+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_zeroize_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
54+
func: true
55+
kat: true
56+
acvp: true
57+
opt: ${{ inputs.opt }}
58+
examples: false # Some examples use a custom config themselves
59+
- name: "No ASM"
60+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'no-asm') }}
61+
uses: ./.github/actions/multi-functest
62+
with:
63+
gh_token: ${{ inputs.gh_token }}
64+
compile_mode: native
65+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/no_asm_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
66+
func: true
67+
kat: true
68+
acvp: true
69+
opt: ${{ inputs.opt }}
70+
examples: false # Some examples use a custom config themselves
71+
- name: "Custom randombytes"
72+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'custom-randombytes') }}
73+
uses: ./.github/actions/multi-functest
74+
with:
75+
gh_token: ${{ inputs.gh_token }}
76+
compile_mode: native
77+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_randombytes_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
78+
func: true
79+
kat: true
80+
acvp: true
81+
opt: ${{ inputs.opt }}
82+
examples: false # Some examples use a custom config themselves
83+
- name: "Custom memcpy"
84+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'custom-memcpy') }}
85+
uses: ./.github/actions/multi-functest
86+
with:
87+
gh_token: ${{ inputs.gh_token }}
88+
compile_mode: native
89+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_memcpy_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
90+
func: true
91+
kat: true
92+
acvp: true
93+
opt: ${{ inputs.opt }}
94+
examples: false # Some examples use a custom config themselves
95+
- name: "Custom memset"
96+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'custom-memset') }}
97+
uses: ./.github/actions/multi-functest
98+
with:
99+
gh_token: ${{ inputs.gh_token }}
100+
compile_mode: native
101+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_memset_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
102+
func: true
103+
kat: true
104+
acvp: true
105+
opt: ${{ inputs.opt }}
106+
examples: false # Some examples use a custom config themselves
107+
- name: "Custom stdlib (memcpy + memset)"
108+
if: ${{ inputs.tests == 'all' || contains(inputs.tests, 'custom-stdlib') }}
109+
uses: ./.github/actions/multi-functest
110+
with:
111+
gh_token: ${{ inputs.gh_token }}
112+
compile_mode: native
113+
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_stdlib_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
114+
func: true
115+
kat: true
116+
acvp: true
117+
opt: ${{ inputs.opt }}
118+
examples: false # Some examples use a custom config themselves

.github/workflows/ci.yml

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -419,86 +419,10 @@ jobs:
419419
runs-on: ${{ matrix.target.runner }}
420420
steps:
421421
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
422-
- name: "PCT enabled"
423-
uses: ./.github/actions/multi-functest
424-
with:
425-
gh_token: ${{ secrets.GITHUB_TOKEN }}
426-
compile_mode: native
427-
cflags: "-DMLD_CONFIG_KEYGEN_PCT -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
428-
func: true
429-
kat: true
430-
acvp: true
431-
- name: "PCT enabled + broken"
432-
run: |
433-
make clean
434-
CFLAGS='-DMLD_CONFIG_FILE=\"../test/break_pct_config.h\"' make func -j4
435-
# PCT breakage is done at runtime via MLD_BREAK_PCT
436-
make run_func # Should be OK
437-
MLD_BREAK_PCT=0 make run_func # Should be OK
438-
if (MLD_BREAK_PCT=1 make run_func 2>&1 >/dev/null); then
439-
echo "PCT failure expected"
440-
exit 1
441-
else
442-
echo "PCT failed as expected"
443-
fi
444-
- name: "Custom zeroization (explicit_bzero)"
445-
uses: ./.github/actions/multi-functest
422+
- name: "Config Variations"
423+
uses: ./.github/actions/config-variations
446424
with:
447425
gh_token: ${{ secrets.GITHUB_TOKEN }}
448-
compile_mode: native
449-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_zeroize_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
450-
func: true
451-
kat: true
452-
acvp: true
453-
examples: false # Some examples use a custom config themselves
454-
- name: "No ASM"
455-
uses: ./.github/actions/multi-functest
456-
with:
457-
gh_token: ${{ secrets.GITHUB_TOKEN }}
458-
compile_mode: native
459-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/no_asm_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
460-
func: true
461-
kat: true
462-
acvp: true
463-
examples: false # Some examples use a custom config themselves
464-
- name: "Custom memcpy"
465-
uses: ./.github/actions/multi-functest
466-
with:
467-
gh_token: ${{ secrets.GITHUB_TOKEN }}
468-
compile_mode: native
469-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_memcpy_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
470-
func: true
471-
kat: true
472-
acvp: true
473-
examples: false # Some examples use a custom config themselves
474-
- name: "Custom memset"
475-
uses: ./.github/actions/multi-functest
476-
with:
477-
gh_token: ${{ secrets.GITHUB_TOKEN }}
478-
compile_mode: native
479-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_memset_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
480-
func: true
481-
kat: true
482-
acvp: true
483-
examples: false # Some examples use a custom config themselves
484-
- name: "Custom stdlib (memcpy + memset)"
485-
uses: ./.github/actions/multi-functest
486-
with:
487-
gh_token: ${{ secrets.GITHUB_TOKEN }}
488-
compile_mode: native
489-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_stdlib_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
490-
func: true
491-
kat: true
492-
acvp: true
493-
examples: false # Some examples use a custom config themselves
494-
- name: "Custom randombytes"
495-
uses: ./.github/actions/multi-functest
496-
with:
497-
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_randombytes_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
498-
func: true
499-
kat: true
500-
acvp: true
501-
examples: false # Some examples use a custom config themselves
502426
check-cf-protections:
503427
name: Test control-flow protections (${{ matrix.compiler.name }}, x86_64)
504428
strategy:

.github/workflows/ci_ec2_reusable.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ on:
5555
test:
5656
type: boolean
5757
default: true
58+
config_variations:
59+
type: string
60+
description: List of configuration variation tests to run (space-separated IDs) or empty for no tests
61+
default: ''
5862
cbmc:
5963
type: boolean
6064
default: false
@@ -168,6 +172,13 @@ jobs:
168172
func: ${{ inputs.functest }}
169173
kat: ${{ inputs.kattest }}
170174
acvp: ${{ inputs.acvptest }}
175+
- name: Config Variations
176+
if: ${{ inputs.config_variations != '' && (success() || failure()) }}
177+
uses: ./.github/actions/config-variations
178+
with:
179+
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
180+
tests: ${{ inputs.config_variations }}
181+
opt: opt
171182
- name: CBMC
172183
if: ${{ inputs.cbmc && (success() || failure()) }}
173184
uses: ./.github/actions/cbmc

0 commit comments

Comments
 (0)