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>
diff --git a/scripts/mbedtls_dev/bignum_common.py b/scripts/mbedtls_dev/bignum_common.py
index d8ef4a8..20f7ff8 100644
--- a/scripts/mbedtls_dev/bignum_common.py
+++ b/scripts/mbedtls_dev/bignum_common.py
@@ -80,6 +80,23 @@
""" 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.