Skip to content

fix: rand_core 0.10 compat — use 0.6 dep, migrate rand 0.8 API#9

Merged
Chace-Berry merged 21 commits into
mainfrom
dev
Apr 25, 2026
Merged

fix: rand_core 0.10 compat — use 0.6 dep, migrate rand 0.8 API#9
Chace-Berry merged 21 commits into
mainfrom
dev

Conversation

@Chace-Berry
Copy link
Copy Markdown
Member

@Chace-Berry Chace-Berry commented Apr 25, 2026

Summary

  • rand_core 0.10 dropped the getrandom feature and OsRng; all crypto crates (x25519-dalek, aes-gcm, argon2) pin to rand_core 0.6 which retains both
  • Adds rand_core = { version = "0.6", features = ["getrandom"] } as a direct dep, replaces the broken 0.10 declaration
  • Migrates call sites in crypt.rs, serializer.rs, and pstore.rs away from removed rand 0.8 APIs (thread_rng, rand::rngs::OsRng, rand::RngCore) to rand_core 0.6 equivalents

Test plan

  • CI passes cargo check / cargo test
  • No duplicate rand_core version conflicts in cargo tree
  • Publish dry-run succeeds on green CI

Chace-Berry and others added 21 commits March 20, 2026 09:22
Interceptor now dispatches hs_* key IDs to ecdh_ephemeral for per-request
forward secrecy. RequestSessionKeys derives ZeroizeOnDrop. Replay deduplication
via Redis SET NX EX 60 on MAC hex. Adds handshake_store and replay_store fields.
feat: add build_request_packet — JSON → compress → msgpack → AES-256-GCM
  (random enc_key) → ECDH-wrap enc_key → Request { data, wrapped_key,
  client_pk, key_id, ts } → msgpack; returns (wire_bytes, enc_key)
feat: add decode_response_packet — HMAC-SHA256 verify (enc_key) → AES-256-GCM
  decrypt → decompress → JSON; takes only enc_key, no second ECDH needed
refactor: rename WrappedPacket → Request, SignedResponse → Response
refactor: replace derive_session_keys with derive_wrap_key; single HKDF key
  used only to wrap enc_key in transit — enc_key is the sole session key
refactor: drop request MAC field; AES-GCM auth tags on data and wrapped_key
  cover integrity without a separate HMAC key
refactor: RequestSessionKeys carries enc_key only; interceptor now unwraps
  enc_key via ECDH rather than deriving it
refactor: build_signed_response / build_signed_response_raw drop mac_key;
  response HMAC signed with enc_key so client verifies with one key
docs: update README with accurate client/server pipeline ASCII diagrams
chore: add x25519-dalek = "2" as explicit dependency
…e interceptor docs and unwrap

refactor: add derive_response_mac_key — HKDF-SHA256(enc_key, "alterion-response-mac") keeps
  the HMAC key domain-separated from the AES key so neither primitive leaks information about
  the shared secret to the other
fix: build_signed_response_raw and decode_response_packet now use the derived mac_key instead
  of enc_key directly for HMAC-SHA256 sign/verify
fix: update Interceptor doc comment — remove stale references to mac_key, packet MAC
  verification, and old key derivation steps; reflect the current wrap_key / unwrap flow
fix: replace unwrap() on shared secret try_into with a proper error return in interceptor
docs: add doc comment to Response struct
The second replay-detection block referenced packet.mac which no longer
exists on Request, causing a compile error in CodeQL CI.
rand_core 0.10 dropped the `getrandom` feature and OsRng; all crypto
crates (x25519-dalek, aes-gcm, argon2) pin to rand_core 0.6 which still
has both.  Adds rand_core 0.6 as a direct dep and updates all call sites
(crypt, serializer, pstore) away from the removed rand 0.8 APIs
(thread_rng, rand::rngs::OsRng, rand::RngCore).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add module-level docs to crypt, serializer, hmac, sha2, pstore with
  architecture tables, security property descriptions, and pipeline diagrams
- Expand hash_password, verify_password, key_encrypt, rotate_pepper,
  get_current_pepper/get_pepper with pepper-versioning rationale
- Expand lib.rs with security properties table and architecture overview
- Document DecryptedBody, RequestSessionKeys, InterceptorService in interceptor
- Move all inline use statements to file tops (anyhow::Context, rand_core::RngCore)
- Remove redundant x25519_dalek import inside test (covered by use super::*)
- Make REPLAY_WINDOW_SECS pub so doc links resolve

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update dev branch deps to match main: alterion-ecdh 1.0, hmac 0.13,
sha2 0.11, hkdf 0.13, keyring 3, redis 1.2.  hmac 0.13 moved
new_from_slice to the KeyInit trait so add that import.

rand_core 0.6 is kept as a direct dep — x25519-dalek 2 still requires
rand_core ^0.6 traits for EphemeralSecret::random_from_rng and rand 0.10
uses rand_core 0.10 which is a separate crate version with no OsRng.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Cargo.toml: version 1.4.0, alterion-ecdh 1.0, keyutils default +
  optional keyring win64, rand_core 0.6 (keeps our fix), [features]
  section, libc dep
- pstore.rs: take main's keyutils/win64 dual-backend implementation,
  keep dev's expanded module and function docs
- serializer.rs + interceptor.rs: rename wrapped_key → kx throughout
- crypt.rs: use rand::random() for generate_random_hex (main's approach)
- hmac.rs: keep module doc, keep KeyInit import
- README.md: take main's accurate kx and HKDF mac key descriptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Chace-Berry Chace-Berry merged commit 57e50ed into main Apr 25, 2026
5 checks passed
@Chace-Berry Chace-Berry deleted the dev branch May 13, 2026 10:35
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