Skip to content

Commit 5fb2f9f

Browse files
committed
ACVP: Adjust to actual ACVP flow
This commit ports pq-code-package/mlkem-native#1052 With HashML-DSA support added in #498, we now have full coverage of the ACVP tests allowing us to switch to the actual ACVP flow: In real ACVP validation, the internalProjection is not available. Rather, one gets a prompt containing the inputs and has to produce a result json that has the match the expected results hold by the ACVP server. This commit modifies the acvp_client.py to follow this flow and aligns it with the client in mlkem-native. This in theory allows to perform CAVP validation without any changes, but I have not done that yet. Resolves #294 Signed-off-by: Matthias J. Kannwischer <[email protected]>
1 parent aa9a401 commit 5fb2f9f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/acvp_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ def run_sigGen_test(tg, tc):
185185
assert tg["testType"] == "AFT"
186186

187187
is_deterministic = tg["deterministic"] is True
188-
189-
if tg["preHash"] == "preHash":
188+
if "preHash" in tg and tg["preHash"] == "preHash":
190189
assert len(tc["context"]) <= 2 * 255
191190

192191
# Use specialized SHAKE256 function that computes hash internally
@@ -217,7 +216,7 @@ def run_sigGen_test(tg, tc):
217216
f"hashAlg={tc['hashAlg']}",
218217
]
219218
elif tg["signatureInterface"] == "external":
220-
assert tc["hashAlg"] == "none"
219+
assert "hashAlg" not in tc or tc["hashAlg"] == "none"
221220
assert len(tc["context"]) <= 2 * 255
222221
assert len(tc["message"]) <= 2 * 65536
223222

@@ -230,7 +229,7 @@ def run_sigGen_test(tg, tc):
230229
f"context={tc['context']}",
231230
]
232231
else: # signatureInterface=internal
233-
assert tc["hashAlg"] == "none"
232+
assert "hashAlg" not in tc or tc["hashAlg"] == "none"
234233
externalMu = 0
235234
if tg["externalMu"] is True:
236235
externalMu = 1
@@ -272,7 +271,7 @@ def run_sigVer_test(tg, tc):
272271
results = {"tcId": tc["tcId"]}
273272
acvp_bin = get_acvp_binary(tg)
274273

275-
if tg["preHash"] == "preHash":
274+
if "preHash" in tg and tg["preHash"] == "preHash":
276275
assert len(tc["context"]) <= 2 * 255
277276

278277
# Use specialized SHAKE256 function that computes hash internally
@@ -297,7 +296,7 @@ def run_sigVer_test(tg, tc):
297296
f"hashAlg={tc['hashAlg']}",
298297
]
299298
elif tg["signatureInterface"] == "external":
300-
assert tc["hashAlg"] == "none"
299+
assert "hashAlg" not in tc or tc["hashAlg"] == "none"
301300
assert len(tc["context"]) <= 2 * 255
302301
assert len(tc["message"]) <= 2 * 65536
303302

@@ -310,7 +309,7 @@ def run_sigVer_test(tg, tc):
310309
f"pk={tc['pk']}",
311310
]
312311
else: # signatureInterface=internal
313-
assert tc["hashAlg"] == "none"
312+
assert "hashAlg" not in tc or tc["hashAlg"] == "none"
314313
externalMu = 0
315314
if tg["externalMu"] is True:
316315
externalMu = 1
@@ -331,8 +330,9 @@ def run_sigVer_test(tg, tc):
331330

332331
result = subprocess.run(acvp_call, encoding="utf-8", capture_output=True)
333332
# Extract results
334-
results["testPassed"] == (result.returncode == 0)
333+
results["testPassed"] = result.returncode == 0
335334
info("done")
335+
return results
336336

337337

338338
def runTestSingle(promptName, prompt, expectedResultName, expectedResult, output):

0 commit comments

Comments
 (0)