summaryrefslogtreecommitdiffstats
path: root/sqv
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-03-14 09:20:10 +0100
committerNeal H. Walfield <neal@pep.foundation>2019-03-14 14:56:47 +0100
commit1434843469109127f41c5dbd8aacf5400c537759 (patch)
tree0ca324cad8a486def769000eb460a13bd51473c4 /sqv
parent6bea117391c1813e956e384c6638b7b0311d8d7c (diff)
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.
Diffstat (limited to 'sqv')
-rw-r--r--sqv/src/sqv.rs16
1 files changed, 5 insertions, 11 deletions
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;
}