psa: cipher: Prefer length rather than size for IV/block length
Prefer length rather than size for IV/block length as
per the PSA specification.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c
index dac9d7f..464bd57 100644
--- a/library/psa_crypto_cipher.c
+++ b/library/psa_crypto_cipher.c
@@ -219,18 +219,18 @@
goto exit;
#endif /* BUILTIN_ALG_CBC_NO_PADDING || BUILTIN_ALG_CBC_PKCS7 */
- operation->block_size = ( PSA_ALG_IS_STREAM_CIPHER( alg ) ? 1 :
- PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type ) );
+ operation->block_length = ( PSA_ALG_IS_STREAM_CIPHER( alg ) ? 1 :
+ PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type ) );
if( ( alg & PSA_ALG_CIPHER_FROM_BLOCK_FLAG ) != 0 &&
alg != PSA_ALG_ECB_NO_PADDING )
{
- operation->iv_size = PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type );
+ operation->iv_length = PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type );
}
#if defined(BUILTIN_KEY_TYPE_CHACHA20)
else
if( ( alg == PSA_ALG_STREAM_CIPHER ) &&
( key_type == PSA_KEY_TYPE_CHACHA20 ) )
- operation->iv_size = 12;
+ operation->iv_length = 12;
#endif
exit:
@@ -262,7 +262,7 @@
static psa_status_t cipher_set_iv( mbedtls_psa_cipher_operation_t *operation,
const uint8_t *iv, size_t iv_length )
{
- if( iv_length != operation->iv_size )
+ if( iv_length != operation->iv_length )
return( PSA_ERROR_INVALID_ARGUMENT );
return( mbedtls_to_psa_error(
@@ -276,14 +276,14 @@
{
int status = PSA_ERROR_CORRUPTION_DETECTED;
- if( iv_size < operation->iv_size )
+ if( iv_size < operation->iv_length )
return( PSA_ERROR_BUFFER_TOO_SMALL );
- status = psa_generate_random( iv, operation->iv_size );
+ status = psa_generate_random( iv, operation->iv_length );
if( status != PSA_SUCCESS )
return( status );
- *iv_length = operation->iv_size;
+ *iv_length = operation->iv_length;
return( cipher_set_iv( operation, iv, *iv_length ) );
}
@@ -394,7 +394,7 @@
* output in this call. */
expected_output_size =
( operation->cipher.unprocessed_len + input_length )
- / operation->block_size * operation->block_size;
+ / operation->block_length * operation->block_length;
}
else
{