Skip to content

Commit 344ef72

Browse files
committed
Add plain security version
1 parent 7333296 commit 344ef72

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

crates/bitwarden-core/src/key_management/crypto.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ pub struct EnrollUserCryptoV2Response {
602602

603603
/// The user's signed security state
604604
signed_security_state: SignedSecurityState,
605+
/// The security state's version
606+
security_version: u64,
605607
}
606608

607609
/// Initializes the user's cryptographic state for v2 users.
@@ -673,6 +675,7 @@ pub fn make_keys_for_user_crypto_v2(
673675
verifying_key: STANDARD.encode(signing_key.to_verifying_key().to_cose()),
674676

675677
signed_security_state,
678+
security_version: security_state.version(),
676679
})
677680
}
678681

crates/bitwarden-crypto/src/security_state.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ impl SecurityState {
6969
signing_key.sign(self, &SigningNamespace::SecurityState)?,
7070
))
7171
}
72+
73+
/// Returns the version of the security state
74+
pub fn version(&self) -> u64 {
75+
self.version
76+
}
7277
}
7378

7479
/// Signs the `SecurityState` with the provided signing key ID from the context.
@@ -183,6 +188,6 @@ mod tests {
183188
),
184189
user_id
185190
);
186-
assert_eq!(verified_security_state.version, 1);
191+
assert_eq!(verified_security_state.version(), 1);
187192
}
188193
}

0 commit comments

Comments
 (0)