hmac_drbg: change two variables to be volatile

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek 2020-07-18 00:10:50 -04:00
parent 4b700a3db3
commit 9167aa96f8
No known key found for this signature in database
GPG key ID: 89A90840DC388527

View file

@ -210,7 +210,7 @@ static int hmac_drbg_reseed_core( mbedtls_hmac_drbg_context *ctx,
size_t seedlen = 0;
size_t total_entropy_len;
int ret = MBEDTLS_ERR_PLATFORM_FAULT_DETECTED;
volatile const unsigned char *additional_dup = additional;
const unsigned char * volatile additional_dup = additional;
volatile size_t len_dup = len;
int reseed_counter_backup = -1;
@ -417,7 +417,7 @@ int mbedtls_hmac_drbg_random_with_add( void *p_rng,
mbedtls_hmac_drbg_context *ctx = (mbedtls_hmac_drbg_context *) p_rng;
size_t md_len = mbedtls_md_get_size(
mbedtls_md_get_handle( &ctx->md_ctx ) );
size_t left = out_len;
volatile size_t left = out_len;
unsigned char *out = output;
/* II. Check request length */
@ -430,8 +430,8 @@ int mbedtls_hmac_drbg_random_with_add( void *p_rng,
/* 1. (aka VII and IX) Check reseed counter and PR */
if( ctx->f_entropy != NULL && /* For no-reseeding instances */
( ctx->prediction_resistance == MBEDTLS_HMAC_DRBG_PR_ON ||
ctx->reseed_counter > ctx->reseed_interval ) )
( ctx->prediction_resistance == MBEDTLS_HMAC_DRBG_PR_ON ||
ctx->reseed_counter > ctx->reseed_interval ) )
{
if( ( ret = mbedtls_hmac_drbg_reseed( ctx, additional, add_len ) ) != 0 )
return( ret );