5 #include "hw/ip/aes/model/aes_modes.h"
11 #include "sw/device/lib/dif/dif_rv_core_ibex.h"
14 #include "sw/device/lib/testing/aes_testutils.h"
15 #include "sw/device/lib/testing/edn_testutils.h"
16 #include "sw/device/lib/testing/entropy_testutils.h"
18 #include "sw/device/lib/testing/rand_testutils.h"
19 #include "sw/device/lib/testing/test_framework/check.h"
21 #include "sw/device/tests/otbn_randomness_impl.h"
27 kTimeout = (10 * 1000 * 1000),
29 kOtbnRandomnessIterations = 1,
30 kTestProcedureRepetitions = 2,
33 static dif_csrng_t csrng;
34 static dif_edn_t edn0;
35 static dif_edn_t edn1;
37 static dif_otbn_t otbn;
38 static dif_rv_core_ibex_t rv_core_ibex;
48 .reseed_on_key_change =
true,
49 .ctrl_aux_lock =
false,
52 OTTF_DEFINE_TEST_CONFIG();
55 static void init_peripherals(
void) {
56 CHECK_DIF_OK(dif_csrng_init(
66 CHECK_DIF_OK(dif_rv_core_ibex_init(
71 static void configure_otbn(
void) {
72 otbn_randomness_test_prepare(&otbn, kOtbnRandomnessIterations);
76 static void entropy_config(
void) {
78 edn_testutils_auto_params_build(
false, 0, 0);
80 edn_testutils_auto_params_build(
false, 0, 0);
82 CHECK_STATUS_OK(entropy_testutils_stop_all());
84 CHECK_STATUS_OK(entropy_testutils_entropy_src_init());
93 static status_t stress_test_edns(
void) {
94 int otbn_execute_rounds = kOtbnRounds;
95 dif_rv_core_ibex_rnd_status_t ibex_rnd_status;
97 uint32_t ibex_rnd_data;
100 LOG_INFO(
"aes_testutils_setup_encryption round %d", otbn_execute_rounds);
101 CHECK_STATUS_OK(aes_testutils_setup_encryption(transaction, &aes));
102 while (otbn_execute_rounds) {
103 LOG_INFO(
"dif_otbn_get_status round %d", otbn_execute_rounds);
105 if (otbn_status == kDifOtbnStatusIdle) {
106 LOG_INFO(
"otbn_testutils_execute round %d", otbn_execute_rounds);
108 otbn_execute_rounds--;
111 LOG_INFO(
"dif_aes_read_output round %d", otbn_execute_rounds);
114 LOG_INFO(
"aes_testutils_setup_encryption round %d", otbn_execute_rounds);
116 CHECK_STATUS_OK(aes_testutils_setup_encryption(transaction, &aes));
120 dif_rv_core_ibex_get_rnd_status(&rv_core_ibex, &ibex_rnd_status));
121 if (ibex_rnd_status == kDifRvCoreIbexRndStatusValid)
123 dif_rv_core_ibex_read_rnd_data(&rv_core_ibex, &ibex_rnd_data));
136 int repetitions = kTestProcedureRepetitions;
142 while (repetitions) {