mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
bignum_core.py: Add "BignumCoreShiftL()"
This patch introduces automatic test input generation for `mpi_core_shift_l()` function. It also adds two utility functions in bignum_common. Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
@ -80,6 +80,23 @@ def hex_digits_for_limb(limbs: int, bits_in_limb: int) -> int:
|
||||
""" Retrun the hex digits need for a number of limbs. """
|
||||
return 2 * (limbs * bits_in_limb // 8)
|
||||
|
||||
def hex_digits_max_int(val: str, bits_in_limb: int) -> int:
|
||||
""" Return the first number exceeding maximum the limb space
|
||||
required to store the input hex-string value. This method
|
||||
weights on the input str_len rather than numerical value
|
||||
and works with zero-padded inputs"""
|
||||
n = ((1 << (len(val) * 4)) - 1)
|
||||
l = limbs_mpi(n, bits_in_limb)
|
||||
return bound_mpi_limbs(l, bits_in_limb)
|
||||
|
||||
def zfill_match(reference: str, target: str) -> str:
|
||||
""" Zero pad target hex-string the match the limb size of
|
||||
the refference input """
|
||||
lt = len(target)
|
||||
lr = len(reference)
|
||||
targen_len = lr if lt < lr else lt
|
||||
return "{:x}".format(int(target, 16)).zfill(targen_len)
|
||||
|
||||
class OperationCommon(test_data_generation.BaseTest):
|
||||
"""Common features for bignum binary operations.
|
||||
|
||||
|
Reference in New Issue
Block a user