From 979d86979313de02c4dab71f99ce1c5dddd5877a Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 28 Aug 2024 12:37:38 +0200 Subject: More ladder multipliers. --- test/ec/test_key_agreement.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'test/ec') diff --git a/test/ec/test_key_agreement.py b/test/ec/test_key_agreement.py index 4afb2de..a045c49 100644 --- a/test/ec/test_key_agreement.py +++ b/test/ec/test_key_agreement.py @@ -105,9 +105,11 @@ def test_ka_secg(): (SwapLadderMultiplier, "ladd-1987-m", "dbl-1987-m", "scale"), (DifferentialLadderMultiplier, "dadd-1987-m", "dbl-1987-m", "scale"), ], + ids=["ladd", "swap", "diff"] ) -@pytest.mark.parametrize("complete", [True, False]) -@pytest.mark.parametrize("short_circuit", [True, False]) +@pytest.mark.parametrize("complete", [True, False], ids=["complete", ""]) +@pytest.mark.parametrize("short_circuit", [True, False], ids=["shorted", ""]) +@pytest.mark.parametrize("full", [True, False], ids=["full", ""]) @pytest.mark.parametrize( "scalar_hex,coord_hex,result_hex", [ @@ -135,7 +137,7 @@ def test_ka_secg(): ids=["RFC7748tv1", "RFC7748tv2", "RFC7748dh1", "RFC7748dh2"], ) def test_x25519( - curve25519, mult_args, complete, short_circuit, scalar_hex, coord_hex, result_hex + curve25519, mult_args, complete, short_circuit, full, scalar_hex, coord_hex, result_hex ): mult_class = mult_args[0] mult_formulas = list( @@ -143,9 +145,12 @@ def test_x25519( lambda name: curve25519.curve.coordinate_model.formulas[name], mult_args[1:] ) ) - multiplier = mult_class( - *mult_formulas, complete=complete, short_circuit=short_circuit - ) + try: + multiplier = mult_class( + *mult_formulas, complete=complete, short_circuit=short_circuit, full=full + ) + except ValueError: + return scalar = int.from_bytes(bytes.fromhex(scalar_hex), "little") coord = int.from_bytes(bytes.fromhex(coord_hex), "little") @@ -165,9 +170,11 @@ def test_x25519( (SwapLadderMultiplier, "ladd-1987-m", "dbl-1987-m", "scale"), (DifferentialLadderMultiplier, "dadd-1987-m", "dbl-1987-m", "scale"), ], + ids=["ladd", "swap", "diff"] ) -@pytest.mark.parametrize("complete", [True, False]) -@pytest.mark.parametrize("short_circuit", [True, False]) +@pytest.mark.parametrize("complete", [True, False], ids=["complete", ""]) +@pytest.mark.parametrize("short_circuit", [True, False], ids=["shorted", ""]) +@pytest.mark.parametrize("full", [True, False], ids=["full", ""]) @pytest.mark.parametrize( "scalar_hex,coord_hex,result_hex", [ @@ -195,15 +202,18 @@ def test_x25519( ids=["RFC7748tv1", "RFC7748tv2", "RFC7748dh1", "RFC7748dh2"], ) def test_x448( - curve448, mult_args, complete, short_circuit, scalar_hex, coord_hex, result_hex + curve448, mult_args, complete, short_circuit, full, scalar_hex, coord_hex, result_hex ): mult_class = mult_args[0] mult_formulas = list( map(lambda name: curve448.curve.coordinate_model.formulas[name], mult_args[1:]) ) - multiplier = mult_class( - *mult_formulas, complete=complete, short_circuit=short_circuit - ) + try: + multiplier = mult_class( + *mult_formulas, complete=complete, short_circuit=short_circuit, full=full + ) + except ValueError: + return scalar = int.from_bytes(bytes.fromhex(scalar_hex), "little") coord = int.from_bytes(bytes.fromhex(coord_hex), "little") -- cgit v1.2.3-70-g09d2