Skip to content

Commit

Permalink
[sival,kmac] Add SHA3 NIST CAVP KAT tests
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Dai <[email protected]>
  • Loading branch information
milesdai committed Nov 19, 2024
1 parent c51a1f6 commit 4c8d3ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sw/device/tests/crypto/cryptotest/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ cryptotest(
test_vectors = SHA512_TESTVECTOR_TARGETS,
)

SHA3_224_TESTVECTOR_TARGETS = [
"//sw/host/cryptotest/testvectors/data:nist_cavp_sha3_fips_202_sha3_224_{}_json".format(
msg_type.lower(),
)
for msg_type in [
"ShortMsg",
"LongMsg",
]
]

SHA3_224_TESTVECTOR_ARGS = " ".join([
"--hash-json=\"$(rootpath {})\"".format(target)
for target in SHA3_224_TESTVECTOR_TARGETS
])

cryptotest(
name = "sha3_224_kat",
test_args = SHA3_224_TESTVECTOR_ARGS,
test_harness = "//sw/host/tests/crypto/hash_kat:harness",
test_vectors = SHA3_224_TESTVECTOR_TARGETS,
)

SHA3_256_TESTVECTOR_TARGETS = [
"//sw/host/cryptotest/testvectors/data:nist_cavp_sha3_fips_202_sha3_256_{}_json".format(
msg_type.lower(),
Expand Down Expand Up @@ -418,6 +440,7 @@ test_suite(
":kmac_kat",
":sha256_kat",
":sha384_kat",
":sha3_224_kat",
":sha3_256_kat",
":sha3_384_kat",
":sha3_512_kat",
Expand Down
5 changes: 5 additions & 0 deletions sw/host/cryptotest/testvectors/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ ECDSA_RANDOM_COUNT = 128
]
]

################################################################################
# SHA2, SHA3 - NIST CAVP KAT
################################################################################

[
run_binary(
name = "nist_cavp_{}_{}_{}_json".format(
Expand Down Expand Up @@ -214,6 +218,7 @@ ECDSA_RANDOM_COUNT = 128
("SHA256", "sha2_fips_180_4", []),
("SHA384", "sha2_fips_180_4", []),
("SHA512", "sha2_fips_180_4", []),
("SHA3_224", "sha3_fips_202", []),
("SHA3_256", "sha3_fips_202", []),
("SHA3_384", "sha3_fips_202", []),
("SHA3_512", "sha3_fips_202", []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"SHA256": "sha-256",
"SHA384": "sha-384",
"SHA512": "sha-512",
"SHA3_224": "sha3-224",
"SHA3_256": "sha3-256",
"SHA3_384": "sha3-384",
"SHA3_512": "sha3-512",
Expand Down

0 comments on commit 4c8d3ce

Please sign in to comment.