-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix make_user_key which previously didn't stretch the users key (#315)
## Type of change <!-- (mark with an `X`) --> ``` - [x] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> The `make_user_key` needs to use the same key as `decrypt_user_key`, which should be the stretched users key. ## Before you submit - Please add **unit tests** where it makes sense to do so (encouraged but not required)
- Loading branch information
Showing
7 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// Integration test for registering a new user and unlocking the vault | ||
#[cfg(feature = "mobile")] | ||
#[tokio::test] | ||
async fn test_register_initialize_crypto() { | ||
use std::num::NonZeroU32; | ||
|
||
use bitwarden::{client::kdf::Kdf, mobile::crypto::InitCryptoRequest, Client}; | ||
|
||
let mut client = Client::new(None); | ||
|
||
let email = "[email protected]"; | ||
let password = "test123"; | ||
let kdf = Kdf::PBKDF2 { | ||
iterations: NonZeroU32::new(600_000).unwrap(), | ||
}; | ||
|
||
let register_response = client | ||
.auth() | ||
.make_register_keys(email.to_owned(), password.to_owned(), kdf.clone()) | ||
.unwrap(); | ||
|
||
// Ensure we can initialize the crypto with the new keys | ||
client | ||
.crypto() | ||
.initialize_crypto(InitCryptoRequest { | ||
kdf_params: kdf, | ||
email: email.to_owned(), | ||
password: password.to_owned(), | ||
user_key: register_response.encrypted_user_key, | ||
private_key: register_response.keys.private.to_string(), | ||
organization_keys: Default::default(), | ||
}) | ||
.await | ||
.unwrap(); | ||
} |