Struct sequoia_openpgp::crypto::SessionKey [−][src]
pub struct SessionKey(_);Expand description
Holds a session key.
The session key is cleared when dropped. Sequoia uses this type to ensure that session keys are not left in memory returned to the allocator.
Session keys can be generated using SessionKey::new, or
converted from various types using From.
Implementations
Creates a new session key.
Creates a new session key size bytes in length initialized
using a strong cryptographic number generator.
Examples
This creates a session key and encrypts it for a given
recipient key producing a PKESK packet.
use sequoia_openpgp as openpgp;
use openpgp::types::{Curve, SymmetricAlgorithm};
use openpgp::crypto::SessionKey;
use openpgp::packet::prelude::*;
let cipher = SymmetricAlgorithm::AES256;
let sk = SessionKey::new(cipher.key_size().unwrap());
let key: Key<key::SecretParts, key::UnspecifiedRole> =
Key4::generate_ecc(false, Curve::Cv25519)?.into();
let pkesk: PKESK =
PKESK3::for_recipient(cipher, &sk, &key)?.into();Trait Implementations
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl RefUnwindSafe for SessionKey
impl Send for SessionKey
impl Sync for SessionKey
impl Unpin for SessionKey
impl UnwindSafe for SessionKey
Blanket Implementations
Mutably borrows from an owned value. Read more