pub struct CipherText<'a> { /* private fields */ }Expand description
An encrypted plaintext, with associated data
This structure contains the payload, encrypted with XChaCha20, the nonce that was used to encrypt
it, as well as the HMAC of the encrypted payload. It also includes a flag indicating whether or not
to treat the plaintext as compressed
Implementations§
Source§impl CipherText<'_>
impl CipherText<'_>
Sourcepub fn decrypt<K>(&self, key: &K) -> Result<ClearText, BackendError>where
K: Key,
pub fn decrypt<K>(&self, key: &K) -> Result<ClearText, BackendError>where
K: Key,
Attempts to decrypt the Ciphertext with the given key, turning it into a Cleartext. This will
also decompress the payload, if it was compressed.
§Errors
Will return:
Error::BadHMAC- If the hmac tag fails to validate (decryption failure)Error::Decompression- If compressed data fails to decompress
Sourcepub fn compressed(&self) -> bool
pub fn compressed(&self) -> bool
Returns true if this CipherText is compressed
Trait Implementations§
Source§impl<'a> Clone for CipherText<'a>
impl<'a> Clone for CipherText<'a>
Source§fn clone(&self) -> CipherText<'a>
fn clone(&self) -> CipherText<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for CipherText<'a>
impl<'a> Debug for CipherText<'a>
Source§impl<'de, 'a> Deserialize<'de> for CipherText<'a>
impl<'de, 'a> Deserialize<'de> for CipherText<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> Hash for CipherText<'a>
impl<'a> Hash for CipherText<'a>
Source§impl<'a> Ord for CipherText<'a>
impl<'a> Ord for CipherText<'a>
Source§fn cmp(&self, other: &CipherText<'a>) -> Ordering
fn cmp(&self, other: &CipherText<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialEq for CipherText<'a>
impl<'a> PartialEq for CipherText<'a>
Source§impl<'a> PartialOrd for CipherText<'a>
impl<'a> PartialOrd for CipherText<'a>
Source§impl<'a> Serialize for CipherText<'a>
impl<'a> Serialize for CipherText<'a>
impl<'a> Eq for CipherText<'a>
impl<'a> StructuralPartialEq for CipherText<'a>
Auto Trait Implementations§
impl<'a> Freeze for CipherText<'a>
impl<'a> RefUnwindSafe for CipherText<'a>
impl<'a> Send for CipherText<'a>
impl<'a> Sync for CipherText<'a>
impl<'a> Unpin for CipherText<'a>
impl<'a> UnwindSafe for CipherText<'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