inner macht bits zu lang :(

This commit is contained in:
Christoph J. Scherr 2023-04-24 21:47:10 +02:00
parent d12156add8
commit f12013a3b7
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 6 additions and 3 deletions

View File

@ -42,10 +42,13 @@ def inner_authur1(input: int) -> int:
# should really be 32 bit block # should really be 32 bit block
# python sucks for binary operations # python sucks for binary operations
# assert input.bit_length() == 32, "not a 32 bit int :(" # 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: int
output = input ^ (rotr(input, SHIFT_LENGTH)) output = input ^ (rotr(input, SHIFT_LENGTH))
assert output.bit_length() <= 32, "output length is <= 32: %d" % output.bit_length()
return output return output
def authur1(input: bytearray) -> bytearray: def authur1(input: bytearray) -> bytearray:
@ -66,7 +69,7 @@ def authur1(input: bytearray) -> bytearray:
# internal_buffer # internal_buffer
int.from_bytes(internal_buffer, byteorder='big', signed=False) 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 # finished loading input bytes into the hash, fill with padding and do it one last time
while not len(internal_buffer) == 4: while not len(internal_buffer) == 4:
@ -82,14 +85,14 @@ def authur1(input: bytearray) -> bytearray:
# internal_buffer # internal_buffer
int.from_bytes(internal_buffer, byteorder='big', signed=False) 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 return accumulator
def main(): def main():
parser = argparse.ArgumentParser(prog="authur1 authentication hash", description='Implementation and attack for the custom authur1 hash') 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') help='an input that should be hashed')
args = parser.parse_args() args = parser.parse_args()