From 12528fcaf99763fc25df694d31208a6fa729d0a3 Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Fri, 19 Dec 2025 19:50:04 +0300 Subject: Working on make autobuild more modular --- src/openpgp/mod.rs | 2 +- src/openpgp/signatures.rs | 1 + src/openpgp/trusted.rs | 34 ++++++++++++++++++++++------------ 3 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src/openpgp') diff --git a/src/openpgp/mod.rs b/src/openpgp/mod.rs index 79c020a..df23ae8 100644 --- a/src/openpgp/mod.rs +++ b/src/openpgp/mod.rs @@ -1,2 +1,2 @@ pub mod signatures; -pub mod trusted; \ No newline at end of file +pub mod trusted; diff --git a/src/openpgp/signatures.rs b/src/openpgp/signatures.rs index e69de29..74bbe86 100644 --- a/src/openpgp/signatures.rs +++ b/src/openpgp/signatures.rs @@ -0,0 +1 @@ +// Worker with signs-db 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; - fn check_sign(&self, sig_path: &Path, context: &Context, file: &Path) -> Result; + fn check_sign( + &self, + sig_path: &Path, + context: &Context, + file: &Path, + ) -> Result; } 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 { + fn check_sign( + &self, + sig_path: &Path, + context: &Context, + file: &Path, + ) -> Result { 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 +} -- cgit v1.2.3