diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-12-19 19:50:04 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-12-19 19:50:04 +0300 |
| commit | 12528fcaf99763fc25df694d31208a6fa729d0a3 (patch) | |
| tree | 9149551ac7b3675cb93fedf0987b5c76eb6ff197 /src/openpgp/trusted.rs | |
| parent | c5cdc8efd1d976f1ce53b124b9cbb33f6f2af097 (diff) | |
Working on make autobuild more modular
Diffstat (limited to 'src/openpgp/trusted.rs')
| -rw-r--r-- | src/openpgp/trusted.rs | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/openpgp/trusted.rs b/src/openpgp/trusted.rs index d2d77b6..003d522 100644 --- a/src/openpgp/trusted.rs +++ b/src/openpgp/trusted.rs @@ -1,18 +1,22 @@ -use gpgme::{Context, Key, Data}; -use std::path::Path; +use gpgme::{Context, Data, Key}; use std::fs::File; -use std::io::BufReader; - +use std::io::BufReader; +use std::path::Path; pub enum ScanResult { Trusted, Unsigned, - Untrusted + Untrusted, } pub trait OpenPGPOpertaions { fn get_trusted_keys(&self, keys: &[Key]) -> Vec<Key>; - fn check_sign(&self, sig_path: &Path, context: &Context, file: &Path) -> Result<ScanResult, gpgme::Error>; + fn check_sign( + &self, + sig_path: &Path, + context: &Context, + file: &Path, + ) -> Result<ScanResult, gpgme::Error>; } impl OpenPGPOpertaions for Key { @@ -25,15 +29,22 @@ impl OpenPGPOpertaions for Key { } trusted_keys } - fn check_sign(&self, sig_path: &Path, context: &Context, file: &Path) -> Result<ScanResult, gpgme::Error> { + fn check_sign( + &self, + sig_path: &Path, + context: &Context, + file: &Path, + ) -> Result<ScanResult, gpgme::Error> { let mut ctx = Context::from_protocol(gpgme::Protocol::OpenPgp)?; let file_reader = BufReader::new(File::open(file)?); let sig_reader = BufReader::new(File::open(sig_path)?); - let sig_data = Data::from_reader(sig_reader).map_err(|e| gpgme::Error::from(std::io::Error::other(e)))?; - let file_data = Data::from_reader(file_reader).map_err(|e| gpgme::Error::from(std::io::Error::other(e)))?; + let sig_data = Data::from_reader(sig_reader) + .map_err(|e| gpgme::Error::from(std::io::Error::other(e)))?; + let file_data = Data::from_reader(file_reader) + .map_err(|e| gpgme::Error::from(std::io::Error::other(e)))?; - let result = ctx.verify_detached(sig_data, file_data); + let result = ctx.verify_detached(sig_data, file_data); if result.is_ok() { Ok(ScanResult::Trusted) @@ -41,5 +52,4 @@ impl OpenPGPOpertaions for Key { Ok(ScanResult::Unsigned) } } - -}
\ No newline at end of file +} |
