ecp.py: Set test-dependencies as attributes.

This patch enables declaring dependencie as test-class
members. ECP curve functions have been updated
to use the new capability.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
Minos Galanakis 2023-04-06 16:33:10 +01:00
parent 92278dc407
commit 0a325b6767
2 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@
from abc import abstractmethod from abc import abstractmethod
import enum import enum
from typing import Iterator, List, Tuple, TypeVar, Any from typing import Iterator, List, Tuple, TypeVar, Any
from copy import deepcopy
from itertools import chain from itertools import chain
from . import test_case from . import test_case
@ -104,6 +105,7 @@ class OperationCommon(test_data_generation.BaseTest):
symbol = "" symbol = ""
input_values = INPUTS_DEFAULT # type: List[str] input_values = INPUTS_DEFAULT # type: List[str]
input_cases = [] # type: List[Any] input_cases = [] # type: List[Any]
dependencies = [] # type: List[Any]
unique_combinations_only = False unique_combinations_only = False
input_styles = ["variable", "fixed", "arch_split"] # type: List[str] input_styles = ["variable", "fixed", "arch_split"] # type: List[str]
input_style = "variable" # type: str input_style = "variable" # type: str
@ -119,10 +121,11 @@ class OperationCommon(test_data_generation.BaseTest):
# provides earlier/more robust input validation. # provides earlier/more robust input validation.
self.int_a = hex_to_int(val_a) self.int_a = hex_to_int(val_a)
self.int_b = hex_to_int(val_b) self.int_b = hex_to_int(val_b)
self.dependencies = deepcopy(self.dependencies)
if bits_in_limb not in self.limb_sizes: if bits_in_limb not in self.limb_sizes:
raise ValueError("Invalid number of bits in limb!") raise ValueError("Invalid number of bits in limb!")
if self.input_style == "arch_split": if self.input_style == "arch_split":
self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)] self.dependencies.append("MBEDTLS_HAVE_INT{:d}".format(bits_in_limb))
self.bits_in_limb = bits_in_limb self.bits_in_limb = bits_in_limb
@property @property

View File

@ -34,6 +34,7 @@ class EcpP192R1Raw(bignum_common.ModOperationCommon,
test_name = "ecp_mod_p192_raw" test_name = "ecp_mod_p192_raw"
input_style = "fixed" input_style = "fixed"
arity = 1 arity = 1
dependencies = ["MBEDTLS_ECP_DP_SECP192R1_ENABLED"]
moduli = ["fffffffffffffffffffffffffffffffeffffffffffffffff"] # type: List[str] moduli = ["fffffffffffffffffffffffffffffffeffffffffffffffff"] # type: List[str]
@ -109,6 +110,7 @@ class EcpP224R1Raw(bignum_common.ModOperationCommon,
test_name = "ecp_mod_p224_raw" test_name = "ecp_mod_p224_raw"
input_style = "arch_split" input_style = "arch_split"
arity = 1 arity = 1
dependencies = ["MBEDTLS_ECP_DP_SECP224R1_ENABLED"]
moduli = ["ffffffffffffffffffffffffffffffff000000000000000000000001"] # type: List[str] moduli = ["ffffffffffffffffffffffffffffffff000000000000000000000001"] # type: List[str]
@ -185,6 +187,7 @@ class EcpP256R1Raw(bignum_common.ModOperationCommon,
test_name = "ecp_mod_p256_raw" test_name = "ecp_mod_p256_raw"
input_style = "fixed" input_style = "fixed"
arity = 1 arity = 1
dependencies = ["MBEDTLS_ECP_DP_SECP256R1_ENABLED"]
moduli = ["ffffffff00000001000000000000000000000000ffffffffffffffffffffffff"] # type: List[str] moduli = ["ffffffff00000001000000000000000000000000ffffffffffffffffffffffff"] # type: List[str]
@ -267,6 +270,7 @@ class EcpP384R1Raw(bignum_common.ModOperationCommon,
test_name = "ecp_mod_p384_raw" test_name = "ecp_mod_p384_raw"
input_style = "fixed" input_style = "fixed"
arity = 1 arity = 1
dependencies = ["MBEDTLS_ECP_DP_SECP384R1_ENABLED"]
moduli = [("ffffffffffffffffffffffffffffffffffffffffffffffff" moduli = [("ffffffffffffffffffffffffffffffffffffffffffffffff"
"fffffffffffffffeffffffff0000000000000000ffffffff") "fffffffffffffffeffffffff0000000000000000ffffffff")
@ -388,6 +392,7 @@ class EcpP521R1Raw(bignum_common.ModOperationCommon,
test_name = "ecp_mod_p521_raw" test_name = "ecp_mod_p521_raw"
input_style = "arch_split" input_style = "arch_split"
arity = 1 arity = 1
dependencies = ["MBEDTLS_ECP_DP_SECP521R1_ENABLED"]
moduli = [("01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" moduli = [("01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")