summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/add_python/lilliput/ae_common.py17
-rw-r--r--src/add_python/lilliput/helpers.py17
-rw-r--r--src/add_python/lilliput/multiplications.py19
-rw-r--r--test/python/crypto_aead.py33
-rwxr-xr-xtest/python/genkat_aead.py17
5 files changed, 95 insertions, 8 deletions
diff --git a/src/add_python/lilliput/ae_common.py b/src/add_python/lilliput/ae_common.py
index 033b5b0..83db056 100644
--- a/src/add_python/lilliput/ae_common.py
+++ b/src/add_python/lilliput/ae_common.py
@@ -1,3 +1,20 @@
+# Implementation of the Lilliput-AE tweakable block cipher.
+#
+# Authors, hereby denoted as "the implementer":
+# Kévin Le Gouguec,
+# Léo Reynaud
+# 2019.
+#
+# For more information, feedback or questions, refer to our website:
+# https://paclido.fr/lilliput-ae
+#
+# To the extent possible under law, the implementer has waived all copyright
+# and related or neighboring rights to the source code in this file.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+"""Helper functions used in both Lilliput-I and Lilliput-II."""
+
+
from .constants import BLOCK_BITS, BLOCK_BYTES
from .helpers import xor
from . import tbc
diff --git a/src/add_python/lilliput/helpers.py b/src/add_python/lilliput/helpers.py
index 048aac7..41f75a6 100644
--- a/src/add_python/lilliput/helpers.py
+++ b/src/add_python/lilliput/helpers.py
@@ -1,2 +1,19 @@
+# Implementation of the Lilliput-AE tweakable block cipher.
+#
+# Authors, hereby denoted as "the implementer":
+# Kévin Le Gouguec,
+# Léo Reynaud
+# 2019.
+#
+# For more information, feedback or questions, refer to our website:
+# https://paclido.fr/lilliput-ae
+#
+# To the extent possible under law, the implementer has waived all copyright
+# and related or neighboring rights to the source code in this file.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+"""Helper functions used in Lilliput-AE."""
+
+
def xor(array1, array2):
return [a1^a2 for (a1, a2) in zip(array1, array2)]
diff --git a/src/add_python/lilliput/multiplications.py b/src/add_python/lilliput/multiplications.py
index dfdc3cb..2dea948 100644
--- a/src/add_python/lilliput/multiplications.py
+++ b/src/add_python/lilliput/multiplications.py
@@ -1,3 +1,22 @@
+# Implementation of the Lilliput-AE tweakable block cipher.
+#
+# Authors, hereby denoted as "the implementer":
+# Kévin Le Gouguec,
+# Léo Reynaud
+# 2019.
+#
+# For more information, feedback or questions, refer to our website:
+# https://paclido.fr/lilliput-ae
+#
+# To the extent possible under law, the implementer has waived all copyright
+# and related or neighboring rights to the source code in this file.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+"""Multiplications for Lilliput-TBC's tweakey schedule.
+
+This module provides a list of functions implementing lane multiplications,
+from ALPHAS[0] = α₀ = I to ALPHAS[6] = α₆ = M_R³.
+"""
def _multiply_M(lane):
diff --git a/test/python/crypto_aead.py b/test/python/crypto_aead.py
index 792369c..6a9b328 100644
--- a/test/python/crypto_aead.py
+++ b/test/python/crypto_aead.py
@@ -1,9 +1,29 @@
+# Implementation of the Lilliput-AE tweakable block cipher.
+#
+# Authors, hereby denoted as "the implementer":
+# Kévin Le Gouguec,
+# 2019.
+#
+# For more information, feedback or questions, refer to our website:
+# https://paclido.fr/lilliput-ae
+#
+# To the extent possible under law, the implementer has waived all copyright
+# and related or neighboring rights to the source code in this file.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+"""Python port of the crypto_aead API for Lilliput-AE."""
+
import lilliput
-from lilliput.constants import NONCE_BYTES as NPUBBYTES, TAG_BYTES
-# Import KEYBYTES to expose it to genkat_aead.
-# Import MODE to provide it to lilliput.
-from parameters import KEYBYTES, MODE
+from lilliput.constants import (
+ NONCE_BYTES as NPUBBYTES, # Expose to genkat_aead.
+ TAG_BYTES
+)
+
+from parameters import (
+ KEYBYTES, # Expose to genkat_aead.
+ MODE
+)
def encrypt(m, ad, npub, k):
@@ -12,7 +32,6 @@ def encrypt(m, ad, npub, k):
def decrypt(c, ad, npub, k):
- clen = len(c)-TAG_BYTES
- ctext = c[:clen]
- tag = c[clen:]
+ ctext = c[:-TAG_BYTES]
+ tag = c[-TAG_BYTES:]
return lilliput.decrypt(ctext, tag, ad, k, npub, MODE)
diff --git a/test/python/genkat_aead.py b/test/python/genkat_aead.py
index 5e953c4..db3a89c 100755
--- a/test/python/genkat_aead.py
+++ b/test/python/genkat_aead.py
@@ -1,11 +1,26 @@
#!/usr/bin/env python3
+# Python port of genkat_aead.c.
+#
+# Authors, hereby denoted as "the implementer":
+# Kévin Le Gouguec,
+# 2019.
+#
+# For more information, feedback or questions, refer to our website:
+# https://paclido.fr/lilliput-ae
+#
+# To the extent possible under law, the implementer has waived all copyright
+# and related or neighboring rights to the source code in this file.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+"""Python port of the genkat_aead.c program."""
+
import crypto_aead
class DecryptionError(Exception):
def __init__(self):
- super().__init__('crypto_aead_decrypt did not recover the plaintext')
+ super().__init__('crypto_aead.decrypt did not recover the plaintext')
MAX_MESSAGE_LENGTH = 32