[][src]Struct sequoia_openpgp::crypto::SessionKey

pub struct SessionKey(_);

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.


impl SessionKey[src]

pub fn new(size: usize) -> Self[src]

Creates a new session key.

Creates a new session key size bytes in length initialized using a strong cryptographic number generator.


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

impl AsMut<[u8]> for SessionKey[src]

impl AsRef<[u8]> for SessionKey[src]

impl Clone for SessionKey[src]

impl Debug for SessionKey[src]

impl Deref for SessionKey[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for SessionKey[src]

impl Eq for SessionKey[src]

impl<'_> From<&'_ [u8]> for SessionKey[src]

impl From<Box<[u8]>> for SessionKey[src]

impl From<Protected> for SessionKey[src]

impl From<Vec<u8>> for SessionKey[src]

impl PartialEq<SessionKey> for SessionKey[src]

impl StructuralEq for SessionKey[src]

impl StructuralPartialEq for SessionKey[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> DynClone for T where
    T: Clone

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.