Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sw/device/tests/penetrationtests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load(":pentest.bzl", "pentest_cryptolib_fi_asym", "pentest_cryptolib_fi_gdb_asym", "pentest_cryptolib_fi_gdb_sym", "pentest_cryptolib_fi_sym", "pentest_cryptolib_sca_asym", "pentest_cryptolib_sca_sym", "pentest_fi", "pentest_fi_ibex", "pentest_fi_otbn", "pentest_gdb_unit", "pentest_owner_upgrade_fi_gdb", "pentest_owner_upgrade_self_signed_fi_gdb", "pentest_rom_ext_fi_gdb", "pentest_rom_ext_rollback_fi_gdb", "pentest_rom_fi_gdb", "pentest_rom_rollback_fi_gdb", "pentest_sca")
load(":pentest.bzl", "pentest_cryptolib_fi_asym", "pentest_cryptolib_fi_gdb_asym", "pentest_cryptolib_fi_gdb_sym", "pentest_cryptolib_fi_sym", "pentest_cryptolib_sca_asym", "pentest_cryptolib_sca_sym", "pentest_fi", "pentest_fi_ibex", "pentest_fi_otbn", "pentest_gdb_unit", "pentest_owner_upgrade_fi_gdb", "pentest_owner_upgrade_self_signed_fi_gdb", "pentest_rom_ext_fi_gdb", "pentest_rom_ext_imm_skip_fi_gdb", "pentest_rom_ext_rollback_fi_gdb", "pentest_rom_fi_gdb", "pentest_rom_rollback_fi_gdb", "pentest_sca")
load("@ot_python_deps//:requirements.bzl", "requirement")

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -526,6 +526,17 @@ pentest_rom_ext_rollback_fi_gdb(
test_vectors = [],
)

pentest_rom_ext_imm_skip_fi_gdb(
name = "fi_rom_ext_imm_skip_python_gdb_test",
tags = [
"manual",
"skip_in_ci",
],
test_args = "",
test_harness = "//sw/host/penetrationtests/python/fi:fi_rom_ext_imm_skip_python_gdb_test",
test_vectors = [],
)

# This test is to perform unit tests of instruction skipping (also in CI).
# The functional test
pentest_gdb_unit(
Expand Down
41 changes: 41 additions & 0 deletions sw/device/tests/penetrationtests/firmware/testdata/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ load(
"otp_hex",
"otp_image",
"otp_json",
"otp_json_immutable_rom_ext",
"otp_partition",
)

Expand Down Expand Up @@ -193,6 +194,46 @@ otp_image(
],
)

otp_json_immutable_rom_ext(
name = "otp_json_rom_ext_imm_skip_fi",
testonly = True,
partitions = [
otp_partition(
name = "CREATOR_SW_CFG",
items = {
"CREATOR_SW_CFG_RMA_SPIN_EN": otp_hex(CONST.HARDENED_TRUE),
# Number of Ibex cycles to spin: we set this to the highest value
"CREATOR_SW_CFG_RMA_SPIN_CYCLES": "0xffffffff",
# Enable the immutable ROM_EXT
"CREATOR_SW_CFG_IMMUTABLE_ROM_EXT_EN": otp_hex(CONST.HARDENED_TRUE),
# Set the hash to a bogus value
"CREATOR_SW_CFG_IMMUTABLE_ROM_EXT_SHA256_HASH": otp_hex(0x1234),
},
),
otp_partition(
name = "SECRET2",
items = {
# We set reproducible bitstreams for the tests
"RMA_TOKEN": "0000000000000005",
"CREATOR_ROOT_KEY_SHARE0": "1111111111111111111111111111111111111111111111111111111111111111",
"CREATOR_ROOT_KEY_SHARE1": "2222222222222222222222222222222222222222222222222222222222222222",
},
lock = True,
),
],
rom_ext = "//sw/device/silicon_creator/rom_ext:rom_ext_dice_x509_slot_virtual",
visibility = ["//visibility:private"],
)

otp_image(
name = "otp_img_rom_ext_imm_skip_fi",
testonly = True,
src = "//hw/ip/otp_ctrl/data:otp_json_rma",
overlays = STD_OTP_OVERLAYS + [
":otp_json_rom_ext_imm_skip_fi",
],
)

exports_files(["bl0_owner_upgrade.c"])

exports_files(["bl0_self_signed_owner_upgrade.c"])
Expand Down
33 changes: 33 additions & 0 deletions sw/device/tests/penetrationtests/pentest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,39 @@ def pentest_rom_ext_rollback_fi_gdb(name, test_vectors, test_args, test_harness,
deps = FIRMWARE_DEPS_CRYPTOLIB_FI_ASYM,
)

def pentest_rom_ext_imm_skip_fi_gdb(name, test_vectors, test_args, test_harness, tags):
"""A macro for defining a CryptoTest test case.

Args:
name: the name of the test.
test_vectors: the test vectors to use.
test_args: additional arguments to pass to the test.
test_harness: the test harness to use.
tags: indicate the tags for CI.
"""
opentitan_test(
name = name,
exec_env = {
"//hw/top_earlgrey:fpga_cw340_rom_ext": None,
},
# Provide a correctly signed binary
srcs = ["//sw/device/tests/penetrationtests/firmware:firmware_cryptolib_fi_asym.c"],
manifest = "//sw/device/silicon_owner:manifest",
fpga = fpga_params(
timeout = "eternal",
# We set an OTP with the RMA lifecycle, ensure ROM_EXT can still boot, but give a bogus ROM_EXT_IMM hash
otp = "//sw/device/tests/penetrationtests/firmware/testdata:otp_img_rom_ext_imm_skip_fi",
data = test_vectors,
tags = tags + ["coverage_broken"],
test_cmd = """
--bootstrap={firmware} --rom_ext={rom_ext} --rom={rom}
""" + test_args,
test_harness = test_harness,
rom_ext = "//sw/device/silicon_creator/rom_ext:rom_ext_dice_x509_slot_virtual",
),
deps = FIRMWARE_DEPS_CRYPTOLIB_FI_ASYM,
)

def pentest_owner_upgrade_fi_gdb(name, test_vectors, test_args, test_harness, tags):
"""A macro for defining a CryptoTest test case.

Expand Down
27 changes: 27 additions & 0 deletions sw/host/penetrationtests/python/fi/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -200,6 +201,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -219,6 +221,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -238,6 +241,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -258,6 +262,26 @@ py_binary(
],
)

py_binary(
name = "fi_rom_ext_imm_skip_python_gdb_test",
testonly = True,
srcs = ["gdb_testing/fi_rom_ext_imm_skip_python_gdb_test.py"],
data = [
"//sw/host/opentitantool",
"//third_party/openocd:jtag_cmsis_dap_adapter_cfg",
"//third_party/openocd:openocd_bin",
"//util/openocd/target:lowrisc-earlgrey.cfg",
"@lowrisc_rv32imcb_toolchain//:bin/riscv32-unknown-elf-gdb",
],
deps = [
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)

py_binary(
name = "fi_sym_cryptolib_python_gdb_test",
testonly = True,
Expand Down Expand Up @@ -339,6 +363,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -358,6 +383,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand All @@ -377,6 +403,7 @@ py_binary(
"//sw/host/penetrationtests/python/util:dis_parser",
"//sw/host/penetrationtests/python/util:gdb_controller",
"//sw/host/penetrationtests/python/util:targets",
"//sw/host/penetrationtests/python/util:utils",
"@rules_python//python/runfiles",
],
)
Expand Down
Loading
Loading