Rust wrapper: random: implement fallible rand_core traits - #11511
Open
holtrop-wolfssl wants to merge 1 commit into
Open
holtrop-wolfssl wants to merge 1 commit into
holtrop-wolfssl wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The ML-KEM module docs currently mix rand_core::* vs kem::common::rand_core::* terminology for UnwrapErr/traits, which is inconsistent with the example and can mislead users about the correct trait path.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR updates the Rust wolfssl-wolfcrypt wrapper’s RNG integration with rand_core to be truly fallible (propagating wolfSSL error codes instead of panicking), and adjusts downstream KEM usage, tests, and documentation accordingly.
Changes:
- Introduces
random::RngErrorand makesrand_core::TryRngforRNGreturn errors instead of panicking. - Updates ML-KEM KEM integration and tests to use
TryCryptoRng/UnwrapErrappropriately. - Documents the breaking change in the README and CHANGELOG.
| File | Description |
|---|---|
| wrapper/rust/wolfssl-wolfcrypt/src/random.rs | Adds RngError and makes TryRng implementations propagate wolfSSL error codes. |
| wrapper/rust/wolfssl-wolfcrypt/tests/test_random.rs | Updates rand_core-related tests to use TryCryptoRng and UnwrapErr where appropriate. |
| wrapper/rust/wolfssl-wolfcrypt/src/mlkem_kem.rs | Updates module documentation and supports fallible RNGs in Generate::try_generate_from_rng. |
| wrapper/rust/wolfssl-wolfcrypt/tests/test_mlkem_kem.rs | Wraps fallible RNG with UnwrapErr for infallible KEM entry points; adds a test for the fallible generation path. |
| wrapper/rust/wolfssl-wolfcrypt/README.md | Documents the new fallible RNG behavior and how to recover the infallible API via UnwrapErr. |
| wrapper/rust/wolfssl-wolfcrypt/CHANGELOG.md | Records the breaking change to RNG’s TryRng::Error type and the loss of infallible trait impls. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
holtrop-wolfssl
force-pushed
the
f-8307
branch
from
September 21, 2026 14:15
4365c34 to
7a943c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Rust wrapper: random: implement fallible rand_core traits
Fixes F-8307.
Testing
How did you test?
Checklist