PebbleOS v4.47.0-372-gac5760587
Loading...
Searching...
No Matches
PRF store

The bonding and root keys the recovery firmware (PRF) and the normal firmware share. More...

Modules

 PRF store layout
 On-flash layout of the PRF store entries.
 

Functions

bool pbl_bt_prf_store_get_root_key (enum pbl_bt_sm_root_key_type key_type, struct pbl_bt_sm_key *key_out)
 Get a BLE root key.
 
void pbl_bt_prf_store_set_root_keys (struct pbl_bt_sm_key *keys_in)
 Store the BLE root keys.
 
bool pbl_bt_prf_store_get_pairing (struct pbl_bt_sm_pairing_info *pairing_info_out, char *name_out, uint8_t *flags)
 Get the BLE pairing.
 
void pbl_bt_prf_store_set_pairing (const struct pbl_bt_sm_pairing_info *pairing_info, const char *name, uint8_t flags)
 Store the BLE pairing, replacing the previous one.
 
void pbl_bt_prf_store_set_pairing_name (const char *name)
 Store the device name of the BLE pairing.
 
void pbl_bt_prf_store_erase_pairing (void)
 Erase the BLE pairing and its device name.
 
void pbl_bt_prf_store_wipe (void)
 Erase everything, for a factory reset.
 
void pbl_bt_prf_store_init (void)
 Initialize the PRF store.
 

Detailed Description

The bonding and root keys the recovery firmware (PRF) and the normal firmware share.

Kept in a flash partition of its own, as a rolling list of 256-byte entries (see PRF store layout) that recovery firmware already in the field reads: the layout cannot change. Each field carries its own CRC; changing a field invalidates the current entry and rewrites the data into the next one, and the partition is erased once it fills up. All functions are serialized by a mutex.

Implemented by the NimBLE store (NIMBLE_STORE_PRF), which can also persist in it (NIMBLE_STORE_BACKEND_PRF).

Function Documentation

◆ pbl_bt_prf_store_erase_pairing()

void pbl_bt_prf_store_erase_pairing ( void  )

Erase the BLE pairing and its device name.

◆ pbl_bt_prf_store_get_pairing()

bool pbl_bt_prf_store_get_pairing ( struct pbl_bt_sm_pairing_info *  pairing_info_out,
char *  name_out,
uint8_t *  flags 
)

Get the BLE pairing.

Output parameters may be NULL and are only valid when true is returned.

Parameters
[out]pairing_info_outPairing keys.
[out]name_outBuffer of PBL_BT_DEVICE_NAME_BUFFER_SIZE bytes for the remote device name, empty if none is stored.
[out]flagsPairing flags.
Returns
true if a pairing is stored.

◆ pbl_bt_prf_store_get_root_key()

bool pbl_bt_prf_store_get_root_key ( enum pbl_bt_sm_root_key_type  key_type,
struct pbl_bt_sm_key *  key_out 
)

Get a BLE root key.

Parameters
key_typeEncryption Root (ER) or Identity Root (IR) key.
[out]key_outKey, may be NULL.
Returns
true if a non-zero key is stored.

◆ pbl_bt_prf_store_init()

void pbl_bt_prf_store_init ( void  )

Initialize the PRF store.

Finds the valid entry, and erases the region, keeping that entry, when more than 75% of the region is used so that later writes are unlikely to block on an erase.

◆ pbl_bt_prf_store_set_pairing()

void pbl_bt_prf_store_set_pairing ( const struct pbl_bt_sm_pairing_info *  pairing_info,
const char *  name,
uint8_t  flags 
)

Store the BLE pairing, replacing the previous one.

Empty pairing info is ignored.

Parameters
pairing_infoPairing keys.
nameRemote device name, or NULL to keep the stored name.
flagsPairing flags.

◆ pbl_bt_prf_store_set_pairing_name()

void pbl_bt_prf_store_set_pairing_name ( const char *  name)

Store the device name of the BLE pairing.

Does nothing without a pairing.

Parameters
nameDevice name.

◆ pbl_bt_prf_store_set_root_keys()

void pbl_bt_prf_store_set_root_keys ( struct pbl_bt_sm_key *  keys_in)

Store the BLE root keys.

Parameters
keys_inArray of PBL_BT_SM_ROOT_KEY_TYPE_NUM keys indexed by pbl_bt_sm_root_key_type, or NULL to store zeroed keys.

◆ pbl_bt_prf_store_wipe()

void pbl_bt_prf_store_wipe ( void  )

Erase everything, for a factory reset.