Software APIs
sigverify_keys_spx.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_SILICON_CREATOR_ROM_SIGVERIFY_KEYS_SPX_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_ROM_SIGVERIFY_KEYS_SPX_H_
7 
8 #include <stdint.h>
9 
10 #include "sw/device/silicon_creator/lib/drivers/lifecycle.h"
11 #include "sw/device/silicon_creator/lib/error.h"
12 #include "sw/device/silicon_creator/lib/sigverify/spx_key.h"
13 #include "sw/device/silicon_creator/rom/sigverify_key_types.h"
14 #include "sw/device/silicon_creator/rom/sigverify_otp_keys.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif // __cplusplus
19 
20 /**
21  * Number of SPX public keys.
22  */
23 extern const size_t kSigverifySpxKeysCnt;
24 
25 /**
26  * Step size to use when checking SPX public keys.
27  *
28  * This must be coprime with and less than `kSigverifyNumSpxKeys`.
29  * Note: Step size is not applicable when `kSigverifyNumSpxKeys` is 1.
30  */
31 extern const size_t kSigverifySpxKeysStep;
32 
33 /**
34  * Public keys for signature verification.
35  */
36 extern const sigverify_rom_spx_key_t kSigverifySpxKeys[];
37 
38 /**
39  * Returns the key with the given ID.
40  *
41  * This function returns the key only if it can be used in the given life cycle
42  * state and is valid in OTP. OTP check is performed only if the device is in a
43  * non-test operational state (PROD, PROD_END, DEV, RMA).
44  *
45  * @param key_id A key ID.
46  * @param lc_state Life cycle state of the device.
47  * @param key Key with the given ID, valid only if it exists.
48  * @param config Key configuration with the given ID, valid only if it exists.
49  * @return Result of the operation.
50  */
52 rom_error_t sigverify_spx_key_get(const sigverify_otp_key_ctx_t *sigverify_ctx,
53  uint32_t key_id, lifecycle_state_t lc_state,
54  const sigverify_spx_key_t **key,
55  sigverify_spx_config_id_t *config);
56 
57 #ifdef __cplusplus
58 } // extern "C"
59 #endif // __cplusplus
60 
61 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_ROM_SIGVERIFY_KEYS_SPX_H_