Skip to content

Rust wrapper: add rand_core, aead, cipher trait implementations#10070

Merged
dgarske merged 6 commits intowolfSSL:masterfrom
holtrop-wolfssl:rust-rand_core-aead-cipher
Apr 13, 2026
Merged

Rust wrapper: add rand_core, aead, cipher trait implementations#10070
dgarske merged 6 commits intowolfSSL:masterfrom
holtrop-wolfssl:rust-rand_core-aead-cipher

Conversation

@holtrop-wolfssl
Copy link
Copy Markdown
Contributor

Description

This PR adds APIs which implement the traits in the rand_core, aead, and cipher crates.

This makes our crate more compatible with the rest of the Rust ecosystem.

Testing

Unit tests

Checklist

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

@holtrop-wolfssl holtrop-wolfssl self-assigned this Mar 25, 2026
Copilot AI review requested due to automatic review settings March 25, 2026 14:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the wolfssl-wolfcrypt Rust wrapper with trait implementations from common ecosystem crates (rand_core, aead, cipher) to improve interoperability with existing Rust crypto APIs.

Changes:

  • Add optional crate features and dependencies for rand_core, aead, and cipher.
  • Implement rand_core RNG traits for RNG, plus aead/cipher trait adapters for ChaCha20-Poly1305/XChaCha20-Poly1305 and multiple AES modes.
  • Add new unit tests covering the new trait-based APIs, and update the wrapper Makefile to build/test with these features enabled.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
wrapper/rust/wolfssl-wolfcrypt/src/random.rs Adds rand_core trait implementation for RNG.
wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs Adds aead trait adapter types for ChaCha20-Poly1305 and XChaCha20-Poly1305; adjusts XChaCha struct form.
wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Adds aead adapters for AES-GCM/CCM and cipher adapters for AES ECB/CBC and stream modes (CTR/OFB).
wrapper/rust/wolfssl-wolfcrypt/tests/test_random.rs Adds tests validating rand_core trait behavior on RNG.
wrapper/rust/wolfssl-wolfcrypt/tests/test_chacha20_poly1305.rs Adds aead-trait tests for ChaCha20-Poly1305 and XChaCha20-Poly1305.
wrapper/rust/wolfssl-wolfcrypt/tests/test_aes.rs Adds aead and cipher trait tests for AES modes (GCM/CCM, ECB/CBC, CTR/OFB).
wrapper/rust/wolfssl-wolfcrypt/Cargo.toml Declares new optional features/dependencies and dev-dependencies for tests.
wrapper/rust/wolfssl-wolfcrypt/Makefile Builds/tests/docs with the new features enabled by default.
wrapper/rust/wolfssl-wolfcrypt/Cargo.lock Locks newly introduced dependency graph entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/random.rs
@holtrop-wolfssl
Copy link
Copy Markdown
Contributor Author

retest this please (Calling Pipeline was cancelled)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs
@holtrop-wolfssl holtrop-wolfssl removed their assignment Mar 26, 2026
Copy link
Copy Markdown
Member

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: REQUEST_CHANGES
Findings: 8 total — 6 posted, 2 skipped

Posted findings

  • [High] check_remaining no-op allows silent len as u32 truncation in StreamCipher implswrapper/rust/wolfssl-wolfcrypt/src/aes.rs:3250-3252
  • [Medium] AEAD key wrapper structs do not zeroize key material on Dropwrapper/rust/wolfssl-wolfcrypt/src/aes.rs:499-501
  • [Medium] GCM/CCM AEAD wrappers re-initialize crypto context on every operationwrapper/rust/wolfssl-wolfcrypt/src/aes.rs:1587-1611
  • [Medium] TryRng::try_fill_bytes panics on wolfCrypt RNG failure instead of returning errorwrapper/rust/wolfssl-wolfcrypt/src/random.rs:401-403
  • [Low] ~1000 lines of near-identical boilerplate for AES key-size variantswrapper/rust/wolfssl-wolfcrypt/src/aes.rs:2882-3885
  • [Low] AEAD GCM/CCM buffer.len() as u32 truncates silently for buffers > 4GBwrapper/rust/wolfssl-wolfcrypt/src/aes.rs:1601
Skipped findings
  • [Medium] XChaCha20Poly1305Aead has undocumented 4096-byte message limit with large stack allocation
  • [Low] Missing AES-192 variants for GCM/CCM AEAD trait implementations

Review generated by Skoll via openclaw

Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/random.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Copy link
Copy Markdown
Member

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Merging and @holtrop-wolfssl will followup with recommended fixes (already in another branch).

@dgarske dgarske merged commit c4e7198 into wolfSSL:master Apr 13, 2026
468 checks passed
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.

5 participants