From 6bcce333963bff1bb588abbe20156abf07004928 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 13 Mar 2019 17:19:49 +0100 Subject: Traduction de genkat_aead.c en Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Et ré-adaptation de l'API de lilliput.py pour simplifier l'interfaçage ; et retrait des print() pour accélérer la génération des vecteurs (qui même comme ça prend 2 bonnes minutes). NB : pour le moment, les vecteurs ne correspondent pas… --- python/lilliput.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'python/lilliput.py') diff --git a/python/lilliput.py b/python/lilliput.py index 6a2aae4..c2e1a69 100644 --- a/python/lilliput.py +++ b/python/lilliput.py @@ -57,8 +57,8 @@ def mainEnc(plaintext, adata, mode=1, length=128): (key_bits, tweak_bits, rounds) = GetParameters(mode, length) - A = adata.encode() - M = plaintext.encode() + A = adata + M = plaintext N = [0 for byte in range(0, N_BYTES)] key = [byte for byte in range(0, int(key_bits/8))] @@ -72,12 +72,6 @@ def mainEnc(plaintext, adata, mode=1, length=128): (C, tag) = lilliput_ae_1.OCB3Enc(A, M, N, A_BITS, M_BITS, key, key_bits, tweak_bits, rounds) if(mode == 2) : (C, tag) = lilliput_ae_2.SCT2Enc(A, M, N, A_BITS, M_BITS, key, key_bits, tweak_bits, rounds) - for block in range(0,len(C)) : - for byte in C[block] : - print("%02x "%(byte), end="") - for byte in tag : - print("%02x "%(byte), end="") - print() return BlockbytesMatrixToBytes(C), bytes(tag) @@ -86,7 +80,7 @@ def mainDec(ciphertext, tag, adata, mode=1, length=128): (key_bits, tweak_bits, rounds) = GetParameters(mode, length) - A = adata.encode() + A = adata C = ciphertext N = [0 for byte in range(0, N_BYTES)] key = [byte for byte in range(0, int(key_bits/8))] @@ -102,9 +96,5 @@ def mainDec(ciphertext, tag, adata, mode=1, length=128): M = lilliput_ae_1.OCB3Dec(A, C, N, tag, A_BITS, M_BITS, key, key_bits, tweak_bits, rounds) if(mode == 2) : M = lilliput_ae_2.SCT2Dec(A, C, N, tag, A_BITS, M_BITS, key, key_bits, tweak_bits, rounds) - for block in range(0,len(M)) : - for byte in M[block] : - print("%02x "%(byte), end="") - print() - return BlockbytesMatrixToBytes(M).decode() + return BlockbytesMatrixToBytes(M) -- cgit v1.2.3