diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 10:38:19 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 10:38:19 +0100 |
| commit | bac28f498c5fee10720c8ed71988434e05d9197f (patch) | |
| tree | 017de97abfb609163669a89c754bb813c50ec891 /python/lilliput.py | |
| parent | dd934c63386c8fa22a5b0944e0256c435d55938c (diff) | |
| download | lilliput-ae-implem-bac28f498c5fee10720c8ed71988434e05d9197f.tar.xz | |
[implem-python] Création d'un paquet "lilliput"
Diffstat (limited to 'python/lilliput.py')
| -rw-r--r-- | python/lilliput.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/python/lilliput.py b/python/lilliput.py deleted file mode 100644 index 90a0ed1..0000000 --- a/python/lilliput.py +++ /dev/null @@ -1,33 +0,0 @@ -from enum import Enum - -import lilliput_ae_1 -import lilliput_ae_2 -from constants import NONCE_BYTES - - -class LilliputAeMode(Enum): - lilliput_1 = lilliput_ae_1 - lilliput_2 = lilliput_ae_2 - - -def _checkInputs(key, mode, nonce): - valid_key_lengths = (128, 192, 256) - - if len(key)*8 not in valid_key_lengths: - raise ValueError('invalid key size: {} not in {}'.format(len(key)*8, valid_key_lengths)) - - if mode.name not in LilliputAeMode.__members__: - raise ValueError('invalid mode: use a member of the LilliputAeMode enumeration') - - if len(nonce) != NONCE_BYTES: - raise ValueError('nonce must be {}-byte long'.format(NONCE_BYTES)) - - -def encrypt(plaintext, adata, key, nonce, mode): - _checkInputs(key, mode, nonce) - return mode.value.encrypt(adata, plaintext, nonce, key) - - -def decrypt(ciphertext, tag, adata, key, nonce, mode): - _checkInputs(key, mode, nonce) - return mode.value.decrypt(adata, ciphertext, nonce, tag, key) |
