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:
- V3 PKESK are used in combination with version 1 Symmetrically Encrypted and Integrity Protected Data Packets.
- V6 PKESK are used in combination with version 2 Symmetrically Encrypted and Integrity Protected Data Packets.
Variants§
Implementations§
Source§impl PublicKeyEncryptedSessionKey
impl PublicKeyEncryptedSessionKey
Sourcepub fn from_slice(version: Version, input: &[u8]) -> Result<Self>
pub fn from_slice(version: Version, input: &[u8]) -> Result<Self>
Parses a PublicKeyEncryptedSessionKey
packet from the given slice.
Sourcepub fn from_session_key_v3<R: CryptoRng + Rng>(
rng: R,
session_key: &[u8],
alg: SymmetricKeyAlgorithm,
pkey: &impl PublicKeyTrait,
) -> Result<Self>
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.
Sourcepub fn from_session_key_v6<R: CryptoRng + Rng>(
rng: R,
session_key: &[u8],
pkey: &impl PublicKeyTrait,
) -> Result<Self>
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.
Sourcepub fn match_identity(&self, pkey: &impl PublicKeyTrait) -> bool
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 ofpkey
?
Sourcepub fn id(&self) -> Result<&KeyId>
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
Sourcepub fn fingerprint(&self) -> Result<Option<&Fingerprint>>
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
Sourcepub fn values(&self) -> Result<&PkeskBytes>
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.
Sourcepub fn algorithm(&self) -> Result<PublicKeyAlgorithm>
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”).
Sourcepub fn version(&self) -> PkeskVersion
pub fn version(&self) -> PkeskVersion
The version of this PKESK (currently “3” and “6” are expected values)
Trait Implementations§
Source§impl Clone for PublicKeyEncryptedSessionKey
impl Clone for PublicKeyEncryptedSessionKey
Source§fn clone(&self) -> PublicKeyEncryptedSessionKey
fn clone(&self) -> PublicKeyEncryptedSessionKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PublicKeyEncryptedSessionKey
impl Debug for PublicKeyEncryptedSessionKey
Source§impl From<PublicKeyEncryptedSessionKey> for Esk
impl From<PublicKeyEncryptedSessionKey> for Esk
Source§fn from(other: PublicKeyEncryptedSessionKey) -> Esk
fn from(other: PublicKeyEncryptedSessionKey) -> Esk
Source§impl From<PublicKeyEncryptedSessionKey> for Packet
impl From<PublicKeyEncryptedSessionKey> for Packet
Source§fn from(other: PublicKeyEncryptedSessionKey) -> Packet
fn from(other: PublicKeyEncryptedSessionKey) -> Packet
Source§impl PartialEq for PublicKeyEncryptedSessionKey
impl PartialEq for PublicKeyEncryptedSessionKey
Source§fn eq(&self, other: &PublicKeyEncryptedSessionKey) -> bool
fn eq(&self, other: &PublicKeyEncryptedSessionKey) -> bool
self
and other
values to be equal, and is used by ==
.