diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:42:23 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-25 09:42:23 +0100 |
| commit | b6186739572125788c9ae0c528458eaaa7361ce9 (patch) | |
| tree | 693f420ea07a43ab58c971dac0e1382a10be934e | |
| parent | e96df775be1ab1553588bb0b81d02b9f6a3d19af (diff) | |
| download | lilliput-ae-implem-b6186739572125788c9ae0c528458eaaa7361ce9.tar.xz | |
[implem-python] Simplification de _tweak_tag
Très similaire à ae_common._tweak_associated_data.
| -rw-r--r-- | src/add_python/lilliput/ae_mode_2.py | 11 |
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 |
