diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 14:48:47 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 14:48:47 +0100 |
| commit | ba01ba773731cb2c906beb6855dfea588dc8cf09 (patch) | |
| tree | 5bdb557fa40184ece254845e0d2b422d9397445b /python/crypto_aead.py | |
| parent | bac28f498c5fee10720c8ed71988434e05d9197f (diff) | |
| download | lilliput-ae-implem-ba01ba773731cb2c906beb6855dfea588dc8cf09.tar.xz | |
[implem-python] Création de la surcouche "crypto_aead"
Il ne reste plus qu'à générer les dossiers lilliputae*/add_python et
les fichiers parameters.py correspondants, et on peut ajouter le tout
à l'archive à soumettre au NIST.
Diffstat (limited to 'python/crypto_aead.py')
| -rw-r--r-- | python/crypto_aead.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/python/crypto_aead.py b/python/crypto_aead.py new file mode 100644 index 0000000..792369c --- /dev/null +++ b/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) |
