Do not return True from MAC verify function on success.

This commit is contained in:
Leo Vasanko
2025-11-06 21:11:24 -06:00
parent a8947c23b3
commit 1b4d43a448
6 changed files with 18 additions and 66 deletions
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis128l Python submodule. """AEGIS-128L"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis128l.py by tools/gen_modules.py! # All modules are generated from aegis128l.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128l_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis128l_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor:
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis128x2 Python submodule. """AEGIS-128X2"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis128x2.py by tools/gen_modules.py! # All modules are generated from aegis128x2.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128x2_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis128x2_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor:
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis128x4 Python submodule. """AEGIS-128X4"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis128x4.py by tools/gen_modules.py! # All modules are generated from aegis128x4.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128x4_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis128x4_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor:
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis256 Python submodule. """AEGIS-256"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis256.py by tools/gen_modules.py! # All modules are generated from aegis256.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis256_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor:
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis256x2 Python submodule. """AEGIS-256X2"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis256x2.py by tools/gen_modules.py! # All modules are generated from aegis256x2.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256x2_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis256x2_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor:
+3 -11
View File
@@ -1,11 +1,4 @@
"""aegis256x4 Python submodule. """AEGIS-256X4"""
Simplified API: single functions can return newly allocated buffers or write
into user-provided buffers via optional `into=` (and `mac_into=` for detached).
Error return codes from the C library raise ValueError.
"""
# All modules are generated from aegis256x4.py by tools/gen_modules.py! # All modules are generated from aegis256x4.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY! # DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}") raise RuntimeError(f"mac final failed: {err_name}")
return out if into is None else memoryview(out)[:maclen] # type: ignore return out if into is None else memoryview(out)[:maclen] # type: ignore
def verify(self, mac: Buffer) -> bool: def verify(self, mac: Buffer):
"""Verify a tag for the current MAC state. """Verify a tag for the current MAC state.
Args: Args:
mac: The tag to verify (16 or 32 bytes). mac: The tag to verify (16 or 32 bytes).
Returns: Returns:
True if verification succeeds. Only if verification succeeds.
Raises: Raises:
TypeError: If tag length is invalid. TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256x4_mac_verify(self._st, _ptr(mac), maclen) rc = _lib.aegis256x4_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0: if rc != 0:
raise ValueError("mac verification failed") raise ValueError("mac verification failed")
return True
class Encryptor: class Encryptor: