mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-06-05 13:08:51 -04:00
fw: Protect zeroisation against compiler optimisation.
The memset() responsible for the zeroisation of the secure_ctx under the compute_cdi() function in FW's main.c, was optimised away by the compiler. Instead of using memset(), secure_wipe() is introduced which uses a volatile keyword to prevent the compiler to try to optimise it. Secure_wipe() is now used on all locations handling removal of sensitive data.
This commit is contained in:
parent
c85b5311cd
commit
3a6a60ff26
3 changed files with 10 additions and 3 deletions
|
@ -155,3 +155,10 @@ int memeq(void *dest, const void *src, size_t n)
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
void secure_wipe(void *v, size_t n)
|
||||
{
|
||||
volatile uint8_t *p = (volatile uint8_t *)v;
|
||||
while (n--)
|
||||
*p++ = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue