Skip to content

aes-gcm 0.11: key and nonce generation move to the Generate trait - #23

Closed
stoatworks-labs wants to merge 3 commits into
mainfrom
chore/aes-gcm-0.11
Closed

aes-gcm 0.11: key and nonce generation move to the Generate trait#23
stoatworks-labs wants to merge 3 commits into
mainfrom
chore/aes-gcm-0.11

Conversation

@stoatworks-labs

Copy link
Copy Markdown
Owner

Supersedes #15, which cannot compile: aes-gcm 0.11 removes aead::OsRng and the generate_key / generate_nonce associated functions.

error[E0432]: unresolved import `aes_gcm::aead::OsRng`
error[E0599]: no associated function named `generate_nonce` found for struct `AesGcm<...>`

RustCrypto moved key and nonce generation onto a Generate trait (crypto-common 0.2), so the calls become:

before after
Aes256Gcm::generate_key(OsRng) Key::<Aes256Gcm>::generate()
Aes256Gcm::generate_nonce(OsRng) Nonce::<<Aes256Gcm as AeadCore>::NonceSize>::generate()

Why this should be equivalent, and where to check me. Generate::generate() draws from the system's ambient CSPRNG (SysRnggetrandom), which is what OsRng was. The nonce type is derived from AeadCore::NonceSize rather than written as a literal, so it stays 12 bytes — the existing NONCE_LEN assertion on the decrypt path still passes. Key size is unchanged at 256 bits.

One behavioural note: generate() panics if the OS RNG fails, where the old OsRng path did the same. try_generate() exists if a Result is preferred.

Verified: cargo build --all-targets clean, and the crypto tests pass — round-trip, key-file persistence across reload, and the legacy-plaintext passthrough.

⚠️ Not self-merging. This is key and nonce generation, and "it compiles and the tests are green" is weak evidence for crypto — a test suite will not notice a weakened RNG or a nonce-size change. Wants a human read before it lands.

dependabot Bot and others added 3 commits August 21, 2026 20:38
Bumps [aes-gcm](https://github.com/RustCrypto/AEADs) from 0.10.3 to 0.11.0.
- [Commits](RustCrypto/AEADs@aes-gcm-v0.10.3...aes-gcm-v0.11.0)

---
updated-dependencies:
- dependency-name: aes-gcm
  dependency-version: 0.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
aes-gcm 0.11 removes aead::OsRng and the generate_key / generate_nonce
associated functions; RustCrypto moved both onto a Generate trait backed by
the system's ambient CSPRNG.

The nonce type is now derived from AeadCore::NonceSize rather than written
as a literal, so it stays 12 bytes and the existing NONCE_LEN check on the
decrypt path still holds.

Verified: cargo build --all-targets clean, crypto tests passing.

Left for review rather than self-merged: this is key and nonce generation,
and a green test suite is weak evidence for crypto.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
flock 56c5ecf Commit Preview URL

Branch Preview URL
Aug 27 2026, 03:19 PM

@stoatworks-labs

Copy link
Copy Markdown
Owner Author

Closing in favour of a branch cut from current main — this one conflicted on Cargo.lock once the mdns-sd migration (#24) landed. Same change, re-verified: see the replacement.

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.

1 participant