Skip to content

Commit

Permalink
Temporarily disable private key validation (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Sep 5, 2024
1 parent 3065a03 commit 6d4f952
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions crates/bitwarden-core/src/client/encryption_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ impl EncryptionSettings {
private_key: EncString,
) -> Result<Self, EncryptionSettingsError> {
use bitwarden_crypto::KeyDecryptable;
use log::warn;

let private_key = {
let dec: Vec<u8> = private_key.decrypt_with_key(&user_key)?;
Some(
AsymmetricCryptoKey::from_der(&dec)
.map_err(|_| EncryptionSettingsError::InvalidPrivateKey)?,
)

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

// Some(
// AsymmetricCryptoKey::from_der(&dec)
// .map_err(|_| EncryptionSettingsError::InvalidPrivateKey)?,
// )
};

Ok(EncryptionSettings {
Expand Down Expand Up @@ -93,12 +103,17 @@ impl EncryptionSettings {

use crate::VaultLocked;

let private_key = self.private_key.as_ref().ok_or(VaultLocked)?;

// Make sure we only keep the keys given in the arguments and not any of the previous
// ones, which might be from organizations that the user is no longer a part of anymore
self.org_keys.clear();

// FIXME: [PM-11690] - Early abort to handle private key being corrupt
if org_enc_keys.is_empty() {
return Ok(self);
}

let private_key = self.private_key.as_ref().ok_or(VaultLocked)?;

// Decrypt the org keys with the private key
for (org_id, org_enc_key) in org_enc_keys {
let mut dec: Vec<u8> = org_enc_key.decrypt_with_key(private_key)?;
Expand Down

0 comments on commit 6d4f952

Please sign in to comment.