summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 09:42:23 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-25 09:42:23 +0100
commitb6186739572125788c9ae0c528458eaaa7361ce9 (patch)
tree693f420ea07a43ab58c971dac0e1382a10be934e /src
parente96df775be1ab1553588bb0b81d02b9f6a3d19af (diff)
downloadlilliput-ae-implem-b6186739572125788c9ae0c528458eaaa7361ce9.tar.xz
[implem-python] Simplification de _tweak_tag
Très similaire à ae_common._tweak_associated_data.
Diffstat (limited to 'src')
-rw-r--r--src/add_python/lilliput/ae_mode_2.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/add_python/lilliput/ae_mode_2.py b/src/add_python/lilliput/ae_mode_2.py
index 1878060..a486bc9 100644
--- a/src/add_python/lilliput/ae_mode_2.py
+++ b/src/add_python/lilliput/ae_mode_2.py
@@ -36,14 +36,13 @@ TWEAK_BYTES = TWEAK_BITS//8
def _tweak_tag(j, padded):
- tweak = [0 for byte in range(0, TWEAK_BYTES)]
+ tweak = integer_to_byte_array(j, TWEAK_BYTES)
- tweak[TWEAK_BYTES - 1] |= ((j >> 120) & 0xf)
- for byte in range(TWEAK_BYTES - 2, -1, -1):
- tweak[byte] = (j >> (8 * byte)) & 0xff
+ prefix = 0b0100 if padded else 0b0000
- if padded:
- tweak[TWEAK_BYTES - 1] |= 0x40
+ # Clear upper 4 bits and set them to prefix.
+ tweak[-1] &= 0b00001111
+ tweak[-1] = prefix << 4
return tweak