diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index 691ff3c3db..6e14d56e73 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -59,6 +59,7 @@ static inline psa_key_type_t mbedtls_psa_translate_cipher_type( case MBEDTLS_CIPHER_AES_128_CBC: case MBEDTLS_CIPHER_AES_192_CBC: case MBEDTLS_CIPHER_AES_256_CBC: + case MBEDTLS_CIPHER_AES_128_ECB: return( PSA_KEY_TYPE_AES ); /* ARIA not yet supported in PSA. */ diff --git a/library/cipher.c b/library/cipher.c index 457f8f6601..c9871ebccd 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -1246,9 +1246,12 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, if( status != PSA_SUCCESS ) return( MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED ); - status = psa_cipher_set_iv( &cipher_op, iv, iv_len ); - if( status != PSA_SUCCESS ) - return( MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED ); + if( ctx->cipher_info->mode != MBEDTLS_MODE_ECB ) + { + status = psa_cipher_set_iv( &cipher_op, iv, iv_len ); + if( status != PSA_SUCCESS ) + return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED ); + } status = psa_cipher_update( &cipher_op, input, ilen,