Skip to content

Commit

Permalink
Rename to CreateDeviceKey to TrustDeviceResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jan 23, 2024
1 parent dde7039 commit 7ce6338
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions crates/bitwarden-crypto/src/keys/device_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
pub struct DeviceKey(SymmetricCryptoKey);

#[derive(Debug)]

Check warning on line 13 in crates/bitwarden-crypto/src/keys/device_key.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-crypto/src/keys/device_key.rs#L13

Added line #L13 was not covered by tests
pub struct CreateDeviceKey {
pub struct TrustDeviceResponse {
pub device_key: DeviceKey,
/// UserKey encrypted with DevicePublicKey
pub protected_user_key: AsymmetricEncString,
Expand All @@ -25,7 +25,7 @@ impl DeviceKey {
/// Generate a new device key
///
/// Note: Input has to be a SymmetricCryptoKey instead of UserKey because that's what we get from EncSettings.
pub fn trust_device(user_key: &SymmetricCryptoKey) -> Result<CreateDeviceKey> {
pub fn trust_device(user_key: &SymmetricCryptoKey) -> Result<TrustDeviceResponse> {
let mut rng = rand::thread_rng();
let device_key = DeviceKey(SymmetricCryptoKey::generate(&mut rng));

Expand All @@ -45,7 +45,7 @@ impl DeviceKey {
.to_der()?
.encrypt_with_key(&device_key.0)?;

Ok(CreateDeviceKey {
Ok(TrustDeviceResponse {
device_key,
protected_user_key,
protected_device_private_key,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-crypto/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pub use asymmetric_crypto_key::AsymmetricCryptoKey;
mod user_key;
pub use user_key::UserKey;
mod device_key;
pub use device_key::{CreateDeviceKey, DeviceKey};
pub use device_key::{DeviceKey, TrustDeviceResponse};
6 changes: 3 additions & 3 deletions crates/bitwarden/src/auth/client_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
error::Error,
};
#[cfg(feature = "internal")]
use bitwarden_crypto::{CreateDeviceKey, DeviceKey};
use bitwarden_crypto::{DeviceKey, TrustDeviceResponse};

pub struct ClientAuth<'a> {
pub(crate) client: &'a mut crate::Client,
Expand Down Expand Up @@ -101,13 +101,13 @@ impl<'a> ClientAuth<'a> {
validate_password(self.client, password, password_hash).await
}

pub async fn trust_device(&self) -> Result<CreateDeviceKey> {
pub async fn trust_device(&self) -> Result<TrustDeviceResponse> {
trust_device(self.client)
}

Check warning on line 106 in crates/bitwarden/src/auth/client_auth.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/auth/client_auth.rs#L104-L106

Added lines #L104 - L106 were not covered by tests
}

#[cfg(feature = "internal")]
fn trust_device(client: &Client) -> Result<CreateDeviceKey> {
fn trust_device(client: &Client) -> Result<TrustDeviceResponse> {
let enc = client.get_encryption_settings()?;

Check warning on line 111 in crates/bitwarden/src/auth/client_auth.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/auth/client_auth.rs#L110-L111

Added lines #L110 - L111 were not covered by tests

let user_key = enc.get_key(&None).ok_or(Error::VaultLocked)?;

Check warning on line 113 in crates/bitwarden/src/auth/client_auth.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/auth/client_auth.rs#L113

Added line #L113 was not covered by tests
Expand Down

0 comments on commit 7ce6338

Please sign in to comment.