Skip to content

Commit

Permalink
[sival] Add extract and insert entropy_src test
Browse files Browse the repository at this point in the history
Signed-off-by: James Wainwright <[email protected]>
(cherry picked from commit 9f56456)
  • Loading branch information
jwnrt committed Mar 4, 2024
1 parent 9c9325d commit b66e51c
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sw/device/lib/dif/dif_entropy_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ dif_result_t dif_entropy_src_fw_override_configure(
return kDifOk;
}

dif_result_t dif_entropy_src_fw_override_sha3_start_insert(
const dif_entropy_src_t *entropy_src, dif_toggle_t enabled) {
if (entropy_src == NULL) {
return kDifBadArg;
}

uint32_t reg = bitfield_field32_write(
0, ENTROPY_SRC_FW_OV_SHA3_START_FW_OV_INSERT_START_FIELD,
dif_toggle_to_multi_bit_bool4(enabled));
mmio_region_write32(entropy_src->base_addr,
ENTROPY_SRC_FW_OV_SHA3_START_REG_OFFSET, reg);

return kDifOk;
}

dif_result_t dif_entropy_src_health_test_configure(
const dif_entropy_src_t *entropy_src,
dif_entropy_src_health_test_config_t config) {
Expand Down
15 changes: 15 additions & 0 deletions sw/device/lib/dif/dif_entropy_src.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,21 @@ dif_result_t dif_entropy_src_fw_override_configure(
const dif_entropy_src_t *entropy_src,
dif_entropy_src_fw_override_config_t config, dif_toggle_t enabled);

/**
* Configures whether to start the entropy source's SHA3 process and be ready to
* accept entropy data.
*
* This is used in firmware override mode and should be enabled before writing
* to the override FIFO. Disable this after writing has finished to ensure the
* SHA3 block finishes processing and pushes the results to the `esfinal` FIFO.
*
* @param entropy_src An entropy source handle.
* @param enabled Whether to start the SHA3 process.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_entropy_src_fw_override_sha3_start_insert(
const dif_entropy_src_t *entropy_src, dif_toggle_t enabled);

/**
* Configures an entropy source health test feature with runtime information.
*
Expand Down
36 changes: 36 additions & 0 deletions sw/device/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,13 @@ opentitan_test(
"//sw/device/lib/base:memory",
"//sw/device/lib/base:mmio",
"//sw/device/lib/dif:base",
"//sw/device/lib/dif:csrng",
"//sw/device/lib/dif:entropy_src",
"//sw/device/lib/dif:rv_core_ibex",
"//sw/device/lib/runtime:log",
"//sw/device/lib/testing:edn_testutils",
"//sw/device/lib/testing:entropy_testutils",
"//sw/device/lib/testing:rv_core_ibex_testutils",
"//sw/device/lib/testing/test_framework:ottf_main",
],
)
Expand Down Expand Up @@ -5204,3 +5207,36 @@ opentitan_test(
"//sw/device/lib/testing/test_framework:ottf_utils",
],
)

opentitan_test(
name = "entropy_src_fw_override_test",
srcs = ["entropy_src_fw_override_test.c"],
exec_env = dicts.add(
EARLGREY_TEST_ENVS,
EARLGREY_SILICON_OWNER_ROM_EXT_ENVS,
{
"//hw/top_earlgrey:silicon_creator": None,
},
),
deps = [
"//hw/ip/entropy_src/data:entropy_src_regs",
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//sw/device/lib/base:memory",
"//sw/device/lib/base:mmio",
"//sw/device/lib/dif:aes",
"//sw/device/lib/dif:base",
"//sw/device/lib/dif:csrng",
"//sw/device/lib/dif:entropy_src",
"//sw/device/lib/dif:hmac",
"//sw/device/lib/dif:kmac",
"//sw/device/lib/dif:rv_core_ibex",
"//sw/device/lib/runtime:log",
"//sw/device/lib/testing:aes_testutils",
"//sw/device/lib/testing:edn_testutils",
"//sw/device/lib/testing:entropy_testutils",
"//sw/device/lib/testing:hmac_testutils",
"//sw/device/lib/testing:kmac_testutils",
"//sw/device/lib/testing:rv_core_ibex_testutils",
"//sw/device/lib/testing/test_framework:ottf_main",
],
)
Loading

0 comments on commit b66e51c

Please sign in to comment.