[][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.

Implementations

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.

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

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
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.