| 114 | # sample returns an input message, and a list of rejection causes it encounters, |
| 115 | # from "z", "r0", "z/r0", "h". |
| 116 | def sample(): |
| 117 | # Running "bin/go test crypto/internal/fips140/mldsa -run TestSample/ML-DSA-44 -v -count 1" produces: |
| 118 | # |
| 119 | # === RUN TestSample |
| 120 | # === RUN TestSample/ML-DSA-44 |
| 121 | # seed: ZAI62RWMNI4MANGIWMBGAT7BME |
| 122 | # rejection: r0 |
| 123 | # rejection: z/r0 |
| 124 | # rejection: z |
| 125 | # rejection: r0 |
| 126 | # --- PASS: TestSample (0.00s) |
| 127 | # --- PASS: TestSample/ML-DSA-44 (0.00s) |
| 128 | # PASS |
| 129 | # ok crypto/internal/fips140/mldsa 0.183s |
| 130 | import subprocess |
| 131 | proc = subprocess.run( |
| 132 | ["./mldsa.test", "-test.run", f"TestSample/ML-DSA-{sys.argv[1]}", "-test.v", "-test.count", "1"], |
| 133 | capture_output=True, |
| 134 | text=True, |
| 135 | ) |
| 136 | lines = proc.stdout.splitlines() |
| 137 | seed_line = next(line for line in lines if line.startswith("seed: ")) |
| 138 | seed = seed_line[len("seed: "):] |
| 139 | rejections = [line[len("rejection: "):] for line in lines if line.startswith("rejection: ")] |
| 140 | return (seed, rejections) |
| 141 | |
| 142 | remaining_only_z = fails_only_z |
| 143 | remaining_only_r0 = fails_only_r0 |