FIDO2 CTAP flash memory helper. More...
FIDO2 CTAP flash memory helper.
Files | |
file | ctap_mem.h |
Definitions for CTAP flash memory helper functions. | |
Macros | |
#define | CONFIG_FIDO2_CTAP_NUM_FLASHPAGES 4 |
Default amount of flashpages to use. | |
#define | CTAP_FLASH_ALIGN_PAD(x) |
Calculate padding needed to align struct size for saving to flash. | |
#define | CTAP_FLASH_RK_SZ |
Resident key size with alignment padding. | |
#define | CTAP_FLASH_STATE_SZ |
State struct size with alignment padding. | |
#define | CTAP_FLASH_MAX_NUM_RKS |
Max amount of resident keys that can be stored on device. | |
#define | CTAP_FLASH_MIN_SECTOR_SZ _MAX(CTAP_FLASH_STATE_SZ, CTAP_FLASH_RK_SZ) |
Minimum flash sector size needed to hold CTAP related data. | |
#define | CTAP_FLASH_PAGES_PER_SECTOR ((CTAP_FLASH_MIN_SECTOR_SZ / FLASHPAGE_SIZE) + 1) |
Pages per sector needed. | |
#define | CTAP_FLASH_RK_OFF 0x1 |
Offset of flashpage for storing resident keys. | |
Functions | |
int | fido2_ctap_mem_init (void) |
Initialize memory helper. | |
int | fido2_ctap_mem_read (void *buf, uint32_t page, uint32_t offset, uint32_t len) |
Read from flash memory. | |
int | fido2_ctap_mem_erase_flash (void) |
Erase all flashpages containing CTAP data. | |
int | fido2_ctap_mem_read_state_from_flash (ctap_state_t *state) |
Read authenticator state from flash. | |
int | fido2_ctap_mem_write_state_to_flash (ctap_state_t *state) |
Write authenticator state to flash. | |
int | fido2_ctap_mem_read_rk_from_flash (ctap_resident_key_t *key, uint8_t *rp_id_hash, uint32_t *addr) |
Find resident credential for rp_id_hash in flash. | |
int | fido2_ctap_mem_write_rk_to_flash (ctap_resident_key_t *rk) |
Write resident credential to flash. | |
#define | _MAX(a, b) ((a) > (b) ? (a) : (b)) |
MAX function for internal use. | |
#define _MAX | ( | a, | |
b | |||
) | ((a) > (b) ? (a) : (b)) |
MAX function for internal use.
Definition at line 39 of file ctap_mem.h.
#define CONFIG_FIDO2_CTAP_NUM_FLASHPAGES 4 |
Default amount of flashpages to use.
Definition at line 47 of file ctap_mem.h.
#define CTAP_FLASH_ALIGN_PAD | ( | x | ) |
Calculate padding needed to align struct size for saving to flash.
Definition at line 57 of file ctap_mem.h.
#define CTAP_FLASH_MAX_NUM_RKS |
Max amount of resident keys that can be stored on device.
Definition at line 77 of file ctap_mem.h.
#define CTAP_FLASH_MIN_SECTOR_SZ _MAX(CTAP_FLASH_STATE_SZ, CTAP_FLASH_RK_SZ) |
Minimum flash sector size needed to hold CTAP related data.
This is needed to ensure that the MTD work_area buffer is big enough
Definition at line 85 of file ctap_mem.h.
#define CTAP_FLASH_PAGES_PER_SECTOR ((CTAP_FLASH_MIN_SECTOR_SZ / FLASHPAGE_SIZE) + 1) |
Pages per sector needed.
Definition at line 90 of file ctap_mem.h.
#define CTAP_FLASH_RK_OFF 0x1 |
Offset of flashpage for storing resident keys.
The offset is in units of flashpages from the beginning of the flash memory area dedicated for storing CTAP data.
Definition at line 98 of file ctap_mem.h.
#define CTAP_FLASH_RK_SZ |
Resident key size with alignment padding.
Definition at line 65 of file ctap_mem.h.
#define CTAP_FLASH_STATE_SZ |
State struct size with alignment padding.
Definition at line 71 of file ctap_mem.h.
int fido2_ctap_mem_erase_flash | ( | void | ) |
Erase all flashpages containing CTAP data.
int fido2_ctap_mem_init | ( | void | ) |
Initialize memory helper.
int fido2_ctap_mem_read | ( | void * | buf, |
uint32_t | page, | ||
uint32_t | offset, | ||
uint32_t | len | ||
) |
Read from flash memory.
[out] | buf | buffer to fil in |
[in] | page | page to read from |
[in] | offset | offset from the start of the page (in bytes) |
[in] | len | number of bytes to write |
int fido2_ctap_mem_read_rk_from_flash | ( | ctap_resident_key_t * | key, |
uint8_t * | rp_id_hash, | ||
uint32_t * | addr | ||
) |
Find resident credential for rp_id_hash
in flash.
The function stores the flash address of the next credential in addr
. This allows for consecutive calls of the function in order to find all stored credentials stored for the relying party identified by rp_id_hash
.
[in] | key | pointer to authenticator state |
[in] | rp_id_hash | pointer to hash of rp domain string |
[in] | addr | pointer to address where to read from |
int fido2_ctap_mem_read_state_from_flash | ( | ctap_state_t * | state | ) |
Read authenticator state from flash.
[in] | state | pointer to authenticator state |
int fido2_ctap_mem_write_rk_to_flash | ( | ctap_resident_key_t * | rk | ) |
Write resident credential to flash.
[in] | rk | pointer to resident credential |
int fido2_ctap_mem_write_state_to_flash | ( | ctap_state_t * | state | ) |
Write authenticator state to flash.
[in] | state | pointer to authenticator state |