mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-21 23:42:31 +00:00
Bignum tests: improve mod descriptions
There are no semantic changes to the generated tests. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
284672ccfb
commit
8ae7a657ac
@ -168,6 +168,11 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||||||
generated to provide some context to the test case.
|
generated to provide some context to the test case.
|
||||||
"""
|
"""
|
||||||
if not self.case_description:
|
if not self.case_description:
|
||||||
|
if self.arity == 1:
|
||||||
|
self.case_description = "{} {:x}".format(
|
||||||
|
self.symbol, self.int_a
|
||||||
|
)
|
||||||
|
elif self.arity == 2:
|
||||||
self.case_description = "{:x} {} {:x}".format(
|
self.case_description = "{:x} {} {:x}".format(
|
||||||
self.int_a, self.symbol, self.int_b
|
self.int_a, self.symbol, self.int_b
|
||||||
)
|
)
|
||||||
@ -232,7 +237,6 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ModOperationCommon(OperationCommon):
|
class ModOperationCommon(OperationCommon):
|
||||||
#pylint: disable=abstract-method
|
#pylint: disable=abstract-method
|
||||||
"""Target for bignum mod_raw test case generation."""
|
"""Target for bignum mod_raw test case generation."""
|
||||||
@ -278,6 +282,17 @@ class ModOperationCommon(OperationCommon):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def description(self) -> str:
|
||||||
|
"""Generate a description for the test case.
|
||||||
|
|
||||||
|
It uses the form A `symbol` B mod N, where symbol is used to represent
|
||||||
|
the operation.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not self.case_description:
|
||||||
|
return super().description() + " mod {:x}".format(self.int_n)
|
||||||
|
return super().description()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def input_cases_args(cls) -> Iterator[Tuple[Any, Any, Any]]:
|
def input_cases_args(cls) -> Iterator[Tuple[Any, Any, Any]]:
|
||||||
if cls.arity == 1:
|
if cls.arity == 1:
|
||||||
|
@ -55,6 +55,7 @@ class BignumModRawConvertToMont(bignum_common.ModOperationCommon,
|
|||||||
|
|
||||||
test_function = "mpi_mod_raw_to_mont_rep"
|
test_function = "mpi_mod_raw_to_mont_rep"
|
||||||
test_name = "Convert into Mont: "
|
test_name = "Convert into Mont: "
|
||||||
|
symbol = "R *"
|
||||||
input_style = "arch_split"
|
input_style = "arch_split"
|
||||||
arity = 1
|
arity = 1
|
||||||
|
|
||||||
@ -108,24 +109,17 @@ class BignumModRawConvertToMont(bignum_common.ModOperationCommon,
|
|||||||
"947fb3baf674f74a673cf1d38126983a19ed52c7439fab42c2185"
|
"947fb3baf674f74a673cf1d38126983a19ed52c7439fab42c2185"
|
||||||
]
|
]
|
||||||
|
|
||||||
descr_tpl = '{} #{} N: \"{}\" A: \"{}\".'
|
|
||||||
|
|
||||||
def result(self) -> List[str]:
|
def result(self) -> List[str]:
|
||||||
result = (self.int_a * self.r) % self.int_n
|
result = (self.int_a * self.r) % self.int_n
|
||||||
return [self.format_result(result)]
|
return [self.format_result(result)]
|
||||||
|
|
||||||
def description(self) -> str:
|
|
||||||
return self.descr_tpl.format(self.test_name,
|
|
||||||
self.count,
|
|
||||||
self.int_n,
|
|
||||||
self.int_a)
|
|
||||||
|
|
||||||
|
|
||||||
class BignumModRawConvertFromMont(BignumModRawConvertToMont):
|
class BignumModRawConvertFromMont(BignumModRawConvertToMont):
|
||||||
""" Test cases for mpi_mod_raw_from_mont_rep(). """
|
""" Test cases for mpi_mod_raw_from_mont_rep(). """
|
||||||
|
count = 0
|
||||||
test_function = "mpi_mod_raw_from_mont_rep"
|
test_function = "mpi_mod_raw_from_mont_rep"
|
||||||
test_name = "Convert from Mont: "
|
test_name = "Convert from Mont: "
|
||||||
|
symbol = "1/R *"
|
||||||
|
|
||||||
input_values = ["0",
|
input_values = ["0",
|
||||||
"1",
|
"1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user