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.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'python/lilliput.py') diff --git a/python/lilliput.py b/python/lilliput.py index 21feb60..f6679a8 100644 --- a/python/lilliput.py +++ b/python/lilliput.py @@ -1,24 +1,9 @@ import lilliput_ae_1 import lilliput_ae_2 -N_BYTES = 15 - -def _getParameters(mode=1, key_length=128) : - rounds = { - 128: 32, - 192: 36, - 256: 42 - } - - tweak_lengths = { - 1: 192, - 2: 128 - } - - return tweak_lengths[mode], rounds[key_length] +N_BYTES = 15 -############################################ def _checkInputs(key, nonce): valid_key_lengths = (128, 192, 256) @@ -33,29 +18,25 @@ def _checkInputs(key, nonce): def mainEnc(plaintext, adata, key, nonce, mode): _checkInputs(key, nonce) - tweak_bits, rounds = _getParameters(mode, len(key)*8) - A = adata M = plaintext N = nonce if(mode == 1) : - return lilliput_ae_1.OCB3Enc(A, M, N, key, tweak_bits, rounds) + return lilliput_ae_1.OCB3Enc(A, M, N, key) if(mode == 2) : - return lilliput_ae_2.SCT2Enc(A, M, N, key, tweak_bits, rounds) + return lilliput_ae_2.SCT2Enc(A, M, N, key) def mainDec(ciphertext, tag, adata, key, nonce, mode): _checkInputs(key, nonce) - tweak_bits, rounds = _getParameters(mode, len(key)*8) - A = adata C = ciphertext N = nonce tag = list(tag) if(mode == 1) : - return lilliput_ae_1.OCB3Dec(A, C, N, tag, key, tweak_bits, rounds) + return lilliput_ae_1.OCB3Dec(A, C, N, tag, key) if(mode == 2) : - return lilliput_ae_2.SCT2Dec(A, C, N, tag, key, tweak_bits, rounds) + return lilliput_ae_2.SCT2Dec(A, C, N, tag, key) -- cgit v1.2.3