diff options
Diffstat (limited to 'python/lilliput_ae_2.py')
| -rw-r--r-- | python/lilliput_ae_2.py | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/python/lilliput_ae_2.py b/python/lilliput_ae_2.py index 720e1aa..cb1d1c4 100644 --- a/python/lilliput_ae_2.py +++ b/python/lilliput_ae_2.py @@ -13,56 +13,9 @@ from helpers import ( ) -KEY_BITS = 128 TWEAK_BITS = 128 -TWEAKEY_BITS = KEY_BITS + TWEAK_BITS -LANE_BITS = 64 -LANES = int((TWEAKEY_BITS) / LANE_BITS) +TWEAK_BYTES = TWEAK_BITS//8 -KEY_BYTES = int(KEY_BITS / 8) -TWEAK_BYTES = int(TWEAK_BITS / 8) -TWEAKEY_BYTES = int(TWEAKEY_BITS / 8) - - -def InitParameters(key_bits) : - global KEY_BITS - global KEY_BYTES - global TWEAKEY_BITS - global TWEAKEY_BYTES - global LANES - - KEY_BITS = key_bits - TWEAKEY_BITS = KEY_BITS + TWEAK_BITS - LANES = int((TWEAKEY_BITS) / LANE_BITS) - KEY_BYTES = int(KEY_BITS / 8) - TWEAKEY_BYTES = int(TWEAKEY_BITS / 8) - - -############################################################################### - -def LowPart(array, number_bits) : - shifted = 0 - for byte in range(0, len(array)) : - shifted |= (array[byte] << (8 * byte)) - - mask = 0 - for bit in range(0, number_bits) : - mask |= (0x1 << bit) - - lower_part = shifted & mask - - will_padd = 0 - if (number_bits % 8) != 0 : - will_padd = 1 - - lower_part_byte = [0 for byte in range(0, int(number_bits / 8) + will_padd)] - for byte in range(0, int(number_bits / 8) + will_padd) : - lower_part_byte[byte] = lower_part & 0xff - lower_part = lower_part >> 8 - - return lower_part_byte - -################################################################################ def TweakTag(j, padded): tweak = [0 for byte in range(0, TWEAK_BYTES)] @@ -146,8 +99,6 @@ def MessageEncryption(M, N, tag, key) : ################################################################################ def SCT2Enc(A, M, N, key) : - InitParameters(len(key)*8) - K = list(key) Auth = BuildAuth(TWEAK_BITS, A, K) @@ -158,8 +109,6 @@ def SCT2Enc(A, M, N, key) : def SCT2Dec(A, C, N, tag, key) : - InitParameters(len(key)*8) - K = list(key) M = BlockbytesMatrixToBytes( |
