Skip to content

Commit 55629ff

Browse files
committed
Cargo fmt
1 parent d0e08f0 commit 55629ff

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

crates/bitwarden-core/src/client/encryption_settings.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bitwarden_crypto::security_state::SignedSecurityState;
1+
use bitwarden_crypto::{security_state::SignedSecurityState, CryptoError};
22
#[cfg(feature = "internal")]
33
use bitwarden_crypto::{EncString, UnsignedSharedKey};
44
#[cfg(any(feature = "internal", feature = "secrets"))]
@@ -8,8 +8,6 @@ use thiserror::Error;
88
#[cfg(any(feature = "internal", feature = "secrets"))]
99
use uuid::Uuid;
1010

11-
use bitwarden_crypto::CryptoError;
12-
1311
#[cfg(any(feature = "internal", feature = "secrets"))]
1412
use crate::key_management::{KeyIds, SymmetricKeyId};
1513
use crate::{error::UserIdAlreadySetError, MissingPrivateKeyError, VaultLockedError};
@@ -64,9 +62,10 @@ impl EncryptionSettings {
6462

6563
use crate::key_management::{AsymmetricKeyId, SymmetricKeyId};
6664

67-
// This is an all-or-nothing check. The server cannot pretend a signing key or security state to be missing, because they are *always* present when the
68-
// user key is an XChaCha20Poly1305Key. Thus, the server or network cannot lie about the presence of these, because otherwise the entire user account will
69-
// fail to decrypt.
65+
// This is an all-or-nothing check. The server cannot pretend a signing key or security
66+
// state to be missing, because they are *always* present when the user key is an
67+
// XChaCha20Poly1305Key. Thus, the server or network cannot lie about the presence of these,
68+
// because otherwise the entire user account will fail to decrypt.
7069
let is_v2_user = if let SymmetricCryptoKey::XChaCha20Poly1305Key(_) = user_key {
7170
true
7271
} else {
@@ -113,8 +112,8 @@ impl EncryptionSettings {
113112
let private_key = {
114113
let dec: Vec<u8> = private_key.decrypt_with_key(&user_key)?;
115114

116-
// FIXME: [PM-11690] - Temporarily ignore invalid private keys until we have a recovery
117-
// process in place.
115+
// FIXME: [PM-11690] - Temporarily ignore invalid private keys until we have a
116+
// recovery process in place.
118117
AsymmetricCryptoKey::from_der(&dec)
119118
.map_err(|_| {
120119
warn!("Invalid private key");

crates/bitwarden-crypto/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ mod store;
3434
pub use store::{KeyStore, KeyStoreContext};
3535
mod cose;
3636
pub use cose::CoseSerializable;
37-
/// The `SecurityState` module provides functionality to cryptographically attest to which features are allowed to be used for
38-
/// a user.
37+
/// The `SecurityState` module provides functionality to cryptographically attest to which features
38+
/// are allowed to be used for a user.
3939
pub mod security_state;
4040
mod signing;
4141
pub use signing::*;

crates/bitwarden-crypto/src/security_state.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
//! Security state is a signed object that attests to a user's (or later an organization's) security state.
2-
//! The security goal is to prevent downgrades of specific features within the user's account by the server / a
3-
//! networked attacker with TLS introspection access.
1+
//! Security state is a signed object that attests to a user's (or later an organization's) security
2+
//! state. The security goal is to prevent downgrades of specific features within the user's account
3+
//! by the server / a networked attacker with TLS introspection access.
44
//!
5-
//! A security state contains a security version. Based on this version, features can be disabled. Since the server cannot
6-
//! sign a security state, it can no longer downgrade the feature, because it cannot produce an arbitrary valid signed security state.
5+
//! A security state contains a security version. Based on this version, features can be disabled.
6+
//! Since the server cannot sign a security state, it can no longer downgrade the feature, because
7+
//! it cannot produce an arbitrary valid signed security state.
78
//!
8-
//! Note: A long-term compromised server can record the security state of a user, and then replay this specific state, or the entire account
9-
//! to downgrade users to previous states. This can be prevented per logged in session by the client, and for bootstrapping a client by
9+
//! Note: A long-term compromised server can record the security state of a user, and then replay
10+
//! this specific state, or the entire account to downgrade users to previous states. This can be
11+
//! prevented per logged in session by the client, and for bootstrapping a client by
1012
//! using an extended login-with-device protocol.
1113
//!
1214
//! To utilize the security state to disable a feature the following steps are taken:
1315
//! 1. Assume: Feature with format version A is insecure, and cannot be changed by simple mutation
1416
//! 2. A new, safe format version B is introduced, and an upgrade path created
1517
//! 3. The upgrade path is made mandatory
16-
//! 4. After upgrades are run, the sdk validates that all items are in format version B, and the security state can be updated to contain the security version N+1
17-
//! 5. The client, given a security state with security version N+1 will reject all items that are in format version A.
18+
//! 4. After upgrades are run, the sdk validates that all items are in format version B, and the
19+
//! security state can be updated to contain the security version N+1
20+
//! 5. The client, given a security state with security version N+1 will reject all items that are
21+
//! in format version A.
1822
1923
use std::str::FromStr;
2024

@@ -34,8 +38,9 @@ export type SignedSecurityState = string;
3438

3539
/// The security state is a signed object attesting to the security state of a user.
3640
///
37-
/// It contains a version, which can only ever increment. Based on the version, old formats and features are blocked. This prevents a server from downgrading
38-
/// a user's account features, because only the user can create this signed object.
41+
/// It contains a version, which can only ever increment. Based on the version, old formats and
42+
/// features are blocked. This prevents a server from downgrading a user's account features, because
43+
/// only the user can create this signed object.
3944
#[derive(Serialize, Deserialize)]
4045
#[serde(rename_all = "camelCase")]
4146
pub struct SecurityState {

0 commit comments

Comments
 (0)