File tree Expand file tree Collapse file tree
sw/device/tests/penetrationtests/firmware/fi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -400,7 +400,9 @@ status_t handle_cryptolib_fi_sym_trng_init(ujson_t *uj) {
400400 & rv_core_ibex ));
401401
402402 cryptolib_fi_sym_trng_init_out_t uj_output ;
403- memset (& uj_output , 0 , sizeof (uj_output ));
403+ uj_output .status = kUnknown ;
404+ uj_output .status =
405+ (size_t )cryptolib_fi_trng_init_impl (uj_input , & uj_output ).value ;
404406
405407 // Get registered alerts from alert handler.
406408 reg_alerts = pentest_get_triggered_alerts ();
Original file line number Diff line number Diff line change 1010#include "sw/device/lib/crypto/include/aes_gcm.h"
1111#include "sw/device/lib/crypto/include/datatypes.h"
1212#include "sw/device/lib/crypto/include/drbg.h"
13+ #include "sw/device/lib/crypto/include/entropy_src.h"
1314#include "sw/device/lib/crypto/include/hmac.h"
1415#include "sw/device/lib/crypto/include/integrity.h"
1516#include "sw/device/lib/crypto/include/key_transport.h"
@@ -217,6 +218,24 @@ status_t cryptolib_fi_drbg_reseed_impl(
217218 return OK_STATUS ();
218219}
219220
221+ status_t cryptolib_fi_trng_init_impl (
222+ cryptolib_fi_sym_trng_init_in_t uj_input ,
223+ cryptolib_fi_sym_trng_init_out_t * uj_output ) {
224+ // Trigger window 0.
225+ if (uj_input .trigger & kPentestTrigger1 ) {
226+ pentest_set_trigger_high ();
227+ }
228+ TRY (otcrypto_entropy_init ());
229+ if (uj_input .trigger & kPentestTrigger1 ) {
230+ pentest_set_trigger_low ();
231+ }
232+
233+ // Return data back to host.
234+ uj_output -> cfg = 0 ;
235+
236+ return OK_STATUS ();
237+ }
238+
220239status_t cryptolib_fi_gcm_impl (cryptolib_fi_sym_gcm_in_t uj_input ,
221240 cryptolib_fi_sym_gcm_out_t * uj_output ) {
222241 // Construct the blinded key configuration.
Original file line number Diff line number Diff line change @@ -41,6 +41,17 @@ status_t cryptolib_fi_drbg_reseed_impl(
4141 cryptolib_fi_sym_drbg_reseed_in_t uj_input ,
4242 cryptolib_fi_sym_drbg_reseed_out_t * uj_output );
4343
44+ /**
45+ * Wrapper to TRNG init cryptolib implementation.
46+ *
47+ * @param uj_input An initialized uJSON context.
48+ * @param uj_output An initialized uJSON context.
49+ * @return OK or error.
50+ */
51+ status_t cryptolib_fi_trng_init_impl (
52+ cryptolib_fi_sym_trng_init_in_t uj_input ,
53+ cryptolib_fi_sym_trng_init_out_t * uj_output );
54+
4455/**
4556 * Wrapper to AES-GCM cryptolib implementation.
4657 *
You can’t perform that action at this time.
0 commit comments