pub struct DetachedVerifier<'a, H: VerificationHelper> { /* private fields */ }
Expand description

Verifies a detached signature.

To create a DetachedVerifier, create a DetachedVerifierBuilder using Parse, and customize it to your needs.

See GoodChecksum for what it means for a signature to be considered valid. When the signature(s) are processed, VerificationHelper::check will be called with a MessageStructure containing exactly one layer, a signature group.

Examples

use std::io::{self, Read};
use sequoia_openpgp as openpgp;
use openpgp::{KeyHandle, Cert, Result};
use openpgp::parse::{Parse, stream::*};
use sequoia_openpgp::policy::StandardPolicy;

let p = &StandardPolicy::new();

// This fetches keys and computes the validity of the verification.
struct Helper {};
impl VerificationHelper for Helper {
    fn get_certs(&mut self, _ids: &[KeyHandle]) -> Result<Vec<Cert>> {
        Ok(Vec::new()) // Feed the Certs to the verifier here...
    }
    fn check(&mut self, structure: MessageStructure) -> Result<()> {
        Ok(()) // Implement your verification policy here.
    }
}

let signature =
   b"-----BEGIN PGP SIGNATURE-----

     wnUEABYKACcFglt+z/EWoQSOjDP6RiYzeXbZeXgGnAw0jdgsGQmQBpwMNI3YLBkA
     AHmUAP9mpj2wV0/ekDuzxZrPQ0bnobFVaxZGg7YzdlksSOERrwEA6v6czXQjKcv2
     KOwGTamb+ajTLQ3YRG9lh+ZYIXynvwE=
     =IJ29
     -----END PGP SIGNATURE-----";

let data = b"Hello World!";
let h = Helper {};
let mut v = DetachedVerifierBuilder::from_bytes(&signature[..])?
    .with_policy(p, None, h)?;
v.verify_bytes(data)?;

Implementations§

Verifies the given data.

Verifies the given data.

Verifies the given data.

Returns a reference to the helper.

Returns a mutable reference to the helper.

Recovers the helper.

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

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
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.