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>
impl<'key, 'prompt> Decryptor<'key, 'prompt>
Sourcepub fn new<P>(
prompt: P,
key: &'key Key,
user_pin: Option<AuthPin>,
composite_user_pin: Option<AuthPin>,
) -> Result<Self>where
P: Prompt + 'prompt,
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.
Trait Implementations§
Source§impl Decryptor for Decryptor<'_, '_>
impl Decryptor for Decryptor<'_, '_>
Source§fn public(&self) -> &Key<PublicParts, UnspecifiedRole>
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more