Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
ctap_mem.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2021 Freie Universität Berlin
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
22
#ifndef FIDO2_CTAP_CTAP_MEM_H
23
#define FIDO2_CTAP_CTAP_MEM_H
24
25
#include <stdint.h>
26
27
#include "
fido2/ctap/ctap.h
"
28
#include "
periph/flashpage.h
"
29
30
#ifdef __cplusplus
31
extern
"C"
{
32
#endif
33
38
#ifndef _MAX
39
#define _MAX(a, b) ((a) > (b) ? (a) : (b))
40
#endif
46
#ifndef CONFIG_FIDO2_CTAP_NUM_FLASHPAGES
47
#define CONFIG_FIDO2_CTAP_NUM_FLASHPAGES 4
48
#endif
49
50
#if CONFIG_FIDO2_CTAP_NUM_FLASHPAGES < 2
51
#error "ctap_mem.h: Configured number of flashpages is invalid"
52
#endif
53
57
#define CTAP_FLASH_ALIGN_PAD(x) (sizeof(x) % FLASHPAGE_WRITE_BLOCK_SIZE == \
58
0 ? \
59
0 : FLASHPAGE_WRITE_BLOCK_SIZE - \
60
sizeof(x) % FLASHPAGE_WRITE_BLOCK_SIZE)
61
65
#define CTAP_FLASH_RK_SZ (sizeof(ctap_resident_key_t) + \
66
CTAP_FLASH_ALIGN_PAD(ctap_resident_key_t))
67
71
#define CTAP_FLASH_STATE_SZ (sizeof(ctap_state_t) + \
72
CTAP_FLASH_ALIGN_PAD(ctap_state_t))
73
77
#define CTAP_FLASH_MAX_NUM_RKS ((CONFIG_FIDO2_CTAP_NUM_FLASHPAGES - 1) * \
78
FLASHPAGE_SIZE / CTAP_FLASH_RK_SZ)
79
85
#define CTAP_FLASH_MIN_SECTOR_SZ _MAX(CTAP_FLASH_STATE_SZ, CTAP_FLASH_RK_SZ)
86
90
#define CTAP_FLASH_PAGES_PER_SECTOR ((CTAP_FLASH_MIN_SECTOR_SZ / FLASHPAGE_SIZE) + 1)
91
98
#define CTAP_FLASH_RK_OFF 0x1
99
105
ctap_status_code_t
fido2_ctap_mem_init
(
void
);
106
117
ctap_status_code_t
fido2_ctap_mem_read
(
void
*buf, uint32_t page, uint32_t offset, uint32_t len);
118
124
ctap_status_code_t
fido2_ctap_mem_erase_flash
(
void
);
125
133
ctap_status_code_t
fido2_ctap_mem_read_state_from_flash
(
ctap_state_t
*state);
134
142
ctap_status_code_t
fido2_ctap_mem_write_state_to_flash
(
ctap_state_t
*state);
143
158
ctap_status_code_t
fido2_ctap_mem_read_rk_from_flash
(
ctap_resident_key_t
*key, uint8_t *rp_id_hash,
159
uint32_t *addr);
160
168
ctap_status_code_t
fido2_ctap_mem_write_rk_to_flash
(
ctap_resident_key_t
*rk);
169
170
#ifdef __cplusplus
171
}
172
#endif
173
#endif
/* FIDO2_CTAP_CTAP_MEM_H */
ctap.h
Internal FIDO2 CTAP defines, structures and function declarations.
flashpage.h
Low-level flash page peripheral driver interface.
fido2_ctap_mem_read
ctap_status_code_t fido2_ctap_mem_read(void *buf, uint32_t page, uint32_t offset, uint32_t len)
Read from flash memory.
fido2_ctap_mem_read_rk_from_flash
ctap_status_code_t 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.
fido2_ctap_mem_erase_flash
ctap_status_code_t fido2_ctap_mem_erase_flash(void)
Erase all flashpages containing CTAP data.
fido2_ctap_mem_write_state_to_flash
ctap_status_code_t fido2_ctap_mem_write_state_to_flash(ctap_state_t *state)
Write authenticator state to flash.
fido2_ctap_mem_write_rk_to_flash
ctap_status_code_t fido2_ctap_mem_write_rk_to_flash(ctap_resident_key_t *rk)
Write resident credential to flash.
fido2_ctap_mem_read_state_from_flash
ctap_status_code_t fido2_ctap_mem_read_state_from_flash(ctap_state_t *state)
Read authenticator state from flash.
fido2_ctap_mem_init
ctap_status_code_t fido2_ctap_mem_init(void)
Initialize memory helper.
ctap_status_code_t
ctap_status_code_t
CTAP status codes.
Definition
ctap.h:47
ctap_resident_key
CTAP resident key struct.
Definition
ctap.h:486
ctap_state_t
CTAP state struct.
Definition
ctap.h:402
Generated on Sat Dec 21 2024 20:58:04 by
1.9.8