Bignum Tests: move properties to superclass
Move properties that are needed in several children to the superclass. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
155ad8c297
commit
b41ab926b2
1 changed files with 21 additions and 19 deletions
|
@ -104,6 +104,27 @@ class OperationCommon(test_data_generation.BaseTest):
|
||||||
self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)]
|
self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)]
|
||||||
self.bits_in_limb = bits_in_limb
|
self.bits_in_limb = bits_in_limb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boundary(self) -> int:
|
||||||
|
data_in = [self.int_a, self.int_b]
|
||||||
|
return max([n for n in data_in if n is not None])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def limbs(self) -> int:
|
||||||
|
return limbs_mpi(self.boundary, self.bits_in_limb)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hex_digits(self) -> int:
|
||||||
|
return 2 * (self.limbs * self.bits_in_limb // 8)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hex_a(self) -> str:
|
||||||
|
return "{:x}".format(self.int_a).zfill(self.hex_digits)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hex_b(self) -> str:
|
||||||
|
return "{:x}".format(self.int_b).zfill(self.hex_digits)
|
||||||
|
|
||||||
def arguments(self) -> List[str]:
|
def arguments(self) -> List[str]:
|
||||||
return [
|
return [
|
||||||
quote_str(self.arg_a), quote_str(self.arg_b)
|
quote_str(self.arg_a), quote_str(self.arg_b)
|
||||||
|
@ -177,26 +198,10 @@ class ModOperationCommon(OperationCommon):
|
||||||
data_in = [self.int_a, self.int_b, self.int_n]
|
data_in = [self.int_a, self.int_b, self.int_n]
|
||||||
return max([n for n in data_in if n is not None])
|
return max([n for n in data_in if n is not None])
|
||||||
|
|
||||||
@property
|
|
||||||
def limbs(self) -> int:
|
|
||||||
return limbs_mpi(self.boundary, self.bits_in_limb)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def hex_digits(self) -> int:
|
|
||||||
return 2 * (self.limbs * self.bits_in_limb // 8)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hex_n(self) -> str:
|
def hex_n(self) -> str:
|
||||||
return "{:x}".format(self.int_n).zfill(self.hex_digits)
|
return "{:x}".format(self.int_n).zfill(self.hex_digits)
|
||||||
|
|
||||||
@property
|
|
||||||
def hex_a(self) -> str:
|
|
||||||
return "{:x}".format(self.int_a).zfill(self.hex_digits)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def hex_b(self) -> str:
|
|
||||||
return "{:x}".format(self.int_b).zfill(self.hex_digits)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def r(self) -> int: # pylint: disable=invalid-name
|
def r(self) -> int: # pylint: disable=invalid-name
|
||||||
l = limbs_mpi(self.int_n, self.bits_in_limb)
|
l = limbs_mpi(self.int_n, self.bits_in_limb)
|
||||||
|
@ -221,9 +226,6 @@ class OperationCommonArchSplit(OperationCommon):
|
||||||
bound_val = max(self.int_a, self.int_b)
|
bound_val = max(self.int_a, self.int_b)
|
||||||
self.bits_in_limb = bits_in_limb
|
self.bits_in_limb = bits_in_limb
|
||||||
self.bound = bound_mpi(bound_val, self.bits_in_limb)
|
self.bound = bound_mpi(bound_val, self.bits_in_limb)
|
||||||
limbs = limbs_mpi(bound_val, self.bits_in_limb)
|
|
||||||
byte_len = limbs * self.bits_in_limb // 8
|
|
||||||
self.hex_digits = 2 * byte_len
|
|
||||||
if self.bits_in_limb == 32:
|
if self.bits_in_limb == 32:
|
||||||
self.dependencies = ["MBEDTLS_HAVE_INT32"]
|
self.dependencies = ["MBEDTLS_HAVE_INT32"]
|
||||||
elif self.bits_in_limb == 64:
|
elif self.bits_in_limb == 64:
|
||||||
|
|
Loading…
Reference in a new issue