pub struct DetachedVerifier<'a, H>where
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§
Source§impl<'a, H> DetachedVerifier<'a, H>where
H: VerificationHelper,
impl<'a, H> DetachedVerifier<'a, H>where
H: VerificationHelper,
Sourcepub fn verify_buffered_reader<R>(&mut self, reader: R) -> Result<(), Error>where
R: BufferedReader<Cookie>,
pub fn verify_buffered_reader<R>(&mut self, reader: R) -> Result<(), Error>where
R: BufferedReader<Cookie>,
Verifies the given data.
Sourcepub fn verify_reader<R>(&mut self, reader: R) -> Result<(), Error>
pub fn verify_reader<R>(&mut self, reader: R) -> Result<(), Error>
Verifies the given data.
Sourcepub fn verify_file<P>(&mut self, path: P) -> Result<(), Error>
pub fn verify_file<P>(&mut self, path: P) -> Result<(), Error>
Verifies the given data.
Sourcepub fn verify_bytes<B>(&mut self, buf: B) -> Result<(), Error>
pub fn verify_bytes<B>(&mut self, buf: B) -> Result<(), Error>
Verifies the given data.
Sourcepub fn helper_ref(&self) -> &H
pub fn helper_ref(&self) -> &H
Returns a reference to the helper.
Sourcepub fn helper_mut(&mut self) -> &mut H
pub fn helper_mut(&mut self) -> &mut H
Returns a mutable reference to the helper.
Sourcepub fn into_helper(self) -> H
pub fn into_helper(self) -> H
Recovers the helper.
Auto Trait Implementations§
impl<'a, H> !Freeze for DetachedVerifier<'a, H>
impl<'a, H> !RefUnwindSafe for DetachedVerifier<'a, H>
impl<'a, H> !UnwindSafe for DetachedVerifier<'a, H>
impl<'a, H> Send for DetachedVerifier<'a, H>
impl<'a, H> Sync for DetachedVerifier<'a, H>
impl<'a, H> Unpin for DetachedVerifier<'a, H>
impl<'a, H> UnsafeUnpin for DetachedVerifier<'a, H>where
Decryptor<'a, NoDecryptionHelper<H>>: UnsafeUnpin,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more