1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

mpi_core_exp_mod: add generated tests

Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
Janos Follath
2022-11-22 21:37:10 +00:00
parent 3321b5842c
commit 05867cb036
2 changed files with 23 additions and 2 deletions

View File

@ -755,6 +755,27 @@ def mpi_modmul_case_generate() -> None:
# BEGIN MERGE SLOT 1
class BignumCoreExpMod(BignumCoreTarget, bignum_common.ModOperationCommon):
"""Test cases for bignum core exponentiation."""
symbol = "^"
test_function = "mpi_core_exp_mod"
test_name = "Core modular exponentiation"
input_style = "fixed"
def result(self) -> List[str]:
result = pow(self.int_a, self.int_b, self.int_n)
return [self.format_result(result)]
@property
def is_valid(self) -> bool:
# The base needs to be canonical, but the exponent can be larger than
# the modulus (see for example exponent blinding)
if self.int_a < self.int_n:
return True
else:
return False
# END MERGE SLOT 1
# BEGIN MERGE SLOT 2