From f161a41e1bb1b379335bb658877a8859a64c9d10 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Thu, 14 Mar 2019 12:47:41 +0100 Subject: [implem-python] Suppression de paramètres redondants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tweak_bits est constant pour un mode donné ; rounds se déduit de la taille de clé. --- python/lilliput_ae_1.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'python/lilliput_ae_1.py') 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 -- cgit v1.2.3