diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-12-20 14:22:09 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-12-20 14:22:09 +0100 |
commit | f078f93025b517609d25ce2cb2ebc41a01d81190 (patch) | |
tree | 32766c92a0a6e7877b538d373cced9c9f0a97019 /tool | |
parent | b3ba97146f534ac5cf67db7f72d8a633112d0a18 (diff) |
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().
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/commands/mod.rs | 8 | ||||
-rw-r--r-- | tool/tests/sq-sign.rs | 2 |
2 files changed, 6 insertions, 4 deletions
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<Recipient> = 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!(), |