mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/puf_sram: counter based reseed after soft reset
This commit is contained in:
parent
8d16ccb96a
commit
9dd3219c3f
@ -89,6 +89,13 @@ extern uint32_t puf_sram_seed;
|
||||
*/
|
||||
extern uint32_t puf_sram_state;
|
||||
|
||||
/**
|
||||
* @brief Counter variable allocated in puf_sram.c. It is incremented
|
||||
during each soft reset when no new PUF measurement was taken
|
||||
and it gets reset to zero after a power cycle was detected.
|
||||
*/
|
||||
extern uint32_t puf_sram_softreset_cnt;
|
||||
|
||||
/**
|
||||
* @brief checks source of reboot by @p puf_sram_softreset and conditionally
|
||||
calls @p puf_sram_generate
|
||||
|
@ -24,6 +24,9 @@ PUF_SRAM_ATTRIBUTES uint32_t puf_sram_seed;
|
||||
/* Allocation of the PUF seed state */
|
||||
PUF_SRAM_ATTRIBUTES uint32_t puf_sram_state;
|
||||
|
||||
/* Allocation of the PUF soft reset conter*/
|
||||
PUF_SRAM_ATTRIBUTES uint32_t puf_sram_softreset_cnt;
|
||||
|
||||
/* Allocation of the memory marker */
|
||||
PUF_SRAM_ATTRIBUTES uint32_t puf_sram_marker;
|
||||
|
||||
@ -42,6 +45,8 @@ void puf_sram_generate(const uint8_t *ram, size_t len)
|
||||
puf_sram_marker = PUF_SRAM_MARKER;
|
||||
/* setting state to 0 means seed was generated from SRAM pattern */
|
||||
puf_sram_state = 0;
|
||||
/* reset counter of detected soft resets */
|
||||
puf_sram_softreset_cnt = 0;
|
||||
}
|
||||
|
||||
bool puf_sram_softreset(void)
|
||||
@ -51,5 +56,12 @@ bool puf_sram_softreset(void)
|
||||
return 0;
|
||||
}
|
||||
puf_sram_state = 1;
|
||||
|
||||
/* increment number of detected soft resets */
|
||||
puf_sram_softreset_cnt++;
|
||||
|
||||
/* generate alterntive seed value */
|
||||
puf_sram_seed ^= puf_sram_softreset_cnt;
|
||||
puf_sram_seed = dek_hash((uint8_t *)&puf_sram_seed, sizeof(puf_sram_seed));
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user