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

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.