11#include <zephyr/types.h>
12#include <zephyr/autoconf.h>
14#if defined(CONFIG_NRFX_NVMC)
16#elif defined(CONFIG_NRFX_RRAMC)
17#include <nrfx_rramc.h>
19#error "No NRFX storage technology supported backend selected"
27#if defined(CONFIG_NRFX_NVMC)
28typedef uint16_t counter_t;
29typedef uint16_t lcs_data_t;
30typedef uint16_t lcs_reserved_t;
31#elif defined(CONFIG_NRFX_RRAMC)
33typedef uint32_t counter_t;
34typedef uint32_t lcs_data_t;
35typedef uint32_t lcs_reserved_t;
40#define EINVALIDLCS 115
43#define SB_PUBLIC_KEY_HASH_LEN 16
52#define BL_MONOTONIC_COUNTERS_DESC_NSIB 0x1
58#define BL_MONOTONIC_COUNTERS_DESC_MCUBOOT_ID0 0x2
177#define BL_STORAGE_IMPLEMENTATION_ID_SIZE 32
#define SB_PUBLIC_KEY_HASH_LEN
Definition bl_storage.h:43
collection_type
Definition bl_storage.h:46
@ BL_COLLECTION_TYPE_MONOTONIC_COUNTERS
Definition bl_storage.h:47
@ BL_COLLECTION_TYPE_VARIABLE_DATA
Definition bl_storage.h:48
variable_data_type
Definition bl_storage.h:115
@ BL_VARIABLE_DATA_TYPE_PSA_CERTIFICATION_REFERENCE
Definition bl_storage.h:116
const volatile struct bl_storage_data *const BL_STORAGE
int set_monotonic_counter(uint16_t counter_desc, counter_t new_counter)
Set the current HW monotonic counter.
int update_life_cycle_state(enum bl_storage_lcs next_lcs)
Update the life cycle state in OTP.
int get_monotonic_counter(uint16_t counter_desc, counter_t *counter_value)
Get the current HW monotonic counter.
int verify_public_keys(void)
Function for verifying public keys.
uint32_t s0_address_read(void)
Function for reading address of slot 0.
uint32_t num_public_keys_read(void)
Function for reading number of public key data slots.
bl_storage_lcs
The PSA life cycle states a device can be in.
Definition bl_storage.h:294
@ BL_STORAGE_LCS_DECOMMISSIONED
Definition bl_storage.h:299
@ BL_STORAGE_LCS_UNKNOWN
Definition bl_storage.h:295
@ BL_STORAGE_LCS_ASSEMBLY
Definition bl_storage.h:296
@ BL_STORAGE_LCS_PROVISIONING
Definition bl_storage.h:297
@ BL_STORAGE_LCS_SECURED
Definition bl_storage.h:298
void invalidate_public_key(uint32_t key_idx)
Function for invalidating a public key.
int num_monotonic_counter_slots(uint16_t counter_desc, uint16_t *counter_slots)
Get the number of monotonic counter slots.
int public_key_data_read(uint32_t key_idx, uint8_t *p_buf)
Function for reading public key hashes.
uint32_t s1_address_read(void)
Function for reading address of slot 1.
int is_monotonic_counter_update_possible(uint16_t counter_desc)
Checks whether it is possible to update the monotonic counter to a new value.
void read_implementation_id_from_otp(uint8_t *buf)
int read_variable_data(enum variable_data_type data_type, uint8_t *buf, uint32_t *buf_len)
Read variable data from OTP.
int read_life_cycle_state(enum bl_storage_lcs *lcs)
Read the current life cycle state the device is in from OTP,.
uint32_t num_public_keys
Definition bl_storage.h:146
uint8_t implementation_id[32]
Definition bl_storage.h:143
uint32_t valid
Definition bl_storage.h:148
struct life_cycle_state_data lcs
Definition bl_storage.h:142
struct bl_storage_data::@137 key_data[]
uint32_t s0_address
Definition bl_storage.h:144
uint32_t s1_address
Definition bl_storage.h:145
Definition bl_storage.h:140
uint16_t type
Definition bl_storage.h:100
uint16_t count
Definition bl_storage.h:101
Definition bl_storage.h:99
struct monotonic_counter counters[]
Definition bl_storage.h:111
Definition bl_storage.h:109
lcs_reserved_t reserved_for_padding
Definition bl_storage.h:78
lcs_data_t secure
Definition bl_storage.h:72
lcs_data_t provisioning
Definition bl_storage.h:71
lcs_data_t decommissioned
Definition bl_storage.h:79
Definition bl_storage.h:70
counter_t counter_slots[]
Definition bl_storage.h:95
uint16_t num_counter_slots
Definition bl_storage.h:94
uint16_t description
Definition bl_storage.h:92
Definition bl_storage.h:88
Definition bl_storage.h:131
uint8_t length
Definition bl_storage.h:120
uint8_t type
Definition bl_storage.h:119
uint8_t data[]
Definition bl_storage.h:121
Definition bl_storage.h:118