diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-21 13:02:06 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-21 13:26:32 +0200 |
commit | 367623a430f7a02186c3b0031ef26815befe4023 (patch) | |
tree | 918ff06f59f02d71b61dd6cb6d7359c0d33c9ded /tool/src/commands | |
parent | 004e65b7e0fc324a325fe23480dc2abd95ecedd7 (diff) |
sq: Rework recipient handling.
Diffstat (limited to 'tool/src/commands')
-rw-r--r-- | tool/src/commands/mod.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs index fa8ed857..a2c2e8cb 100644 --- a/tool/src/commands/mod.rs +++ b/tool/src/commands/mod.rs @@ -86,16 +86,12 @@ fn get_signing_keys(certs: &[openpgp::Cert], p: &dyn Policy, } pub fn encrypt(policy: &dyn Policy, - mapping: &mut store::Mapping, input: &mut dyn io::Read, output: &mut dyn io::Write, - npasswords: usize, recipients: Vec<&str>, - mut certs: Vec<openpgp::Cert>, signers: Vec<openpgp::Cert>, + npasswords: usize, recipients: &[openpgp::Cert], + signers: Vec<openpgp::Cert>, mode: openpgp::types::KeyFlags, compression: &str, time: Option<SystemTime>) -> Result<()> { - for r in recipients { - certs.push(mapping.lookup(r).context("No such key found")?.cert()?); - } let mut passwords: Vec<crypto::Password> = Vec::with_capacity(npasswords); for n in 0..npasswords { let nprompt = format!("Enter password {}: ", n + 1); @@ -107,19 +103,16 @@ pub fn encrypt(policy: &dyn Policy, }))?.into()); } - if certs.len() + passwords.len() == 0 { + if recipients.len() + passwords.len() == 0 { return Err(anyhow::anyhow!( "Neither recipient nor password given")); } let mut signers = get_signing_keys(&signers, policy, time)?; - // Build a vector of references to hand to Signer. - let recipients: Vec<&openpgp::Cert> = certs.iter().collect(); - // Build a vector of recipients to hand to Encryptor. let mut recipient_subkeys: Vec<Recipient> = Vec::new(); - for cert in certs.iter() { + for cert in recipients.iter() { let mut count = 0; for key in cert.keys().with_policy(policy, None).alive().revoked(false) .key_flags(&mode).map(|ka| ka.key()) @@ -167,7 +160,7 @@ pub fn encrypt(policy: &dyn Policy, signer = signer.creation_time(time); } } - for r in recipients { + for r in recipients.iter() { signer = signer.add_intended_recipient(r); } sink = signer.build()?; |