Skip to content

Generate multipart ML-DSA tests#300

Open
gilles-peskine-arm wants to merge 3 commits intoMbed-TLS:mainfrom
gilles-peskine-arm:mldsa-sign-multipart-dispatch-framework
Open

Generate multipart ML-DSA tests#300
gilles-peskine-arm wants to merge 3 commits intoMbed-TLS:mainfrom
gilles-peskine-arm:mldsa-sign-multipart-dispatch-framework

Conversation

@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Apr 20, 2026

Expand the ML-DSA test case generator to multipart tests.

PR checklist

We tend to generate the signature of the same message under the same keys
multiple times for different APIs (sign/verify, driver/dispatch, ...).
Caching results makes the script noticeably faster.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Not done by default for smooth transition in the consuming TF-PSA-Crypto
branch. It's up to the calling script `generate_mldsa_tests.py` to
enable the new test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most) labels Apr 20, 2026
@gilles-peskine-arm gilles-peskine-arm added the needs-review Every commit must be reviewed by at least two team members. label Apr 22, 2026
The number of message chunks must be at most MULTIPART_ARITY.
"""
assert len(lengths) <= self.MULTIPART_ARITY
chunks = ([bytes(i) * n for i, n in enumerate(lengths, 65)] +
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be bytes([i]) * n?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that's what I had meant to write. I wanted a little diversity, not a fixed message like all-bytes-zero, because that could hide some bugs.

Though looking back at it, I think it would make more sense to have multiple test cases with the same message split in different ways. Having that doesn't help catch bugs, but it could make diagnosing easier. So I'll change the message content, of course fixing it to be the intended length.

Fix a bug whereby the chunks did not actually have the desired lengths.

Make the message content depend only on its length, and not how it is split
into chunks. This way, it'll be easier to notice and analyze bugs that cause
different outputs for different ways to split the input.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Copy link
Copy Markdown

@bjwtaylor bjwtaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved subject to ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Every commit must be reviewed by at least two team members. priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most)

Projects

Development

Successfully merging this pull request may close these issues.

2 participants