diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-13 17:19:49 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-13 17:46:05 +0100 |
| commit | 6bcce333963bff1bb588abbe20156abf07004928 (patch) | |
| tree | 29b511e8d6bcc9b665481e21a7aabdd56fae117d /python/lilliput.py | |
| parent | 1870b1eadf3963f9ec5d52bed21f04e523933612 (diff) | |
| download | lilliput-ae-implem-6bcce333963bff1bb588abbe20156abf07004928.tar.xz | |
Traduction de genkat_aead.c en Python
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…
Diffstat (limited to 'python/lilliput.py')
| -rw-r--r-- | python/lilliput.py | 18 |
1 files changed, 4 insertions, 14 deletions
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) |
