From dc5efdfce750c02d4f3c4b35d5137342002fd78d Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Thu, 14 Mar 2019 14:21:39 +0100 Subject: [implem-python] Retrait des variables globales de lilliput_tbc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On peut tout déduire de len(tweak) / len(key) ; la seule raison d'utiliser autant de constantes en C est que les tableaux se dégradent en pointeurs, donc c'est où les constantes, où une tétrachiée d'arguments. --- python/lilliput_ae_2.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'python/lilliput_ae_2.py') diff --git a/python/lilliput_ae_2.py b/python/lilliput_ae_2.py index ed57cdf..aeebe27 100644 --- a/python/lilliput_ae_2.py +++ b/python/lilliput_ae_2.py @@ -221,19 +221,11 @@ def SCT2Enc(A, M, N, key) : A = ArrayToBlockbytesMatrix(A) M = ArrayToBlockbytesMatrix(M) + K = list(key) - ltbc.KEY_BITS = KEY_BITS - ltbc.TWEAK_BITS = TWEAK_BITS - ltbc.LANES = LANES - - ltbc.TWEAKEY_BITS = TWEAKEY_BITS - ltbc.KEY_BYTES = KEY_BYTES - ltbc.TWEAK_BYTES = TWEAK_BYTES - ltbc.TWEAKEY_BYTES = TWEAKEY_BYTES - - Auth = BuildAuth(A, key) - tag = MesssageAuthTag(M, N, Auth, key) - C = MessageEncryption(M, N, tag, key) + Auth = BuildAuth(A, K) + tag = MesssageAuthTag(M, N, Auth, K) + C = MessageEncryption(M, N, tag, K) return BlockbytesMatrixToBytes(C), bytes(tag) @@ -249,19 +241,11 @@ def SCT2Dec(A, C, N, tag, key) : A = ArrayToBlockbytesMatrix(A) C = ArrayToBlockbytesMatrix(C) + K = list(key) - ltbc.KEY_BITS = KEY_BITS - ltbc.TWEAK_BITS = TWEAK_BITS - ltbc.LANES = LANES - - ltbc.TWEAKEY_BITS = TWEAKEY_BITS - ltbc.KEY_BYTES = KEY_BYTES - ltbc.TWEAK_BYTES = TWEAK_BYTES - ltbc.TWEAKEY_BYTES = TWEAKEY_BYTES - - M = MessageEncryption(C, N, tag, key) - Auth = BuildAuth(A, key) - tag2 = MesssageAuthTag(M, N, Auth, key) + M = MessageEncryption(C, N, tag, K) + Auth = BuildAuth(A, K) + tag2 = MesssageAuthTag(M, N, Auth, K) if(tag == tag2) : return BlockbytesMatrixToBytes(M) -- cgit v1.2.3