Software APIs
ibex_sca.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_SCA_IBEX_SCA_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SCA_IBEX_SCA_H_
7 
8 #include "sw/device/lib/base/status.h"
9 #include "sw/device/lib/ujson/ujson.h"
10 
11 /**
12  * Initializes the trigger and configures the device for the Ibex SCA test.
13  *
14  *
15  * @param uj An initialized uJSON context.
16  * @return OK or error.
17  */
18 status_t handle_ibex_pentest_init(ujson_t *uj);
19 
20 /**
21  * ibex.sca.key_sideloading
22  *
23  * This SCA penetration test executes the following instructions:
24  * - Retrieve salt over UART & feed salt into keymanager
25  * - Set trigger
26  * - Instruct the keymanager to generate a key based on the salt.
27  * - Unset trigger
28  * - Read back generated key provided at the SW interface of the keymanager.
29  *
30  * SCA traces are captured during trigger_high & trigger_low.
31  *
32  * @param uj An initialized uJSON context.
33  * @return OK or error.
34  */
35 status_t handle_ibex_sca_key_sideloading(ujson_t *uj);
36 
37 /**
38  * ibex.sca.register_file_read
39  *
40  * This SCA penetration test executes the following instructions:
41  * - Loop num_iterations:
42  * - Set trigger
43  * - Read data from RF
44  * - Unset trigger
45  *
46  * SCA traces are captured during trigger_high & trigger_low.
47  *
48  * @param uj An initialized uJSON context.
49  * @return OK or error.
50  */
51 status_t handle_ibex_sca_register_file_read(ujson_t *uj);
52 
53 /**
54  * ibex.sca.register_file_read_batch_fvsr
55  *
56  * This SCA penetration test executes the following instructions:
57  * - Generate num_iteration FvsR values using the software LFSR.
58  * - Loop num_iterations:
59  * - Set trigger
60  * - Read data from RF
61  * - Unset trigger
62  *
63  * SCA traces are captured during trigger_high & trigger_low.
64  *
65  * @param uj An initialized uJSON context.
66  * @return OK or error.
67  */
68 status_t handle_ibex_sca_register_file_read_batch_fvsr(ujson_t *uj);
69 
70 /**
71  * ibex.sca.register_file_read_batch_random
72  *
73  * This SCA penetration test executes the following instructions:
74  * - Generate num_iteration random values using the software LFSR.
75  * - Loop num_iterations:
76  * - Set trigger
77  * - Read data from RF
78  * - Unset trigger
79  *
80  * SCA traces are captured during trigger_high & trigger_low.
81  *
82  * @param uj An initialized uJSON context.
83  * @return OK or error.
84  */
85 status_t handle_ibex_sca_register_file_read_batch_random(ujson_t *uj);
86 
87 /**
88  * ibex.sca.register_file_write
89  *
90  * This SCA penetration test executes the following instructions:
91  * - Set trigger
92  * - Write provided data to registers in RF
93  * - Unset trigger
94  *
95  * SCA traces are captured during trigger_high & trigger_low.
96  *
97  * @param uj An initialized uJSON context.
98  * @return OK or error.
99  */
100 status_t handle_ibex_sca_register_file_write(ujson_t *uj);
101 
102 /**
103  * ibex.sca.register_file_write_batch_fvsr
104  *
105  * This SCA penetration test executes the following instructions:
106  * - Generate num_iteration FvsR values using the software LFSR.
107  * - Set trigger
108  * - Write random data to registers in RF
109  * - Unset trigger
110  *
111  * SCA traces are captured during trigger_high & trigger_low.
112  *
113  * @param uj An initialized uJSON context.
114  * @return OK or error.
115  */
116 status_t handle_ibex_sca_register_file_write_batch_fvsr(ujson_t *uj);
117 
118 /**
119  * ibex.sca.register_file_write_batch_random
120  *
121  * This SCA penetration test executes the following instructions:
122  * - Generate num_iteration random values using the software LFSR.
123  * - Set trigger
124  * - Write random data to registers in RF
125  * - Unset trigger
126  *
127  * SCA traces are captured during trigger_high & trigger_low.
128  *
129  * @param uj An initialized uJSON context.
130  * @return OK or error.
131  */
132 status_t handle_ibex_sca_register_file_write_batch_random(ujson_t *uj);
133 
134 /**
135  * ibex.sca.tl_read
136  *
137  * This SCA penetration test executes the following instructions:
138  * - Set trigger
139  * - Read data from SRAM over TL-UL.
140  * - Unset trigger
141  *
142  * SCA traces are captured during trigger_high & trigger_low.
143  *
144  * @param uj An initialized uJSON context.
145  * @return OK or error.
146  */
147 status_t handle_ibex_sca_tl_read(ujson_t *uj);
148 
149 /**
150  * ibex.sca.tl_read_batch_fvsr
151  *
152  * This SCA penetration test executes the following instructions:
153  * - Generate num_iteration FvsR values using the software LFSR.
154  * - Set trigger
155  * - Read data from SRAM over TL-UL.
156  * - Unset trigger
157  *
158  * SCA traces are captured during trigger_high & trigger_low.
159  *
160  * @param uj An initialized uJSON context.
161  * @return OK or error.
162  */
163 status_t handle_ibex_sca_tl_read_batch_fvsr(ujson_t *uj);
164 
165 /**
166  * ibex.sca.tl_read_batch_fvsr_fix_address
167  *
168  * This SCA penetration test executes the following instructions:
169  * - Generate num_iteration FvsR values using the software LFSR.
170  * - Set trigger
171  * - Read data from a single address in SRAM over TL-UL.
172  * - Unset trigger
173  *
174  * SCA traces are captured during trigger_high & trigger_low.
175  *
176  * @param uj An initialized uJSON context.
177  * @return OK or error.
178  */
179 status_t handle_ibex_sca_tl_read_batch_fvsr_fix_address(ujson_t *uj);
180 
181 /**
182  * ibex.sca.tl_read_batch_random
183  *
184  * This SCA penetration test executes the following instructions:
185  * - Generate num_iteration random values using the software LFSR.
186  * - Set trigger
187  * - Read data from SRAM over TL-UL.
188  * - Unset trigger
189  *
190  * SCA traces are captured during trigger_high & trigger_low.
191  *
192  * @param uj An initialized uJSON context.
193  * @return OK or error.
194  */
195 status_t handle_ibex_sca_tl_read_batch_random(ujson_t *uj);
196 
197 /**
198  * ibex.sca.tl_read_batch_random_fix_address
199  *
200  * This SCA penetration test executes the following instructions:
201  * - Generate num_iteration random values using the software LFSR.
202  * - Set trigger
203  * - Read data from a single address in SRAM over TL-UL.
204  * - Unset trigger
205  *
206  * SCA traces are captured during trigger_high & trigger_low.
207  *
208  * @param uj An initialized uJSON context.
209  * @return OK or error.
210  */
211 status_t handle_ibex_sca_tl_read_batch_random_fix_address(ujson_t *uj);
212 
213 /**
214  * ibex.sca.tl_write
215  *
216  * This SCA penetration test executes the following instructions:
217  * - Set trigger
218  * - Write data over TL-UL into SRAM.
219  * - Unset trigger
220  *
221  * SCA traces are captured during trigger_high & trigger_low.
222  *
223  * @param uj An initialized uJSON context.
224  * @return OK or error.
225  */
226 status_t handle_ibex_sca_tl_write(ujson_t *uj);
227 
228 /**
229  * ibex.sca.tl_write_batch_fvsr
230  *
231  * This SCA penetration test executes the following instructions:
232  * - Generate num_iteration FvsR values using the software LFSR.
233  * - Loop num_iterations:
234  * - Set trigger
235  * - Write data over TL-UL into SRAM.
236  * - Unset trigger
237  *
238  * SCA traces are captured during trigger_high & trigger_low.
239  *
240  * @param uj An initialized uJSON context.
241  * @return OK or error.
242  */
243 status_t handle_ibex_sca_tl_write_batch_fvsr(ujson_t *uj);
244 
245 /**
246  * ibex.sca.tl_write_batch_fvsr_fix_address
247  *
248  * This SCA penetration test executes the following instructions:
249  * - Generate num_iteration FvsR values using the software LFSR.
250  * - Loop num_iterations:
251  * - Set trigger
252  * - Write data over TL-UL into a single position in SRAM.
253  * - Unset trigger
254  *
255  * SCA traces are captured during trigger_high & trigger_low.
256  *
257  * @param uj An initialized uJSON context.
258  * @return OK or error.
259  */
260 status_t handle_ibex_sca_tl_write_batch_fvsr_fix_address(ujson_t *uj);
261 
262 /**
263  * ibex.sca.tl_write_batch_random
264  *
265  * This SCA penetration test executes the following instructions:
266  * - Generate num_iteration random values using the software LFSR.
267  * - Loop num_iterations:
268  * - Set trigger
269  * - Write data over TL-UL into SRAM.
270  * - Unset trigger
271  *
272  * SCA traces are captured during trigger_high & trigger_low.
273  *
274  * @param uj An initialized uJSON context.
275  * @return OK or error.
276  */
277 status_t handle_ibex_sca_tl_write_batch_random(ujson_t *uj);
278 
279 /**
280  * ibex.sca.tl_write_batch_random_fix_address
281  *
282  * This SCA penetration test executes the following instructions:
283  * - Generate num_iteration random values using the software LFSR.
284  * - Loop num_iterations:
285  * - Set trigger
286  * - Write data over TL-UL into a single position in SRAM.
287  * - Unset trigger
288  *
289  * SCA traces are captured during trigger_high & trigger_low.
290  *
291  * @param uj An initialized uJSON context.
292  * @return OK or error.
293  */
294 status_t handle_ibex_sca_tl_write_batch_random_fix_address(ujson_t *uj);
295 
296 /**
297  * Ibex SCA command handler.
298  *
299  * Command handler for the Ibex SCA command.
300  *
301  * @param uj An initialized uJSON context.
302  * @return OK or error.
303  */
304 status_t handle_ibex_sca(ujson_t *uj);
305 
306 #endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_SCA_IBEX_SCA_H_