diff --git a/sw/device/tests/crypto/cryptotest/firmware/BUILD b/sw/device/tests/crypto/cryptotest/firmware/BUILD index 6662c89146ff4..b271b374686d7 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/BUILD +++ b/sw/device/tests/crypto/cryptotest/firmware/BUILD @@ -143,224 +143,14 @@ cc_library( ], ) -cc_library( - name = "aes_sca", - srcs = ["aes_sca.c"], - hdrs = [ - "aes_sca.h", - "status.h", - ], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:aes", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing:aes_testutils", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:aes", - "//sw/device/sca/lib:prng", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/json:aes_sca_commands", - ], -) - -cc_library( - name = "ibex_fi", - srcs = [ - "ibex_fi.S", - "ibex_fi.c", - ], - hdrs = ["ibex_fi.h"], - deps = [ - "//sw/device/lib/base:csr", - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:flash_ctrl", - "//sw/device/lib/dif:rv_core_ibex", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing:flash_ctrl_testutils", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/json:ibex_fi_commands", - ], -) - -cc_library( - name = "ibex_sca", - srcs = ["ibex_sca.c"], - hdrs = ["ibex_sca.h"], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:keymgr", - "//sw/device/lib/dif:kmac", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing:keymgr_testutils", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/json:ibex_sca_commands", - ], -) - -cc_library( - name = "extclk_sca_fi", - srcs = ["extclk_sca_fi.c"], - hdrs = ["extclk_sca_fi.h"], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:multibits", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:clkmgr", - "//sw/device/lib/runtime:ibex", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing/test_framework:check", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/tests/crypto/cryptotest/json:extclk_sca_fi_commands", - ], -) - -cc_library( - name = "kmac_sca", - srcs = ["kmac_sca.c"], - hdrs = [ - "kmac_sca.h", - "status.h", - ], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:kmac", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:prng", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/json:kmac_sca_commands", - ], -) - -cc_library( - name = "otbn_fi", - srcs = ["otbn_fi.c"], - hdrs = [ - "otbn_fi.h", - "status.h", - ], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/crypto/drivers:keymgr", - "//sw/device/lib/crypto/drivers:otbn", - "//sw/device/lib/dif:otbn", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing:entropy_testutils", - "//sw/device/lib/testing:keymgr_testutils", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_char_hardware_dmem_op_loop", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_char_hardware_reg_op_loop", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_char_unrolled_dmem_op_loop", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_char_unrolled_reg_op_loop", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_key_sideload", - "//sw/device/tests/crypto/cryptotest/firmware/otbn:otbn_load_integrity", - "//sw/device/tests/crypto/cryptotest/json:otbn_fi_commands", - ], -) - -cc_library( - name = "prng_sca", - srcs = ["prng_sca.c"], - hdrs = ["prng_sca.h"], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:prng", - "//sw/device/tests/crypto/cryptotest/json:prng_sca_commands", - ], -) - -cc_library( - name = "sca_lib", - srcs = ["sca_lib.c"], - hdrs = ["sca_lib.h"], - deps = [ - "//sw/device/lib/base:csr", - "//sw/device/lib/dif:alert_handler", - "//sw/device/lib/dif:rstmgr", - "//sw/device/lib/dif:rv_core_ibex", - "//sw/device/lib/dif:rv_plic", - "//sw/device/lib/testing:alert_handler_testutils", - "//sw/device/lib/testing:rv_plic_testutils", - "//sw/device/lib/testing/test_framework:ottf_main", - ], -) - -cc_library( - name = "sha3_sca", - srcs = ["sha3_sca.c"], - hdrs = [ - "sha3_sca.h", - "status.h", - ], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/dif:kmac", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:prng", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/firmware:sca_lib", - "//sw/device/tests/crypto/cryptotest/json:sha3_sca_commands", - ], -) - -cc_library( - name = "trigger_sca", - srcs = ["trigger_sca.c"], - hdrs = ["trigger_sca.h"], - deps = [ - "//sw/device/lib/base:memory", - "//sw/device/lib/base:status", - "//sw/device/lib/runtime:log", - "//sw/device/lib/testing/test_framework:ujson_ottf", - "//sw/device/lib/ujson", - "//sw/device/sca/lib:sca", - "//sw/device/tests/crypto/cryptotest/json:trigger_sca_commands", - ], -) - FIRMWARE_DEPS = [ - ":aes_sca", ":aes", ":drbg", ":ecdh", ":ecdsa", - ":extclk_sca_fi", ":hash", ":hmac", - ":ibex_fi", - ":ibex_sca", - ":kmac_sca", ":kmac", - ":otbn_fi", - ":prng_sca", - ":sha3_sca", - ":trigger_sca", "//sw/device/lib/base:csr", "//sw/device/lib/base:status", "//sw/device/lib/crypto/drivers:entropy", @@ -390,17 +180,3 @@ FIRMWARE_DEPS = [ "silicon_owner_prodc_rom_ext", ] ] - -opentitan_test( - name = "chip_pen_test", - srcs = [":firmware.c"], - exec_env = { - "//hw/top_earlgrey:silicon_owner_sival_rom_ext": "silicon_owner", - "//hw/top_earlgrey:silicon_owner_prodc_rom_ext": "silicon_owner", - "//hw/top_earlgrey:silicon_owner_proda_rom_ext": "silicon_owner", - }, - silicon_owner = silicon_params( - tags = ["broken"], - ), - deps = FIRMWARE_DEPS, -) diff --git a/sw/device/tests/crypto/cryptotest/firmware/firmware.c b/sw/device/tests/crypto/cryptotest/firmware/firmware.c index 544f360fcea60..be1950d5ead72 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/firmware.c +++ b/sw/device/tests/crypto/cryptotest/firmware/firmware.c @@ -12,40 +12,22 @@ // Include commands #include "sw/device/tests/crypto/cryptotest/json/aes_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/aes_sca_commands.h" #include "sw/device/tests/crypto/cryptotest/json/commands.h" #include "sw/device/tests/crypto/cryptotest/json/drbg_commands.h" #include "sw/device/tests/crypto/cryptotest/json/ecdh_commands.h" #include "sw/device/tests/crypto/cryptotest/json/ecdsa_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.h" #include "sw/device/tests/crypto/cryptotest/json/hash_commands.h" #include "sw/device/tests/crypto/cryptotest/json/hmac_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.h" #include "sw/device/tests/crypto/cryptotest/json/kmac_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/prng_sca_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.h" -#include "sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.h" // Include handlers #include "aes.h" -#include "aes_sca.h" #include "drbg.h" #include "ecdh.h" #include "ecdsa.h" -#include "extclk_sca_fi.h" #include "hash.h" #include "hmac.h" -#include "ibex_fi.h" -#include "ibex_sca.h" #include "kmac.h" -#include "kmac_sca.h" -#include "otbn_fi.h" -#include "prng_sca.h" -#include "sha3_sca.h" -#include "trigger_sca.h" OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control = true); @@ -75,33 +57,6 @@ status_t process_cmd(ujson_t *uj) { case kCryptotestCommandKmac: RESP_ERR(uj, handle_kmac(uj)); break; - case kCryptotestCommandAesSca: - RESP_ERR(uj, handle_aes_sca(uj)); - break; - case kCryptotestCommandExtClkScaFi: - RESP_ERR(uj, handle_extclk_sca_fi(uj)); - break; - case kCryptotestCommandIbexFi: - RESP_ERR(uj, handle_ibex_fi(uj)); - break; - case kCryptotestCommandIbexSca: - RESP_ERR(uj, handle_ibex_sca(uj)); - break; - case kCryptotestCommandKmacSca: - RESP_ERR(uj, handle_kmac_sca(uj)); - break; - case kCryptotestCommandOtbnFi: - RESP_ERR(uj, handle_otbn_fi(uj)); - break; - case kCryptotestCommandPrngSca: - RESP_ERR(uj, handle_prng_sca(uj)); - break; - case kCryptotestCommandSha3Sca: - RESP_ERR(uj, handle_sha3_sca(uj)); - break; - case kCryptotestCommandTriggerSca: - RESP_ERR(uj, handle_trigger_sca(uj)); - break; default: LOG_ERROR("Unrecognized command: %d", cmd); RESP_ERR(uj, INVALID_ARGUMENT()); diff --git a/sw/device/tests/crypto/cryptotest/firmware/status.h b/sw/device/tests/crypto/cryptotest/firmware/status.h deleted file mode 100644 index 6faec310b0e61..0000000000000 --- a/sw/device/tests/crypto/cryptotest/firmware/status.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright lowRISC contributors (OpenTitan project). -// Licensed under the Apache License, Version 2.0, see LICENSE for details. -// SPDX-License-Identifier: Apache-2.0 - -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_STATUS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_STATUS_H_ - -#define UJSON_CHECK_DIF_OK(dif_call) \ - do { \ - if (dif_call != kDifOk) { \ - return ABORTED(); \ - } \ - } while (false) - -#define UJSON_CHECK_STATUS_OK(status) \ - do { \ - if (status.value != 0) { \ - return ABORTED(); \ - } \ - } while (false) - -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_STATUS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/BUILD b/sw/device/tests/crypto/cryptotest/json/BUILD index 52049084c8329..18bcc5ab5d6b0 100644 --- a/sw/device/tests/crypto/cryptotest/json/BUILD +++ b/sw/device/tests/crypto/cryptotest/json/BUILD @@ -10,21 +10,12 @@ cc_library( hdrs = ["commands.h"], deps = [ ":aes_commands", - ":aes_sca_commands", ":drbg_commands", ":ecdh_commands", ":ecdsa_commands", - ":extclk_sca_fi_commands", ":hash_commands", ":hmac_commands", - ":ibex_fi_commands", - ":ibex_sca_commands", ":kmac_commands", - ":kmac_sca_commands", - ":otbn_fi_commands", - ":prng_sca_commands", - ":sha3_sca_commands", - ":trigger_sca_commands", "//sw/device/lib/ujson", ], ) @@ -77,66 +68,3 @@ cc_library( hdrs = ["kmac_commands.h"], deps = ["//sw/device/lib/ujson"], ) - -cc_library( - name = "aes_sca_commands", - srcs = ["aes_sca_commands.c"], - hdrs = ["aes_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "ibex_fi_commands", - srcs = ["ibex_fi_commands.c"], - hdrs = ["ibex_fi_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "ibex_sca_commands", - srcs = ["ibex_sca_commands.c"], - hdrs = ["ibex_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "kmac_sca_commands", - srcs = ["kmac_sca_commands.c"], - hdrs = ["kmac_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "otbn_fi_commands", - srcs = ["otbn_fi_commands.c"], - hdrs = ["otbn_fi_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "prng_sca_commands", - srcs = ["prng_sca_commands.c"], - hdrs = ["prng_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "extclk_sca_fi_commands", - srcs = ["extclk_sca_fi_commands.c"], - hdrs = ["extclk_sca_fi_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "sha3_sca_commands", - srcs = ["sha3_sca_commands.c"], - hdrs = ["sha3_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) - -cc_library( - name = "trigger_sca_commands", - srcs = ["trigger_sca_commands.c"], - hdrs = ["trigger_sca_commands.h"], - deps = ["//sw/device/lib/ujson"], -) diff --git a/sw/device/tests/crypto/cryptotest/json/commands.h b/sw/device/tests/crypto/cryptotest/json/commands.h index 0e3a1b9de9792..76325e9186f71 100644 --- a/sw/device/tests/crypto/cryptotest/json/commands.h +++ b/sw/device/tests/crypto/cryptotest/json/commands.h @@ -18,16 +18,7 @@ extern "C" { value(_, Ecdh) \ value(_, Hash) \ value(_, Hmac) \ - value(_, Kmac) \ - value(_, AesSca) \ - value(_, ExtClkScaFi) \ - value(_, IbexFi) \ - value(_, IbexSca) \ - value(_, KmacSca) \ - value(_, OtbnFi) \ - value(_, PrngSca) \ - value(_, Sha3Sca) \ - value(_, TriggerSca) + value(_, Kmac) UJSON_SERDE_ENUM(CryptotestCommand, cryptotest_cmd_t, COMMAND); // clang-format on diff --git a/sw/device/tests/penetrationtests/README.md b/sw/device/tests/penetrationtests/README.md new file mode 100644 index 0000000000000..16309139bf192 --- /dev/null +++ b/sw/device/tests/penetrationtests/README.md @@ -0,0 +1,4 @@ +# Penetration Testing Framework + +The penetration testing framework is based on the [Cryptotest](../crypto/cryptotest/README.md) framework. +The purpose of this framework is to perform side-channel analysis (SCA) and fault injection (FI) attacks on the FPGA as well as on the chip. diff --git a/sw/device/tests/penetrationtests/firmware/BUILD b/sw/device/tests/penetrationtests/firmware/BUILD new file mode 100644 index 0000000000000..fc595938cf083 --- /dev/null +++ b/sw/device/tests/penetrationtests/firmware/BUILD @@ -0,0 +1,253 @@ +# Copyright lowRISC contributors (OpenTitan project). +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +load( + "//rules/opentitan:defs.bzl", + "opentitan_binary", + "opentitan_test", + "silicon_params", +) + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "aes_sca", + srcs = ["aes_sca.c"], + hdrs = ["aes_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:aes", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing:aes_testutils", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:aes", + "//sw/device/sca/lib:prng", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/json:aes_sca_commands", + ], +) + +cc_library( + name = "ibex_fi", + srcs = [ + "ibex_fi.S", + "ibex_fi.c", + ], + hdrs = ["ibex_fi.h"], + deps = [ + "//sw/device/lib/base:csr", + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:flash_ctrl", + "//sw/device/lib/dif:rv_core_ibex", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing:flash_ctrl_testutils", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/json:ibex_fi_commands", + ], +) + +cc_library( + name = "ibex_sca", + srcs = ["ibex_sca.c"], + hdrs = ["ibex_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:keymgr", + "//sw/device/lib/dif:kmac", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing:keymgr_testutils", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/json:ibex_sca_commands", + ], +) + +cc_library( + name = "extclk_sca_fi", + srcs = ["extclk_sca_fi.c"], + hdrs = ["extclk_sca_fi.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:multibits", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:clkmgr", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/tests/penetrationtests/json:extclk_sca_fi_commands", + ], +) + +cc_library( + name = "kmac_sca", + srcs = ["kmac_sca.c"], + hdrs = ["kmac_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:kmac", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:prng", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/json:kmac_sca_commands", + ], +) + +cc_library( + name = "otbn_fi", + srcs = ["otbn_fi.c"], + hdrs = ["otbn_fi.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/crypto/drivers:keymgr", + "//sw/device/lib/crypto/drivers:otbn", + "//sw/device/lib/dif:otbn", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing:entropy_testutils", + "//sw/device/lib/testing:keymgr_testutils", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_char_hardware_dmem_op_loop", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_char_hardware_reg_op_loop", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_char_unrolled_dmem_op_loop", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_char_unrolled_reg_op_loop", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_key_sideload", + "//sw/device/tests/penetrationtests/firmware/otbn:otbn_load_integrity", + "//sw/device/tests/penetrationtests/json:otbn_fi_commands", + ], +) + +cc_library( + name = "prng_sca", + srcs = ["prng_sca.c"], + hdrs = ["prng_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:prng", + "//sw/device/tests/penetrationtests/json:prng_sca_commands", + ], +) + +cc_library( + name = "sca_lib", + srcs = ["sca_lib.c"], + hdrs = ["sca_lib.h"], + deps = [ + "//sw/device/lib/base:csr", + "//sw/device/lib/dif:alert_handler", + "//sw/device/lib/dif:rstmgr", + "//sw/device/lib/dif:rv_core_ibex", + "//sw/device/lib/dif:rv_plic", + "//sw/device/lib/testing:alert_handler_testutils", + "//sw/device/lib/testing:rv_plic_testutils", + "//sw/device/lib/testing/test_framework:ottf_main", + ], +) + +cc_library( + name = "sha3_sca", + srcs = ["sha3_sca.c"], + hdrs = ["sha3_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/dif:kmac", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:prng", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/firmware:sca_lib", + "//sw/device/tests/penetrationtests/json:sha3_sca_commands", + ], +) + +cc_library( + name = "trigger_sca", + srcs = ["trigger_sca.c"], + hdrs = ["trigger_sca.h"], + deps = [ + "//sw/device/lib/base:memory", + "//sw/device/lib/base:status", + "//sw/device/lib/runtime:log", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + "//sw/device/sca/lib:sca", + "//sw/device/tests/penetrationtests/json:trigger_sca_commands", + ], +) + +FIRMWARE_DEPS = [ + ":aes_sca", + ":extclk_sca_fi", + ":ibex_fi", + ":ibex_sca", + ":kmac_sca", + ":otbn_fi", + ":prng_sca", + ":sha3_sca", + ":trigger_sca", + "//sw/device/lib/base:csr", + "//sw/device/lib/base:status", + "//sw/device/lib/crypto/drivers:entropy", + "//sw/device/lib/testing/test_framework:check", + "//sw/device/lib/testing/test_framework:ottf_main", + "//sw/device/lib/testing/test_framework:ujson_ottf", + "//sw/device/lib/ujson", + + # Include all JSON commands. + "//sw/device/tests/penetrationtests/json:commands", +] + +[ + opentitan_binary( + name = "firmware_{}".format(exec_env), + testonly = True, + srcs = [":firmware.c"], + exec_env = [ + "//hw/top_earlgrey:{}".format(exec_env), + ], + deps = FIRMWARE_DEPS, + ) + for exec_env in [ + "fpga_cw310_test_rom", + "silicon_owner_sival_rom_ext", + "silicon_owner_proda_rom_ext", + "silicon_owner_prodc_rom_ext", + ] +] + +opentitan_test( + name = "chip_pen_test", + srcs = [":firmware.c"], + exec_env = { + "//hw/top_earlgrey:silicon_owner_sival_rom_ext": "silicon_owner", + "//hw/top_earlgrey:silicon_owner_prodc_rom_ext": "silicon_owner", + "//hw/top_earlgrey:silicon_owner_proda_rom_ext": "silicon_owner", + }, + silicon_owner = silicon_params( + tags = ["broken"], + ), + deps = FIRMWARE_DEPS, +) diff --git a/sw/device/tests/crypto/cryptotest/firmware/aes_sca.c b/sw/device/tests/penetrationtests/firmware/aes_sca.c similarity index 93% rename from sw/device/tests/crypto/cryptotest/firmware/aes_sca.c rename to sw/device/tests/penetrationtests/firmware/aes_sca.c index f04cb8159209f..65f0fd59818c1 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/aes_sca.c +++ b/sw/device/tests/penetrationtests/firmware/aes_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/aes_sca.h" +#include "sw/device/tests/penetrationtests/firmware/aes_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -14,9 +14,8 @@ #include "sw/device/sca/lib/aes.h" #include "sw/device/sca/lib/prng.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/firmware/status.h" -#include "sw/device/tests/crypto/cryptotest/json/aes_sca_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/aes_sca_commands.h" #if !OT_IS_ENGLISH_BREAKFAST #include "sw/device/lib/testing/aes_testutils.h" @@ -209,8 +208,8 @@ static void aes_manual_trigger(void) { * @param uj The received uJSON data. */ status_t handle_aes_sca_key_set(ujson_t *uj) { - cryptotest_aes_sca_key_t uj_key_data; - TRY(ujson_deserialize_cryptotest_aes_sca_key_t(uj, &uj_key_data)); + penetrationtest_aes_sca_key_t uj_key_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_key_t(uj, &uj_key_data)); memcpy(key_fixed, uj_key_data.key, uj_key_data.key_length); block_ctr = 0; @@ -275,9 +274,9 @@ static status_t aes_send_ciphertext(bool only_first_word, ujson_t *uj) { } while (!ready); dif_aes_data_t ciphertext; - UJSON_CHECK_DIF_OK(dif_aes_read_output(&aes, &ciphertext)); + TRY(dif_aes_read_output(&aes, &ciphertext)); - cryptotest_aes_sca_ciphertext_t uj_output; + penetrationtest_aes_sca_ciphertext_t uj_output; memset(uj_output.ciphertext, 0, AESSCA_CMD_MAX_DATA_BYTES); uj_output.ciphertext_length = kAesTextLength; if (only_first_word) { @@ -285,7 +284,7 @@ static status_t aes_send_ciphertext(bool only_first_word, ujson_t *uj) { } memcpy(uj_output.ciphertext, (uint8_t *)ciphertext.data, uj_output.ciphertext_length); - RESP_OK(ujson_serialize_cryptotest_aes_sca_ciphertext_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_aes_sca_ciphertext_t, uj, &uj_output); return OK_STATUS(0); } @@ -303,8 +302,8 @@ static status_t aes_send_ciphertext(bool only_first_word, ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_single_encrypt(ujson_t *uj) { - cryptotest_aes_sca_text_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_text_t(uj, &uj_data)); + penetrationtest_aes_sca_text_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_text_t(uj, &uj_data)); if (uj_data.text_length != kAesTextLength) { return OUT_OF_RANGE(); } @@ -397,8 +396,8 @@ static void aes_serial_advance_random_data(void) { * @param uj The received uJSON data. */ status_t handle_aes_sca_batch_encrypt(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); uint32_t num_encryptions = 0; num_encryptions = read_32(uj_data.data); @@ -455,8 +454,8 @@ status_t handle_aes_sca_batch_encrypt(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_batch_alternative_encrypt(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); // Get num_encryptions from input uint32_t num_encryptions = 0; @@ -505,9 +504,9 @@ status_t handle_aes_sca_batch_alternative_encrypt(ujson_t *uj) { } // send last ciphertext - cryptotest_aes_sca_ciphertext_t uj_output; + penetrationtest_aes_sca_ciphertext_t uj_output; memcpy(uj_output.ciphertext, (uint8_t *)ciphertext.data, kAesTextLength); - RESP_OK(ujson_serialize_cryptotest_aes_sca_ciphertext_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_aes_sca_ciphertext_t, uj, &uj_output); return OK_STATUS(0); } @@ -527,8 +526,8 @@ status_t handle_aes_sca_batch_alternative_encrypt(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_batch_plaintext_set(ujson_t *uj) { - cryptotest_aes_sca_text_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_text_t(uj, &uj_data)); + penetrationtest_aes_sca_text_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_text_t(uj, &uj_data)); if (uj_data.text_length != kAesTextLength) { return OUT_OF_RANGE(); @@ -553,8 +552,8 @@ status_t handle_aes_sca_batch_plaintext_set(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_fvsr_key_set(ujson_t *uj) { - cryptotest_aes_sca_key_t uj_key_data; - TRY(ujson_deserialize_cryptotest_aes_sca_key_t(uj, &uj_key_data)); + penetrationtest_aes_sca_key_t uj_key_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_key_t(uj, &uj_key_data)); if (uj_key_data.key_length != kAesKeyLength) { return OUT_OF_RANGE(); @@ -590,7 +589,8 @@ status_t handle_aes_sca_fvsr_key_set(ujson_t *uj) { * * @param uj The received uJSON data. */ -status_t aes_sca_fvsr_key_batch_generate(cryptotest_aes_sca_data_t uj_data) { +status_t aes_sca_fvsr_key_batch_generate( + penetrationtest_aes_sca_data_t uj_data) { uint32_t num_encryptions = 0; num_encryptions = read_32(uj_data.data); if (num_encryptions > kNumBatchOpsMax) { @@ -622,8 +622,8 @@ status_t aes_sca_fvsr_key_batch_generate(cryptotest_aes_sca_data_t uj_data) { * @param uj The received uJSON data. */ status_t handle_aes_sca_fvsr_key_batch_generate(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); return aes_sca_fvsr_key_batch_generate(uj_data); } @@ -663,8 +663,8 @@ status_t handle_aes_sca_fvsr_key_batch_generate(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_fvsr_key_batch_encrypt(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); uint32_t num_encryptions = 0; num_encryptions = read_32(uj_data.data); @@ -723,8 +723,8 @@ status_t handle_aes_sca_fvsr_key_batch_encrypt(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_fvsr_data_batch_encrypt(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); uint32_t num_encryptions = 0; num_encryptions = read_32(uj_data.data); @@ -771,8 +771,8 @@ status_t handle_aes_sca_fvsr_data_batch_encrypt(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_seed_lfsr(ujson_t *uj) { - cryptotest_aes_sca_lfsr_t uj_lfsr_data; - TRY(ujson_deserialize_cryptotest_aes_sca_lfsr_t(uj, &uj_lfsr_data)); + penetrationtest_aes_sca_lfsr_t uj_lfsr_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_lfsr_t(uj, &uj_lfsr_data)); uint32_t seed_local = read_32(uj_lfsr_data.seed); if (seed_local == 0) { @@ -791,7 +791,7 @@ status_t handle_aes_sca_seed_lfsr(ujson_t *uj) { if (res.value != 0) { return ABORTED(); } - UJSON_CHECK_DIF_OK(dif_aes_trigger(&aes, kDifAesTriggerPrngReseed)); + TRY(dif_aes_trigger(&aes, kDifAesTriggerPrngReseed)); } #endif @@ -811,8 +811,8 @@ status_t handle_aes_sca_seed_lfsr(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_seed_lfsr_order(ujson_t *uj) { - cryptotest_aes_sca_lfsr_t uj_lfsr_data; - TRY(ujson_deserialize_cryptotest_aes_sca_lfsr_t(uj, &uj_lfsr_data)); + penetrationtest_aes_sca_lfsr_t uj_lfsr_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_lfsr_t(uj, &uj_lfsr_data)); uint32_t seed_local = read_32(uj_lfsr_data.seed); sca_seed_lfsr(seed_local, kScaLfsrOrder); @@ -833,8 +833,8 @@ status_t handle_aes_sca_seed_lfsr_order(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_aes_sca_fvsr_key_start_batch_generate(ujson_t *uj) { - cryptotest_aes_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_data_t(uj, &uj_data)); + penetrationtest_aes_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_data_t(uj, &uj_data)); uint32_t command = 0; command = read_32(uj_data.data); @@ -893,16 +893,15 @@ status_t handle_aes_sca_fvsr_key_start_batch_generate(ujson_t *uj) { */ status_t handle_aes_sca_init(ujson_t *uj) { // Read mode. FPGA or discrete. - cryptotest_aes_sca_fpga_mode_t uj_data; - TRY(ujson_deserialize_cryptotest_aes_sca_fpga_mode_t(uj, &uj_data)); + penetrationtest_aes_sca_fpga_mode_t uj_data; + TRY(ujson_deserialize_penetrationtest_aes_sca_fpga_mode_t(uj, &uj_data)); if (uj_data.fpga_mode == 0x01) { fpga_mode = true; } sca_init(kScaTriggerSourceAes, kScaPeripheralIoDiv4 | kScaPeripheralAes); - UJSON_CHECK_DIF_OK( - dif_aes_init(mmio_region_from_addr(TOP_EARLGREY_AES_BASE_ADDR), &aes)); - UJSON_CHECK_DIF_OK(dif_aes_reset(&aes)); + TRY(dif_aes_init(mmio_region_from_addr(TOP_EARLGREY_AES_BASE_ADDR), &aes)); + TRY(dif_aes_reset(&aes)); // Disable the instruction cache and dummy instructions for better SCA // measurements. diff --git a/sw/device/tests/crypto/cryptotest/firmware/aes_sca.h b/sw/device/tests/penetrationtests/firmware/aes_sca.h similarity index 86% rename from sw/device/tests/crypto/cryptotest/firmware/aes_sca.h rename to sw/device/tests/penetrationtests/firmware/aes_sca.h index 74098fee129b8..1a7176201b456 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/aes_sca.h +++ b/sw/device/tests/penetrationtests/firmware/aes_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_AES_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_AES_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_AES_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_AES_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -41,4 +41,4 @@ status_t handle_aes_sca_select_trigger_source(ujson_t *uj); status_t handle_aes_sca_init(ujson_t *uj); status_t handle_aes_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_AES_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_AES_SCA_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.c b/sw/device/tests/penetrationtests/firmware/extclk_sca_fi.c similarity index 89% rename from sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.c rename to sw/device/tests/penetrationtests/firmware/extclk_sca_fi.c index 1fba212b5cfd9..7ce3661da9d2b 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.c +++ b/sw/device/tests/penetrationtests/firmware/extclk_sca_fi.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.h" +#include "sw/device/tests/penetrationtests/firmware/extclk_sca_fi.h" #include "sw/device/lib/base/multibits.h" #include "sw/device/lib/base/status.h" @@ -14,7 +14,7 @@ #include "sw/device/lib/testing/test_framework/ottf_test_config.h" #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" -#include "sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.h" +#include "sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" @@ -32,8 +32,8 @@ static bool did_extclk_settle(const dif_clkmgr_t *clkmgr) { } status_t handle_extclk_sca_fi_configure(ujson_t *uj) { - cryptotest_extclk_sca_fi_cfg_t uj_data; - TRY(ujson_deserialize_cryptotest_extclk_sca_fi_cfg_t(uj, &uj_data)); + penetrationtest_extclk_sca_fi_cfg_t uj_data; + TRY(ujson_deserialize_penetrationtest_extclk_sca_fi_cfg_t(uj, &uj_data)); TRY(dif_clkmgr_init(mmio_region_from_addr(TOP_EARLGREY_CLKMGR_AON_BASE_ADDR), &clkmgr)); diff --git a/sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.h b/sw/device/tests/penetrationtests/firmware/extclk_sca_fi.h similarity index 77% rename from sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.h rename to sw/device/tests/penetrationtests/firmware/extclk_sca_fi.h index 4a66109b9400c..3a2300bda51f1 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/extclk_sca_fi.h +++ b/sw/device/tests/penetrationtests/firmware/extclk_sca_fi.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_EXTCLK_SCA_FI_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_EXTCLK_SCA_FI_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_EXTCLK_SCA_FI_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_EXTCLK_SCA_FI_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -31,4 +31,4 @@ status_t handle_extclk_sca_fi_configure(ujson_t *uj); */ status_t handle_extclk_sca_fi(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_EXTCLK_SCA_FI_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_EXTCLK_SCA_FI_H_ diff --git a/sw/device/tests/penetrationtests/firmware/firmware.c b/sw/device/tests/penetrationtests/firmware/firmware.c new file mode 100644 index 0000000000000..869e1c970e0b6 --- /dev/null +++ b/sw/device/tests/penetrationtests/firmware/firmware.c @@ -0,0 +1,83 @@ +// Copyright lowRISC contributors (OpenTitan project). +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 +#include + +#include "sw/device/lib/base/status.h" +#include "sw/device/lib/crypto/drivers/entropy.h" +#include "sw/device/lib/testing/test_framework/check.h" +#include "sw/device/lib/testing/test_framework/ottf_main.h" +#include "sw/device/lib/testing/test_framework/ujson_ottf.h" +#include "sw/device/lib/ujson/ujson.h" + +// Include commands +#include "sw/device/tests/penetrationtests/json/aes_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/commands.h" +#include "sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.h" +#include "sw/device/tests/penetrationtests/json/ibex_fi_commands.h" +#include "sw/device/tests/penetrationtests/json/ibex_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/kmac_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/otbn_fi_commands.h" +#include "sw/device/tests/penetrationtests/json/prng_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/sha3_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/trigger_sca_commands.h" + +// Include handlers +#include "aes_sca.h" +#include "extclk_sca_fi.h" +#include "ibex_fi.h" +#include "ibex_sca.h" +#include "kmac_sca.h" +#include "otbn_fi.h" +#include "prng_sca.h" +#include "sha3_sca.h" +#include "trigger_sca.h" + +OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control = true); + +status_t process_cmd(ujson_t *uj) { + while (true) { + penetrationtest_cmd_t cmd; + TRY(ujson_deserialize_penetrationtest_cmd_t(uj, &cmd)); + switch (cmd) { + case kPenetrationtestCommandAesSca: + RESP_ERR(uj, handle_aes_sca(uj)); + break; + case kPenetrationtestCommandExtClkScaFi: + RESP_ERR(uj, handle_extclk_sca_fi(uj)); + break; + case kPenetrationtestCommandIbexFi: + RESP_ERR(uj, handle_ibex_fi(uj)); + break; + case kPenetrationtestCommandIbexSca: + RESP_ERR(uj, handle_ibex_sca(uj)); + break; + case kPenetrationtestCommandKmacSca: + RESP_ERR(uj, handle_kmac_sca(uj)); + break; + case kPenetrationtestCommandOtbnFi: + RESP_ERR(uj, handle_otbn_fi(uj)); + break; + case kPenetrationtestCommandPrngSca: + RESP_ERR(uj, handle_prng_sca(uj)); + break; + case kPenetrationtestCommandSha3Sca: + RESP_ERR(uj, handle_sha3_sca(uj)); + break; + case kPenetrationtestCommandTriggerSca: + RESP_ERR(uj, handle_trigger_sca(uj)); + break; + default: + LOG_ERROR("Unrecognized command: %d", cmd); + RESP_ERR(uj, INVALID_ARGUMENT()); + } + } + + return OK_STATUS(0); +} + +bool test_main(void) { + CHECK_STATUS_OK(entropy_complex_init()); + ujson_t uj = ujson_ottf_console(); + return status_ok(process_cmd(&uj)); +} diff --git a/sw/device/tests/crypto/cryptotest/firmware/ibex_fi.S b/sw/device/tests/penetrationtests/firmware/ibex_fi.S similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/ibex_fi.S rename to sw/device/tests/penetrationtests/firmware/ibex_fi.S diff --git a/sw/device/tests/crypto/cryptotest/firmware/ibex_fi.c b/sw/device/tests/penetrationtests/firmware/ibex_fi.c similarity index 99% rename from sw/device/tests/crypto/cryptotest/firmware/ibex_fi.c rename to sw/device/tests/penetrationtests/firmware/ibex_fi.c index e10e335796583..39c62ab5cc241 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/ibex_fi.c +++ b/sw/device/tests/penetrationtests/firmware/ibex_fi.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/ibex_fi.h" +#include "sw/device/tests/penetrationtests/firmware/ibex_fi.h" #include "sw/device/lib/base/csr.h" #include "sw/device/lib/base/csr_registers.h" @@ -16,8 +16,8 @@ #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/ibex_fi_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" diff --git a/sw/device/tests/crypto/cryptotest/firmware/ibex_fi.h b/sw/device/tests/penetrationtests/firmware/ibex_fi.h similarity index 97% rename from sw/device/tests/crypto/cryptotest/firmware/ibex_fi.h rename to sw/device/tests/penetrationtests/firmware/ibex_fi.h index 9cfe18f99baf3..2b3a356f8afcd 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/ibex_fi.h +++ b/sw/device/tests/penetrationtests/firmware/ibex_fi.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_FI_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_FI_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_FI_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_FI_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -326,4 +326,4 @@ status_t handle_ibex_fi_char_register_file_read(ujson_t *uj); */ status_t handle_ibex_fi(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_FI_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_FI_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c b/sw/device/tests/penetrationtests/firmware/ibex_sca.c similarity index 97% rename from sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c rename to sw/device/tests/penetrationtests/firmware/ibex_sca.c index 2973feab6aea8..2aa5c93e8d748 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c +++ b/sw/device/tests/penetrationtests/firmware/ibex_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/ibex_sca.h" +#include "sw/device/tests/penetrationtests/firmware/ibex_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -14,8 +14,8 @@ #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/ibex_sca_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" diff --git a/sw/device/tests/crypto/cryptotest/firmware/ibex_sca.h b/sw/device/tests/penetrationtests/firmware/ibex_sca.h similarity index 92% rename from sw/device/tests/crypto/cryptotest/firmware/ibex_sca.h rename to sw/device/tests/penetrationtests/firmware/ibex_sca.h index 7aa80c6c71618..9518cff7ef24e 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/ibex_sca.h +++ b/sw/device/tests/penetrationtests/firmware/ibex_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -108,4 +108,4 @@ status_t handle_ibex_sca_init(ujson_t *uj); */ status_t handle_ibex_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_IBEX_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_IBEX_SCA_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/kmac_sca.c b/sw/device/tests/penetrationtests/firmware/kmac_sca.c similarity index 94% rename from sw/device/tests/crypto/cryptotest/firmware/kmac_sca.c rename to sw/device/tests/penetrationtests/firmware/kmac_sca.c index 7165d7cb39576..71cfcdf4e4d44 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/kmac_sca.c +++ b/sw/device/tests/penetrationtests/firmware/kmac_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/kmac_sca.h" +#include "sw/device/tests/penetrationtests/firmware/kmac_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -13,9 +13,8 @@ #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/prng.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/firmware/status.h" -#include "sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/kmac_sca_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" #include "kmac_regs.h" @@ -448,15 +447,14 @@ kmac_sca_error_t kmac_get_digest(uint32_t *out, size_t len) { */ status_t handle_kmac_sca_init(ujson_t *uj) { // Read mode. FPGA or discrete. - cryptotest_kmac_sca_fpga_mode_t uj_data; - TRY(ujson_deserialize_cryptotest_kmac_sca_fpga_mode_t(uj, &uj_data)); + penetrationtest_kmac_sca_fpga_mode_t uj_data; + TRY(ujson_deserialize_penetrationtest_kmac_sca_fpga_mode_t(uj, &uj_data)); if (uj_data.fpga_mode == 0x01) { fpga_mode = true; } // Setup the trigger. sca_init(kScaTriggerSourceKmac, kScaPeripheralIoDiv4 | kScaPeripheralKmac); - UJSON_CHECK_DIF_OK( - dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); + TRY(dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); dif_kmac_config_t config = (dif_kmac_config_t){ .entropy_mode = kDifKmacEntropyModeSoftware, @@ -468,7 +466,7 @@ status_t handle_kmac_sca_init(ujson_t *uj) { .sideload = kDifToggleDisabled, .msg_mask = kDifToggleEnabled, }; - UJSON_CHECK_DIF_OK(dif_kmac_configure(&kmac, config)); + TRY(dif_kmac_configure(&kmac, config)); kmac_block_until_idle(); @@ -494,8 +492,8 @@ status_t handle_kmac_sca_init(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_kmac_sca_set_key(ujson_t *uj) { - cryptotest_kmac_sca_key_t uj_key; - TRY(ujson_deserialize_cryptotest_kmac_sca_key_t(uj, &uj_key)); + penetrationtest_kmac_sca_key_t uj_key; + TRY(ujson_deserialize_penetrationtest_kmac_sca_key_t(uj, &uj_key)); if (uj_key.key_length != kKeyLength) { return OUT_OF_RANGE(); @@ -582,8 +580,8 @@ static kmac_sca_error_t sha3_ujson_absorb(const uint8_t *msg, size_t msg_len) { * @param uj The received uJSON data. */ status_t handle_kmac_sca_single_absorb(ujson_t *uj) { - cryptotest_kmac_sca_msg_t uj_msg; - TRY(ujson_deserialize_cryptotest_kmac_sca_msg_t(uj, &uj_msg)); + penetrationtest_kmac_sca_msg_t uj_msg; + TRY(ujson_deserialize_penetrationtest_kmac_sca_msg_t(uj, &uj_msg)); if (uj_msg.msg_length != kMessageLength) { return OUT_OF_RANGE(); @@ -605,9 +603,10 @@ status_t handle_kmac_sca_single_absorb(ujson_t *uj) { return ABORTED(); } - cryptotest_kmac_sca_batch_digest_t uj_output; + penetrationtest_kmac_sca_batch_digest_t uj_output; memcpy(uj_output.batch_digest, (uint8_t *)out, kDigestLength * 4); - RESP_OK(ujson_serialize_cryptotest_kmac_sca_batch_digest_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_kmac_sca_batch_digest_t, uj, + &uj_output); // Reset before the next absorb since KMAC must be idle before starting // another absorb. @@ -626,8 +625,8 @@ status_t handle_kmac_sca_single_absorb(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_kmac_sca_fixed_key_set(ujson_t *uj) { - cryptotest_kmac_sca_key_t uj_key; - TRY(ujson_deserialize_cryptotest_kmac_sca_key_t(uj, &uj_key)); + penetrationtest_kmac_sca_key_t uj_key; + TRY(ujson_deserialize_penetrationtest_kmac_sca_key_t(uj, &uj_key)); if (uj_key.key_length != kKeyLength) { return OUT_OF_RANGE(); @@ -649,8 +648,8 @@ status_t handle_kmac_sca_fixed_key_set(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_kmac_sca_batch(ujson_t *uj) { - cryptotest_kmac_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_kmac_sca_data_t(uj, &uj_data)); + penetrationtest_kmac_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_kmac_sca_data_t(uj, &uj_data)); uint32_t num_encryptions = 0; uint32_t out[kDigestLength]; @@ -695,9 +694,10 @@ status_t handle_kmac_sca_batch(ujson_t *uj) { } } // Send the batch digest to the host for verification. - cryptotest_kmac_sca_batch_digest_t uj_output; + penetrationtest_kmac_sca_batch_digest_t uj_output; memcpy(uj_output.batch_digest, (uint8_t *)batch_digest, kDigestLength * 4); - RESP_OK(ujson_serialize_cryptotest_kmac_sca_batch_digest_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_kmac_sca_batch_digest_t, uj, + &uj_output); return OK_STATUS(0); } @@ -713,8 +713,8 @@ status_t handle_kmac_sca_batch(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_kmac_sca_seed_lfsr(ujson_t *uj) { - cryptotest_kmac_sca_lfsr_t uj_lfsr_data; - TRY(ujson_deserialize_cryptotest_kmac_sca_lfsr_t(uj, &uj_lfsr_data)); + penetrationtest_kmac_sca_lfsr_t uj_lfsr_data; + TRY(ujson_deserialize_penetrationtest_kmac_sca_lfsr_t(uj, &uj_lfsr_data)); sca_seed_lfsr(read_32(uj_lfsr_data.seed), kScaLfsrMasking); return OK_STATUS(0); diff --git a/sw/device/tests/crypto/cryptotest/firmware/kmac_sca.h b/sw/device/tests/penetrationtests/firmware/kmac_sca.h similarity index 81% rename from sw/device/tests/crypto/cryptotest/firmware/kmac_sca.h rename to sw/device/tests/penetrationtests/firmware/kmac_sca.h index ff575b5a556e6..8a43b90b38333 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/kmac_sca.h +++ b/sw/device/tests/penetrationtests/firmware/kmac_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_KMAC_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_KMAC_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_KMAC_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_KMAC_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -35,4 +35,4 @@ status_t handle_kmac_sca_set_key(ujson_t *uj); status_t handle_kmac_sca_init(ujson_t *uj); status_t handle_kmac_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_KMAC_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_KMAC_SCA_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/BUILD b/sw/device/tests/penetrationtests/firmware/otbn/BUILD similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/BUILD rename to sw/device/tests/penetrationtests/firmware/otbn/BUILD diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_hardware_dmem_op_loop.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_char_hardware_dmem_op_loop.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_hardware_dmem_op_loop.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_char_hardware_dmem_op_loop.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_hardware_reg_op_loop.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_char_hardware_reg_op_loop.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_hardware_reg_op_loop.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_char_hardware_reg_op_loop.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_unrolled_dmem_op_loop.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_char_unrolled_dmem_op_loop.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_unrolled_dmem_op_loop.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_char_unrolled_dmem_op_loop.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_unrolled_reg_op_loop.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_char_unrolled_reg_op_loop.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_char_unrolled_reg_op_loop.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_char_unrolled_reg_op_loop.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_key_sideload.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_key_sideload.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_key_sideload.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_key_sideload.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_load_integrity.s b/sw/device/tests/penetrationtests/firmware/otbn/otbn_load_integrity.s similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/otbn/otbn_load_integrity.s rename to sw/device/tests/penetrationtests/firmware/otbn/otbn_load_integrity.s diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn_fi.c b/sw/device/tests/penetrationtests/firmware/otbn_fi.c similarity index 94% rename from sw/device/tests/crypto/cryptotest/firmware/otbn_fi.c rename to sw/device/tests/penetrationtests/firmware/otbn_fi.c index a63b7134ee88a..edb25ed8a0bb7 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/otbn_fi.c +++ b/sw/device/tests/penetrationtests/firmware/otbn_fi.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/otbn_fi.h" +#include "sw/device/tests/penetrationtests/firmware/otbn_fi.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -14,9 +14,8 @@ #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/firmware/status.h" -#include "sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/otbn_fi_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" #include "otbn_regs.h" @@ -44,9 +43,8 @@ static const keymgr_diversification_t kTestDiversification = { */ status_t read_otbn_err_bits(dif_otbn_err_bits_t *err_bits) { dif_otbn_t otbn; - UJSON_CHECK_DIF_OK( - dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); - UJSON_CHECK_DIF_OK(dif_otbn_get_err_bits(&otbn, err_bits)); + TRY(dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); + TRY(dif_otbn_get_err_bits(&otbn, err_bits)); return OK_STATUS(0); } @@ -57,9 +55,8 @@ status_t read_otbn_err_bits(dif_otbn_err_bits_t *err_bits) { */ status_t read_otbn_load_checksum(uint32_t *checksum) { dif_otbn_t otbn; - UJSON_CHECK_DIF_OK( - dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); - UJSON_CHECK_DIF_OK(dif_otbn_get_load_checksum(&otbn, checksum)); + TRY(dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); + TRY(dif_otbn_get_load_checksum(&otbn, checksum)); return OK_STATUS(0); } @@ -68,9 +65,8 @@ status_t read_otbn_load_checksum(uint32_t *checksum) { */ status_t clear_otbn_load_checksum(void) { dif_otbn_t otbn; - UJSON_CHECK_DIF_OK( - dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); - UJSON_CHECK_DIF_OK(dif_otbn_clear_load_checksum(&otbn)); + TRY(dif_otbn_init(mmio_region_from_addr(TOP_EARLGREY_OTBN_BASE_ADDR), &otbn)); + TRY(dif_otbn_clear_load_checksum(&otbn)); return OK_STATUS(0); } @@ -456,13 +452,10 @@ status_t handle_otbn_fi_char_unrolled_reg_op_loop(ujson_t *uj) { status_t handle_otbn_fi_init_keymgr(ujson_t *uj) { dif_keymgr_t keymgr; dif_kmac_t kmac; - UJSON_CHECK_STATUS_OK(keymgr_testutils_startup(&keymgr, &kmac)); - UJSON_CHECK_STATUS_OK( - keymgr_testutils_advance_state(&keymgr, &kOwnerIntParams)); - UJSON_CHECK_STATUS_OK( - keymgr_testutils_advance_state(&keymgr, &kOwnerRootKeyParams)); - UJSON_CHECK_STATUS_OK( - keymgr_testutils_check_state(&keymgr, kDifKeymgrStateOwnerRootKey)); + TRY(keymgr_testutils_startup(&keymgr, &kmac)); + TRY(keymgr_testutils_advance_state(&keymgr, &kOwnerIntParams)); + TRY(keymgr_testutils_advance_state(&keymgr, &kOwnerRootKeyParams)); + TRY(keymgr_testutils_check_state(&keymgr, kDifKeymgrStateOwnerRootKey)); return OK_STATUS(0); } diff --git a/sw/device/tests/crypto/cryptotest/firmware/otbn_fi.h b/sw/device/tests/penetrationtests/firmware/otbn_fi.h similarity index 81% rename from sw/device/tests/crypto/cryptotest/firmware/otbn_fi.h rename to sw/device/tests/penetrationtests/firmware/otbn_fi.h index ac880796fe938..417a6dca09a21 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/otbn_fi.h +++ b/sw/device/tests/penetrationtests/firmware/otbn_fi.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_OTBN_FI_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_OTBN_FI_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_OTBN_FI_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_OTBN_FI_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/crypto/drivers/otbn.h" @@ -24,4 +24,4 @@ status_t handle_otbn_fi_init_keymgr(ujson_t *uj); status_t handle_otbn_init(ujson_t *uj); status_t handle_otbn_fi(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_OTBN_FI_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_OTBN_FI_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/prng_sca.c b/sw/device/tests/penetrationtests/firmware/prng_sca.c similarity index 85% rename from sw/device/tests/crypto/cryptotest/firmware/prng_sca.c rename to sw/device/tests/penetrationtests/firmware/prng_sca.c index aa72ed448c62f..467d9848a52f1 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/prng_sca.c +++ b/sw/device/tests/penetrationtests/firmware/prng_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/prng_sca.h" +#include "sw/device/tests/penetrationtests/firmware/prng_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -11,7 +11,7 @@ #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/prng.h" -#include "sw/device/tests/crypto/cryptotest/json/prng_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/prng_sca_commands.h" /** * Seed PRNG command handler. @@ -24,8 +24,8 @@ * @param uj The received uJSON data. */ status_t handle_prng_sca_seed_prng(ujson_t *uj) { - cryptotest_prng_sca_lfsr_t uj_data; - TRY(ujson_deserialize_cryptotest_prng_sca_lfsr_t(uj, &uj_data)); + penetrationtest_prng_sca_lfsr_t uj_data; + TRY(ujson_deserialize_penetrationtest_prng_sca_lfsr_t(uj, &uj_data)); if (uj_data.seed_length != sizeof(uint32_t)) { return OUT_OF_RANGE(); diff --git a/sw/device/tests/crypto/cryptotest/firmware/prng_sca.h b/sw/device/tests/penetrationtests/firmware/prng_sca.h similarity index 60% rename from sw/device/tests/crypto/cryptotest/firmware/prng_sca.h rename to sw/device/tests/penetrationtests/firmware/prng_sca.h index 25c10c19e575f..99261419369ef 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/prng_sca.h +++ b/sw/device/tests/penetrationtests/firmware/prng_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_PRNG_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_PRNG_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_PRNG_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_PRNG_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -11,4 +11,4 @@ status_t handle_prng_sca_seed_prng(ujson_t *uj); status_t handle_prng_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_PRNG_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_PRNG_SCA_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/sca_lib.c b/sw/device/tests/penetrationtests/firmware/sca_lib.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/firmware/sca_lib.c rename to sw/device/tests/penetrationtests/firmware/sca_lib.c diff --git a/sw/device/tests/crypto/cryptotest/firmware/sca_lib.h b/sw/device/tests/penetrationtests/firmware/sca_lib.h similarity index 56% rename from sw/device/tests/crypto/cryptotest/firmware/sca_lib.h rename to sw/device/tests/penetrationtests/firmware/sca_lib.h index 7655fcf97b112..04a62f96f1790 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/sca_lib.h +++ b/sw/device/tests/penetrationtests/firmware/sca_lib.h @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SCA_LIB_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SCA_LIB_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SCA_LIB_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SCA_LIB_H_ uint32_t sca_get_triggered_alerts(void); void sca_configure_alert_handler(void); void sca_configure_cpu(void); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SCA_LIB_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SCA_LIB_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/sha3_sca.c b/sw/device/tests/penetrationtests/firmware/sha3_sca.c similarity index 91% rename from sw/device/tests/crypto/cryptotest/firmware/sha3_sca.c rename to sw/device/tests/penetrationtests/firmware/sha3_sca.c index 8d019a4afd1cd..7b2701c844b9a 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/sha3_sca.c +++ b/sw/device/tests/penetrationtests/firmware/sha3_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/sha3_sca.h" +#include "sw/device/tests/penetrationtests/firmware/sha3_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -13,9 +13,8 @@ #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/prng.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/firmware/sca_lib.h" -#include "sw/device/tests/crypto/cryptotest/firmware/status.h" -#include "sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.h" +#include "sw/device/tests/penetrationtests/firmware/sca_lib.h" +#include "sw/device/tests/penetrationtests/json/sha3_sca_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" #include "kmac_regs.h" @@ -364,11 +363,10 @@ static dif_result_t sha3_get_digest(uint32_t *out, size_t len) { * This function configures KMAC/SHA3 with the appropriate mask setting. */ status_t handle_sha3_sca_disable_masking(ujson_t *uj) { - cryptotest_sha3_sca_masks_off_t uj_data; - TRY(ujson_deserialize_cryptotest_sha3_sca_masks_off_t(uj, &uj_data)); + penetrationtest_sha3_sca_masks_off_t uj_data; + TRY(ujson_deserialize_penetrationtest_sha3_sca_masks_off_t(uj, &uj_data)); - UJSON_CHECK_DIF_OK( - dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); + TRY(dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); if (uj_data.masks_off == 0x01) { config.entropy_fast_process = kDifToggleEnabled; @@ -377,13 +375,13 @@ status_t handle_sha3_sca_disable_masking(ujson_t *uj) { config.entropy_fast_process = kDifToggleDisabled; config.msg_mask = kDifToggleEnabled; } - UJSON_CHECK_DIF_OK(dif_kmac_configure(&kmac, config)); + TRY(dif_kmac_configure(&kmac, config)); kmac_block_until_idle(); // Acknowledge the command. This is crucial to be in sync with the host. - cryptotest_sha3_sca_status_t uj_status; + penetrationtest_sha3_sca_status_t uj_status; uj_status.status = 0; - RESP_OK(ujson_serialize_cryptotest_sha3_sca_status_t, uj, &uj_status); + RESP_OK(ujson_serialize_penetrationtest_sha3_sca_status_t, uj, &uj_status); return OK_STATUS(0); } @@ -440,8 +438,8 @@ sha3_sca_error_t sha3_serial_absorb(const uint8_t *msg, size_t msg_len) { * @param uj The received uJSON data. */ status_t handle_sha3_sca_single_absorb(ujson_t *uj) { - cryptotest_sha3_sca_msg_t uj_msg; - TRY(ujson_deserialize_cryptotest_sha3_sca_msg_t(uj, &uj_msg)); + penetrationtest_sha3_sca_msg_t uj_msg; + TRY(ujson_deserialize_penetrationtest_sha3_sca_msg_t(uj, &uj_msg)); if (uj_msg.msg_length != kMessageLength) { return OUT_OF_RANGE(); } @@ -459,9 +457,10 @@ status_t handle_sha3_sca_single_absorb(ujson_t *uj) { if (sha3_get_digest(out, kDigestLength) != kDifOk) { return ABORTED(); } - cryptotest_sha3_sca_batch_digest_t uj_output; + penetrationtest_sha3_sca_batch_digest_t uj_output; memcpy(uj_output.batch_digest, (uint8_t *)out, kDigestLength * 4); - RESP_OK(ujson_serialize_cryptotest_sha3_sca_batch_digest_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_sha3_sca_batch_digest_t, uj, + &uj_output); // Reset before the next absorb since KMAC must be idle before starting // another absorb. @@ -482,8 +481,8 @@ status_t handle_sha3_sca_single_absorb(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_sha3_sca_fixed_message_set(ujson_t *uj) { - cryptotest_sha3_sca_msg_t uj_msg; - TRY(ujson_deserialize_cryptotest_sha3_sca_msg_t(uj, &uj_msg)); + penetrationtest_sha3_sca_msg_t uj_msg; + TRY(ujson_deserialize_penetrationtest_sha3_sca_msg_t(uj, &uj_msg)); if (uj_msg.msg_length != kMessageLength) { return OUT_OF_RANGE(); @@ -505,8 +504,8 @@ status_t handle_sha3_sca_fixed_message_set(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_sha3_sca_batch(ujson_t *uj) { - cryptotest_sha3_sca_data_t uj_data; - TRY(ujson_deserialize_cryptotest_sha3_sca_data_t(uj, &uj_data)); + penetrationtest_sha3_sca_data_t uj_data; + TRY(ujson_deserialize_penetrationtest_sha3_sca_data_t(uj, &uj_data)); uint32_t num_hashes = 0; uint32_t out[kDigestLength]; @@ -550,13 +549,14 @@ status_t handle_sha3_sca_batch(ujson_t *uj) { } // Acknowledge the batch command. This is crucial to be in sync with the host - cryptotest_sha3_sca_status_t uj_status; + penetrationtest_sha3_sca_status_t uj_status; uj_status.status = 0; - RESP_OK(ujson_serialize_cryptotest_sha3_sca_status_t, uj, &uj_status); + RESP_OK(ujson_serialize_penetrationtest_sha3_sca_status_t, uj, &uj_status); // Send the batch digest to the host for verification. - cryptotest_sha3_sca_batch_digest_t uj_output; + penetrationtest_sha3_sca_batch_digest_t uj_output; memcpy(uj_output.batch_digest, (uint8_t *)batch_digest, kDigestLength * 4); - RESP_OK(ujson_serialize_cryptotest_sha3_sca_batch_digest_t, uj, &uj_output); + RESP_OK(ujson_serialize_penetrationtest_sha3_sca_batch_digest_t, uj, + &uj_output); return OK_STATUS(0); } @@ -572,8 +572,8 @@ status_t handle_sha3_sca_batch(ujson_t *uj) { * @param uj The received uJSON data. */ status_t handle_sha3_sca_seed_lfsr(ujson_t *uj) { - cryptotest_sha3_sca_lfsr_t uj_lfsr_data; - TRY(ujson_deserialize_cryptotest_sha3_sca_lfsr_t(uj, &uj_lfsr_data)); + penetrationtest_sha3_sca_lfsr_t uj_lfsr_data; + TRY(ujson_deserialize_penetrationtest_sha3_sca_lfsr_t(uj, &uj_lfsr_data)); sca_seed_lfsr(read_32(uj_lfsr_data.seed), kScaLfsrMasking); return OK_STATUS(0); @@ -589,18 +589,17 @@ status_t handle_sha3_sca_seed_lfsr(ujson_t *uj) { */ status_t handle_sha3_sca_init(ujson_t *uj) { // Read mode. FPGA or discrete. - cryptotest_sha3_sca_fpga_mode_t uj_data; - TRY(ujson_deserialize_cryptotest_sha3_sca_fpga_mode_t(uj, &uj_data)); + penetrationtest_sha3_sca_fpga_mode_t uj_data; + TRY(ujson_deserialize_penetrationtest_sha3_sca_fpga_mode_t(uj, &uj_data)); if (uj_data.fpga_mode == 0x01) { fpga_mode = true; } sca_init(kScaTriggerSourceKmac, kScaPeripheralIoDiv4 | kScaPeripheralKmac); - UJSON_CHECK_DIF_OK( - dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); + TRY(dif_kmac_init(mmio_region_from_addr(TOP_EARLGREY_KMAC_BASE_ADDR), &kmac)); - UJSON_CHECK_DIF_OK(dif_kmac_configure(&kmac, config)); + TRY(dif_kmac_configure(&kmac, config)); kmac_block_until_idle(); diff --git a/sw/device/tests/crypto/cryptotest/firmware/sha3_sca.h b/sw/device/tests/penetrationtests/firmware/sha3_sca.h similarity index 81% rename from sw/device/tests/crypto/cryptotest/firmware/sha3_sca.h rename to sw/device/tests/penetrationtests/firmware/sha3_sca.h index c89773e50346c..29f6658001817 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/sha3_sca.h +++ b/sw/device/tests/penetrationtests/firmware/sha3_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SHA3_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SHA3_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SHA3_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SHA3_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -35,4 +35,4 @@ status_t handle_sha3_sca_single_absorb(ujson_t *uj); status_t handle_sha3_sca_init(ujson_t *uj); status_t handle_sha3_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_SHA3_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SHA3_SCA_H_ diff --git a/sw/device/tests/crypto/cryptotest/firmware/trigger_sca.c b/sw/device/tests/penetrationtests/firmware/trigger_sca.c similarity index 82% rename from sw/device/tests/crypto/cryptotest/firmware/trigger_sca.c rename to sw/device/tests/penetrationtests/firmware/trigger_sca.c index 6820acfaed97c..8703f8a8d5717 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/trigger_sca.c +++ b/sw/device/tests/penetrationtests/firmware/trigger_sca.c @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#include "sw/device/tests/crypto/cryptotest/firmware/trigger_sca.h" +#include "sw/device/tests/penetrationtests/firmware/trigger_sca.h" #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/status.h" @@ -10,7 +10,7 @@ #include "sw/device/lib/testing/test_framework/ujson_ottf.h" #include "sw/device/lib/ujson/ujson.h" #include "sw/device/sca/lib/sca.h" -#include "sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.h" +#include "sw/device/tests/penetrationtests/json/trigger_sca_commands.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" @@ -24,8 +24,8 @@ * @param uj The received uJSON data. */ status_t handle_trigger_sca_select_source(ujson_t *uj) { - cryptotest_trigger_sca_source_t uj_trigger; - TRY(ujson_deserialize_cryptotest_trigger_sca_source_t(uj, &uj_trigger)); + penetrationtest_trigger_sca_source_t uj_trigger; + TRY(ujson_deserialize_penetrationtest_trigger_sca_source_t(uj, &uj_trigger)); sca_select_trigger_type(uj_trigger.source); diff --git a/sw/device/tests/crypto/cryptotest/firmware/trigger_sca.h b/sw/device/tests/penetrationtests/firmware/trigger_sca.h similarity index 60% rename from sw/device/tests/crypto/cryptotest/firmware/trigger_sca.h rename to sw/device/tests/penetrationtests/firmware/trigger_sca.h index 98f6a9e433a60..a6ab40ac38083 100644 --- a/sw/device/tests/crypto/cryptotest/firmware/trigger_sca.h +++ b/sw/device/tests/penetrationtests/firmware/trigger_sca.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_TRIGGER_SCA_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_TRIGGER_SCA_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_TRIGGER_SCA_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_TRIGGER_SCA_H_ #include "sw/device/lib/base/status.h" #include "sw/device/lib/ujson/ujson.h" @@ -11,4 +11,4 @@ status_t handle_trigger_sca_select_source(ujson_t *uj); status_t handle_trigger_sca(ujson_t *uj); -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_FIRMWARE_TRIGGER_SCA_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_TRIGGER_SCA_H_ diff --git a/sw/device/tests/penetrationtests/json/BUILD b/sw/device/tests/penetrationtests/json/BUILD new file mode 100644 index 0000000000000..e6f627d140775 --- /dev/null +++ b/sw/device/tests/penetrationtests/json/BUILD @@ -0,0 +1,86 @@ +# Copyright lowRISC contributors (OpenTitan project). +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "commands", + srcs = ["commands.c"], + hdrs = ["commands.h"], + deps = [ + ":aes_sca_commands", + ":extclk_sca_fi_commands", + ":ibex_fi_commands", + ":ibex_sca_commands", + ":kmac_sca_commands", + ":otbn_fi_commands", + ":prng_sca_commands", + ":sha3_sca_commands", + ":trigger_sca_commands", + "//sw/device/lib/ujson", + ], +) + +cc_library( + name = "aes_sca_commands", + srcs = ["aes_sca_commands.c"], + hdrs = ["aes_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "ibex_fi_commands", + srcs = ["ibex_fi_commands.c"], + hdrs = ["ibex_fi_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "ibex_sca_commands", + srcs = ["ibex_sca_commands.c"], + hdrs = ["ibex_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "kmac_sca_commands", + srcs = ["kmac_sca_commands.c"], + hdrs = ["kmac_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "otbn_fi_commands", + srcs = ["otbn_fi_commands.c"], + hdrs = ["otbn_fi_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "prng_sca_commands", + srcs = ["prng_sca_commands.c"], + hdrs = ["prng_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "extclk_sca_fi_commands", + srcs = ["extclk_sca_fi_commands.c"], + hdrs = ["extclk_sca_fi_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "sha3_sca_commands", + srcs = ["sha3_sca_commands.c"], + hdrs = ["sha3_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) + +cc_library( + name = "trigger_sca_commands", + srcs = ["trigger_sca_commands.c"], + hdrs = ["trigger_sca_commands.h"], + deps = ["//sw/device/lib/ujson"], +) diff --git a/sw/device/tests/crypto/cryptotest/json/aes_sca_commands.c b/sw/device/tests/penetrationtests/json/aes_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/aes_sca_commands.c rename to sw/device/tests/penetrationtests/json/aes_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/aes_sca_commands.h b/sw/device/tests/penetrationtests/json/aes_sca_commands.h similarity index 67% rename from sw/device/tests/crypto/cryptotest/json/aes_sca_commands.h rename to sw/device/tests/penetrationtests/json/aes_sca_commands.h index e727968011fcf..f5791a8fec064 100644 --- a/sw/device/tests/crypto/cryptotest/json/aes_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/aes_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_AES_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_AES_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_AES_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_AES_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -37,32 +37,32 @@ UJSON_SERDE_ENUM(AesScaSubcommand, aes_sca_subcommand_t, AESSCA_SUBCOMMAND); #define AES_SCA_KEY(field, string) \ field(key, uint8_t, AESSCA_CMD_MAX_KEY_BYTES) \ field(key_length, size_t) -UJSON_SERDE_STRUCT(CryptotestAesScaKey, cryptotest_aes_sca_key_t, AES_SCA_KEY); +UJSON_SERDE_STRUCT(PenetrationtestAesScaKey, penetrationtest_aes_sca_key_t, AES_SCA_KEY); #define AES_SCA_DATA(field, string) \ field(data, uint8_t, AESSCA_CMD_MAX_DATA_BYTES) -UJSON_SERDE_STRUCT(CryptotestAesScaData, cryptotest_aes_sca_data_t, AES_SCA_DATA); +UJSON_SERDE_STRUCT(PenetrationtestAesScaData, penetrationtest_aes_sca_data_t, AES_SCA_DATA); #define AES_SCA_TEXT(field, string) \ field(text, uint8_t, AESSCA_CMD_MAX_DATA_BYTES) \ field(text_length, size_t) -UJSON_SERDE_STRUCT(CryptotestAesScaText, cryptotest_aes_sca_text_t, AES_SCA_TEXT); +UJSON_SERDE_STRUCT(PenetrationtestAesScaText, penetrationtest_aes_sca_text_t, AES_SCA_TEXT); #define AES_SCA_LFSR(field, string) \ field(seed, uint8_t, AESSCA_CMD_MAX_LFSR_BYTES) -UJSON_SERDE_STRUCT(CryptotestAesScaLfsr, cryptotest_aes_sca_lfsr_t, AES_SCA_LFSR); +UJSON_SERDE_STRUCT(PenetrationtestAesScaLfsr, penetrationtest_aes_sca_lfsr_t, AES_SCA_LFSR); #define AES_SCA_CIPHERTEXT(field, string) \ field(ciphertext, uint8_t, AESSCA_CMD_MAX_MSG_BYTES) \ field(ciphertext_length, uint32_t) -UJSON_SERDE_STRUCT(CryptotestAesScaCiphertext, cryptotest_aes_sca_ciphertext_t, AES_SCA_CIPHERTEXT); +UJSON_SERDE_STRUCT(PenetrationtestAesScaCiphertext, penetrationtest_aes_sca_ciphertext_t, AES_SCA_CIPHERTEXT); #define AES_SCA_FPGA_MODE(field, string) \ field(fpga_mode, uint8_t) -UJSON_SERDE_STRUCT(CryptotestAesScaFpgaMode, cryptotest_aes_sca_fpga_mode_t, AES_SCA_FPGA_MODE); +UJSON_SERDE_STRUCT(PenetrationtestAesScaFpgaMode, penetrationtest_aes_sca_fpga_mode_t, AES_SCA_FPGA_MODE); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_AES_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_AES_SCA_COMMANDS_H_ diff --git a/sw/device/tests/penetrationtests/json/commands.c b/sw/device/tests/penetrationtests/json/commands.c new file mode 100644 index 0000000000000..b7fc48f711fde --- /dev/null +++ b/sw/device/tests/penetrationtests/json/commands.c @@ -0,0 +1,6 @@ +// Copyright lowRISC contributors (OpenTitan project). +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +#define UJSON_SERDE_IMPL 1 +#include "commands.h" diff --git a/sw/device/tests/penetrationtests/json/commands.h b/sw/device/tests/penetrationtests/json/commands.h new file mode 100644 index 0000000000000..e9b7fa2d60366 --- /dev/null +++ b/sw/device/tests/penetrationtests/json/commands.h @@ -0,0 +1,31 @@ +// Copyright lowRISC contributors (OpenTitan project). +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_COMMANDS_H_ +#include "sw/device/lib/ujson/ujson_derive.h" +#ifdef __cplusplus +extern "C" { +#endif + +// clang-format off + +#define COMMAND(_, value) \ + value(_, AesSca) \ + value(_, ExtClkScaFi) \ + value(_, IbexFi) \ + value(_, IbexSca) \ + value(_, KmacSca) \ + value(_, OtbnFi) \ + value(_, PrngSca) \ + value(_, Sha3Sca) \ + value(_, TriggerSca) +UJSON_SERDE_ENUM(PenetrationtestCommand, penetrationtest_cmd_t, COMMAND); + +// clang-format on + +#ifdef __cplusplus +} +#endif +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.c b/sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.c rename to sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.h b/sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.h similarity index 63% rename from sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.h rename to sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.h index 8cb6064c684b0..9c7dd6c3c9e23 100644 --- a/sw/device/tests/crypto/cryptotest/json/extclk_sca_fi_commands.h +++ b/sw/device/tests/penetrationtests/json/extclk_sca_fi_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_EXTCLK_SCA_FI_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_EXTCLK_SCA_FI_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_EXTCLK_SCA_FI_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_EXTCLK_SCA_FI_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -20,11 +20,11 @@ UJSON_SERDE_ENUM(ExtClkScaFiSubcommand, extclk_sca_fi_subcommand_t, EXTCLK_SCA_F #define EXTCLK_SCA_FI_CFG(field, string) \ field(sel, bool) \ field(hi_speed_sel, bool) -UJSON_SERDE_STRUCT(CryptotestExtClkScaFiCfg, cryptotest_extclk_sca_fi_cfg_t, EXTCLK_SCA_FI_CFG); +UJSON_SERDE_STRUCT(PenetrationtestExtClkScaFiCfg, penetrationtest_extclk_sca_fi_cfg_t, EXTCLK_SCA_FI_CFG); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_EXTCLK_SCA_FI_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_EXTCLK_SCA_FI_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.c b/sw/device/tests/penetrationtests/json/ibex_fi_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.c rename to sw/device/tests/penetrationtests/json/ibex_fi_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.h b/sw/device/tests/penetrationtests/json/ibex_fi_commands.h similarity index 89% rename from sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.h rename to sw/device/tests/penetrationtests/json/ibex_fi_commands.h index fdfb4961f4ed6..de16804d76da9 100644 --- a/sw/device/tests/crypto/cryptotest/json/ibex_fi_commands.h +++ b/sw/device/tests/penetrationtests/json/ibex_fi_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_FI_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_FI_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_FI_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_FI_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -62,4 +62,4 @@ UJSON_SERDE_STRUCT(IbexFiLoopCounterMirroredOutput, ibex_fi_loop_counter_mirrore #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_FI_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_FI_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.c b/sw/device/tests/penetrationtests/json/ibex_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.c rename to sw/device/tests/penetrationtests/json/ibex_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.h b/sw/device/tests/penetrationtests/json/ibex_sca_commands.h similarity index 83% rename from sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.h rename to sw/device/tests/penetrationtests/json/ibex_sca_commands.h index fdeeb30f67152..e80430926f127 100644 --- a/sw/device/tests/crypto/cryptotest/json/ibex_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/ibex_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -43,4 +43,4 @@ UJSON_SERDE_STRUCT(IbexScaResult, ibex_sca_result_t, IBEXSCA_RESULT); #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_IBEX_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_IBEX_SCA_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.c b/sw/device/tests/penetrationtests/json/kmac_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.c rename to sw/device/tests/penetrationtests/json/kmac_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.h b/sw/device/tests/penetrationtests/json/kmac_sca_commands.h similarity index 62% rename from sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.h rename to sw/device/tests/penetrationtests/json/kmac_sca_commands.h index 80263aded792b..309569180e898 100644 --- a/sw/device/tests/crypto/cryptotest/json/kmac_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/kmac_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_KMAC_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_KMAC_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_KMAC_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_KMAC_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -29,32 +29,32 @@ UJSON_SERDE_ENUM(KmacScaSubcommand, kmac_sca_subcommand_t, KMAC_SCA_SUBCOMMAND); #define KMAC_SCA_KEY(field, string) \ field(key, uint8_t, KMACSCA_CMD_MAX_KEY_BYTES) \ field(key_length, size_t) -UJSON_SERDE_STRUCT(CryptotestKmacScaKey, cryptotest_kmac_sca_key_t, KMAC_SCA_KEY); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaKey, penetrationtest_kmac_sca_key_t, KMAC_SCA_KEY); #define KMAC_SCA_LFSR(field, string) \ field(seed, uint8_t, KMACSCA_CMD_MAX_LFSR_BYTES) -UJSON_SERDE_STRUCT(CryptotestKmacScaLfsr, cryptotest_kmac_sca_lfsr_t, KMAC_SCA_LFSR); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaLfsr, penetrationtest_kmac_sca_lfsr_t, KMAC_SCA_LFSR); #define KMAC_SCA_FPGA_MODE(field, string) \ field(fpga_mode, uint8_t) -UJSON_SERDE_STRUCT(CryptotestKmacScaFpgaMode, cryptotest_kmac_sca_fpga_mode_t, KMAC_SCA_FPGA_MODE); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaFpgaMode, penetrationtest_kmac_sca_fpga_mode_t, KMAC_SCA_FPGA_MODE); #define KMAC_SCA_DATA(field, string) \ field(data, uint8_t, KMACSCA_CMD_MAX_DATA_BYTES) -UJSON_SERDE_STRUCT(CryptotestKmacScaData, cryptotest_kmac_sca_data_t, KMAC_SCA_DATA); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaData, penetrationtest_kmac_sca_data_t, KMAC_SCA_DATA); #define KMAC_SCA_MSG(field, string) \ field(msg, uint8_t, KMACSCA_CMD_MAX_MSG_BYTES) \ field(msg_length, size_t) -UJSON_SERDE_STRUCT(CryptotestKmacScaMsg, cryptotest_kmac_sca_msg_t, KMAC_SCA_MSG); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaMsg, penetrationtest_kmac_sca_msg_t, KMAC_SCA_MSG); #define KMAC_SCA_BATCH_DIGEST(field, string) \ field(batch_digest, uint8_t, KMACSCA_CMD_MAX_BATCH_DIGEST_BYTES) -UJSON_SERDE_STRUCT(CryptotestKmacScaBatchDigest, cryptotest_kmac_sca_batch_digest_t, KMAC_SCA_BATCH_DIGEST); +UJSON_SERDE_STRUCT(PenetrationtestKmacScaBatchDigest, penetrationtest_kmac_sca_batch_digest_t, KMAC_SCA_BATCH_DIGEST); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_KMAC_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_KMAC_SCA_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.c b/sw/device/tests/penetrationtests/json/otbn_fi_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.c rename to sw/device/tests/penetrationtests/json/otbn_fi_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.h b/sw/device/tests/penetrationtests/json/otbn_fi_commands.h similarity index 82% rename from sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.h rename to sw/device/tests/penetrationtests/json/otbn_fi_commands.h index 7035b7caba162..6c6ba71165458 100644 --- a/sw/device/tests/crypto/cryptotest/json/otbn_fi_commands.h +++ b/sw/device/tests/penetrationtests/json/otbn_fi_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_OTBN_FI_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_OTBN_FI_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -38,4 +38,4 @@ UJSON_SERDE_STRUCT(OtbnFiResultOutput, otbn_fi_result_t, OTBNFI_RESULT_OUTPUT); #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_OTBN_FI_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_OTBN_FI_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/prng_sca_commands.c b/sw/device/tests/penetrationtests/json/prng_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/prng_sca_commands.c rename to sw/device/tests/penetrationtests/json/prng_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/prng_sca_commands.h b/sw/device/tests/penetrationtests/json/prng_sca_commands.h similarity index 66% rename from sw/device/tests/crypto/cryptotest/json/prng_sca_commands.h rename to sw/device/tests/penetrationtests/json/prng_sca_commands.h index c19a29b2568ad..3e60793fadfce 100644 --- a/sw/device/tests/crypto/cryptotest/json/prng_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/prng_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_PRNG_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_PRNG_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_PRNG_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_PRNG_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -22,11 +22,11 @@ UJSON_SERDE_ENUM(PrngScaSubcommand, prng_sca_subcommand_t, PRNGSCA_SUBCOMMAND); #define PRNG_SCA_LFSR(field, string) \ field(seed, uint8_t, PRNGSCA_CMD_MAX_LFSR_BYTES) \ field(seed_length, size_t) -UJSON_SERDE_STRUCT(CryptotestPrngScaLfsr, cryptotest_prng_sca_lfsr_t, PRNG_SCA_LFSR); +UJSON_SERDE_STRUCT(PenetrationtestPrngScaLfsr, penetrationtest_prng_sca_lfsr_t, PRNG_SCA_LFSR); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_PRNG_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_PRNG_SCA_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.c b/sw/device/tests/penetrationtests/json/sha3_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.c rename to sw/device/tests/penetrationtests/json/sha3_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.h b/sw/device/tests/penetrationtests/json/sha3_sca_commands.h similarity index 60% rename from sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.h rename to sw/device/tests/penetrationtests/json/sha3_sca_commands.h index 1b3b081d61f8b..6365e50c02d38 100644 --- a/sw/device/tests/crypto/cryptotest/json/sha3_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/sha3_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_SHA3_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_SHA3_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_SHA3_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_SHA3_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -28,36 +28,36 @@ UJSON_SERDE_ENUM(Sha3ScaSubcommand, sha3_sca_subcommand_t, SHA3_SCA_SUBCOMMAND); #define SHA3_SCA_MASKS(field, string) \ field(masks_off, uint8_t) -UJSON_SERDE_STRUCT(CryptotestSha3ScaMasks, cryptotest_sha3_sca_masks_off_t, SHA3_SCA_MASKS); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaMasks, penetrationtest_sha3_sca_masks_off_t, SHA3_SCA_MASKS); #define SHA3_SCA_LFSR(field, string) \ field(seed, uint8_t, SHA3SCA_CMD_MAX_LFSR_BYTES) -UJSON_SERDE_STRUCT(CryptotestSha3ScaLfsr, cryptotest_sha3_sca_lfsr_t, SHA3_SCA_LFSR); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaLfsr, penetrationtest_sha3_sca_lfsr_t, SHA3_SCA_LFSR); #define SHA3_SCA_DATA(field, string) \ field(data, uint8_t, SHA3SCA_CMD_MAX_DATA_BYTES) -UJSON_SERDE_STRUCT(CryptotestSha3ScaData, cryptotest_sha3_sca_data_t, SHA3_SCA_DATA); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaData, penetrationtest_sha3_sca_data_t, SHA3_SCA_DATA); #define SHA3_SCA_FPGA_MODE(field, string) \ field(fpga_mode, uint8_t) -UJSON_SERDE_STRUCT(CryptotestSha3ScaFpgaMode, cryptotest_sha3_sca_fpga_mode_t, SHA3_SCA_FPGA_MODE); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaFpgaMode, penetrationtest_sha3_sca_fpga_mode_t, SHA3_SCA_FPGA_MODE); #define SHA3_SCA_MSG(field, string) \ field(msg, uint8_t, SHA3SCA_CMD_MAX_MSG_BYTES) \ field(msg_length, size_t) -UJSON_SERDE_STRUCT(CryptotestSha3ScaMsg, cryptotest_sha3_sca_msg_t, SHA3_SCA_MSG); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaMsg, penetrationtest_sha3_sca_msg_t, SHA3_SCA_MSG); #define SHA3_SCA_STATUS(field, string) \ field(status, uint8_t) -UJSON_SERDE_STRUCT(CryptotestSha3ScaStatus, cryptotest_sha3_sca_status_t, SHA3_SCA_STATUS); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaStatus, penetrationtest_sha3_sca_status_t, SHA3_SCA_STATUS); #define SHA3_SCA_BATCH_DIGEST(field, string) \ field(batch_digest, uint8_t, SHA3SCA_CMD_MAX_BATCH_DIGEST_BYTES) -UJSON_SERDE_STRUCT(CryptotestSha3ScaBatchDigest, cryptotest_sha3_sca_batch_digest_t, SHA3_SCA_BATCH_DIGEST); +UJSON_SERDE_STRUCT(PenetrationtestSha3ScaBatchDigest, penetrationtest_sha3_sca_batch_digest_t, SHA3_SCA_BATCH_DIGEST); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_SHA3_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_SHA3_SCA_COMMANDS_H_ diff --git a/sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.c b/sw/device/tests/penetrationtests/json/trigger_sca_commands.c similarity index 100% rename from sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.c rename to sw/device/tests/penetrationtests/json/trigger_sca_commands.c diff --git a/sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.h b/sw/device/tests/penetrationtests/json/trigger_sca_commands.h similarity index 64% rename from sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.h rename to sw/device/tests/penetrationtests/json/trigger_sca_commands.h index d8711fb7f7cc9..2b44f64b27e8a 100644 --- a/sw/device/tests/crypto/cryptotest/json/trigger_sca_commands.h +++ b/sw/device/tests/penetrationtests/json/trigger_sca_commands.h @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_TRIGGER_SCA_COMMANDS_H_ -#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_TRIGGER_SCA_COMMANDS_H_ +#ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_TRIGGER_SCA_COMMANDS_H_ +#define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_TRIGGER_SCA_COMMANDS_H_ #include "sw/device/lib/ujson/ujson_derive.h" #ifdef __cplusplus extern "C" { @@ -21,11 +21,11 @@ UJSON_SERDE_ENUM(TriggerScaSubcommand, trigger_sca_subcommand_t, TRIGGERSCA_SUBC #define TRIGGER_SCA_SOURCE(field, string) \ field(source, uint8_t) -UJSON_SERDE_STRUCT(CryptotestTriggerScaSource, cryptotest_trigger_sca_source_t, TRIGGER_SCA_SOURCE); +UJSON_SERDE_STRUCT(PenetrationtestTriggerScaSource, penetrationtest_trigger_sca_source_t, TRIGGER_SCA_SOURCE); // clang-format on #ifdef __cplusplus } #endif -#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_TRIGGER_SCA_COMMANDS_H_ +#endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_JSON_TRIGGER_SCA_COMMANDS_H_