lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

commit b6186739572125788c9ae0c528458eaaa7361ce9
parent e96df775be1ab1553588bb0b81d02b9f6a3d19af
Author: Kévin Le Gouguec <kevin.legouguec@airbus.com>
Date:   Mon, 25 Mar 2019 09:42:23 +0100

[implem-python] Simplification de _tweak_tag

Très similaire à ae_common._tweak_associated_data.

Diffstat:
Msrc/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 @@ -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