From 5ff03d49c0be5d1dea0e13cb803016fa210faf17 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Mon, 17 Oct 2022 11:21:22 +0100 Subject: [PATCH] Bignum Core test: move bound to constructor We will need it to pad parameters in the base class, but it is useful because every child class would need to calculate it anyway. Signed-off-by: Janos Follath --- scripts/mbedtls_dev/bignum_core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mbedtls_dev/bignum_core.py b/scripts/mbedtls_dev/bignum_core.py index 0b6ee97172..8327df1b85 100644 --- a/scripts/mbedtls_dev/bignum_core.py +++ b/scripts/mbedtls_dev/bignum_core.py @@ -79,11 +79,13 @@ class BignumCoreOperationArchSplit(BignumCoreOperation): def __init__(self, val_a: str, val_b: str, bits_in_limb: int) -> None: super().__init__(val_a, val_b) + bound_val = max(self.int_a, self.int_b) self.bits_in_limb = bits_in_limb + self.bound = bignum_common.bound_mpi(bound_val, self.bits_in_limb) if self.bits_in_limb == 32: self.dependencies = ["MBEDTLS_HAVE_INT32"] elif self.bits_in_limb == 64: - self.dependencies = ["MBEDTLS_HAVE_INT64"] + self.dependencies = ["MBDTLS_HAVE_INT64"] @classmethod def generate_function_tests(cls) -> Iterator[test_case.TestCase]: @@ -100,10 +102,8 @@ class BignumCoreAddIf(BignumCoreOperationArchSplit): def result(self) -> List[str]: result = self.int_a + self.int_b - bound_val = max(self.int_a, self.int_b) - bound = bignum_common.bound_mpi(bound_val, self.bits_in_limb) - carry, result = divmod(result, bound) + carry, result = divmod(result, self.bound) return [ "\"{:x}\"".format(result),