Skip to content

Commit 774cfe7

Browse files
author
Brian Orr
committed
[cryptotest] ACVP harness for HMAC-SHA2-256
Introduce test harness capable of running ACVP test vectors on the Cryptotest firmware. Test outputs can be written to a result file for uploading to the NIST demo server or another verification authority. Also supports comparing results against a golden reference. This initial version supports HMAC-SHA2, with test vectors and expected outputs that have been verified against the NIST demo server. Signed-off-by: Brian Orr <[email protected]>
1 parent 06f44d0 commit 774cfe7

File tree

7 files changed

+5921
-0
lines changed

7 files changed

+5921
-0
lines changed

sw/device/tests/crypto/cryptotest/BUILD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@ filegroup(
1111
srcs = glob(["**/*.md"]),
1212
)
1313

14+
# Special Cryptotest firmware and harness used to run ACVP test vectors. The
15+
# test_args are left empty by default. This allows the user to manually specify
16+
# paths to the input and output ACVP JSON files that should be used.
17+
#
18+
# Example usage:
19+
# ./bazelisk.sh run \
20+
# //sw/device/tests/crypto/cryptotest:acvp_fpga_cw340_sival_rom_ext -- \
21+
# --input=${ACVP_DIR}/hmac_sha2_256_vectors.json \
22+
# --output=${ACVP_DIR}/hmac_sha2_256_results.json
23+
cryptotest(
24+
name = "acvp",
25+
test_args = "",
26+
test_harness = "//sw/host/tests/crypto/acvp:harness",
27+
test_vectors = [],
28+
)
29+
30+
cryptotest(
31+
name = "acvp_hmac_sha256",
32+
test_args = " ".join([
33+
"--input=\"$(rootpath //sw/host/cryptotest/testvectors/acvp:hmac_sha256_vectors.json)\"",
34+
"--expected=\"$(rootpath //sw/host/cryptotest/testvectors/acvp:hmac_sha256_expected.json)\"",
35+
]),
36+
test_harness = "//sw/host/tests/crypto/acvp:harness",
37+
test_vectors = [
38+
"//sw/host/cryptotest/testvectors/acvp:hmac_sha256_vectors.json",
39+
"//sw/host/cryptotest/testvectors/acvp:hmac_sha256_expected.json",
40+
],
41+
)
42+
1443
AES_TESTVECTOR_TARGETS = [
1544
"//sw/host/cryptotest/testvectors/data:nist_cavp_aes_kat_{}_{}_{}_json".format(alg, kat_type, key_len)
1645
for alg in ("cbc", "cfb128", "ecb", "ofb")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
exports_files([
8+
"hmac_sha256_expected.json",
9+
"hmac_sha256_vectors.json",
10+
])

0 commit comments

Comments
 (0)