Skip to content

Commit

Permalink
Use &[u8] instead of vec
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jan 8, 2024
1 parent 879ff65 commit 192dac3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bitwarden/src/vault/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ impl Send {
enc_key: &SymmetricCryptoKey,
) -> Result<SymmetricCryptoKey> {
let key: Vec<u8> = send_key.decrypt_with_key(enc_key)?;
Self::derive_shareable_key(key)
Self::derive_shareable_key(&key)
}

fn derive_shareable_key(key: Vec<u8>) -> Result<SymmetricCryptoKey, Error> {
fn derive_shareable_key(key: &[u8]) -> Result<SymmetricCryptoKey, Error> {
let key = key.try_into().map_err(|_| CryptoError::InvalidKeyLen)?;
Ok(derive_shareable_key(key, "send", Some("send")))
}
Expand Down Expand Up @@ -191,7 +191,7 @@ impl KeyDecryptable<SendView> for Send {
// For sends, we first decrypt the send key with the user key, and stretch it to it's full size
// For the rest of the fields, we ignore the provided SymmetricCryptoKey and the stretched key
let k: Vec<u8> = self.key.decrypt_with_key(key)?;
let key = Send::derive_shareable_key(k.clone())?;
let key = Send::derive_shareable_key(&k)?;

Ok(SendView {
id: self.id,
Expand Down Expand Up @@ -248,7 +248,7 @@ impl KeyEncryptable<Send> for SendView {
let k = URL_SAFE_NO_PAD
.decode(self.key.ok_or(CryptoError::MissingKey)?)
.map_err(|_| CryptoError::InvalidKey)?;
let send_key = Send::derive_shareable_key(k.clone())?;
let send_key = Send::derive_shareable_key(&k)?;

Ok(Send {
id: self.id,
Expand Down

0 comments on commit 192dac3

Please sign in to comment.