pub struct Verifier { /* private fields */ }Expand description
Builder for verification operations.
§Examples
Basic verification:
use libsignify_rs::{KeyGenerator, Signer, Verifier};
use tempfile::tempdir;
use std::fs;
let dir = tempdir()?;
let pub_path = dir.path().join("key.pub");
let sec_path = dir.path().join("key.sec");
let msg_path = dir.path().join("msg.txt");
let sig_path = dir.path().join("msg.sig");
// Setup
KeyGenerator::new().rounds(0).generate(&pub_path, &sec_path)?;
fs::write(&msg_path, "test message")?;
Signer::new().seckey(&sec_path).sign(&msg_path, &sig_path)?;
// Verify
Verifier::new()
.pubkey(&pub_path)
.quiet(true)
.verify(&msg_path, &sig_path)?;Embedded verification:
// Sign with embed
Signer::new()
.seckey(&sec_path)
.embed(true)
.sign(&msg_path, &sig_path)?;
// Remove original message to verify extraction
fs::remove_file(&msg_path)?;
// Verify embedded
Verifier::new()
.pubkey(&pub_path)
.quiet(true)
.embed(true)
.verify(&msg_path, &sig_path)?;Gzip verification:
// Sign gzip
Signer::new()
.seckey(&sec_path)
.gzip(true)
.sign(&msg_path, &sig_path)?;
// Verify gzip
Verifier::new()
.pubkey(&pub_path)
.quiet(true)
.gzip(true)
.verify(&Path::new("-"), &sig_path)?; // Output to stdout (-) or fileHandling verification failures:
// Tamper with the message
fs::write(&msg_path, "tampered message")?;
// Verification should fail
let result = Verifier::new()
.pubkey(&pub_path)
.verify(&msg_path, &sig_path);
assert!(result.is_err());Implementations§
Source§impl Verifier
impl Verifier
Sourcepub fn quiet(self, quiet: bool) -> Self
pub fn quiet(self, quiet: bool) -> Self
Set quiet mode.
If true, suppresses “Signature Verified” output.
Sourcepub fn embed(self, embed: bool) -> Self
pub fn embed(self, embed: bool) -> Self
Set embed mode (signify -I).
Used when verifying an embedded signature.
Sourcepub fn gzip(self, gzip: bool) -> Self
pub fn gzip(self, gzip: bool) -> Self
Set gzip mode (signify -z).
Used when verifying a signed gzip archive.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Verifier
impl RefUnwindSafe for Verifier
impl Send for Verifier
impl Sync for Verifier
impl Unpin for Verifier
impl UnwindSafe for Verifier
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> 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