summaryrefslogtreecommitdiff
path: root/python/lilliput.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-22 10:38:19 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-22 10:38:19 +0100
commitbac28f498c5fee10720c8ed71988434e05d9197f (patch)
tree017de97abfb609163669a89c754bb813c50ec891 /python/lilliput.py
parentdd934c63386c8fa22a5b0944e0256c435d55938c (diff)
downloadlilliput-ae-implem-bac28f498c5fee10720c8ed71988434e05d9197f.tar.xz
[implem-python] Création d'un paquet "lilliput"
Diffstat (limited to 'python/lilliput.py')
-rw-r--r--python/lilliput.py33
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)