From 8d1c76ec7caf247d5675e14260d20fc508977ffb Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 23 Aug 2024 03:14:03 +0000 Subject: release v0.1.8 --- frozen_deps/Cryptodome/Cipher/_mode_gcm.py | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'frozen_deps/Cryptodome/Cipher/_mode_gcm.py') diff --git a/frozen_deps/Cryptodome/Cipher/_mode_gcm.py b/frozen_deps/Cryptodome/Cipher/_mode_gcm.py index c90061b..9914400 100644 --- a/frozen_deps/Cryptodome/Cipher/_mode_gcm.py +++ b/frozen_deps/Cryptodome/Cipher/_mode_gcm.py @@ -186,7 +186,7 @@ class GcmMode(object): if len(nonce) == 0: raise ValueError("Nonce cannot be empty") - + if not is_buffer(nonce): raise TypeError("Nonce must be bytes, bytearray or memoryview") @@ -207,8 +207,8 @@ class GcmMode(object): raise ValueError("Parameter 'mac_len' must be in the range 4..16") # Allowed transitions after initialization - self._next = [self.update, self.encrypt, self.decrypt, - self.digest, self.verify] + self._next = ["update", "encrypt", "decrypt", + "digest", "verify"] self._no_more_assoc_data = False @@ -229,10 +229,10 @@ class GcmMode(object): if len(self.nonce) == 12: j0 = self.nonce + b"\x00\x00\x00\x01" else: - fill = (16 - (len(nonce) % 16)) % 16 + 8 + fill = (16 - (len(self.nonce) % 16)) % 16 + 8 ghash_in = (self.nonce + b'\x00' * fill + - long_to_bytes(8 * len(nonce), 8)) + long_to_bytes(8 * len(self.nonce), 8)) j0 = _GHASH(hash_subkey, ghash_c).update(ghash_in).digest() # Step 3 - Prepare GCTR cipher for encryption/decryption @@ -282,12 +282,12 @@ class GcmMode(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._update(assoc_data) self._auth_len += len(assoc_data) @@ -364,10 +364,10 @@ class GcmMode(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"] ciphertext = self._cipher.encrypt(plaintext, output=output) @@ -417,10 +417,10 @@ class GcmMode(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"] if self._status == MacStatus.PROCESSING_AUTH_DATA: self._pad_cache_and_update() @@ -442,10 +442,10 @@ class GcmMode(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"] return self._compute_mac() @@ -492,10 +492,10 @@ class GcmMode(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"] secret = get_random_bytes(16) -- cgit v1.2.3-70-g09d2