summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 09:10:33 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 09:10:33 +0100
commit0d0ecee46d6e5d47ff390cbaa254bf0d560d504f (patch)
treeb222a6c70fb0f8e4db974d28c38c2dd01c5a5d05 /src
parent07af965f2687105324e0142270a9e194a5ae6af5 (diff)
downloadlilliput-ae-implem-0d0ecee46d6e5d47ff390cbaa254bf0d560d504f.tar.xz
[implem-python] Ajustements de forme
Diffstat (limited to 'src')
-rw-r--r--src/add_python/lilliput/ae_common.py6
-rw-r--r--src/add_python/lilliput/ae_mode_1.py4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/add_python/lilliput/ae_common.py b/src/add_python/lilliput/ae_common.py
index 83db056..b94be1b 100644
--- a/src/add_python/lilliput/ae_common.py
+++ b/src/add_python/lilliput/ae_common.py
@@ -51,8 +51,12 @@ def pad10(X):
return zeroes + [0b10000000] + X
+def integer_to_byte_array(i, n):
+ return list(i.to_bytes(n, 'little'))
+
+
def _tweak_associated_data(t, i, padded):
- tweak = list(i.to_bytes(t//8, 'little'))
+ tweak = integer_to_byte_array(i, t//8)
prefix = 0b0110 if padded else 0b0010
diff --git a/src/add_python/lilliput/ae_mode_1.py b/src/add_python/lilliput/ae_mode_1.py
index a5ba7c8..b07adf6 100644
--- a/src/add_python/lilliput/ae_mode_1.py
+++ b/src/add_python/lilliput/ae_mode_1.py
@@ -87,7 +87,7 @@ def _treat_message_enc(M, N, key):
tweak_final = _tweak_message(N, l+1, _MessageTweak.FINAL)
Final = tbc.encrypt(tweak_final, key, checksum)
- return (Final, C)
+ return Final, C
def _treat_message_dec(C, N, key):
@@ -119,7 +119,7 @@ def _treat_message_dec(C, N, key):
tweak_final = _tweak_message(N, l+1, _MessageTweak.FINAL)
Final = tbc.encrypt(tweak_final, key, checksum)
- return (Final, M)
+ return Final, M
def encrypt(A, M, N, key):