def harakatruncated(config): """ Find best attack in our truncated model for Haraka. """ num_states = ((config["aesrounds"] + 1) * config["rounds"]) + 1 # Iterate over all possible starting states for the attack best_attack = 999999 best_round = -1 best_model = 0 for rnd in range(num_states - 1): if haraka.isAESround(rnd, config["aesrounds"]): config["attackerstart"] = rnd model = haraka.buildmodel(config) attack_costs = round(solvemodel(model).objVal) print("Subround {} - Best Attack: {}".format(rnd, attack_costs)) if attack_costs < best_attack: best_attack = attack_costs best_round = rnd best_model = model print("Found best attack in round {} with costs {}".format(best_round, best_attack)) haraka.printmodel(best_model, config) return
def findminactivesbox(config): """ Example which finds the minimum number of active S-boxes for AES like ciphers, with the parameters given in the config file. """ if config["name"] == "aeslike": model = aeslike.buildmodel(config) solved_model = solvemodel(model) aeslike.printmodel(solved_model, config) elif config["name"] == "haraka": model = haraka.buildmodel(config) solved_model = solvemodel(model) haraka.printmodel(solved_model, config) return