cube attack offline phase
This commit is contained in:
+55
-2
@@ -5,6 +5,7 @@ from tea3.variable_search import run_exhaustive, run_exhaustive_staircase, run_e
|
||||
from tea3.sbox import run_sbox
|
||||
from tea3.variable_xor import run_variable_xor, run_exhaustive_xor
|
||||
from tea3.f31f32 import run_f31f32
|
||||
from tea3.cube_attack import run_cube_attack
|
||||
|
||||
|
||||
def run_classic_cli():
|
||||
@@ -188,6 +189,55 @@ def run_exhaustive_xor_cli():
|
||||
print("Done.")
|
||||
|
||||
|
||||
def run_cube_attack_cli():
|
||||
print("\nCube attack search on TEA3 model to search for low-degree superpolys.")
|
||||
|
||||
rounds = prompt_int("How many rounds? (1–100): ", 1, 100)
|
||||
target_reg = prompt_int("Target R register (0–7): ", 0, 7)
|
||||
target_bit = prompt_int("Target bit of that register (0–7): ", 0, 7)
|
||||
|
||||
raw = input("Bits to set to 0: ").strip()
|
||||
fixed_zero_bits = raw.split() if raw else []
|
||||
|
||||
raw = input("Bits to set to 1: ").strip()
|
||||
fixed_one_bits = raw.split() if raw else []
|
||||
|
||||
cube_size = prompt_int("Cube size (1–64): ", 1, 64)
|
||||
|
||||
print("\nSearch strategy:")
|
||||
print(" 1) Exhaustive")
|
||||
print(" 2) Random sampling")
|
||||
strategy = prompt_choice("Your choice (1 or 2): ", {1, 2})
|
||||
|
||||
if strategy == 1:
|
||||
mode = "exhaustive"
|
||||
samples = 0
|
||||
limit = prompt_int("How many results to keep? (1–100): ", 1, 100)
|
||||
else:
|
||||
mode = "random"
|
||||
samples = prompt_int("How many random cubes to test? (1–200000): ", 1, 200000)
|
||||
limit = prompt_int("How many results to keep? (1–100): ", 1, 100)
|
||||
|
||||
max_degree = prompt_int("Maximum accepted degree (0–5): ", 0, 5)
|
||||
|
||||
print("-" * 50)
|
||||
run_cube_attack(
|
||||
rounds=rounds,
|
||||
target_reg=target_reg,
|
||||
target_bit=target_bit,
|
||||
cube_size=cube_size,
|
||||
mode=mode,
|
||||
samples=samples,
|
||||
limit=limit,
|
||||
max_degree=max_degree,
|
||||
fixed_zero_bits=fixed_zero_bits,
|
||||
fixed_one_bits=fixed_one_bits,
|
||||
)
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("Done.")
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
while True:
|
||||
@@ -203,11 +253,12 @@ def main():
|
||||
print(" 5) Variable XOR")
|
||||
print(" 6) F31, F32 analysis")
|
||||
print(" 7) Exhaustive XOR search")
|
||||
print(" 8) Cube attack search")
|
||||
print(" 0) Exit")
|
||||
|
||||
mode = prompt_choice(
|
||||
"Your choice (0-7): ",
|
||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
"Your choice (0-8): ",
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8}
|
||||
)
|
||||
|
||||
if mode == 0:
|
||||
@@ -227,6 +278,8 @@ def main():
|
||||
run_f31f32()
|
||||
elif mode == 7:
|
||||
run_exhaustive_xor_cli()
|
||||
elif mode == 8:
|
||||
run_cube_attack_cli()
|
||||
|
||||
input("\nPress Enter to return to the main menu...")
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user