aboutsummaryrefslogtreecommitdiff
path: root/frozen_deps/Cryptodome/Cipher/_mode_eax.py
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2024-08-23 03:14:03 +0000
committerDeterminant <[email protected]>2024-08-22 20:34:57 -0700
commit8d1c76ec7caf247d5675e14260d20fc508977ffb (patch)
tree8fa7c8ce3b7e3f4ece150a6da5922b5eb2dc7772 /frozen_deps/Cryptodome/Cipher/_mode_eax.py
parent258780284151d49cba1d9c0d2ce33f9a19bb058b (diff)
release v0.1.8
Diffstat (limited to 'frozen_deps/Cryptodome/Cipher/_mode_eax.py')
-rw-r--r--frozen_deps/Cryptodome/Cipher/_mode_eax.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/frozen_deps/Cryptodome/Cipher/_mode_eax.py b/frozen_deps/Cryptodome/Cipher/_mode_eax.py
index 8efb77a..44ef21f 100644
--- a/frozen_deps/Cryptodome/Cipher/_mode_eax.py
+++ b/frozen_deps/Cryptodome/Cipher/_mode_eax.py
@@ -90,12 +90,12 @@ class EaxMode(object):
self._mac_tag = None # Cache for MAC tag
# Allowed transitions after initialization
- self._next = [self.update, self.encrypt, self.decrypt,
- self.digest, self.verify]
+ self._next = ["update", "encrypt", "decrypt",
+ "digest", "verify"]
# MAC tag length
- if not (4 <= self._mac_len <= self.block_size):
- raise ValueError("Parameter 'mac_len' must not be larger than %d"
+ if not (2 <= self._mac_len <= self.block_size):
+ raise ValueError("'mac_len' must be at least 2 and not larger than %d"
% self.block_size)
# Nonce cannot be empty and must be a byte string
@@ -145,12 +145,12 @@ class EaxMode(object):
A piece of associated data. There are no restrictions on its size.
"""
- if self.update not in self._next:
+ if "update" not in self._next:
raise TypeError("update() can only be called"
" immediately after initialization")
- self._next = [self.update, self.encrypt, self.decrypt,
- self.digest, self.verify]
+ self._next = ["update", "encrypt", "decrypt",
+ "digest", "verify"]
self._signer.update(assoc_data)
return self
@@ -188,10 +188,10 @@ class EaxMode(object):
Otherwise, ``None``.
"""
- if self.encrypt not in self._next:
+ if "encrypt" not in self._next:
raise TypeError("encrypt() can only be called after"
" initialization or an update()")
- self._next = [self.encrypt, self.digest]
+ self._next = ["encrypt", "digest"]
ct = self._cipher.encrypt(plaintext, output=output)
if output is None:
self._omac[2].update(ct)
@@ -232,10 +232,10 @@ class EaxMode(object):
Otherwise, ``None``.
"""
- if self.decrypt not in self._next:
+ if "decrypt" not in self._next:
raise TypeError("decrypt() can only be called"
" after initialization or an update()")
- self._next = [self.decrypt, self.verify]
+ self._next = ["decrypt", "verify"]
self._omac[2].update(ciphertext)
return self._cipher.decrypt(ciphertext, output=output)
@@ -250,10 +250,10 @@ class EaxMode(object):
:Return: the MAC, as a byte string.
"""
- if self.digest not in self._next:
+ if "digest" not in self._next:
raise TypeError("digest() cannot be called when decrypting"
" or validating a message")
- self._next = [self.digest]
+ self._next = ["digest"]
if not self._mac_tag:
tag = b'\x00' * self.block_size
@@ -289,10 +289,10 @@ class EaxMode(object):
or the key is incorrect.
"""
- if self.verify not in self._next:
+ if "verify" not in self._next:
raise TypeError("verify() cannot be called"
" when encrypting a message")
- self._next = [self.verify]
+ self._next = ["verify"]
if not self._mac_tag:
tag = b'\x00' * self.block_size