mpi_core_exp_mod: add generated tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/scripts/mbedtls_dev/bignum_core.py b/scripts/mbedtls_dev/bignum_core.py
index 4910dae..f85fb2e 100644
--- a/scripts/mbedtls_dev/bignum_core.py
+++ b/scripts/mbedtls_dev/bignum_core.py
@@ -755,6 +755,27 @@
# 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 e262ec1..f9a768c 100644
--- a/tests/suites/test_suite_bignum_core.function
+++ b/tests/suites/test_suite_bignum_core.function
@@ -1042,8 +1042,8 @@
/* 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;