summaryrefslogtreecommitdiff
path: root/src/openpgp
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-12-19 19:50:04 +0300
committerNamilskyy <alive6863@gmail.com>2025-12-19 19:50:04 +0300
commit12528fcaf99763fc25df694d31208a6fa729d0a3 (patch)
tree9149551ac7b3675cb93fedf0987b5c76eb6ff197 /src/openpgp
parentc5cdc8efd1d976f1ce53b124b9cbb33f6f2af097 (diff)
Working on make autobuild more modular
Diffstat (limited to 'src/openpgp')
-rw-r--r--src/openpgp/mod.rs2
-rw-r--r--src/openpgp/signatures.rs1
-rw-r--r--src/openpgp/trusted.rs34
3 files changed, 24 insertions, 13 deletions
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<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
+}