Bignum Tests: move ModOperationArchSplit to common
The class BignumModRawOperationArchSplit has functionality that are needed in other modules, therefore moving it to bignum_common. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
5b1dbb4cbc
commit
948afcecb9
2 changed files with 24 additions and 22 deletions
|
@ -226,6 +226,28 @@ class OperationCommonArchSplit(OperationCommon):
|
|||
yield cls(a_value, b_value, 64).create_test_case()
|
||||
|
||||
|
||||
class ModOperationCommonArchSplit(ModOperationCommon):
|
||||
#pylint: disable=abstract-method
|
||||
"""Common features for bignum mod raw operations where the result depends on
|
||||
the limb size."""
|
||||
|
||||
limb_sizes = [32, 64] # type: List[int]
|
||||
|
||||
def __init__(self, val_n: str, val_a: str, val_b: str = "0", bits_in_limb: int = 64) -> None:
|
||||
super().__init__(val_n=val_n, val_a=val_a, val_b=val_b, bits_in_limb=bits_in_limb)
|
||||
|
||||
if bits_in_limb not in self.limb_sizes:
|
||||
raise ValueError("Invalid number of bits in limb!")
|
||||
|
||||
self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)]
|
||||
|
||||
@classmethod
|
||||
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
|
||||
for a_value, b_value in cls.get_value_pairs():
|
||||
for bil in cls.limb_sizes:
|
||||
yield cls(a_value, b_value, bits_in_limb=bil).create_test_case()
|
||||
|
||||
|
||||
# BEGIN MERGE SLOT 1
|
||||
|
||||
# END MERGE SLOT 1
|
||||
|
|
|
@ -25,27 +25,6 @@ class BignumModRawTarget(test_data_generation.BaseTarget):
|
|||
"""Target for bignum mod_raw test case generation."""
|
||||
target_basename = 'test_suite_bignum_mod_raw.generated'
|
||||
|
||||
class BignumModRawOperationArchSplit(bignum_common.ModOperationCommon,
|
||||
BignumModRawTarget):
|
||||
#pylint: disable=abstract-method
|
||||
"""Common features for bignum mod raw operations where the result depends on
|
||||
the limb size."""
|
||||
|
||||
limb_sizes = [32, 64] # type: List[int]
|
||||
|
||||
def __init__(self, val_n: str, val_a: str, val_b: str = "0", bits_in_limb: int = 64) -> None:
|
||||
super().__init__(val_n=val_n, val_a=val_a, val_b=val_b, bits_in_limb=bits_in_limb)
|
||||
|
||||
if bits_in_limb not in self.limb_sizes:
|
||||
raise ValueError("Invalid number of bits in limb!")
|
||||
|
||||
self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)]
|
||||
|
||||
@classmethod
|
||||
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
|
||||
for a_value, b_value in cls.get_value_pairs():
|
||||
for bil in cls.limb_sizes:
|
||||
yield cls(a_value, b_value, bits_in_limb=bil).create_test_case()
|
||||
# BEGIN MERGE SLOT 1
|
||||
|
||||
# END MERGE SLOT 1
|
||||
|
@ -71,7 +50,8 @@ class BignumModRawOperationArchSplit(bignum_common.ModOperationCommon,
|
|||
# END MERGE SLOT 6
|
||||
|
||||
# BEGIN MERGE SLOT 7
|
||||
class BignumModRawConvertToMont(BignumModRawOperationArchSplit):
|
||||
class BignumModRawConvertToMont(bignum_common.ModOperationCommonArchSplit,
|
||||
BignumModRawTarget):
|
||||
""" Test cases for mpi_mod_raw_to_mont_rep(). """
|
||||
|
||||
test_function = "mpi_mod_raw_to_mont_rep"
|
||||
|
|
Loading…
Reference in a new issue