summaryrefslogtreecommitdiff
path: root/test/python/crypto_aead.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 08:38:01 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 08:38:01 +0100
commit07af965f2687105324e0142270a9e194a5ae6af5 (patch)
tree229f5ac8a60245a5de1638a4384ba7b29c2583e4 /test/python/crypto_aead.py
parent62cff183e2e9e67549db0461589a05138ce2ed00 (diff)
downloadlilliput-ae-implem-07af965f2687105324e0142270a9e194a5ae6af5.tar.xz
[implem-python] Ajout des entêtes manquants
Diffstat (limited to 'test/python/crypto_aead.py')
-rw-r--r--test/python/crypto_aead.py33
1 files changed, 26 insertions, 7 deletions
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)