Struct IdentityLockboxRef

Source
pub struct IdentityLockboxRef(/* private fields */);
Expand description

An encrypted IdentityKey.

This must be decrypted by the matching recipient, which will return the IdentityKey on success. It can either be decrypted on its own, returning a temporary IdentityKey, or through a Vault, which will store the IdentityKey.

This is only a reference to an encrypted payload. The owned version is IdentityLockbox.

See: StreamKey::decrypt_identity_key, LockKey::decrypt_identity_key, and Vault::decrypt_identity_key.

§Example

Using a StreamKey for decryption:

// We have `enc`, a byte vector containing a lockbox
let dec_lockbox: &IdentityLockboxRef = IdentityLockboxRef::from_bytes(&enc[..])?;
let recipient: LockboxRecipient = dec_lockbox.recipient();
// ...
// Retrieve the key by looking up recipient
// ...
let dec_key: IdentityKey = key.decrypt_identity_key(&dec_lockbox)?;

Implementations§

Source§

impl IdentityLockboxRef

Source

pub fn as_parts(&self) -> LockboxParts<'_>

Decompose the lockbox into its component parts.

Source

pub fn version(&self) -> u8

Get the stream encryption version.

Source

pub fn recipient(&self) -> LockboxRecipient

Get the target recipient who can decrypt this.

Source

pub fn as_bytes(&self) -> &[u8]

The raw bytestream, suitable for serialization.

Source

pub fn from_bytes(buf: &[u8]) -> Result<&IdentityLockboxRef, CryptoError>

Trait Implementations§

Source§

impl Borrow<IdentityLockboxRef> for IdentityLockbox

Source§

fn borrow(&self) -> &IdentityLockboxRef

Immutably borrows from an owned value. Read more
Source§

impl Debug for IdentityLockboxRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de, 'a> Deserialize<'de> for &'a IdentityLockboxRef
where 'de: 'a,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<&'a IdentityLockboxRef, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> From<&'a IdentityLockboxRef> for ValueRef<'a>

Source§

fn from(v: &'a IdentityLockboxRef) -> Self

Converts to this type from the input type.
Source§

impl Hash for IdentityLockboxRef

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for IdentityLockboxRef

Source§

fn eq(&self, other: &IdentityLockboxRef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for IdentityLockboxRef

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToOwned for IdentityLockboxRef

Source§

type Owned = IdentityLockbox

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> <IdentityLockboxRef as ToOwned>::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<'a> TryFrom<ValueRef<'a>> for &'a IdentityLockboxRef

Source§

type Error = ValueRef<'a>

The type returned in the event of a conversion error.
Source§

fn try_from(v: ValueRef<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for IdentityLockboxRef

Source§

impl StructuralPartialEq for IdentityLockboxRef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more