diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 11:01:42 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 11:01:42 +0100 |
| commit | 24c5f5d817085bd875fa6b86ef261d87b9d5fef4 (patch) | |
| tree | b70624d4c77e1635c9f8f4953a1b46fce8a1631a /test/python/crypto_aead.py | |
| parent | 7d08844da485016ce87432a36b397d9919d91f38 (diff) | |
| parent | fc64da017336c553a345fdb690a2e496a4aefff3 (diff) | |
| download | lilliput-ae-implem-24c5f5d817085bd875fa6b86ef261d87b9d5fef4.tar.xz | |
Merge branch 'refactor-python-implem'
Diffstat (limited to 'test/python/crypto_aead.py')
| -rw-r--r-- | test/python/crypto_aead.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/python/crypto_aead.py b/test/python/crypto_aead.py new file mode 100644 index 0000000..d2f1896 --- /dev/null +++ b/test/python/crypto_aead.py @@ -0,0 +1,40 @@ +# 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_BITS, + TAG_BYTES +) + +from parameters import ( + KEYBYTES, # Expose to genkat_aead. + MODE +) + + +NPUBBYTES = NONCE_BITS//8 + + +def encrypt(m, ad, npub, k): + c, tag = lilliput.encrypt(m, ad, k, npub, MODE) + return c+tag + + +def decrypt(c, ad, npub, k): + ctext = c[:-TAG_BYTES] + tag = c[-TAG_BYTES:] + return lilliput.decrypt(ctext, tag, ad, k, npub, MODE) |
