mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-25 18:39:54 +00:00
mbedtls_ctr_drbg_reseed: Minor readability improvement
No semantic change.
This commit is contained in:
parent
c0ace355a4
commit
dbd3f7c68d
@ -337,41 +337,32 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
|
|||||||
size_t seedlen = 0;
|
size_t seedlen = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if( ctx->entropy_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ||
|
if( ctx->entropy_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT )
|
||||||
len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len )
|
return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
|
||||||
|
if( len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len )
|
||||||
return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
|
return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
|
||||||
|
|
||||||
memset( seed, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT );
|
memset( seed, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT );
|
||||||
|
|
||||||
/*
|
/* Gather entropy_len bytes of entropy to seed state. */
|
||||||
* Gather entropy_len bytes of entropy to seed state
|
if( 0 != ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) )
|
||||||
*/
|
|
||||||
if( 0 != ctx->f_entropy( ctx->p_entropy, seed,
|
|
||||||
ctx->entropy_len ) )
|
|
||||||
{
|
{
|
||||||
return( MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED );
|
return( MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
seedlen += ctx->entropy_len;
|
seedlen += ctx->entropy_len;
|
||||||
|
|
||||||
/*
|
/* Add additional data if provided. */
|
||||||
* Add additional data
|
if( additional != NULL && len != 0 )
|
||||||
*/
|
|
||||||
if( additional && len )
|
|
||||||
{
|
{
|
||||||
memcpy( seed + seedlen, additional, len );
|
memcpy( seed + seedlen, additional, len );
|
||||||
seedlen += len;
|
seedlen += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Reduce to 384 bits. */
|
||||||
* Reduce to 384 bits
|
|
||||||
*/
|
|
||||||
if( ( ret = block_cipher_df( seed, seed, seedlen ) ) != 0 )
|
if( ( ret = block_cipher_df( seed, seed, seedlen ) ) != 0 )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/*
|
/* Update state. */
|
||||||
* Update state
|
|
||||||
*/
|
|
||||||
if( ( ret = ctr_drbg_update_internal( ctx, seed ) ) != 0 )
|
if( ( ret = ctr_drbg_update_internal( ctx, seed ) ) != 0 )
|
||||||
goto exit;
|
goto exit;
|
||||||
ctx->reseed_counter = 1;
|
ctx->reseed_counter = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user