From 5623ecc2d62bcdd2c4bd2dd501591502713a7725 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 20 Dec 2022 19:16:54 +0100 Subject: [PATCH] Mod operations: fill arguments to the width of the modulus With the default input style (which is "variable"), fill all bignum test case arguments to the same width as the modulus. Signed-off-by: Gilles Peskine --- scripts/mbedtls_dev/bignum_common.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/mbedtls_dev/bignum_common.py b/scripts/mbedtls_dev/bignum_common.py index 9db567b7c..03055f02b 100644 --- a/scripts/mbedtls_dev/bignum_common.py +++ b/scripts/mbedtls_dev/bignum_common.py @@ -267,6 +267,12 @@ class ModOperationCommon(OperationCommon): def arg_n(self) -> str: return self.format_arg(self.val_n) + def format_arg(self, val: str) -> str: + if self.input_style == "variable": + return val.zfill(len(hex(self.int_n)) - 2) + else: + return super().format_arg(val) + def arguments(self) -> List[str]: return [quote_str(self.arg_n)] + super().arguments()