Skip to content

Backport 3.6: ssl_fork_server RNG testing#10666

Open
gilles-peskine-arm wants to merge 9 commits intoMbed-TLS:mbedtls-3.6from
gilles-peskine-arm:ssl_fork_server-rng-test-3.6
Open

Backport 3.6: ssl_fork_server RNG testing#10666
gilles-peskine-arm wants to merge 9 commits intoMbed-TLS:mbedtls-3.6from
gilles-peskine-arm:ssl_fork_server-rng-test-3.6

Conversation

@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

Test that ssl_fork_server has a different RNG state in each client. Fixes #10664.

Needs preceding PR: Mbed-TLS/mbedtls-framework#296

PR checklist

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
`ssl_fork_server` reseeds its RNG, so in a build with a nonvolatile seed, it
re-reads the seed file midway. If the client also rewrites the seed file
while the server is running, that causes the test conditions to not reflect
real-world conditions for the server.

Fix this by running `ssl_fork_server` in its own directory when we're
asserting properties of the random generator. This was a relatively easy
way to separate the client seed file from the server seed file, since the
seed file name `"seedfile"` is not configurable at runtime.

This mostly matters for builds with no actual entropy source, only an NV seed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Assert that when two clients connect to ssl_fork_server, they see different
random values from the server. This validates that each child process has
its own random generator state.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Assert that when two clients connect to ssl_fork_server, they see different
ephemeral public keys from the server. This validates that each child
process has its own random generator state.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Run some of `ssl-opt.sh` on builds with only an NV seed as the entropy
source. There isn't much that isn't already covered by unit tests, but do
test that it works in a "real" program. In particular, run `ssl_fork_server`
which has a peculiar challenge since its RNG state is replicated.

Test both builds with `MBEDTLS_USE_PSA_CRYPTO` enabled (via the `full`
config) and `MBEDTLS_USE_PSA_CRYPTO` disabled (by minimally tweaking the
default config), as this makes a difference to RNG usage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added the needs-ci Needs to pass CI tests label Apr 1, 2026
@gilles-peskine-arm gilles-peskine-arm added size-s Estimated task size: small (~2d) priority-high High priority - will be reviewed soon labels Apr 1, 2026
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-ci Needs to pass CI tests labels Apr 1, 2026
@gilles-peskine-arm gilles-peskine-arm removed the needs-reviewer This PR needs someone to pick it up for review label Apr 8, 2026
Comment thread tests/ssl-opt.sh
@@ -2041,6 +2076,10 @@ cleanup() {
rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fairly minor, however if I've understood correctly this cleanup is only run under the conditions on line 2273 ie. INT TERM HUP. Would it be better to to either add normal exit to the exit conditions or change the test -s as currently the seedfile will be reused for each test. If the test corrupts or overwrites it possibly could effect the result.

…ient random values

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
bjwtaylor
bjwtaylor previously approved these changes Apr 13, 2026
@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Apr 13, 2026
Fix a bug introduced in "Fix temporary directory left behind on normal exit"
that caused the exit code of `ssl-opt.sh` to be 1 on success.

Also, when exiting on a trapped signal, re-raise the signal rather than
exiting with status 1.

Also, on failure, where we report the number of failures through the exit
code, clamp the exit code to 125 to avoid confusion with standard values.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci Needs to pass CI tests priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)

Projects

Development

Successfully merging this pull request may close these issues.

2 participants