Skip to main content

Decryptor

Struct Decryptor 

Source
pub struct Decryptor<'key, 'prompt> { /* private fields */ }
Expand description

A decryptor for a PKCS#11 key.

This implements sequoia_openpgp::crypto::Decryptor and hence can be used wherever a Sequoia method needs to decrypt data.

Implementations§

Source§

impl<'key, 'prompt> Decryptor<'key, 'prompt>

Source

pub fn new<P>( prompt: P, key: &'key Key, user_pin: Option<AuthPin>, composite_user_pin: Option<AuthPin>, ) -> Result<Self>
where P: Prompt + 'prompt,

Creates a Decryptor.

This is a bit ugly, because we can’t stash a PKCS#11 Session: a struct that implements Decryptor has to implement Sync, but a Session is not Sync.

If the user PIN is known, pass it through to avoid prompting the user. (If user_pin is wrong, we don’t prompt the user, but immediately return an error.) Otherwise, the user is prompted.

If the key is a composite key (e.g., ML-KEM-768+X25519, or ML-KEM-1024+X448), then composite_user_pin is the pin for the composite component. Like with the user PIN, if the composite user pin is needed and not specified, we prompt for the PIN.

Source

pub fn new_owned<P>( prompt: P, key: Key, user_pin: Option<AuthPin>, composite_user_pin: Option<AuthPin>, ) -> Result<Self>
where P: Prompt + 'prompt,

Creates a Decryptor.

Like Decryptor::new, but takes ownership of key.

Trait Implementations§

Source§

impl Decryptor for Decryptor<'_, '_>

Source§

fn public(&self) -> &Key<PublicParts, UnspecifiedRole>

Returns a reference to the public key.
Source§

fn decrypt( &mut self, ciphertext: &Ciphertext, plaintext_len: Option<usize>, ) -> Result<SessionKey>

Decrypts ciphertext, returning the plain session key.

Auto Trait Implementations§

§

impl<'key, 'prompt> !Freeze for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> !RefUnwindSafe for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> !UnwindSafe for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> Forget for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> Move for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> Send for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> Sync for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> Unpin for Decryptor<'key, 'prompt>

§

impl<'key, 'prompt> UnsafeUnpin for Decryptor<'key, 'prompt>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.