mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +01:00
Introduce polarssl_zeroize() instead of memset() for zeroization
This commit is contained in:
parent
bbcb1ce703
commit
3461772559
36 changed files with 325 additions and 129 deletions
|
|
@ -52,6 +52,11 @@
|
|||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
static int rsa_can_do( pk_type_t type )
|
||||
{
|
||||
|
|
@ -426,6 +431,7 @@ static void *rsa_alt_alloc_wrap( void )
|
|||
|
||||
static void rsa_alt_free_wrap( void *ctx )
|
||||
{
|
||||
polarssl_zeroize( ctx, sizeof( rsa_alt_context ) );
|
||||
polarssl_free( ctx );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue