Skip to content

Commit

Permalink
Change attachment key to EncString (#449)
Browse files Browse the repository at this point in the history
## Type of change
```
- [x] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other
```

## Objective
Change `AttachmentView` key to be an `EncString`, and skip decrypting
it. This is to avoid a uniffi issue with the representation of Vec<u8>
on Android.

Note that this is very similar to what we're doing with Sends, where we
don't decrypt the key on the model either until we're ready to decrypt
the file.
  • Loading branch information
dani-garcia authored Dec 19, 2023
1 parent 9d4ec76 commit f3d200f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/bitwarden/src/vault/cipher/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct AttachmentView {
pub size: Option<String>,
pub size_name: Option<String>,
pub file_name: Option<String>,
pub key: Option<Vec<u8>>, // TODO: Should be made into SymmetricCryptoKey
pub key: Option<EncString>,
}

impl KeyEncryptable<Attachment> for AttachmentView {
Expand All @@ -39,7 +39,7 @@ impl KeyEncryptable<Attachment> for AttachmentView {
size: self.size,
size_name: self.size_name,
file_name: self.file_name.encrypt_with_key(key)?,
key: self.key.as_deref().encrypt_with_key(key)?,
key: self.key,
})
}
}
Expand All @@ -52,7 +52,7 @@ impl KeyDecryptable<AttachmentView> for Attachment {
size: self.size.clone(),
size_name: self.size_name.clone(),
file_name: self.file_name.decrypt_with_key(key)?,
key: self.key.decrypt_with_key(key)?,
key: self.key.clone(),
})
}
}
Expand Down

0 comments on commit f3d200f

Please sign in to comment.