From 0a325b6767706e4cdec1290e52cb50fd14caaffb Mon Sep 17 00:00:00 2001 From: Minos Galanakis Date: Thu, 6 Apr 2023 16:33:10 +0100 Subject: [PATCH] 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 --- scripts/mbedtls_dev/bignum_common.py | 5 ++++- scripts/mbedtls_dev/ecp.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/mbedtls_dev/bignum_common.py b/scripts/mbedtls_dev/bignum_common.py index b942070e8..d8ef4a84f 100644 --- a/scripts/mbedtls_dev/bignum_common.py +++ b/scripts/mbedtls_dev/bignum_common.py @@ -17,6 +17,7 @@ from abc import abstractmethod import enum from typing import Iterator, List, Tuple, TypeVar, Any +from copy import deepcopy from itertools import chain from . import test_case @@ -104,6 +105,7 @@ class OperationCommon(test_data_generation.BaseTest): symbol = "" input_values = INPUTS_DEFAULT # type: List[str] input_cases = [] # type: List[Any] + dependencies = [] # type: List[Any] unique_combinations_only = False input_styles = ["variable", "fixed", "arch_split"] # type: List[str] input_style = "variable" # type: str @@ -119,10 +121,11 @@ class OperationCommon(test_data_generation.BaseTest): # provides earlier/more robust input validation. self.int_a = hex_to_int(val_a) self.int_b = hex_to_int(val_b) + self.dependencies = deepcopy(self.dependencies) if bits_in_limb not in self.limb_sizes: raise ValueError("Invalid number of bits in limb!") 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 @property diff --git a/scripts/mbedtls_dev/ecp.py b/scripts/mbedtls_dev/ecp.py index 0f4651151..d1d23c130 100644 --- a/scripts/mbedtls_dev/ecp.py +++ b/scripts/mbedtls_dev/ecp.py @@ -34,6 +34,7 @@ class EcpP192R1Raw(bignum_common.ModOperationCommon, test_name = "ecp_mod_p192_raw" input_style = "fixed" arity = 1 + dependencies = ["MBEDTLS_ECP_DP_SECP192R1_ENABLED"] moduli = ["fffffffffffffffffffffffffffffffeffffffffffffffff"] # type: List[str] @@ -109,6 +110,7 @@ class EcpP224R1Raw(bignum_common.ModOperationCommon, test_name = "ecp_mod_p224_raw" input_style = "arch_split" arity = 1 + dependencies = ["MBEDTLS_ECP_DP_SECP224R1_ENABLED"] moduli = ["ffffffffffffffffffffffffffffffff000000000000000000000001"] # type: List[str] @@ -185,6 +187,7 @@ class EcpP256R1Raw(bignum_common.ModOperationCommon, test_name = "ecp_mod_p256_raw" input_style = "fixed" arity = 1 + dependencies = ["MBEDTLS_ECP_DP_SECP256R1_ENABLED"] moduli = ["ffffffff00000001000000000000000000000000ffffffffffffffffffffffff"] # type: List[str] @@ -267,6 +270,7 @@ class EcpP384R1Raw(bignum_common.ModOperationCommon, test_name = "ecp_mod_p384_raw" input_style = "fixed" arity = 1 + dependencies = ["MBEDTLS_ECP_DP_SECP384R1_ENABLED"] moduli = [("ffffffffffffffffffffffffffffffffffffffffffffffff" "fffffffffffffffeffffffff0000000000000000ffffffff") @@ -388,6 +392,7 @@ class EcpP521R1Raw(bignum_common.ModOperationCommon, test_name = "ecp_mod_p521_raw" input_style = "arch_split" arity = 1 + dependencies = ["MBEDTLS_ECP_DP_SECP521R1_ENABLED"] moduli = [("01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")