diff options
Diffstat (limited to 'src')
| -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( |
