mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-21 11:07:51 +00:00
psa: cipher: Use psa_generate_random to generate IVs
Use psa_generate_random() to generate IVs instead of mbedtls_psa_get_random(). mbedtls_psa_get_random() is meant to be used as the f_rng argument of Mbed TLS library functions. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
e6f6301390
commit
f2381aaa43
|
@ -274,15 +274,14 @@ static psa_status_t cipher_generate_iv(
|
||||||
mbedtls_psa_cipher_operation_t *operation,
|
mbedtls_psa_cipher_operation_t *operation,
|
||||||
uint8_t *iv, size_t iv_size, size_t *iv_length )
|
uint8_t *iv, size_t iv_size, size_t *iv_length )
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
|
|
||||||
if( iv_size < operation->iv_size )
|
if( iv_size < operation->iv_size )
|
||||||
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
||||||
|
|
||||||
ret = mbedtls_psa_get_random( MBEDTLS_PSA_RANDOM_STATE,
|
status = psa_generate_random( iv, operation->iv_size );
|
||||||
iv, operation->iv_size );
|
if( status != PSA_SUCCESS )
|
||||||
if( ret != 0 )
|
return( status );
|
||||||
return( mbedtls_to_psa_error( ret ) );
|
|
||||||
|
|
||||||
*iv_length = operation->iv_size;
|
*iv_length = operation->iv_size;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue