summaryrefslogtreecommitdiff
path: root/python/lilliput_ae_1.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/lilliput_ae_1.py')
-rw-r--r--python/lilliput_ae_1.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/python/lilliput_ae_1.py b/python/lilliput_ae_1.py
index 3629fec..688148f 100644
--- a/python/lilliput_ae_1.py
+++ b/python/lilliput_ae_1.py
@@ -3,6 +3,7 @@
"""
import lilliput_tbc as ltbc
+from constants import rounds
from helpers import ArrayToBlockbytesMatrix, BlockbytesMatrixToBytes
@@ -24,23 +25,19 @@ M_BITS = BLOCK_BITS
N_BITS = 120
N_BYTES = int(N_BITS / 8)
-def InitParameters(key_bits = 128, tweak_bits = 192, rounds = 32) :
+def InitParameters(key_bits) :
global KEY_BITS
global KEY_BYTES
- global TWEAK_BITS
- global TWEAK_BYTES
global TWEAKEY_BITS
global TWEAKEY_BYTES
global LANES
global ROUNDS
KEY_BITS = key_bits
- TWEAK_BITS = tweak_bits
TWEAKEY_BITS = KEY_BITS + TWEAK_BITS
LANES = int((TWEAKEY_BITS) / LANE_BITS)
- ROUNDS = rounds
+ ROUNDS = rounds(key_bits)
KEY_BYTES = int(KEY_BITS / 8)
- TWEAK_BYTES = int(TWEAK_BITS / 8)
TWEAKEY_BYTES = int(TWEAKEY_BITS / 8)
@@ -221,8 +218,8 @@ def TreatMessageDec(C, N, key) :
################################################################################
-def OCB3Enc(A, M, N, key, tweak_bits, rounds) :
- InitParameters(len(key)*8, tweak_bits, rounds)
+def OCB3Enc(A, M, N, key) :
+ InitParameters(len(key)*8)
global A_BITS
global M_BITS
@@ -255,8 +252,8 @@ def OCB3Enc(A, M, N, key, tweak_bits, rounds) :
return BlockbytesMatrixToBytes(C), bytes(tag)
-def OCB3Dec(A, C, N, tag, key, tweak_bits, rounds) :
- InitParameters(len(key)*8, tweak_bits, rounds)
+def OCB3Dec(A, C, N, tag, key) :
+ InitParameters(len(key)*8)
global A_BITS
global M_BITS