summaryrefslogtreecommitdiff
path: root/python/lilliput.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/lilliput.py')
-rw-r--r--python/lilliput.py18
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)