Skip to content

[PM-24683] Add updateKdf function #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: km/pm-24051-add-master-password-unlock-decryption-options-to-identity-sync-response
Choose a base branch
from

Conversation

quexten
Copy link
Contributor

@quexten quexten commented Aug 13, 2025

🎟️ Tracking

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

📔 Objective

Exposes functionality to update the KDF, with the new masterpassword unlock data, and masterpassword authentication data models. These can be directly passed to the server models.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@quexten quexten changed the title Add updateKdf function [PM-24683] Add updateKdf function Aug 13, 2025
Copy link
Contributor

github-actions bot commented Aug 13, 2025

Logo
Checkmarx One – Scan Summary & Details7008af26-045d-45d4-9900-07574b70bf73

Great job! No new security vulnerabilities introduced in this pull request

Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 89.51965% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.19%. Comparing base (ecfde52) to head (db8e8b0).

Files with missing lines Patch % Lines
crates/bitwarden-uniffi/src/crypto.rs 0.00% 10 Missing ⚠️
...bitwarden-core/src/key_management/crypto_client.rs 0.00% 9 Missing ⚠️
...es/bitwarden-core/src/platform/get_user_api_key.rs 0.00% 3 Missing ⚠️
crates/bitwarden-core/src/auth/login/password.rs 0.00% 1 Missing ⚠️
crates/bitwarden-core/src/key_management/crypto.rs 99.23% 1 Missing ⚠️
Additional details and impacted files
@@                                                   Coverage Diff                                                   @@
##           km/pm-24051-add-master-password-unlock-decryption-options-to-identity-sync-response     #383      +/-   ##
=======================================================================================================================
+ Coverage                                                                                76.01%   76.19%   +0.18%     
=======================================================================================================================
  Files                                                                                      261      261              
  Lines                                                                                    23945    24156     +211     
=======================================================================================================================
+ Hits                                                                                     18201    18406     +205     
- Misses                                                                                    5744     5750       +6     

☔ View full report in Codecov by Sentry.
📢 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 added a commit that referenced this pull request Aug 14, 2025
## 🎟️ Tracking

https://bitwarden.slack.com/archives/C054ZQSBS49/p1755188403409309

## 📔 Objective

It seems #279 accidentally
required wasm in all uniffi builds via `bitwarden-vault` ->
`bitwarden-collections` -> `bitwarden-core`. Since it is only required
on core, this leads to build issues on anything where an impl is tagged
with wasm-bindgen, but uses a struct from a third package - such as
`bitwarden-crypto` that does not have the wasm feature enabled.

Attempts to fix the build errors of:
#383

Note: This flags out a function from the collections client. This has to
be fixed by the owning team and updated, this PR just unblocks builds
and fixes the imports.

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes

---------

Co-authored-by: Oscar Hinton <[email protected]>
@quexten quexten marked this pull request as ready for review August 18, 2025 09:31
@quexten quexten requested review from a team as code owners August 18, 2025 09:31
@quexten quexten requested review from dani-garcia and removed request for a team August 18, 2025 09:31
@quexten
Copy link
Contributor Author

quexten commented Aug 19, 2025

@dani-garcia Yeah, the valid kdf newtype makes sense. We enforce the same correct values on e.g. keys too with custom types that can only be validly created, so there is no reason not to do that with KDF.

Not adding it to this PR, but I'd definitely also like to see this as a future improvement.

@quexten quexten removed request for a team and shane-melton August 19, 2025 11:25
@@ -20,6 +20,7 @@ uniffi = ["dep:uniffi", "bitwarden-core/uniffi"] # Uniffi bindings
wasm = [
"bitwarden-collections/wasm",
"bitwarden-vault/wasm",
"bitwarden-collections/wasm",
Copy link
Member

Choose a reason for hiding this comment

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

Duplicative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left over from the upstream changes that were needed to unblock the PR. I've undone the duplicate import now.

/// re-encrypted with the new password. This returns the new encrypted user key and the new
/// password hash but does not update sdk state.
///
/// Note: This is deprecated and `make_update_password` should be used instead
Copy link
Member

Choose a reason for hiding this comment

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

question: Why not mark this as deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not seem to play nice with uniffi / clippy, and ends up failing the CI because a warning gets emitted. I tried #[allow(deprecated)] on it, but it did not seem to help.

&self,
password: String,
kdf: Kdf,
) -> Result<bitwarden_core::key_management::crypto::UpdateKdfResponse> {
Copy link
Member

Choose a reason for hiding this comment

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

nit: The other functions here uses the shorthand path.

Suggested change
) -> Result<bitwarden_core::key_management::crypto::UpdateKdfResponse> {
) -> Result<UpdateKdfResponse> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned up!

/// re-encrypted with the new password. This returns the new encrypted user key and the new
/// password hash but does not update sdk state.
///
/// Note: This is deprecated and `make_update_password` should be used instead
Copy link
Member

Choose a reason for hiding this comment

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

question: Can we just remove this function here? Or is it actively used in web?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

Copy link

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.

4 participants