Skip to content

Commit

Permalink
[pentest] Separate from cryptotest
Browse files Browse the repository at this point in the history
This commit separates the penetration testing firmware from
the cryptotest. The reason for that is that we are running out
of instruction memory when having both tests in one firmware.

The penetration testing firmware for the FPGA can be build with:
./bazelisk.sh build //sw/device/tests/penetrationtests/firmware:firmware_fpga_cw310_test_rom

Signed-off-by: Pascal Nasahl <[email protected]>
  • Loading branch information
nasahlpa authored and engdoreis committed Apr 9, 2024
1 parent 61ea8b2 commit 59eb520
Show file tree
Hide file tree
Showing 57 changed files with 665 additions and 583 deletions.
224 changes: 0 additions & 224 deletions sw/device/tests/crypto/cryptotest/firmware/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
)
45 changes: 0 additions & 45 deletions sw/device/tests/crypto/cryptotest/firmware/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down
22 changes: 0 additions & 22 deletions sw/device/tests/crypto/cryptotest/firmware/status.h

This file was deleted.

Loading

0 comments on commit 59eb520

Please sign in to comment.