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

Merge pull request #6772 from wernerlewis/bignum_refactor_sub

Bignum: Refactor mpi_core_sub tests to use arch_split
This commit is contained in:
Gilles Peskine
2022-12-15 12:32:44 +01:00
committed by GitHub
2 changed files with 12 additions and 24 deletions

View File

@ -130,24 +130,20 @@ class BignumCoreAddAndAddIf(BignumCoreTarget, bignum_common.OperationCommon):
class BignumCoreSub(BignumCoreTarget, bignum_common.OperationCommon):
"""Test cases for bignum core sub."""
count = 0
input_style = "arch_split"
symbol = "-"
test_function = "mpi_core_sub"
test_name = "mbedtls_mpi_core_sub"
def result(self) -> List[str]:
if self.int_a >= self.int_b:
result_4 = result_8 = self.int_a - self.int_b
result = self.int_a - self.int_b
carry = 0
else:
bound_val = max(self.int_a, self.int_b)
bound_4 = bignum_common.bound_mpi(bound_val, 32)
result_4 = bound_4 + self.int_a - self.int_b
bound_8 = bignum_common.bound_mpi(bound_val, 64)
result_8 = bound_8 + self.int_a - self.int_b
result = self.limb_boundary + self.int_a - self.int_b
carry = 1
return [
"\"{:x}\"".format(result_4),
"\"{:x}\"".format(result_8),
self.format_result(result),
str(carry)
]