pub struct BackupDecryptor<'a> {
pub(crate) backup: &'a Backup,
pub(crate) cipher: Aes256Gcm,
}
Expand description
Backup decryptor which decrypts backup items on the fly.
Fields§
§backup: &'a Backup
§cipher: Aes256Gcm
Implementations§
source§impl<'a> BackupDecryptor<'a>
impl<'a> BackupDecryptor<'a>
sourcepub(crate) fn new(backup: &'a Backup, passphrase: &[u8]) -> Result<Self>
pub(crate) fn new(backup: &'a Backup, passphrase: &[u8]) -> Result<Self>
Create a new BackupDecryptor
using a Backup
and a passphrase.
§Errors
Even though this function returns a Result
it is unlikely to fail since all parameters are
static.
sourcepub(crate) fn decrypt(&self, ciphertext: &[u8], aad: &[u8]) -> Result<Vec<u8>>
pub(crate) fn decrypt(&self, ciphertext: &[u8], aad: &[u8]) -> Result<Vec<u8>>
Decrypts ciphertext
while verifying additional data (aad
).
§Errors
Returns:
- Error::Decryption if a decryption error is encountered, for example the ciphertext is of incorrect length, has been tampered with, the decryption passphrase is wrong or the additional authenticated data is incorrect.
sourcepub fn version(&self) -> Result<Vec<u8>>
pub fn version(&self) -> Result<Vec<u8>>
Decrypted backup version.
§Errors
Returns:
- Error::Decryption if a decryption error is encountered, for example the encrypted version is of incorrect length, has been tampered with, the decryption passphrase is wrong or the additional authenticated data is incorrect (e.g. a different encrypted piece of data is impersonating the backup version).
sourcepub fn domain_key(&self) -> Result<Vec<u8>>
pub fn domain_key(&self) -> Result<Vec<u8>>
Decrypted domain key.
§Errors
Returns:
- Error::Decryption if a decryption error is encountered, for example the encrypted domain key is of incorrect length, has been tampered with, the decryption passphrase is wrong or the additional authenticated data is incorrect (e.g. a different encrypted piece of data is impersonating the domain key).
sourcepub fn items_iter(
&'a self,
) -> impl Iterator<Item = Result<(String, Vec<u8>)>> + 'a
pub fn items_iter( &'a self, ) -> impl Iterator<Item = Result<(String, Vec<u8>)>> + 'a
Returns an iterator over backup entries.
The entries are pairs of keys (which are strings) and values (byte vectors).
Since the entries are decrypted as they are being read the pairs are wrapped in
Result
s.
§Errors
This function does not fail but reading the inner iterator may return errors:
- Error::Decryption if a decryption error is encountered, for example the encrypted entry is of incorrect length, has been tampered with, the decryption passphrase is wrong or the additional authenticated data is incorrect (e.g. a different encrypted piece of data is impersonating the backup entry).
- Error::Utf8 if the entry’s key is not a well-formed UTF-8 string.
Auto Trait Implementations§
impl<'a> Freeze for BackupDecryptor<'a>
impl<'a> RefUnwindSafe for BackupDecryptor<'a>
impl<'a> Send for BackupDecryptor<'a>
impl<'a> Sync for BackupDecryptor<'a>
impl<'a> Unpin for BackupDecryptor<'a>
impl<'a> UnwindSafe for BackupDecryptor<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more