From 1434843469109127f41c5dbd8aacf5400c537759 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Thu, 14 Mar 2019 09:20:10 +0100 Subject: openpgp: Replace TPK::select_keys with an iterator. - TPK::select_keys mixes iterating and filtering. - Make KeyIter an implicit builder, which supports convenient filtering. - Provide a convenience function to key an iterator with a reasonable filter default. --- sqv/src/sqv.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'sqv') diff --git a/sqv/src/sqv.rs b/sqv/src/sqv.rs index c9cc65c6..1ab6568d 100644 --- a/sqv/src/sqv.rs +++ b/sqv/src/sqv.rs @@ -145,15 +145,9 @@ fn real_main() -> Result<(), failure::Error> { .into_iter().collect(); fn tpk_has_key(tpk: &TPK, keyid: &KeyID) -> bool { - if *keyid == tpk.primary().keyid() { - return true; - } - for binding in tpk.subkeys() { - if *keyid == binding.subkey().keyid() { - return true; - } - } - false + // Even if a key is revoked or expired, we can still use it to + // verify a message. + tpk.keys_all().any(|(_, _, k)| *keyid == k.keyid()) } // Find the keys. @@ -215,7 +209,7 @@ fn real_main() -> Result<(), failure::Error> { if let Some(ref tpk) = tpko { // Find the right key. - for (maybe_binding, _, key) in tpk.keys() { + for (maybe_binding, _, key) in tpk.keys_all() { let binding = match maybe_binding { Some(b) => b, None => continue, @@ -223,7 +217,7 @@ fn real_main() -> Result<(), failure::Error> { if issuer == key.keyid() { if !binding.key_flags().can_sign() { - eprintln!("Cannot check signature, key has no siginig \ + eprintln!("Cannot check signature, key has no signing \ capability"); continue 'sig_loop; } -- cgit v1.2.3