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

View File

@@ -1,11 +1,4 @@
"""aegis128l Python submodule.
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.
"""
"""AEGIS-128L"""
# All modules are generated from aegis128l.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128l_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor:

View File

@@ -1,11 +1,4 @@
"""aegis128x2 Python submodule.
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.
"""
"""AEGIS-128X2"""
# All modules are generated from aegis128x2.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128x2_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor:

View File

@@ -1,11 +1,4 @@
"""aegis128x4 Python submodule.
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.
"""
"""AEGIS-128X4"""
# All modules are generated from aegis128x4.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis128x4_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor:

View File

@@ -1,11 +1,4 @@
"""aegis256 Python submodule.
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.
"""
"""AEGIS-256"""
# All modules are generated from aegis256.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor:

View File

@@ -1,11 +1,4 @@
"""aegis256x2 Python submodule.
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.
"""
"""AEGIS-256X2"""
# All modules are generated from aegis256x2.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256x2_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor:

View File

@@ -1,11 +1,4 @@
"""aegis256x4 Python submodule.
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.
"""
"""AEGIS-256X4"""
# All modules are generated from aegis256x4.py by tools/gen_modules.py!
# DO NOT EDIT OTHER ALGORITHM FILES MANUALLY!
@@ -529,14 +522,14 @@ class Mac:
raise RuntimeError(f"mac final failed: {err_name}")
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.
Args:
mac: The tag to verify (16 or 32 bytes).
Returns:
True if verification succeeds.
Only if verification succeeds.
Raises:
TypeError: If tag length is invalid.
@@ -548,7 +541,6 @@ class Mac:
rc = _lib.aegis256x4_mac_verify(self._st, _ptr(mac), maclen)
if rc != 0:
raise ValueError("mac verification failed")
return True
class Encryptor: