From cd55bd1021376800765269642dcfd2bcc6d904bf Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 22 Apr 2023 01:05:00 +0200 Subject: [PATCH] preimage attack progress --- src/trash-hash.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/trash-hash.py b/src/trash-hash.py index 5bef3b2..151fcc6 100644 --- a/src/trash-hash.py +++ b/src/trash-hash.py @@ -66,9 +66,7 @@ def test_against_hash(input: bytearray, target_hash: bytearray) -> bool: def first_preimage(): print("Trying to find a message that produces %s" % THE_HASH.hex()) - # a xor b = c - # c xor b = a - target = bytearray(b'\ff' * 16) + target = bytearray(b'\00' * 16) input = bytearray(b'\00' * 16) between = bytearray(16) # this is an arbituary target @@ -76,8 +74,12 @@ def first_preimage(): target[0] = ord('A') for i in range(0, 16): - between[i] = target[i] ^ THE_HASH[i] + + between[i] = target[i] ^ DEFINED_INITIAL[i] + print("%d:\tbtw %s\ttar %s\thash %s" % (i, between.hex(), target.hex(), THE_HASH.hex())) input[i] = between[i] ^ THE_HASH[i] + print("%d:\tbtw %s\ttar %s\thash %s" % (i, between.hex(), target.hex(), THE_HASH.hex())) + assert THE_HASH[i] == input[i] ^ target[i], "xor circle is broken" print(test_against_hash(input, THE_HASH))