From f12013a3b742659687e419443fb59dc451c8e9c1 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Mon, 24 Apr 2023 21:47:10 +0200 Subject: [PATCH] inner macht bits zu lang :( --- src/authur1.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/authur1.py b/src/authur1.py index bad15eb..b17c91b 100755 --- a/src/authur1.py +++ b/src/authur1.py @@ -42,10 +42,13 @@ def inner_authur1(input: int) -> int: # should really be 32 bit block # python sucks for binary operations # assert input.bit_length() == 32, "not a 32 bit int :(" + assert input.bit_length() <= 32, "input length is <= 32: %d" % input.bit_length() output: int output = input ^ (rotr(input, SHIFT_LENGTH)) + assert output.bit_length() <= 32, "output length is <= 32: %d" % output.bit_length() + return output def authur1(input: bytearray) -> bytearray: @@ -66,7 +69,7 @@ def authur1(input: bytearray) -> bytearray: # internal_buffer int.from_bytes(internal_buffer, byteorder='big', signed=False) ) - .to_bytes(byteorder="big", signed=False) + .to_bytes(length=2**16, byteorder="big", signed=False) ) # finished loading input bytes into the hash, fill with padding and do it one last time while not len(internal_buffer) == 4: @@ -82,14 +85,14 @@ def authur1(input: bytearray) -> bytearray: # internal_buffer int.from_bytes(internal_buffer, byteorder='big', signed=False) ) - .to_bytes(byteorder="big", signed=False) + .to_bytes(length=2**16, byteorder="big", signed=False) ) return accumulator def main(): parser = argparse.ArgumentParser(prog="authur1 authentication hash", description='Implementation and attack for the custom authur1 hash') - parser.add_argument('--hash', type=str, + parser.add_argument('-i', '--hash', type=str, help='an input that should be hashed') args = parser.parse_args()