summaryrefslogtreecommitdiff
path: root/python/lilliput_ae_1.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-14 13:06:45 +0100
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-03-21 14:49:15 +0100
commit504c32f4bd4d6e90864fec066de950a1b8925709 (patch)
tree30332f3725f336c9e9c2f3c6a75c1d457a2f664e /python/lilliput_ae_1.py
parentf161a41e1bb1b379335bb658877a8859a64c9d10 (diff)
downloadlilliput-ae-implem-504c32f4bd4d6e90864fec066de950a1b8925709.tar.xz
[implem-python] Ajout de NONCE_BYTES dans constants.py
Diffstat (limited to 'python/lilliput_ae_1.py')
-rw-r--r--python/lilliput_ae_1.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/python/lilliput_ae_1.py b/python/lilliput_ae_1.py
index 688148f..92cfa6e 100644
--- a/python/lilliput_ae_1.py
+++ b/python/lilliput_ae_1.py
@@ -3,7 +3,7 @@
"""
import lilliput_tbc as ltbc
-from constants import rounds
+from constants import NONCE_BYTES, rounds
from helpers import ArrayToBlockbytesMatrix, BlockbytesMatrixToBytes
@@ -22,8 +22,7 @@ TWEAKEY_BYTES = int(TWEAKEY_BITS / 8)
A_BITS = BLOCK_BITS
M_BITS = BLOCK_BITS
-N_BITS = 120
-N_BYTES = int(N_BITS / 8)
+
def InitParameters(key_bits) :
global KEY_BITS
@@ -131,12 +130,12 @@ def BuildAuth(A, key) :
def TweakMessage(N, j, null = 0, padded = 0, final_padded = 0) :
tweak = [0 for byte in range(0, TWEAK_BYTES)]
- for byte in range(N_BYTES - 1, -1, -1) :
- tweak[byte + (TWEAK_BYTES - N_BYTES)] |= (N[byte] & 0xf0) >> 4
- tweak[byte + (TWEAK_BYTES - N_BYTES - 1)] |= (N[byte] & 0x0f) << 4
+ for byte in range(NONCE_BYTES-1, -1, -1) :
+ tweak[byte + (TWEAK_BYTES-NONCE_BYTES)] |= (N[byte] & 0xf0) >> 4
+ tweak[byte + (TWEAK_BYTES-NONCE_BYTES-1)] |= (N[byte] & 0x0f) << 4
- tweak[TWEAK_BYTES - N_BYTES - 1] |= ((j >> 64) & 0xf)
- for byte in range(TWEAK_BYTES - N_BYTES - 2, -1, -1) :
+ tweak[TWEAK_BYTES-NONCE_BYTES-1] |= ((j >> 64) & 0xf)
+ for byte in range(TWEAK_BYTES-NONCE_BYTES-2, -1, -1) :
tweak[byte] = (j >> (8 * byte)) & 0xff
if null == 1 :