Skip to content

[PM-35105] Add HighEntropySecret to bitwarden-crypto#1201

Open
quexten wants to merge 5 commits into
mainfrom
km/high-entropy-secret
Open

[PM-35105] Add HighEntropySecret to bitwarden-crypto#1201
quexten wants to merge 5 commits into
mainfrom
km/high-entropy-secret

Conversation

@quexten

@quexten quexten commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-35105

📔 Objective

Stacked PR 1/4 splitting the secret-protected key envelope work.

Adds HighEntropySecret to the bitwarden-crypto safe module: a wrapper around secret bytes guaranteed to be high-entropy, safe to use as input keying material for a cheap KDF. Includes the bitwarden-sensitive-value dependency and the UniFFI custom-type binding.

Base: main.

A high-entropy secret wraps secret bytes guaranteed to be high-entropy,
making them safe as input keying material for a cheap KDF. Adds the
HighEntropySecret type, its safe-module export, the bitwarden-sensitive-value
dependency, and the UniFFI custom-type binding.
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🔍 SDK Breaking Change Detection

SDK Version: km/high-entropy-secret (0eaefd4)

⚠️ If breaking changes are detected, a corresponding pull request addressing them must be ready for merge in the affected client repository.

Client Status Details
typescript ✅ No breaking changes detected Compilation passed with new SDK version - View Details
android ✅ No breaking changes detected Compilation passed with new SDK version - View Details

Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm.
Results update as workflows complete.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.30864% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.09%. Comparing base (378df4c) to head (53771bf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/bitwarden-crypto/src/safe/high_entropy_secret.rs 76.25% 19 Missing ⚠️
crates/bitwarden-crypto/src/uniffi_support.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1201      +/-   ##
==========================================
- Coverage   85.09%   85.09%   -0.01%     
==========================================
  Files         464      465       +1     
  Lines       63866    63947      +81     
==========================================
+ Hits        54348    54415      +67     
- Misses       9518     9532      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quexten quexten marked this pull request as ready for review June 22, 2026 12:07
@quexten quexten requested a review from a team as a code owner June 22, 2026 12:07
@quexten quexten requested a review from eligrubb June 22, 2026 12:07
@quexten quexten marked this pull request as draft June 22, 2026 12:08
@sonarqubecloud

Copy link
Copy Markdown

@quexten quexten marked this pull request as ready for review June 22, 2026 14:33
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new HighEntropySecret wrapper added to the bitwarden-crypto safe module (stacked PR 1/4). The type stores secret bytes in Zeroizing, redacts its Debug output, generates material via the CSPRNG (rand::rng().fill_bytes) matching the sibling envelope pattern, and enforces a 16-byte minimum on make(). WASM and UniFFI custom-type bindings follow the established SensitiveString/PasswordProtectedKeyEnvelope conventions, and the bitwarden-sensitive-value workspace dependency is an existing internal crate (path, pinned =3.0.0), not a net-new external dependency.

Code Review Details

No blocking findings.

Notes considered and intentionally not flagged:

  • The minimum-length guard is enforced only in make(); from(), from_internal(), and the WASM/UniFFI lift paths trust the caller. This is documented as an explicit trust contract on HighEntropySecretSource and from_internal, with approved sources (PRF outputs, key-connector bytes) that are high-entropy by construction.
  • WASM lowering exposes the secret as a Base64 string while UniFFI uses raw Vec<u8>; both round-trip correctly and the exposure is acknowledged in the UniFFI EXPOSE comment.

Test coverage exercises redaction, length rejection/acceptance, distinct generation, byte preservation, and clone behavior.

@quexten quexten added the ai-review Request a Claude code review label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant