Skip to content

Rust wrapper: random: implement fallible rand_core traits - #11511

Open
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:f-8307
Open

holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:f-8307

Conversation

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor

Description

Rust wrapper: random: implement fallible rand_core traits

Fixes F-8307.

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@holtrop-wolfssl holtrop-wolfssl self-assigned this Sep 21, 2026
Copilot AI lite review requested due to automatic review settings September 21, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Low severity

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::RngError and makes rand_core::TryRng for RNG return errors instead of panicking.
  • Updates ML-KEM KEM integration and tests to use TryCryptoRng/UnwrapErr appropriately.
  • 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.

Comment thread wrapper/rust/wolfssl-wolfcrypt/src/mlkem_kem.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants