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 # 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 # END MERGE SLOT 1
# BEGIN MERGE SLOT 2 # BEGIN MERGE SLOT 2

View file

@ -1042,8 +1042,8 @@ exit:
/* BEGIN MERGE SLOT 1 */ /* BEGIN MERGE SLOT 1 */
/* BEGIN_CASE */ /* BEGIN_CASE */
void mpi_core_exp_mod( char * input_A, char * input_E, void mpi_core_exp_mod( char * input_N, char * input_A,
char * input_N, char * input_X ) char * input_E, char * input_X )
{ {
mbedtls_mpi_uint *A = NULL; mbedtls_mpi_uint *A = NULL;
size_t A_limbs; size_t A_limbs;