From f078f93025b517609d25ce2cb2ebc41a01d81190 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Fri, 20 Dec 2019 14:22:09 +0100 Subject: openpgp: Simplify key iteration interface. - Cert::keys_valid() is just a short-cut for Cert::keys_all().alive().revoked(false). - Remove Cert::keys_valid() and rename Cert::keys_all() to Cert::keys(). --- tool/src/commands/mod.rs | 8 +++++--- tool/tests/sq-sign.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tool') diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs index 1263fa05..1e136572 100644 --- a/tool/src/commands/mod.rs +++ b/tool/src/commands/mod.rs @@ -48,7 +48,7 @@ fn get_signing_keys(certs: &[openpgp::Cert]) { let mut keys = Vec::new(); 'next_cert: for tsk in certs { - for key in tsk.keys_valid() + for key in tsk.keys().alive().revoked(false) .for_signing() .map(|ka| ka.key()) { @@ -112,7 +112,9 @@ pub fn encrypt(mapping: &mut store::Mapping, let mut recipient_subkeys: Vec = Vec::new(); for cert in certs.iter() { let mut count = 0; - for key in cert.keys_valid().key_flags(mode.clone()).map(|ka| ka.key()) { + for key in cert.keys().alive().revoked(false). + key_flags(mode.clone()).map(|ka| ka.key()) + { recipient_subkeys.push(key.into()); count += 1; } @@ -306,7 +308,7 @@ impl<'a> VerificationHelper for VHelper<'a> { .flat_map(|cert| { // Even if a key is revoked or expired, we can still // use it to verify a message. - cert.keys_all().map(|ka| ka.key().fingerprint().into()) + cert.keys().map(|ka| ka.key().fingerprint().into()) }).collect(); // Explicitly provided keys are trusted. diff --git a/tool/tests/sq-sign.rs b/tool/tests/sq-sign.rs index 0c1fbed8..32d45add 100644 --- a/tool/tests/sq-sign.rs +++ b/tool/tests/sq-sign.rs @@ -208,7 +208,7 @@ fn sq_sign_append_on_compress_then_sign() { // message by foot. let tsk = Cert::from_file(&p("keys/dennis-simon-anton-private.pgp")) .unwrap(); - let key = tsk.keys_all().for_signing().nth(0).unwrap().key(); + let key = tsk.keys().for_signing().nth(0).unwrap().key(); let sec = match key.secret() { Some(SecretKeyMaterial::Unencrypted(ref u)) => u.clone(), _ => unreachable!(), -- cgit v1.2.3