Skip to main content

Signer

Struct Signer 

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

A signer for a PKCS#11 key.

This implements sequoia_openpgp::crypto::Signer and hence can be used wherever a Sequoia method needs to create a signature.

Implementations§

Source§

impl<'key, 'prompt> Signer<'key, 'prompt>

Source

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

Creates a Signer.

This is a bit ugly, because we can’t stash a PKCS#11 Session: a struct that implements Signer 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.

Source

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

Creates a Signer.

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

Trait Implementations§

Source§

impl Signer for Signer<'_, '_>

Source§

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

Returns a reference to the public key.
Source§

fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) -> Result<Signature>

Creates a signature over the digest produced by hash_algo.
Source§

fn acceptable_hashes(&self) -> &[HashAlgorithm]

Returns a list of hashes that this signer accepts. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<'key, 'prompt> UnsafeUnpin for Signer<'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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.