Skip to content

Commit

Permalink
[cryptotest] add build rule to run SPHINCS+ tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Torok <[email protected]>
  • Loading branch information
RyanTorok committed Jul 1, 2024
1 parent 7ec3381 commit 20dee7f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 19 deletions.
20 changes: 20 additions & 0 deletions sw/device/tests/crypto/cryptotest/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,25 @@ cryptotest(
test_vectors = KMAC_TESTVECTOR_TARGETS,
)

SPHINCSPLUS_TESTVECTOR_TARGETS = [
"//sw/host/cryptotest/testvectors/data:{}".format(target)
for target in [
"rsp_sphincsplus_sha256_128s_simple_json",
]
]

SPHINCSPLUS_TESTVECTOR_ARGS = " ".join([
"--sphincsplus-json=\"$(rootpath {})\"".format(target)
for target in SPHINCSPLUS_TESTVECTOR_TARGETS
])

cryptotest(
name = "sphincsplus_kat",
test_args = SPHINCSPLUS_TESTVECTOR_ARGS,
test_harness = "//sw/host/tests/crypto/sphincsplus_kat:harness",
test_vectors = SPHINCSPLUS_TESTVECTOR_TARGETS,
)

# Use the following command to run the entire test suite in a given target:
# $ export OT_EXEC_ENV=silicon_owner_sival_rom_ext
# $ bazel test --//signing:token=//signing/tokens:cloud_kms \
Expand Down Expand Up @@ -392,5 +411,6 @@ test_suite(
":sha512_kat",
":shake128_kat",
":shake256_kat",
":sphincsplus_kat",
],
)
44 changes: 25 additions & 19 deletions sw/host/cryptotest/testvectors/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -714,25 +714,31 @@ WYCHEPROOF_RSA_PSS_SUFFIXES = {
]
]

run_binary(
name = "rsp_sphincsplus_shake256_128s_simple_json",
srcs = [
"//sw/host/cryptotest/testvectors/data/schemas:sphincsplus_schema.json",
"@sphincsplus_kat//:sphincs-shake256-128s-simple/PQCsignKAT_64.rsp",
],
outs = [":rsp_sphincsplus_shake256_128s_simple.json"],
args = [
"--src",
"$(location @sphincsplus_kat//:sphincs-shake256-128s-simple/PQCsignKAT_64.rsp)",
"--dst",
"$(location :rsp_sphincsplus_shake256_128s_simple.json)",
"--schema",
"$(location //sw/host/cryptotest/testvectors/data/schemas:sphincsplus_schema.json)",
"--hash_alg",
"shake-256",
],
tool = "//sw/host/cryptotest/testvectors/parsers:rsp_sphincsplus_parser",
)
[
run_binary(
name = "rsp_sphincsplus_{}_128s_simple_json".format(hash_alg),
srcs = [
"//sw/host/cryptotest/testvectors/data/schemas:sphincsplus_schema.json",
"@sphincsplus_{h}_kat//:sphincs-{h}-128s-simple/PQCsignKAT_64.rsp".format(h = hash_alg),
],
outs = [":rsp_sphincsplus_{}_128s_simple.json".format(hash_alg)],
args = [
"--src",
"$(location @sphincsplus_{h}_kat//:sphincs-{h}-128s-simple/PQCsignKAT_64.rsp)".format(h = hash_alg),
"--dst",
"$(location :rsp_sphincsplus_{}_128s_simple.json)".format(hash_alg),
"--schema",
"$(location //sw/host/cryptotest/testvectors/data/schemas:sphincsplus_schema.json)",
"--hash_alg",
hash_arg,
],
tool = "//sw/host/cryptotest/testvectors/parsers:rsp_sphincsplus_parser",
)
for (hash_alg, hash_arg) in [
("sha256", "sha-256"),
("shake256", "shake-256"),
]
]

run_binary(
name = "hjson_kmac",
Expand Down

0 comments on commit 20dee7f

Please sign in to comment.