diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-28 11:19:27 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-28 11:19:27 +0100 |
commit | d97a6a10067bfc7e7fc95bc280d7cec400dc0615 (patch) | |
tree | 8dd6229577755037504560865e743ad63cfab458 /sq/src/commands/mod.rs | |
parent | 3b548e7a1bccde28dde3d4bbd59ccc2bd470db5c (diff) |
sq: Copy policy into struct Config.
Diffstat (limited to 'sq/src/commands/mod.rs')
-rw-r--r-- | sq/src/commands/mod.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sq/src/commands/mod.rs b/sq/src/commands/mod.rs index 7becf237..ca0e03e7 100644 --- a/sq/src/commands/mod.rs +++ b/sq/src/commands/mod.rs @@ -205,9 +205,9 @@ pub fn encrypt<'a>(policy: &'a dyn Policy, Ok(()) } -struct VHelper { +struct VHelper<'a> { #[allow(dead_code)] - config: Config, + config: Config<'a>, signatures: usize, certs: Option<Vec<Cert>>, labels: HashMap<KeyID, String>, @@ -220,12 +220,12 @@ struct VHelper { broken_signatures: usize, } -impl VHelper { - fn new(config: Config, signatures: usize, +impl<'a> VHelper<'a> { + fn new(config: &Config<'a>, signatures: usize, certs: Vec<Cert>) -> Self { VHelper { - config, + config: config.clone(), signatures: signatures, certs: Some(certs), labels: HashMap::new(), @@ -331,7 +331,7 @@ impl VHelper { } } -impl VerificationHelper for VHelper { +impl<'a> VerificationHelper for VHelper<'a> { fn get_certs(&mut self, _ids: &[openpgp::KeyHandle]) -> Result<Vec<Cert>> { let certs = self.certs.take().unwrap(); // Get all keys. @@ -373,21 +373,21 @@ impl VerificationHelper for VHelper { } } -pub fn verify(config: Config, policy: &dyn Policy, +pub fn verify(config: Config, input: &mut (dyn io::Read + Sync + Send), detached: Option<&mut (dyn io::Read + Sync + Send)>, output: &mut dyn io::Write, signatures: usize, certs: Vec<Cert>) -> Result<()> { - let helper = VHelper::new(config, signatures, certs); + let helper = VHelper::new(&config, signatures, certs); let helper = if let Some(dsig) = detached { let mut v = DetachedVerifierBuilder::from_reader(dsig)? - .with_policy(policy, None, helper)?; + .with_policy(&config.policy, None, helper)?; v.verify_reader(input)?; v.into_helper() } else { let mut v = VerifierBuilder::from_reader(input)? - .with_policy(policy, None, helper)?; + .with_policy(&config.policy, None, helper)?; io::copy(&mut v, output)?; v.into_helper() }; |