Trait sequoia_openpgp::crypto::Signer

source ·
pub trait Signer {
    // Required methods
    fn public(&self) -> &Key<PublicParts, UnspecifiedRole>;
    fn sign(
        &mut self,
        hash_algo: HashAlgorithm,
        digest: &[u8]
    ) -> Result<Signature>;

    // Provided method
    fn acceptable_hashes(&self) -> &[HashAlgorithm] { ... }
}
Expand description

Creates a signature.

Used in the streaming Signer, the methods binding components to certificates (e.g. UserID::bind), SignatureBuilder’s signing functions (e.g. SignatureBuilder::sign_standalone), and likely many more places.

This is a low-level mechanism to produce an arbitrary OpenPGP signature. Using this trait allows Sequoia to perform all operations involving signing to use a variety of secret key storage mechanisms (e.g. smart cards).

A signer consists of the public key and a way of creating a signature. This crate implements Signer for KeyPair, which is a tuple containing the public and unencrypted secret key in memory. Other crates may provide their own implementations of Signer to utilize keys stored in various places. Currently, the following implementations exist:

Required Methods§

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.

Provided Methods§

source

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

Returns a list of hashes that this signer accepts.

Some cryptographic libraries or hardware modules support signing digests produced with only a limited set of hashing algorithms. This function indicates to callers which algorithm digests are supported by this signer.

The default implementation of this function allows all hash algorithms to be used. Provide an explicit implementation only when a smaller subset of hashing algorithms is valid for this Signer implementation.

Trait Implementations§

source§

impl Signer for Box<dyn Signer>

source§

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

Returns a reference to the public key.
source§

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

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

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

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

impl Signer for Box<dyn Signer + Send + Sync>

source§

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

Returns a reference to the public key.
source§

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

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

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

Creates a signature over the digest produced by hash_algo.

Implementations on Foreign Types§

source§

impl Signer for Box<dyn Signer + Send + Sync>

source§

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

source§

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

source§

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

source§

impl Signer for Box<dyn Signer>

source§

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

source§

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

source§

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

Implementors§