Software APIs
rng_fi.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_FI_RNG_FI_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_FI_RNG_FI_H_
7 
8 #include "sw/device/lib/base/status.h"
9 #include "sw/device/lib/ujson/ujson.h"
10 
11 /**
12  * rng_fi_entropy_src_bias command handler.
13  *
14  * Configures the entropy source module to return data on the ENTROPY_DATA
15  * register. The goal is to inject a fault such that a BIAS is visible.
16  *
17  * Faults are injected during the trigger_high & trigger_low.
18  *
19  * @param uj An initialized uJSON context.
20  * @return OK or error.
21  */
22 status_t handle_rng_fi_entropy_src_bias(ujson_t *uj);
23 
24 /**
25  * rng_fi_firmware_override command handler.
26  *
27  * Configures the entropy source module with the firmware override mode allowing
28  * the test to directly access the generated entropy bits.
29  *
30  * Faults are injected during the trigger_high & trigger_low.
31  *
32  * @param uj An initialized uJSON context.
33  * @return OK or error.
34  */
35 status_t handle_rng_fi_firmware_override(ujson_t *uj);
36 
37 /**
38  * rng_fi_edn_bias command handler.
39  *
40  * Induce a bias into the random data generated by the EDN.
41  *
42  * Faults are injected during the trigger_high & trigger_low.
43  *
44  * @param uj An initialized uJSON context.
45  * @return OK or error.
46  */
47 status_t handle_rng_fi_edn_bias(ujson_t *uj);
48 
49 /**
50  * rng_fi_edn_resp_ack command handler.
51  *
52  * Generate random data. Try to inject fault during bus ack to receive the same
53  * random data multiple times.
54  *
55  * Faults are injected during the trigger_high & trigger_low.
56  *
57  * @param uj An initialized uJSON context.
58  * @return OK or error.
59  */
60 status_t handle_rng_fi_edn_resp_ack(ujson_t *uj);
61 
62 /**
63  * Initializes the trigger and configures the device for the EDN FI test.
64  *
65  * @param uj An initialized uJSON context.
66  * @return OK or error.
67  */
68 status_t handle_rng_fi_edn_init(ujson_t *uj);
69 
70 /**
71  * csrng_bias command handler.
72  *
73  * Generate known data using the CSRNG.
74  *
75  * Faults are injected during the trigger_high & trigger_low.
76  *
77  * @param uj An initialized uJSON context.
78  * @return OK or error.
79  */
80 status_t handle_rng_fi_csrng_bias(ujson_t *uj);
81 
82 /**
83  * rng_fi_entropy_src_bias_fw_override command handler.
84  *
85  * Write a fixed seed into the FW_OV_WR_DATA register in the FW override mode.
86  * This seed goes through the conditioner into the CSRNG. The software interface
87  * of the CSRNG is used to extract the random data.
88  *
89  * Faults are injected during the trigger_high & trigger_low.
90  *
91  * @param uj An initialized uJSON context.
92  * @param static_seed Use static seed or seed provided by user.
93  * @return OK or error.
94  */
95 status_t handle_rng_fi_csrng_bias_fw_override(ujson_t *uj, bool static_seed);
96 
97 /**
98  * Initializes the trigger and configures the device for the CSRNG FI test.
99  *
100  * @param uj An initialized uJSON context.
101  * @return OK or error.
102  */
103 status_t handle_rng_fi_csrng_init(ujson_t *uj);
104 
105 /**
106  * Rng FI command handler.
107  *
108  * Command handler for the Rng FI command.
109  *
110  * @param uj An initialized uJSON context.
111  * @return OK or error.
112  */
113 status_t handle_rng_fi(ujson_t *uj);
114 
115 #endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_FI_RNG_FI_H_