summaryrefslogtreecommitdiff
path: root/src/add_python/lilliput/ae_mode_1.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/add_python/lilliput/ae_mode_1.py')
-rw-r--r--src/add_python/lilliput/ae_mode_1.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/add_python/lilliput/ae_mode_1.py b/src/add_python/lilliput/ae_mode_1.py
index cc550e8..efa0b6f 100644
--- a/src/add_python/lilliput/ae_mode_1.py
+++ b/src/add_python/lilliput/ae_mode_1.py
@@ -21,13 +21,13 @@ using Lilliput-AE's nonce-respecting mode based on ΘCB3.
from enum import Enum
from .constants import BLOCK_BYTES, NONCE_BYTES
-from .helpers import (
+from .ae_common import (
bytes_to_block_matrix,
block_matrix_to_bytes,
build_auth,
pad10,
TagValidationError,
- xor_state
+ xor
)
from . import tbc
@@ -92,7 +92,7 @@ def _treat_message_enc(M, N, key):
C = []
for j in range(0, l):
- checksum = xor_state(checksum, M[j])
+ checksum = xor(checksum, M[j])
tweak = _tweak_message(N, j, _MessageTweak.BLOCK)
C.append(tbc.encrypt(tweak, key, M[j]))
@@ -102,12 +102,12 @@ def _treat_message_enc(M, N, key):
else:
m_padded = pad10(M[l])
- checksum = xor_state(checksum, m_padded)
+ checksum = xor(checksum, m_padded)
tweak = _tweak_message(N, l, _MessageTweak.PAD)
pad = tbc.encrypt(tweak, key, [0 for byte in range(0, BLOCK_BYTES)])
lower_part = _low_part(pad, padding_bytes*8)
- C.append(xor_state(M[l], lower_part))
+ C.append(xor(M[l], lower_part))
tweak_final = _tweak_message(N, l+1, _MessageTweak.FINAL)
Final = tbc.encrypt(tweak_final, key, checksum)
@@ -126,7 +126,7 @@ def _treat_message_dec(C, N, key):
for j in range(0, l):
tweak = _tweak_message(N, j, _MessageTweak.BLOCK)
M.append(tbc.decrypt(tweak, key, C[j]))
- checksum = xor_state(checksum, M[j])
+ checksum = xor(checksum, M[j])
if padding_bytes == 0:
tweak = _tweak_message(N, l, _MessageTweak.NO_PADDING)
@@ -136,10 +136,10 @@ def _treat_message_dec(C, N, key):
tweak = _tweak_message(N, l, _MessageTweak.PAD)
pad = tbc.encrypt(tweak, key, [0 for byte in range(0, BLOCK_BYTES)])
lower_part = _low_part(pad, padding_bytes*8)
- M.append(xor_state(C[l], lower_part))
+ M.append(xor(C[l], lower_part))
m_padded = pad10(M[l])
- checksum = xor_state(checksum, m_padded)
+ checksum = xor(checksum, m_padded)
tweak_final = _tweak_message(N, l+1, _MessageTweak.FINAL)
Final = tbc.encrypt(tweak_final, key, checksum)
@@ -151,7 +151,7 @@ def encrypt(A, M, N, key):
Auth = build_auth(TWEAK_BITS, A, K)
(Final, C) = _treat_message_enc(M, N, K)
- tag = xor_state(Auth, Final)
+ tag = xor(Auth, Final)
return block_matrix_to_bytes(C), bytes(tag)
@@ -162,7 +162,7 @@ def decrypt(A, C, N, tag, key):
Auth = build_auth(TWEAK_BITS, A, K)
(Final, M) = _treat_message_dec(C, N, K)
- tag2 = xor_state(Auth, Final)
+ tag2 = xor(Auth, Final)
if tag != tag2:
raise TagValidationError(tag, tag2)