pub struct DataLockboxRef(/* private fields */);
Expand description
General encrypted data.
This must be decrypted by the matching recipient, which will return a Vec<u8>
on success.
It can either be decrypted on its own or through a Vault. In both cases, the data is returned
without being stored anywhere.
This is only a reference to an encrypted payload. The owned version is DataLockbox
.
See: StreamKey::decrypt_data
,
LockKey::decrypt_data
, and
Vault::decrypt_data
.
§Example
Using a StreamKey
for decryption:
// We have `enc`, a byte vector containing a lockbox
let dec_lockbox: &DataLockboxRef = DataLockboxRef::from_bytes(&enc[..])?;
let recipient: LockboxRecipient = dec_lockbox.recipient();
// ...
// Retrieve the key by looking up recipient
// ...
let plaintext: Vec<u8> = key.decrypt_data(&dec_lockbox)?;
Implementations§
Source§impl DataLockboxRef
impl DataLockboxRef
Sourcepub fn as_parts(&self) -> LockboxParts<'_>
pub fn as_parts(&self) -> LockboxParts<'_>
Decompose the lockbox into its component parts.
Sourcepub fn recipient(&self) -> LockboxRecipient
pub fn recipient(&self) -> LockboxRecipient
Get the target recipient who can decrypt this.
pub fn from_bytes(buf: &[u8]) -> Result<&Self, CryptoError>
Trait Implementations§
Source§impl Borrow<DataLockboxRef> for DataLockbox
impl Borrow<DataLockboxRef> for DataLockbox
Source§fn borrow(&self) -> &DataLockboxRef
fn borrow(&self) -> &DataLockboxRef
Immutably borrows from an owned value. Read more
Source§impl Debug for DataLockboxRef
impl Debug for DataLockboxRef
Source§impl<'de: 'a, 'a> Deserialize<'de> for &'a DataLockboxRef
impl<'de: 'a, 'a> Deserialize<'de> for &'a DataLockboxRef
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 Hash for DataLockboxRef
impl Hash for DataLockboxRef
Source§impl PartialEq for DataLockboxRef
impl PartialEq for DataLockboxRef
Source§impl Serialize for DataLockboxRef
impl Serialize for DataLockboxRef
Source§impl ToOwned for DataLockboxRef
impl ToOwned for DataLockboxRef
Source§type Owned = DataLockbox
type Owned = DataLockbox
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more