Software APIs
crypto_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_CRYPTO_FI_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_FI_CRYPTO_FI_H_
7 
8 #include "sw/device/lib/base/status.h"
9 #include "sw/device/lib/ujson/ujson.h"
10 
11 /**
12  * AES FI test.
13  *
14  * This test encrypts a static plaintext with a static key and returns the
15  * ciphertext over UART back to the host. The host can define, whether the
16  * trigger gets set and unset during(i) loading the key, (ii) loading the
17  * plaintext, (iii) encryption, or (iv) when reading back the ciphertext.
18  *
19  * @param uj An initialized uJSON context.
20  * @return OK or error.
21  */
22 status_t handle_crypto_fi_aes(ujson_t *uj);
23 
24 /**
25  * Initializes the trigger and configures the device for the Crypto FI test.
26  *
27  * @param uj An initialized uJSON context.
28  * @return OK or error.
29  */
30 status_t handle_crypto_fi_init(ujson_t *uj);
31 
32 /**
33  * KMAC FI test.
34  *
35  * This test absorbs a static message with a static key and returns the
36  * digest over UART back to the host. The host can define, whether the
37  * trigger gets set and unset during(i) loading the key, (ii) absorbing, or
38  * (iii) squeezing.
39  *
40  * @param uj An initialized uJSON context.
41  * @return OK or error.
42  */
43 status_t handle_crypto_fi_kmac(ujson_t *uj);
44 
45 /**
46  * KMAC State FI test.
47  *
48  * Try to inject a fault into the KMAC state.
49  *
50  * @param uj An initialized uJSON context.
51  * @return OK or error.
52  */
53 status_t handle_crypto_fi_kmac_state(ujson_t *uj);
54 
55 /**
56  * Shadow Register Access FI test.
57  *
58  * In this test, faults are injected when accessing KMAC shadow registers.
59  *
60  * @param uj An initialized uJSON context.
61  * @return OK or error.
62  */
63 status_t handle_crypto_fi_shadow_reg_access(ujson_t *uj);
64 
65 /**
66  * Shadow Register Read FI test.
67  *
68  * In this test, faults are injected when reading the AES and KMAC shadow
69  * registers.
70  *
71  * @param uj An initialized uJSON context.
72  * @return OK or error.
73  */
74 status_t handle_crypto_fi_shadow_reg_read(ujson_t *uj);
75 
76 /**
77  * Crypto FI command handler.
78  *
79  * Command handler for the Crypto FI command.
80  *
81  * @param uj An initialized uJSON context.
82  * @return OK or error.
83  */
84 status_t handle_crypto_fi(ujson_t *uj);
85 
86 #endif // OPENTITAN_SW_DEVICE_TESTS_PENETRATIONTESTS_FIRMWARE_FI_CRYPTO_FI_H_