diff --git a/claasp/cipher.py b/claasp/cipher.py index 2a6f5635..f966528b 100644 --- a/claasp/cipher.py +++ b/claasp/cipher.py @@ -1708,4 +1708,12 @@ def get_descendants_subgraph(G, start_nodes): def update_input_id_links_from_component_id(self, component_id, new_input_id_links): round_number = self.get_round_from_component_id(component_id) - self._rounds.rounds[round_number].update_input_id_links_from_component_id(component_id, new_input_id_links) \ No newline at end of file + self._rounds.rounds[round_number].update_input_id_links_from_component_id(component_id, new_input_id_links) + + def all_sboxes_are_standard(self): + for comp in self.get_all_components(): + if 'sbox' in comp.id: + if (comp.input_bit_size != comp.output_bit_size) or (comp.input_bit_size % 2 != 0) or ( + comp.output_bit_size % 2 != 0): + return False + return True diff --git a/claasp/cipher_modules/evaluator.py b/claasp/cipher_modules/evaluator.py index e4e5a1be..e2f55267 100644 --- a/claasp/cipher_modules/evaluator.py +++ b/claasp/cipher_modules/evaluator.py @@ -78,7 +78,7 @@ def evaluate_using_c(cipher, inputs, intermediate_output, verbosity): def evaluate_vectorized(cipher, cipher_input, intermediate_outputs=False, verbosity=False): - if np.any(np.array(cipher.inputs_bit_size) % 8 != 0): + if np.any(np.array(cipher.inputs_bit_size) % 8 != 0) or not cipher.all_sboxes_are_standard(): python_code_string = code_generator \ .generate_bit_based_vectorized_python_code_string(cipher, store_intermediate_outputs=intermediate_outputs,