summaryrefslogtreecommitdiffstats
path: root/openpgp/examples
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-01-06 22:36:01 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-01-06 23:01:29 +0100
commitfc6ded10e255a2fc4423e7f360951a2f3eed5d6f (patch)
treeb478c144171354bbf518a0d94d371a75139a94b4 /openpgp/examples
parentfe16487556c2b4d16400515aea8c448b0890e74c (diff)
openpgp: Use KeyAmalgamation::for_xxx instead of building a KeyFlags
- Use the convenient functions KeyAmalgamation::for_storage_encryption, KeyAmalgamation::for_transport_encryption, etc., instead of building up a KeyFlags and then calling KeyAmalgamation::key_flags. - This pattern requires less boilerplate.
Diffstat (limited to 'openpgp/examples')
-rw-r--r--openpgp/examples/decrypt-with.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index b3feceb6..c28dbe1c 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -58,18 +58,14 @@ impl Helper {
// Map (sub)KeyIDs to secrets.
let mut keys = HashMap::new();
for cert in certs {
- for ka in cert.keys().policy(None) {
- if ka.binding_signature(None)
- .map(|s| (s.key_flags().for_storage_encryption()
- || s.key_flags().for_transport_encryption()))
- .unwrap_or(false)
+ for ka in cert.keys().policy(None)
+ .for_storage_encryption().for_transport_encryption()
+ {
+ // This only works for unencrypted secret keys.
+ if let Ok(keypair) =
+ ka.key().clone().mark_parts_secret().unwrap().into_keypair()
{
- // This only works for unencrypted secret keys.
- if let Ok(keypair) =
- ka.key().clone().mark_parts_secret().unwrap().into_keypair()
- {
- keys.insert(ka.key().keyid(), keypair);
- }
+ keys.insert(ka.key().keyid(), keypair);
}
}
}