Skip to content

Commit b00f48b

Browse files
committed
Make content format trait sealed and add type aliases
1 parent 6da4a0b commit b00f48b

File tree

17 files changed

+146
-181
lines changed

17 files changed

+146
-181
lines changed

crates/bitwarden-core/src/auth/auth_request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ mod tests {
111111
use std::num::NonZeroU32;
112112

113113
use bitwarden_crypto::{
114-
BitwardenLegacyKeyContentFormat, Bytes, Kdf, MasterKey, SpkiPublicKeyDerContentFormat,
114+
BitwardenLegacyKeyBytes, Bytes, Kdf, MasterKey, SpkiPublicKeyDerContentFormat,
115115
};
116116

117117
use super::*;
@@ -135,7 +135,7 @@ mod tests {
135135
AsymmetricCryptoKey::from_der(&STANDARD.decode(&request.private_key).unwrap().into())
136136
.unwrap();
137137

138-
let secret = Bytes::<BitwardenLegacyKeyContentFormat>::from(secret);
138+
let secret = BitwardenLegacyKeyBytes::from(secret);
139139
let encrypted = UnsignedSharedKey::encapsulate_key_unsigned(
140140
&SymmetricCryptoKey::try_from(&secret).unwrap(),
141141
&private_key.to_public_key(),

crates/bitwarden-core/src/auth/login/access_token.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::path::{Path, PathBuf};
22

33
use base64::{engine::general_purpose::STANDARD, Engine};
4-
use bitwarden_crypto::{
5-
BitwardenLegacyKeyContentFormat, Bytes, EncString, KeyDecryptable, SymmetricCryptoKey,
6-
};
4+
use bitwarden_crypto::{BitwardenLegacyKeyBytes, EncString, KeyDecryptable, SymmetricCryptoKey};
75
use chrono::Utc;
86
use schemars::JsonSchema;
97
use serde::{Deserialize, Serialize};
@@ -69,7 +67,7 @@ pub(crate) async fn login_access_token(
6967

7068
let payload: Payload = serde_json::from_slice(&decrypted_payload)?;
7169
let encryption_key = STANDARD.decode(&payload.encryption_key)?;
72-
let encryption_key = Bytes::<BitwardenLegacyKeyContentFormat>::from(encryption_key);
70+
let encryption_key = BitwardenLegacyKeyBytes::from(encryption_key);
7371
let encryption_key = SymmetricCryptoKey::try_from(&encryption_key)?;
7472

7573
let access_token_obj: JwtToken = r.access_token.parse()?;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ impl EncryptionSettings {
5858
use crate::key_management::{AsymmetricKeyId, SigningKeyId, SymmetricKeyId};
5959

6060
let private_key = {
61-
use bitwarden_crypto::{Bytes, Pkcs8PrivateKeyDerContentFormat};
61+
use bitwarden_crypto::Bytes;
6262

6363
let dec: Vec<u8> = private_key.decrypt_with_key(&user_key)?;
64-
let dec: Bytes<Pkcs8PrivateKeyDerContentFormat> = Bytes::from(dec);
6564
// FIXME: [PM-11690] - Temporarily ignore invalid private keys until we have a recovery
6665
// process in place.
67-
AsymmetricCryptoKey::from_der(&dec)
66+
AsymmetricCryptoKey::from_der(&Bytes::from(dec))
6867
.map_err(|_| {
6968
warn!("Invalid private key");
7069
})

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ use std::collections::HashMap;
99
use base64::{engine::general_purpose::STANDARD, Engine};
1010
use bitwarden_crypto::{
1111
AsymmetricCryptoKey, Bytes, CoseSerializable, CryptoError, EncString, Kdf, KeyDecryptable,
12-
KeyEncryptable, MasterKey, Pkcs8PrivateKeyDerContentFormat, PrimitiveEncryptable,
13-
SignatureAlgorithm, SignedPublicKey, SigningKey, SymmetricCryptoKey, UnsignedSharedKey,
14-
UserKey,
12+
KeyEncryptable, MasterKey, Pkcs8PrivateKeyBytes, PrimitiveEncryptable, SignatureAlgorithm,
13+
SignedPublicKey, SigningKey, SymmetricCryptoKey, UnsignedSharedKey, UserKey,
1514
};
1615
use bitwarden_error::bitwarden_error;
1716
use schemars::JsonSchema;
@@ -537,8 +536,7 @@ pub(super) fn verify_asymmetric_keys(
537536
.decrypt_with_key(user_key)
538537
.map_err(VerifyError::DecryptFailed)?;
539538

540-
let decrypted_private_key: Bytes<Pkcs8PrivateKeyDerContentFormat> =
541-
Bytes::from(decrypted_private_key);
539+
let decrypted_private_key: Pkcs8PrivateKeyBytes = Bytes::from(decrypted_private_key);
542540
let private_key = AsymmetricCryptoKey::from_der(&decrypted_private_key)
543541
.map_err(VerifyError::ParseFailed)?;
544542

@@ -616,7 +614,7 @@ pub fn make_user_signing_keys_for_enrollment(
616614
mod tests {
617615
use std::num::NonZeroU32;
618616

619-
use bitwarden_crypto::RsaKeyPair;
617+
use bitwarden_crypto::{Pkcs8PrivateKeyDerContentFormat, RsaKeyPair};
620618

621619
use super::*;
622620
use crate::Client;
@@ -844,7 +842,7 @@ mod tests {
844842

845843
let private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzLtEUdxfcLxDj84yaGFsVF5hZ8Hjlb08NMQDy1RnBma06I3ZESshLYzVz4r/gegMn9OOltfV/Yxlyvida8oW6qdlfJ7AVz6Oa8pV7BiL40C7b76+oqraQpyYw2HChANB1AhXL9SqWngKmLZwjA7qiCrmcc0kZHeOb4KnKtp9iVvPVs+8veFvKgYO4ba2AAOHKFdR0W55/agXfAy+fWUAkC8mc9ikyJdQWaPV6OZvC2XFkOseBQm9Rynudh3BQpoWiL6w620efe7t5k+02/EyOFJL9f/XEEjM/+Yo0t3LAfkuhHGeKiRST59Xc9hTEmyJTeVXROtz+0fjqOp3xkaObAgMBAAECggEACs4xhnO0HaZhh1/iH7zORMIRXKeyxP2LQiTR8xwN5JJ9wRWmGAR9VasS7EZFTDidIGVME2u/h4s5EqXnhxfO+0gGksVvgNXJ/qw87E8K2216g6ZNo6vSGA7H1GH2voWwejJ4/k/cJug6dz2S402rRAKh2Wong1arYHSkVlQp3diiMa5FHAOSE+Cy09O2ZsaF9IXQYUtlW6AVXFrBEPYH2kvkaPXchh8VETMijo6tbvoKLnUHe+wTaDMls7hy8exjtVyI59r3DNzjy1lNGaGb5QSnFMXR+eHhPZc844Wv02MxC15zKABADrl58gpJyjTl6XpDdHCYGsmGpVGH3X9TQQKBgQDz/9beFjzq59ve6rGwn+EtnQfSsyYT+jr7GN8lNEXb3YOFXBgPhfFIcHRh2R00Vm9w2ApfAx2cd8xm2I6HuvQ1Os7g26LWazvuWY0Qzb+KaCLQTEGH1RnTq6CCG+BTRq/a3J8M4t38GV5TWlzv8wr9U4dl6FR4efjb65HXs1GQ4QKBgQC7/uHfrOTEHrLeIeqEuSl0vWNqEotFKdKLV6xpOvNuxDGbgW4/r/zaxDqt0YBOXmRbQYSEhmO3oy9J6XfE1SUln0gbavZeW0HESCAmUIC88bDnspUwS9RxauqT5aF8ODKN/bNCWCnBM1xyonPOs1oT1nyparJVdQoG//Y7vkB3+wKBgBqLqPq8fKAp3XfhHLfUjREDVoiLyQa/YI9U42IOz9LdxKNLo6p8rgVthpvmnRDGnpUuS+KOWjhdqDVANjF6G3t3DG7WNl8Rh5Gk2H4NhFswfSkgQrjebFLlBy9gjQVCWXt8KSmjvPbiY6q52Aaa8IUjA0YJAregvXxfopxO+/7BAoGARicvEtDp7WWnSc1OPoj6N14VIxgYcI7SyrzE0d/1x3ffKzB5e7qomNpxKzvqrVP8DzG7ydh8jaKPmv1MfF8tpYRy3AhmN3/GYwCnPqT75YYrhcrWcVdax5gmQVqHkFtIQkRSCIftzPLlpMGKha/YBV8c1fvC4LD0NPh/Ynv0gtECgYEAyOZg95/kte0jpgUEgwuMrzkhY/AaUJULFuR5MkyvReEbtSBQwV5tx60+T95PHNiFooWWVXiLMsAgyI2IbkxVR1Pzdri3gWK5CTfqb7kLuaj/B7SGvBa2Sxo478KS5K8tBBBWkITqo+wLC0mn3uZi1dyMWO1zopTA+KtEGF2dtGQ=";
846844
let private_key = STANDARD.decode(private_key).unwrap();
847-
let private_key = Bytes::<Pkcs8PrivateKeyDerContentFormat>::from(private_key);
845+
let private_key = Pkcs8PrivateKeyBytes::from(private_key);
848846
let private_key = AsymmetricCryptoKey::from_der(&private_key).unwrap();
849847
let decrypted: SymmetricCryptoKey =
850848
encrypted.decapsulate_key_unsigned(&private_key).unwrap();

crates/bitwarden-crypto/src/content_format.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ pub enum ContentFormat {
3939
Cbor,
4040
}
4141

42+
mod private {
43+
/// This trait is used to seal the `ConstContentFormat` trait, preventing external
44+
/// implementations.
45+
pub trait Sealed {}
46+
}
47+
4248
/// This trait is used to instantiate different typed byte vectors with a specific content format,
4349
/// using `SerializedBytes<C>`. This allows for compile-time guarantees about the content format
4450
/// of the serialized bytes. The exception here is the escape hatch using e.g. `from(Vec<u8>)`,
4551
/// which can still be mis-used, but has to be misused explicitly.
46-
pub trait ConstContentFormat {
52+
pub trait ConstContentFormat: private::Sealed {
4753
/// Returns the content format as a `ContentFormat` enum.
4854
fn content_format() -> ContentFormat;
4955
}
@@ -89,68 +95,90 @@ impl<C: ConstContentFormat> Bytes<C> {
8995
/// Content format for UTF-8 encoded text. Used for most text messages.
9096
#[derive(PartialEq, Eq, Clone, Debug)]
9197
pub(crate) struct Utf8ContentFormat;
98+
impl private::Sealed for Utf8ContentFormat {}
9299
impl ConstContentFormat for Utf8ContentFormat {
93100
fn content_format() -> ContentFormat {
94101
ContentFormat::Utf8
95102
}
96103
}
104+
/// Utf8Bytes is a type alias for Bytes with `Utf8ContentFormat`, which is used for any textual data.
105+
pub(crate) type Utf8Bytes = Bytes<Utf8ContentFormat>;
97106

98107
/// Content format for raw bytes. Used for attachments and send seed keys.
99108
#[derive(PartialEq, Eq, Clone, Debug)]
100109
pub struct OctetStreamContentFormat;
110+
impl private::Sealed for OctetStreamContentFormat {}
101111
impl ConstContentFormat for OctetStreamContentFormat {
102112
fn content_format() -> ContentFormat {
103113
ContentFormat::OctetStream
104114
}
105115
}
116+
/// OctetStreamBytes is a type alias for Bytes with `OctetStreamContentFormat`. This should be used for e.g. attachments and other data without an
117+
/// explicit content format.
118+
pub type OctetStreamBytes = Bytes<OctetStreamContentFormat>;
106119

107120
/// Content format for PKCS8 private keys in DER format.
108121
#[derive(PartialEq, Eq, Clone, Debug)]
109122
pub struct Pkcs8PrivateKeyDerContentFormat;
123+
impl private::Sealed for Pkcs8PrivateKeyDerContentFormat {}
110124
impl ConstContentFormat for Pkcs8PrivateKeyDerContentFormat {
111125
fn content_format() -> ContentFormat {
112126
ContentFormat::Pkcs8PrivateKey
113127
}
114128
}
129+
/// Pkcs8PrivateKeyBytes is a type alias for Bytes with `Pkcs8PrivateKeyDerContentFormat`. This is used for PKCS8 private keys in DER format.
130+
pub type Pkcs8PrivateKeyBytes = Bytes<Pkcs8PrivateKeyDerContentFormat>;
115131

116132
/// Content format for SPKI public keys in DER format.
117133
#[derive(PartialEq, Eq, Clone, Debug)]
118134
pub struct SpkiPublicKeyDerContentFormat;
135+
impl private::Sealed for SpkiPublicKeyDerContentFormat {}
119136
impl ConstContentFormat for SpkiPublicKeyDerContentFormat {
120137
fn content_format() -> ContentFormat {
121138
ContentFormat::SPKIPublicKeyDer
122139
}
123140
}
141+
/// SpkiPublicKeyBytes is a type alias for Bytes with `SpkiPublicKeyDerContentFormat`. This is used for SPKI public keys in DER format.
142+
pub type SpkiPublicKeyBytes = Bytes<SpkiPublicKeyDerContentFormat>;
124143

125144
/// Content format for COSE keys.
126145
#[derive(PartialEq, Eq, Clone, Debug)]
127146
pub struct CoseKeyContentFormat;
147+
impl private::Sealed for CoseKeyContentFormat {}
128148
impl ConstContentFormat for CoseKeyContentFormat {
129149
fn content_format() -> ContentFormat {
130150
ContentFormat::CoseKey
131151
}
132152
}
133153
impl CoseContentFormat for CoseKeyContentFormat {}
154+
/// CoseKeyBytes is a type alias for Bytes with `CoseKeyContentFormat`. This is used for serialized CoseKey objects.
155+
pub type CoseKeyBytes = Bytes<CoseKeyContentFormat>;
134156

135157
/// A legacy content format for Bitwarden keys. See `ContentFormat::BitwardenLegacyKey`
136-
#[allow(unused)]
137158
#[derive(PartialEq, Eq, Clone, Debug)]
138159
pub struct BitwardenLegacyKeyContentFormat;
160+
impl private::Sealed for BitwardenLegacyKeyContentFormat {}
139161
impl ConstContentFormat for BitwardenLegacyKeyContentFormat {
140162
fn content_format() -> ContentFormat {
141163
ContentFormat::BitwardenLegacyKey
142164
}
143165
}
166+
/// BitwardenLegacyKeyBytes is a type alias for Bytes with `BitwardenLegacyKeyContentFormat`. This is used for the legacy format for symmetric keys.
167+
/// A description of the format is available in the `ContentFormat::BitwardenLegacyKey` documentation.
168+
pub type BitwardenLegacyKeyBytes = Bytes<BitwardenLegacyKeyContentFormat>;
144169

145170
/// Content format for COSE Sign1 messages.
146171
#[derive(PartialEq, Eq, Clone, Debug)]
147172
pub struct CoseSign1ContentFormat;
173+
impl private::Sealed for CoseSign1ContentFormat {}
148174
impl ConstContentFormat for CoseSign1ContentFormat {
149175
fn content_format() -> ContentFormat {
150176
ContentFormat::CoseSign1
151177
}
152178
}
153179
impl CoseContentFormat for CoseSign1ContentFormat {}
180+
/// CoseSign1Bytes is a type alias for Bytes with `CoseSign1ContentFormat`. This is used for serialized COSE Sign1 messages.
181+
pub type CoseSign1Bytes = Bytes<CoseSign1ContentFormat>;
154182

155183
/// A marker trait for COSE content formats.
156184
pub trait CoseContentFormat {}

crates/bitwarden-crypto/src/enc_string/asymmetric.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
error::{CryptoError, EncStringParseError, Result},
1111
rsa::encrypt_rsa2048_oaep_sha1,
1212
util::FromStrVisitor,
13-
AsymmetricCryptoKey, AsymmetricPublicCryptoKey, BitwardenLegacyKeyContentFormat, Bytes,
14-
RawPrivateKey, RawPublicKey, SymmetricCryptoKey,
13+
AsymmetricCryptoKey, AsymmetricPublicCryptoKey, BitwardenLegacyKeyBytes, RawPrivateKey,
14+
RawPublicKey, SymmetricCryptoKey,
1515
};
1616
// This module is a workaround to avoid deprecated warnings that come from the ZeroizeOnDrop
1717
// macro expansion
@@ -217,9 +217,7 @@ impl UnsignedSharedKey {
217217
}
218218
}
219219
.map_err(|_| CryptoError::KeyDecrypt)?;
220-
SymmetricCryptoKey::try_from(&Bytes::<BitwardenLegacyKeyContentFormat>::from(
221-
key_data,
222-
))
220+
SymmetricCryptoKey::try_from(&BitwardenLegacyKeyBytes::from(key_data))
223221
}
224222
}
225223
}

crates/bitwarden-crypto/src/enc_string/symmetric.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use serde::Deserialize;
66

77
use super::{check_length, from_b64, from_b64_vec, split_enc_string};
88
use crate::{
9-
content_format::{Bytes, Utf8ContentFormat},
109
error::{CryptoError, EncStringParseError, Result, UnsupportedOperation},
1110
util::FromStrVisitor,
1211
Aes256CbcHmacKey, ContentFormat, KeyDecryptable, KeyEncryptable, KeyEncryptableWithContentType,
13-
SymmetricCryptoKey, XChaCha20Poly1305Key,
12+
SymmetricCryptoKey, Utf8Bytes, XChaCha20Poly1305Key,
1413
};
1514

1615
#[cfg(feature = "wasm")]
@@ -323,13 +322,13 @@ impl KeyDecryptable<SymmetricCryptoKey, Vec<u8>> for EncString {
323322

324323
impl KeyEncryptable<SymmetricCryptoKey, EncString> for String {
325324
fn encrypt_with_key(self, key: &SymmetricCryptoKey) -> Result<EncString> {
326-
Into::<Bytes<Utf8ContentFormat>>::into(self).encrypt_with_key(key)
325+
Into::<Utf8Bytes>::into(self).encrypt_with_key(key)
327326
}
328327
}
329328

330329
impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str {
331330
fn encrypt_with_key(self, key: &SymmetricCryptoKey) -> Result<EncString> {
332-
Into::<Bytes<Utf8ContentFormat>>::into(self).encrypt_with_key(key)
331+
Into::<Utf8Bytes>::into(self).encrypt_with_key(key)
333332
}
334333
}
335334

crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
55

66
use super::key_encryptable::CryptoKey;
77
use crate::{
8-
content_format::{Bytes, Pkcs8PrivateKeyDerContentFormat, SpkiPublicKeyDerContentFormat},
8+
content_format::{Bytes, SpkiPublicKeyDerContentFormat},
99
error::{CryptoError, Result},
10+
Pkcs8PrivateKeyBytes,
1011
};
1112

1213
/// Algorithm / public key encryption scheme used for encryption/decryption.
@@ -114,7 +115,7 @@ impl AsymmetricCryptoKey {
114115
}
115116

116117
#[allow(missing_docs)]
117-
pub fn from_der(der: &Bytes<Pkcs8PrivateKeyDerContentFormat>) -> Result<Self> {
118+
pub fn from_der(der: &Pkcs8PrivateKeyBytes) -> Result<Self> {
118119
use rsa::pkcs8::DecodePrivateKey;
119120
Ok(Self {
120121
inner: RawPrivateKey::RsaOaepSha1(Box::pin(
@@ -124,7 +125,7 @@ impl AsymmetricCryptoKey {
124125
}
125126

126127
#[allow(missing_docs)]
127-
pub fn to_der(&self) -> Result<Bytes<Pkcs8PrivateKeyDerContentFormat>> {
128+
pub fn to_der(&self) -> Result<Pkcs8PrivateKeyBytes> {
128129
match &self.inner {
129130
RawPrivateKey::RsaOaepSha1(private_key) => {
130131
use rsa::pkcs8::EncodePrivateKey;

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use super::{AsymmetricCryptoKey, PublicKeyEncryptionAlgorithm};
22
use crate::{
3-
content_format::{Bytes, Pkcs8PrivateKeyDerContentFormat},
4-
error::Result,
5-
CryptoError, EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, UnsignedSharedKey,
3+
content_format::Bytes, error::Result, CryptoError, EncString, KeyDecryptable, KeyEncryptable,
4+
Pkcs8PrivateKeyBytes, SymmetricCryptoKey, UnsignedSharedKey,
65
};
76

87
/// Device Key
@@ -66,8 +65,7 @@ impl DeviceKey {
6665
protected_user_key: UnsignedSharedKey,
6766
) -> Result<SymmetricCryptoKey> {
6867
let device_private_key: Vec<u8> = protected_device_private_key.decrypt_with_key(&self.0)?;
69-
let device_private_key: Bytes<Pkcs8PrivateKeyDerContentFormat> =
70-
Bytes::from(device_private_key);
68+
let device_private_key: Pkcs8PrivateKeyBytes = Bytes::from(device_private_key);
7169
let device_private_key = AsymmetricCryptoKey::from_der(&device_private_key)?;
7270

7371
let user_key: SymmetricCryptoKey =
@@ -91,7 +89,7 @@ impl TryFrom<String> for DeviceKey {
9189
#[cfg(test)]
9290
mod tests {
9391
use super::*;
94-
use crate::{derive_symmetric_key, BitwardenLegacyKeyContentFormat};
92+
use crate::{derive_symmetric_key, BitwardenLegacyKeyBytes, BitwardenLegacyKeyContentFormat};
9593

9694
#[test]
9795
fn test_trust_device() {
@@ -121,8 +119,7 @@ mod tests {
121119
218, 106, 89, 254, 208, 251, 101, 130, 10,
122120
];
123121
let user_key =
124-
SymmetricCryptoKey::try_from(&Bytes::<BitwardenLegacyKeyContentFormat>::from(user_key))
125-
.unwrap();
122+
SymmetricCryptoKey::try_from(&BitwardenLegacyKeyBytes::from(user_key)).unwrap();
126123

127124
let key_data: &[u8] = &[
128125
114, 235, 60, 115, 172, 156, 203, 145, 195, 130, 215, 250, 88, 146, 215, 230, 12, 109,
@@ -131,8 +128,7 @@ mod tests {
131128
8, 247, 7, 203, 201, 65, 147, 206, 247,
132129
];
133130
let device_key = DeviceKey(
134-
SymmetricCryptoKey::try_from(&Bytes::<BitwardenLegacyKeyContentFormat>::from(key_data))
135-
.unwrap(),
131+
SymmetricCryptoKey::try_from(&BitwardenLegacyKeyBytes::from(key_data)).unwrap(),
136132
);
137133

138134
let protected_user_key: UnsignedSharedKey = "4.f+VbbacRhO2q4MOUSdt1AIjQ2FuLAvg4aDxJMXAh3VxvbmUADj8Ct/R7XEpPUqApmbRS566jS0eRVy8Sk08ogoCdj1IFN9VsIky2i2X1WHK1fUnr3UBmXE3tl2NPBbx56U+h73S2jNTSyet2W18Jg2q7/w8KIhR3J41QrG9aGoOTN93to3hb5W4z6rdrSI0e7GkizbwcIA0NH7Z1JyAhrjPm9+tjRjg060YbEbGaWTAOkZWfgbLjr8bY455DteO2xxG139cOx7EBo66N+YhjsLi0ozkeUyPQkoWBdKMcQllS7jCfB4fDyJA05ALTbk74syKkvqFxqwmQbg+aVn+dcw==".parse().unwrap();

crates/bitwarden-crypto/src/keys/master_key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use super::{
1212
};
1313
use crate::{
1414
util::{self},
15-
BitwardenLegacyKeyContentFormat, Bytes, CryptoError, EncString, KeyDecryptable, Result,
16-
SymmetricCryptoKey, UserKey,
15+
BitwardenLegacyKeyBytes, CryptoError, EncString, KeyDecryptable, Result, SymmetricCryptoKey,
16+
UserKey,
1717
};
1818

1919
#[allow(missing_docs)]
@@ -160,7 +160,7 @@ pub(super) fn decrypt_user_key(
160160
}
161161
};
162162

163-
SymmetricCryptoKey::try_from(&Bytes::<BitwardenLegacyKeyContentFormat>::from(dec))
163+
SymmetricCryptoKey::try_from(&BitwardenLegacyKeyBytes::from(dec))
164164
}
165165

166166
/// Generate a new random user key and encrypt it with the master key.

0 commit comments

Comments
 (0)