Skip to content

Commit

Permalink
Fixing pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
p-huynh committed Apr 4, 2024
1 parent c809bcb commit a671af4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_find_one_bitwise_impossible_xor_differential_trail_model_with_external_
key = set_fixed_variables(component_id='key', constraint_type='equal', bit_positions=range(64), bit_values=[0] * 64)
ciphertext = set_fixed_variables(component_id='cipher_output_10_13', constraint_type='equal',
bit_positions=range(32), bit_values=[0] * 6 + [2, 0, 2] + [0] * 23)
trail = milp.find_one_bitwise_impossible_xor_differential_trail(6, fixed_values=[plaintext, key, ciphertext], external_solver_name='glpk')
trail = milp.find_one_bitwise_impossible_xor_differential_trail(6, fixed_values=[plaintext, key, ciphertext], external_solver_name='glpk_ext')
assert trail['status'] == 'SATISFIABLE'
assert trail['components_values']['intermediate_output_5_12']['value'] == '????????????????0??????1??????0?'
assert trail['components_values']['intermediate_output_5_12_backward']['value'] == SIMON_INCOMPATIBLE_ROUND_OUTPUT
Expand All @@ -145,7 +145,7 @@ def test_find_one_bitwise_impossible_xor_differential_trail_with_fully_automatic
ciphertext_backward = set_fixed_variables(component_id='cipher_output_10_13_backward', constraint_type='equal',
bit_positions=range(32), bit_values=[0] * 6 + [2, 0, 2] + [0] * 23)
trail = milp.find_one_bitwise_impossible_xor_differential_trail_with_fully_automatic_model(
fixed_values=[plaintext, key, key_backward, ciphertext_backward], external_solver_name='glpk')
fixed_values=[plaintext, key, key_backward, ciphertext_backward], external_solver_name='glpk_ext')
assert trail['status'] == 'SATISFIABLE'
assert trail['components_values']['plaintext']['value'] == '00000000000000000000000000000001'
assert trail['components_values']['intermediate_output_5_12_backward']['value'] == SIMON_INCOMPATIBLE_ROUND_OUTPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_find_one_wordwise_impossible_xor_differential_trail_model_with_external
ciphertext = set_fixed_variables(component_id='cipher_output_1_32', constraint_type='equal', bit_positions=range(16),
bit_values=[1] + [0]*15)
trail = milp.find_one_wordwise_impossible_xor_differential_trail(1, fixed_bits=[key],
fixed_words=[plaintext, ciphertext], external_solver_name='glpk')
fixed_words=[plaintext, ciphertext], external_solver_name='glpk_ext')
assert trail['status'] == 'SATISFIABLE'
assert trail['components_values']['plaintext']['value'] == '1003000000000000'
assert trail['components_values']['key']['value'] == '0000000000000000'
Expand All @@ -113,7 +113,7 @@ def test_find_one_wordwise_impossible_xor_differential_trail_with_fully_automati
ciphertext_backward = set_fixed_variables(component_id='cipher_output_1_32_backward', constraint_type='equal', bit_positions=range(16),
bit_values=[1] + [0]*15)
trail = milp.find_one_wordwise_impossible_xor_differential_trail_with_fully_automatic_model(fixed_bits=[key, key_backward],
fixed_words=[plaintext, ciphertext_backward], external_solver_name='glpk')
fixed_words=[plaintext, ciphertext_backward], external_solver_name='glpk_ext')
assert trail['status'] == 'SATISFIABLE'
assert trail['components_values']['plaintext']['value'] == '1003000000000000'
assert trail['components_values']['key']['value'] == '0000000000000000'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_find_one_xor_linear_trail_with_fixed_weight():
def test_find_one_xor_linear_trail_with_fixed_weight_with_external_solver():
speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2)
milp = MilpXorLinearModel(speck)
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="glpk")
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="glpk_ext")
assert len(trail) == 10
assert trail["total_weight"] == 1.0

Expand All @@ -123,14 +123,14 @@ def test_find_one_xor_linear_trail_with_fixed_weight_with_supported_but_not_inst
with pytest.raises(Exception) as e_info:
speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2)
milp = MilpXorLinearModel(speck)
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="cplex")
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="cplex_ext")


def test_find_one_xor_linear_trail_with_fixed_weight_with_installed_external_solver_but_missing_license():
with pytest.raises(Exception) as e_info:
speck = SpeckBlockCipher(block_bit_size=32, key_bit_size=64, number_of_rounds=2)
milp = MilpXorLinearModel(speck)
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="Gurobi")
trail = milp.find_one_xor_linear_trail_with_fixed_weight(1, external_solver_name="Gurobi_ext")

def test_find_one_xor_linear_trail_with_fixed_weight_with_unsupported_external_solver():
with pytest.raises(Exception) as e_info:
Expand Down

0 comments on commit a671af4

Please sign in to comment.