diff --git a/scripts/mbedtls_dev/bignum_core.py b/scripts/mbedtls_dev/bignum_core.py index 4910daea87..f85fb2e36a 100644 --- a/scripts/mbedtls_dev/bignum_core.py +++ b/scripts/mbedtls_dev/bignum_core.py @@ -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 diff --git a/tests/suites/test_suite_bignum_core.function b/tests/suites/test_suite_bignum_core.function index e262ec1039..f9a768c0ca 100644 --- a/tests/suites/test_suite_bignum_core.function +++ b/tests/suites/test_suite_bignum_core.function @@ -1042,8 +1042,8 @@ exit: /* BEGIN MERGE SLOT 1 */ /* BEGIN_CASE */ -void mpi_core_exp_mod( char * input_A, char * input_E, - char * input_N, char * input_X ) +void mpi_core_exp_mod( char * input_N, char * input_A, + char * input_E, char * input_X ) { mbedtls_mpi_uint *A = NULL; size_t A_limbs;