mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-03 20:54:00 +00:00
Zeroize tmp buf in mbedtls_mpi_fill_random()
This commit is contained in:
parent
79a2e7ef06
commit
7351e12410
@ -63,6 +63,10 @@ static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) {
|
|||||||
volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0;
|
volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mbedtls_zeroize( void *v, size_t n ) {
|
||||||
|
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
||||||
#define biL (ciL << 3) /* bits in limb */
|
#define biL (ciL << 3) /* bits in limb */
|
||||||
#define biH (ciL << 2) /* half limb size */
|
#define biH (ciL << 2) /* half limb size */
|
||||||
@ -1882,6 +1886,8 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
|
|||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
mbedtls_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user