summaryrefslogtreecommitdiff
path: root/test/python/crypto_aead.py
blob: 792369c59d1e4b580254fafac165ca12ce16d051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)