diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:35:19 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:35:19 +0100 |
| commit | e96df775be1ab1553588bb0b81d02b9f6a3d19af (patch) | |
| tree | e66ba552c84d437d8467cee23521daf51d78d523 /src/add_python | |
| parent | 2cdc379dc0d4a260c5ca20619c892bdfbb6c0248 (diff) | |
| download | lilliput-ae-implem-e96df775be1ab1553588bb0b81d02b9f6a3d19af.tar.xz | |
[implem-python] Simplification de _add_tag_j
Diffstat (limited to 'src/add_python')
| -rw-r--r-- | src/add_python/lilliput/ae_mode_2.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/add_python/lilliput/ae_mode_2.py b/src/add_python/lilliput/ae_mode_2.py index bf09731..1878060 100644 --- a/src/add_python/lilliput/ae_mode_2.py +++ b/src/add_python/lilliput/ae_mode_2.py @@ -22,6 +22,7 @@ from .constants import BLOCK_BYTES from .ae_common import ( bytes_to_block_matrix, block_matrix_to_bytes, + integer_to_byte_array, build_auth, pad10, TagValidationError, @@ -48,15 +49,11 @@ def _tweak_tag(j, padded): def _add_tag_j(tag, j): - array_j = [0 for byte in range(0, TWEAK_BYTES)] - for byte in range(0, TWEAK_BYTES): - array_j[byte] = (j >> (byte * 8)) + array_j = integer_to_byte_array(j, TWEAK_BYTES) + tweak = xor(tag, array_j) + tweak[-1] |= 0b10000000 - xorr = xor(tag, array_j) - - xorr[TWEAK_BYTES - 1] |= 0x80 - - return xorr + return tweak def _message_auth_tag(M, N, Auth, key): |
