From 772b8facedf0b293b492d8c92f2c7a90df77ea9a Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 25 Apr 2023 12:21:28 +0200 Subject: [PATCH] asserts --- src/authur1.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/authur1.py b/src/authur1.py index 85592eb..701f05c 100755 --- a/src/authur1.py +++ b/src/authur1.py @@ -26,14 +26,22 @@ VALUE_SIZE = 4 The rotations are tested agains a c implementation and are still garbage. FIXME """ def rotl(value: int, count: int) -> int: + # FIXME mask: int = CHAR_BIT * VALUE_SIZE - 1; + print("mask length: %d" % mask.bit_length()) count = count & mask - return (value << count) | (value >> (-count & mask)); + result = (value << count) | (value >> (-count & mask)); + assert result.bit_length() <= 32, "python made the numbers too big: %d bit" % result.bit_length() + return result def rotr(value: int, count: int) -> int: + # FIXME mask: int = CHAR_BIT * VALUE_SIZE - 1; + print("mask length: %d" % mask.bit_length()) count = count & mask - return (value >> count) | (value << (-count & mask)); + result = (value >> count) | (value << (-count & mask)); + assert result.bit_length() <= 32, "python made the numbers too big: %d bit" % result.bit_length() + return result """ Now for the actual implementation of authur1