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:
dehanj 2024-02-02 14:20:21 +01:00
parent c85b5311cd
commit 3a6a60ff26
No known key found for this signature in database
GPG key ID: 3707A9DBF4BB8F1A
3 changed files with 10 additions and 3 deletions

View file

@ -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;
}