mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-09-05 01:39:55 +00:00
Clean up how private key formats are specified to DriverGenerator
Instead of having `gen_all()` change the object state, have the constructor set the object field as desired. This doesn't change the runtime behavior since we're only running `gen_all()` once after constructing the object, and nothing else. But do clean thing up, to avoid any surprises later. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -94,8 +94,14 @@ MESSAGES = [
|
|||||||
class Generator:
|
class Generator:
|
||||||
"""Abstract base class to generate tests for one API."""
|
"""Abstract base class to generate tests for one API."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
PRIVATE_KEY_FORMATS: Sequence[PrivateKeyFormat] = [PrivateKeyFormat.SEED]
|
||||||
self.private_key_formats: Sequence[PrivateKeyFormat] = [PrivateKeyFormat.SEED]
|
|
||||||
|
def __init__(self,
|
||||||
|
private_key_formats: Optional[Sequence[PrivateKeyFormat]] = None,
|
||||||
|
) -> None:
|
||||||
|
self.private_key_formats = \
|
||||||
|
private_key_formats if private_key_formats is not None else \
|
||||||
|
self.PRIVATE_KEY_FORMATS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def function(cls, func: str, kl: int) -> str:
|
def function(cls, func: str, kl: int) -> str:
|
||||||
@@ -243,8 +249,7 @@ class Generator:
|
|||||||
class PQCPGenerator(Generator):
|
class PQCPGenerator(Generator):
|
||||||
"""Test mldsa-native entry points."""
|
"""Test mldsa-native entry points."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
PRIVATE_KEY_FORMATS = [PrivateKeyFormat.EXPANDED]
|
||||||
self.private_key_formats = [PrivateKeyFormat.EXPANDED]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def function(cls, func: str, kl: int) -> str:
|
def function(cls, func: str, kl: int) -> str:
|
||||||
@@ -401,11 +406,8 @@ class DriverGenerator(Generator):
|
|||||||
|
|
||||||
def gen_all(self,
|
def gen_all(self,
|
||||||
multipart: bool = False,
|
multipart: bool = False,
|
||||||
private_key_formats: Optional[Sequence[PrivateKeyFormat]] = None,
|
|
||||||
) -> Iterator[test_case.TestCase]:
|
) -> Iterator[test_case.TestCase]:
|
||||||
"""Generate all the tests for this API."""
|
"""Generate all the tests for this API."""
|
||||||
if private_key_formats is not None:
|
|
||||||
self.private_key_formats = private_key_formats
|
|
||||||
yield from super().gen_all()
|
yield from super().gen_all()
|
||||||
if multipart:
|
if multipart:
|
||||||
for kl in sorted(KEYS.keys()):
|
for kl in sorted(KEYS.keys()):
|
||||||
|
|||||||
Reference in New Issue
Block a user