mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 22:54:24 +01:00
CTR_DRBG: clean stack buffers
Wipe stack buffers that may contain sensitive data (data that contributes to the DRBG state.
This commit is contained in:
parent
96e0d8ebfc
commit
17b2ac2a7c
@ -264,6 +264,7 @@ static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx,
|
|||||||
mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS );
|
mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS );
|
||||||
memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE );
|
memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE );
|
||||||
|
|
||||||
|
mbedtls_zeroize( tmp, sizeof( tmp ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +282,7 @@ void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
|
|||||||
|
|
||||||
block_cipher_df( add_input, additional, add_len );
|
block_cipher_df( add_input, additional, add_len );
|
||||||
ctr_drbg_update_internal( ctx, add_input );
|
ctr_drbg_update_internal( ctx, add_input );
|
||||||
|
mbedtls_zeroize( add_input, sizeof( add_input ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +329,7 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
|
|||||||
ctr_drbg_update_internal( ctx, seed );
|
ctr_drbg_update_internal( ctx, seed );
|
||||||
ctx->reseed_counter = 1;
|
ctx->reseed_counter = 1;
|
||||||
|
|
||||||
|
mbedtls_zeroize( seed, sizeof( seed ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +396,8 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng,
|
|||||||
|
|
||||||
ctx->reseed_counter++;
|
ctx->reseed_counter++;
|
||||||
|
|
||||||
|
mbedtls_zeroize( add_input, sizeof( add_input ) );
|
||||||
|
mbedtls_zeroize( tmp, sizeof( tmp ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user