Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
16a12c0
Add initial tracing
quexten Nov 12, 2025
fd78440
Add some more logging
quexten Nov 12, 2025
5a11190
Merge branch 'main' into km/tracing
quexten Nov 12, 2025
eb9396c
Fix build
quexten Nov 12, 2025
d3a73b7
Cleanup
quexten Nov 12, 2025
c18ce0c
Cargo fmt
quexten Nov 12, 2025
bfbcebb
Add span
quexten Nov 12, 2025
6fa35f5
Cleanup
quexten Nov 12, 2025
2384c07
Purecrypto tracing
quexten Nov 12, 2025
b26d055
Fix
quexten Nov 12, 2025
9eedc6a
Merge branch 'main' into km/tracing
quexten Nov 13, 2025
0c2ef20
Cleanup
quexten Nov 13, 2025
c60c1ee
Merge branch 'km/tracing' of github.com:bitwarden/sdk-internal into kโ€ฆ
quexten Nov 13, 2025
2600658
Cleanup
quexten Nov 13, 2025
91f4dc9
Cleanup
quexten Nov 13, 2025
096615b
Cleanup
quexten Nov 13, 2025
3ad907a
Cleanup deps
quexten Nov 13, 2025
1b840fd
Cleanup deps
quexten Nov 13, 2025
824a1f0
Fix wasm bulid
quexten Nov 13, 2025
2ac0c60
Merge branch 'main' into km/tracing
quexten Nov 13, 2025
6e4588b
Update crates/bitwarden-core/src/client/encryption_settings.rs
quexten Nov 13, 2025
7ff9302
Add more tracing
quexten Nov 14, 2025
d366d05
Skip all
quexten Nov 14, 2025
ce93f3b
Set max log level to info
quexten Nov 17, 2025
ddee1bb
Fix build
quexten Nov 17, 2025
fa414f7
Follow-up changes
quexten Dec 2, 2025
0f2d0f1
Fix build
quexten Dec 2, 2025
d10d599
Merge branch 'main' into km/tracing
quexten Dec 2, 2025
8f9b3b4
Undo change
quexten Dec 2, 2025
6515170
Merge branch 'km/tracing' of github.com:bitwarden/sdk-internal into kโ€ฆ
quexten Dec 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion crates/bitwarden-core/src/client/encryption_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bitwarden_crypto::{KeyStore, SymmetricCryptoKey};
use bitwarden_error::bitwarden_error;
use thiserror::Error;
#[cfg(feature = "internal")]
use tracing::warn;
use tracing::{info, instrument, warn};

#[cfg(any(feature = "secrets", feature = "internal"))]
use crate::OrganizationId;
Expand Down Expand Up @@ -108,11 +108,13 @@ impl EncryptionSettings {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
fn init_v1(
user_key: Aes256CbcHmacKey,
private_key: EncString,
store: &KeyStore<KeyIds>,
) -> Result<(), EncryptionSettingsError> {
info!("Account has v1 encryption keys");
let user_key = SymmetricCryptoKey::Aes256CbcHmacKey(user_key);

let private_key = {
Expand Down Expand Up @@ -146,6 +148,7 @@ impl EncryptionSettings {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
fn init_v2(
user_key: XChaCha20Poly1305Key,
private_key: EncString,
Expand All @@ -154,6 +157,7 @@ impl EncryptionSettings {
store: &KeyStore<KeyIds>,
sdk_security_state: &RwLock<Option<SecurityState>>,
) -> Result<(), EncryptionSettingsError> {
info!("Account has v2 encryption keys");
use crate::key_management::SecurityState;

let user_key = SymmetricCryptoKey::XChaCha20Poly1305Key(user_key);
Expand Down Expand Up @@ -201,6 +205,7 @@ impl EncryptionSettings {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
pub(crate) fn set_org_keys(
org_enc_keys: Vec<(OrganizationId, UnsignedSharedKey)>,
store: &KeyStore<KeyIds>,
Expand Down
7 changes: 7 additions & 0 deletions crates/bitwarden-core/src/client/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use bitwarden_crypto::{
#[cfg(feature = "internal")]
use bitwarden_state::registry::StateRegistry;
use chrono::Utc;
#[cfg(feature = "internal")]
use tracing::instrument;

#[cfg(any(feature = "internal", feature = "secrets"))]
use crate::client::encryption_settings::EncryptionSettings;
Expand Down Expand Up @@ -288,6 +290,7 @@ impl InternalClient {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
pub(crate) fn initialize_user_crypto_master_key(
&self,
master_key: MasterKey,
Expand All @@ -299,6 +302,7 @@ impl InternalClient {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all, fields(user_id = ?self.get_user_id()))]
pub(crate) fn initialize_user_crypto_decrypted_key(
&self,
user_key: SymmetricCryptoKey,
Expand Down Expand Up @@ -340,6 +344,7 @@ impl InternalClient {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
pub(crate) fn initialize_user_crypto_pin(
&self,
pin_key: PinKey,
Expand All @@ -351,6 +356,7 @@ impl InternalClient {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
pub(crate) fn initialize_user_crypto_pin_envelope(
&self,
pin: String,
Expand Down Expand Up @@ -393,6 +399,7 @@ impl InternalClient {
}

#[cfg(feature = "internal")]
#[instrument(err, skip_all)]
pub(crate) fn initialize_user_crypto_master_password_unlock(
&self,
password: String,
Expand Down
9 changes: 9 additions & 0 deletions crates/bitwarden-core/src/key_management/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use bitwarden_encoding::B64;
use bitwarden_error::bitwarden_error;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use tracing::info;
#[cfg(feature = "wasm")]
use {tsify::Tsify, wasm_bindgen::prelude::*};

Expand Down Expand Up @@ -167,6 +168,12 @@ pub(super) async fn initialize_user_crypto(
}

let key_state = (&req).into();
let _span_guard = tracing::info_span!(
"User Crypto Initialization",
user_id = ?client.internal.get_user_id(),
method = ?req.method
)
.entered();

match req.method {
InitUserCryptoMethod::Password { password, user_key } => {
Expand Down Expand Up @@ -261,6 +268,8 @@ pub(super) async fn initialize_user_crypto(
}
}

info!("User crypto initialized successfully");

client
.internal
.set_login_method(LoginMethod::User(UserLoginMethod::Username {
Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ sha1 = { workspace = true }
sha2 = ">=0.10.6, <0.11"
subtle = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
tsify = { workspace = true, optional = true }
typenum = ">=1.18.0, <1.19.0"
uniffi = { workspace = true, optional = true }
Expand Down
2 changes: 2 additions & 0 deletions crates/bitwarden-crypto/src/cose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use coset::{
};
use generic_array::GenericArray;
use thiserror::Error;
use tracing::instrument;
use typenum::U32;

use crate::{
Expand Down Expand Up @@ -135,6 +136,7 @@ const SYMMETRIC_KEY: Label = Label::Int(iana::SymmetricKeyParameter::K as i64);
impl TryFrom<&coset::CoseKey> for SymmetricCryptoKey {
type Error = CryptoError;

#[instrument(err, skip_all)]
fn try_from(cose_key: &coset::CoseKey) -> Result<Self, Self::Error> {
let key_bytes = cose_key
.params
Expand Down
2 changes: 2 additions & 0 deletions crates/bitwarden-crypto/src/enc_string/symmetric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{borrow::Cow, str::FromStr};
use bitwarden_encoding::{B64, FromStrVisitor};
use coset::{CborSerializable, iana::KeyOperation};
use serde::Deserialize;
use tracing::instrument;
#[cfg(feature = "wasm")]
use wasm_bindgen::convert::FromWasmAbi;

Expand Down Expand Up @@ -367,6 +368,7 @@ impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str {
}

impl KeyDecryptable<SymmetricCryptoKey, String> for EncString {
#[instrument(err, skip_all)]
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<String> {
let dec: Vec<u8> = self.decrypt_with_key(key)?;
String::from_utf8(dec).map_err(|_| CryptoError::InvalidUtf8String)
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-crypto/src/traits/decryptable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tracing::instrument;

use crate::{CryptoError, EncString, KeyId, KeyIds, store::KeyStoreContext};

/// A decryption operation that takes the input value and decrypts it into the output value.
Expand All @@ -9,6 +11,7 @@ pub trait Decryptable<Ids: KeyIds, Key: KeyId, Output> {
}

impl<Ids: KeyIds> Decryptable<Ids, Ids::Symmetric, Vec<u8>> for EncString {
#[instrument(err, skip_all)]
fn decrypt(
&self,
ctx: &mut KeyStoreContext<Ids>,
Expand All @@ -19,6 +22,7 @@ impl<Ids: KeyIds> Decryptable<Ids, Ids::Symmetric, Vec<u8>> for EncString {
}

impl<Ids: KeyIds> Decryptable<Ids, Ids::Symmetric, String> for EncString {
#[instrument(err, skip_all)]
fn decrypt(
&self,
ctx: &mut KeyStoreContext<Ids>,
Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ sha1 = ">=0.10.5, <0.11"
sha2 = ">=0.10.6, <0.11"
subtle = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
tsify = { workspace = true, optional = true }
uniffi = { workspace = true, optional = true }
uuid = { workspace = true }
Expand Down
3 changes: 3 additions & 0 deletions crates/bitwarden-vault/src/cipher/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use chrono::{DateTime, SecondsFormat, Utc};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use thiserror::Error;
use tracing::instrument;
#[cfg(feature = "wasm")]
use tsify::Tsify;
#[cfg(feature = "wasm")]
Expand Down Expand Up @@ -512,6 +513,7 @@ impl CompositeEncryptable<KeyIds, SymmetricKeyId, Cipher> for CipherView {
}

impl Decryptable<KeyIds, SymmetricKeyId, CipherView> for Cipher {
#[instrument(err, skip_all, fields(cipher_id = ?self.id, org_id = ?self.organization_id, kind = ?self.r#type))]
fn decrypt(
&self,
ctx: &mut KeyStoreContext<KeyIds>,
Expand Down Expand Up @@ -576,6 +578,7 @@ impl Cipher {
/// * `key` - The key to use to decrypt the cipher key, this should be the user or organization
/// key
/// * `ciphers_key` - The encrypted cipher key
#[instrument(err, skip_all)]
pub(super) fn decrypt_cipher_key(
ctx: &mut KeyStoreContext<KeyIds>,
key: SymmetricKeyId,
Expand Down
Loading