Add safety to dummy_random in case of NULL context
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
bb0168144e
commit
a1dc3e5a60
1 changed files with 5 additions and 2 deletions
|
@ -60,8 +60,11 @@ int dummy_random( void *p_rng, unsigned char *output, size_t output_len )
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
|
//mbedtls_ctr_drbg_random requires a valid mbedtls_ctr_drbg_context in p_rng
|
||||||
|
if( p_rng != NULL ) {
|
||||||
//use mbedtls_ctr_drbg_random to find bugs in it
|
//use mbedtls_ctr_drbg_random to find bugs in it
|
||||||
ret = mbedtls_ctr_drbg_random(p_rng, output, output_len);
|
ret = mbedtls_ctr_drbg_random(p_rng, output, output_len);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
(void) p_rng;
|
(void) p_rng;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
Loading…
Reference in a new issue