diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:30:23 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:30:23 +0100 |
| commit | 2cdc379dc0d4a260c5ca20619c892bdfbb6c0248 (patch) | |
| tree | fd50082a24cc9728eb177c472dd13f4cd73ea408 /src/add_python | |
| parent | 0d0ecee46d6e5d47ff390cbaa254bf0d560d504f (diff) | |
| download | lilliput-ae-implem-2cdc379dc0d4a260c5ca20619c892bdfbb6c0248.tar.xz | |
[implem-python] Remplacement de _tweak_tag_end par une concaténation
Diffstat (limited to 'src/add_python')
| -rw-r--r-- | src/add_python/lilliput/ae_mode_2.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/add_python/lilliput/ae_mode_2.py b/src/add_python/lilliput/ae_mode_2.py index 91c53f3..bf09731 100644 --- a/src/add_python/lilliput/ae_mode_2.py +++ b/src/add_python/lilliput/ae_mode_2.py @@ -47,16 +47,6 @@ def _tweak_tag(j, padded): return tweak -def _tweak_tag_end(N): - tweak = [0 for byte in range(0, TWEAK_BYTES)] - - for byte in range(0, TWEAK_BYTES - 1): - tweak[byte] = N[byte] - tweak[TWEAK_BYTES - 1] = 0x10 - - return tweak - - def _add_tag_j(tag, j): array_j = [0 for byte in range(0, TWEAK_BYTES)] for byte in range(0, TWEAK_BYTES): @@ -87,7 +77,7 @@ def _message_auth_tag(M, N, Auth, key): encryption = tbc.encrypt(tweak, key, m_padded) tag = xor(tag, encryption) - tweak = _tweak_tag_end(N) + tweak = N + [0b00010000] encryption = tbc.encrypt(tweak, key, tag) tag = encryption @@ -103,13 +93,13 @@ def _message_encryption(M, N, tag, key): for j in range(0, l): tweak = _add_tag_j(tag, j) - padded_nonce = list(N) + [0x00] + padded_nonce = N + [0b00000000] encryption = tbc.encrypt(tweak, key, padded_nonce) C.append(xor(M[j], encryption)) if need_padding: tweak = _add_tag_j(tag, l) - padded_nonce = list(N) + [0x00] + padded_nonce = N + [0b00000000] encryption = tbc.encrypt(tweak, key, padded_nonce) C.append(xor(M[l], encryption)) @@ -119,6 +109,7 @@ def _message_encryption(M, N, tag, key): ################################################################################ def encrypt(A, M, N, key): K = list(key) + N = list(N) Auth = build_auth(TWEAK_BITS, A, K) tag = _message_auth_tag(M, N, Auth, K) @@ -129,6 +120,7 @@ def encrypt(A, M, N, key): def decrypt(A, C, N, tag, key): K = list(key) + N = list(N) tag = list(tag) M = block_matrix_to_bytes( |
