Skip to content

Commit 6128697

Browse files
committed
fixup! sys/fido2: update flash handling based on flashpage API extension
1 parent 427a532 commit 6128697

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

sys/fido2/ctap/ctap_mem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int fido2_ctap_mem_init(void)
6767
static unsigned _amount_flashpages_rk(void)
6868
{
6969
/* -1 because first page holds authenticator state information */
70-
return CTAP_FLASH_NUM_FLASHPAGES - 1;
70+
return CONFIG_FIDO2_CTAP_NUM_FLASHPAGES - 1;
7171
}
7272

7373
int fido2_ctap_mem_read(void *buf, uint32_t page, uint32_t offset, uint32_t len)
@@ -164,7 +164,7 @@ int fido2_ctap_mem_get_offset_of_rk_into_flashpage(uint16_t rk_idx)
164164

165165
unsigned fido2_ctap_mem_get_state_flashpage_number(void)
166166
{
167-
return flashpage_last_free() - CTAP_FLASH_NUM_FLASHPAGES + 1;
167+
return flashpage_last_free() - CONFIG_FIDO2_CTAP_NUM_FLASHPAGES + 1;
168168
}
169169

170170
unsigned fido2_ctap_mem_get_rk_start_page(void)

sys/include/fido2/ctap/ctap_mem.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ extern "C" {
4343
/**
4444
* @brief Default amount of flashpages to use
4545
*/
46-
#if defined(CONFIG_FIDO2_CTAP_NUM_FLASHPAGES) && \
47-
(CONFIG_FIDO2_CTAP_NUM_FLASHPAGES >= 2)
48-
#define CTAP_FLASH_NUM_FLASHPAGES CONFIG_FIDO2_CTAP_NUM_FLASHPAGES
49-
#else
50-
#define CTAP_FLASH_NUM_FLASHPAGES 4
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+
CONFIG_FIDO2_CTAP_NUM_FLASHPAGES >= FLASHPAGE_NUMOF
52+
#error "ctap_mem.h: Configured number of flashpages is invalid"
5153
#endif
5254

5355
/**

0 commit comments

Comments
 (0)