summaryrefslogtreecommitdiff
path: root/test/python/crypto_aead.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-22 16:41:34 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-22 16:52:21 +0100
commite83abe9fdbab07e6df80443240d4d649303a3dd4 (patch)
tree76febb030151dff29ef62a4b27145ed73bd57b42 /test/python/crypto_aead.py
parentba01ba773731cb2c906beb6855dfea588dc8cf09 (diff)
downloadlilliput-ae-implem-e83abe9fdbab07e6df80443240d4d649303a3dd4.tar.xz
[implem-python] Déplacement dans le dossier SOUMISSION_NIST
Et ajout d'un métascript pour vérifier la conformité. Il ne reste plus qu'à… (bis)
Diffstat (limited to 'test/python/crypto_aead.py')
-rw-r--r--test/python/crypto_aead.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/python/crypto_aead.py b/test/python/crypto_aead.py
new file mode 100644
index 0000000..792369c
--- /dev/null
+++ b/test/python/crypto_aead.py
@@ -0,0 +1,18 @@
+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
+
+
+def encrypt(m, ad, npub, k):
+ c, tag = lilliput.encrypt(m, ad, k, npub, MODE)
+ return c+tag
+
+
+def decrypt(c, ad, npub, k):
+ clen = len(c)-TAG_BYTES
+ ctext = c[:clen]
+ tag = c[clen:]
+ return lilliput.decrypt(ctext, tag, ad, k, npub, MODE)