From b6186739572125788c9ae0c528458eaaa7361ce9 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Mon, 25 Mar 2019 09:42:23 +0100 Subject: [implem-python] Simplification de _tweak_tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Très similaire à ae_common._tweak_associated_data. --- src/add_python/lilliput/ae_mode_2.py | 11 +++++------ 1 file 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 -- cgit v1.2.3