diff --git a/include/psa/crypto_builtin_cipher.h b/include/psa/crypto_builtin_cipher.h index 0fd577af3..df26c91d6 100644 --- a/include/psa/crypto_builtin_cipher.h +++ b/include/psa/crypto_builtin_cipher.h @@ -39,8 +39,8 @@ typedef struct { /* Context structure for the Mbed TLS cipher implementation. */ psa_algorithm_t alg; - uint8_t iv_size; - uint8_t block_size; + uint8_t iv_length; + uint8_t block_length; mbedtls_cipher_context_t cipher; } mbedtls_psa_cipher_operation_t; diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index dac9d7f41..464bd5778 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -219,18 +219,18 @@ static psa_status_t cipher_setup( 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_decrypt_setup( 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 @@ static psa_status_t cipher_generate_iv( { 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 @@ static psa_status_t cipher_update( mbedtls_psa_cipher_operation_t *operation, * 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 {