Merge pull request #282 from gilles-peskine-arm/mldsa-pqcp-driver-framework

Generate MLDSA test cases for the driver and dispatch layers
This commit is contained in:
Gilles Peskine
2026-04-08 15:50:19 +02:00
committed by GitHub
6 changed files with 337 additions and 195 deletions
+11 -2
View File
@@ -55,6 +55,10 @@ elif [ "$1" = "--can-mypy" ]; then
fi
echo 'Running pylint ...'
# Exclude `maintainer` subdirectories, because they can contain code
# that does not work with the versions of pylint and mypy we use on the CI.
# https://github.com/Mbed-TLS/mbedtls-framework/issues/293
#
# When we move Python code between repositories, there is a transition
# period during which code is duplicated between the old repository and
# the new repository.
@@ -64,7 +68,9 @@ echo 'Running pylint ...'
# runs of pylint: one for the A files, and one for the others.
# Remove exceptions below once the A file (or the moved code in the A file)
# has been removed from all consuming branches.
find framework/scripts scripts tests/scripts -name '*.py' \( \
find framework/scripts scripts tests/scripts \
-name maintainer -prune -o \
-name '*.py' \( \
! -path scripts/abi_check.py \
! -path scripts/code_size_compare.py \
! -path scripts/ecp_comb_table.py \
@@ -87,7 +93,10 @@ $PYTHON -m mypy framework/scripts || {
ret=1
}
$PYTHON -m mypy scripts tests/scripts || {
# Exclude `maintainer` subdirectories, because they can contain code
# that does not work with the versions of pylint and mypy we use on the CI.
# https://github.com/Mbed-TLS/mbedtls-framework/issues/293
$PYTHON -m mypy --exclude maintainer scripts tests/scripts || {
echo >&2 "mypy reported errors in the parent repository"
ret=1
}
+6 -7
View File
@@ -37,14 +37,13 @@ class read_file_lines:
except that if process(line) raises an exception, then the read_file_lines
snippet annotates the exception with the file name and line number.
"""
def __init__(self, filename: str, binary: bool = False) -> None:
def __init__(self, filename: str) -> None:
self.filename = filename
self.file = None #type: Optional[IO[str]]
self.line_number = 'entry' #type: Union[int, str]
self.generator = None #type: Optional[Iterable[Tuple[int, str]]]
self.binary = binary
def __enter__(self) -> 'read_file_lines':
self.file = open(self.filename, 'rb' if self.binary else 'r')
self.file = open(self.filename)
self.generator = enumerate(self.file)
return self
def __iter__(self) -> Iterator[str]:
@@ -517,10 +516,10 @@ enumerate
_nonascii_re = re.compile(rb'[^\x00-\x7f]+') #type: Pattern
def parse_header(self, filename: str) -> None:
"""Parse a C header file, looking for "#define PSA_xxx"."""
with read_file_lines(filename, binary=True) as lines:
for line in lines:
line = re.sub(self._nonascii_re, rb'', line).decode('ascii')
self.parse_header_line(line)
with open(filename, 'rb') as input_:
for line in input_:
line = re.sub(self._nonascii_re, rb'', line)
self.parse_header_line(line.decode('ascii'))
_macro_identifier_re = re.compile(r'[A-Z]\w+')
def generate_undeclared_names(self, expr: str) -> Iterable[str]: