Enum PublicKeyEncryptedSessionKey

Source
pub enum PublicKeyEncryptedSessionKey {
    V3 {
        packet_version: Version,
        id: KeyId,
        pk_algo: PublicKeyAlgorithm,
        values: PkeskBytes,
    },
    V6 {
        packet_version: Version,
        fingerprint: Option<Fingerprint>,
        pk_algo: PublicKeyAlgorithm,
        values: PkeskBytes,
    },
    Other {
        packet_version: Version,
        version: u8,
    },
}
Expand description

Public Key Encrypted Session Key Packet (PKESK) https://www.rfc-editor.org/rfc/rfc9580.html#name-public-key-encrypted-sessio

A PKESK contains an encrypted session key that has been encrypted to a specific public key. PKESK are used in combination with a symmetric encryption container:

Variants§

§

V3

Fields

§packet_version: Version
§values: PkeskBytes
§

V6

Fields

§packet_version: Version
§fingerprint: Option<Fingerprint>
§values: PkeskBytes
§

Other

Fields

§packet_version: Version
§version: u8

Implementations§

Source§

impl PublicKeyEncryptedSessionKey

Source

pub fn from_slice(version: Version, input: &[u8]) -> Result<Self>

Parses a PublicKeyEncryptedSessionKey packet from the given slice.

Source

pub fn from_session_key_v3<R: CryptoRng + Rng>( rng: R, session_key: &[u8], alg: SymmetricKeyAlgorithm, pkey: &impl PublicKeyTrait, ) -> Result<Self>

Encrypts the given session key to pkey as a v3 pkesk.

Source

pub fn from_session_key_v6<R: CryptoRng + Rng>( rng: R, session_key: &[u8], pkey: &impl PublicKeyTrait, ) -> Result<Self>

Encrypts the given session key to pkey as a v6 pkesk.

Source

pub fn match_identity(&self, pkey: &impl PublicKeyTrait) -> bool

Check if a Key matches with this PKESK’s target

  • for v3: is PKESK key id the wildcard, or does it match the key id of pkey?
  • for v6: is PKESK fingerprint the wildcard (represented as None), or does it match the fingerprint of pkey?
Source

pub fn id(&self) -> Result<&KeyId>

The Key ID in this PKESK. Only available for v3 PKESK (the function returns an Error for v6 PKESK).

The Key ID may consist of all Zero-Bytes (if the PKESK was created for an anonymous recipient).

See https://www.rfc-editor.org/rfc/rfc9580.html#section-5.1.1-3.2

Source

pub fn fingerprint(&self) -> Result<Option<&Fingerprint>>

The Fingerprint in this PKESK. Only available for v6 PKESK (the function returns an Error for v3 PKESK).

Additionally, the Fingerprint may be None (if the PKESK was created for an anonymous recipient).

See https://www.rfc-editor.org/rfc/rfc9580.html#section-5.1.2-3.2

Source

pub fn values(&self) -> Result<&PkeskBytes>

The raw encrypted session key data inside this PKESK. This data is algorithm specific.

See https://www.rfc-editor.org/rfc/rfc9580.html#name-algorithm-specific-fields-f and the following sections.

Source

pub fn algorithm(&self) -> Result<PublicKeyAlgorithm>

The public key algorithm used in this PKESK.

An error is returned for unsupported PKESK versions (any version except “3” and “6”).

Source

pub fn version(&self) -> PkeskVersion

The version of this PKESK (currently “3” and “6” are expected values)

Trait Implementations§

Source§

impl Clone for PublicKeyEncryptedSessionKey

Source§

fn clone(&self) -> PublicKeyEncryptedSessionKey

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PublicKeyEncryptedSessionKey

Source§

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

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

impl From<PublicKeyEncryptedSessionKey> for Esk

Source§

fn from(other: PublicKeyEncryptedSessionKey) -> Esk

Converts to this type from the input type.
Source§

impl From<PublicKeyEncryptedSessionKey> for Packet

Source§

fn from(other: PublicKeyEncryptedSessionKey) -> Packet

Converts to this type from the input type.
Source§

impl PacketTrait for PublicKeyEncryptedSessionKey

Source§

impl PartialEq for PublicKeyEncryptedSessionKey

Source§

fn eq(&self, other: &PublicKeyEncryptedSessionKey) -> 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 PublicKeyEncryptedSessionKey

Source§

fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

fn to_bytes(&self) -> Result<Vec<u8>>

Source§

impl TryFrom<Esk> for PublicKeyEncryptedSessionKey

Source§

type Error = Error

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

fn try_from(other: Esk) -> Result<PublicKeyEncryptedSessionKey, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Packet> for PublicKeyEncryptedSessionKey

Source§

type Error = Error

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

fn try_from(other: Packet) -> Result<PublicKeyEncryptedSessionKey, Self::Error>

Performs the conversion.
Source§

impl Eq for PublicKeyEncryptedSessionKey

Source§

impl StructuralPartialEq for PublicKeyEncryptedSessionKey

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V