summaryrefslogtreecommitdiffstats
path: root/openpgp/examples/decrypt-with.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-02-17 15:18:40 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-02-17 15:18:40 +0100
commit6ae9d4ec0661d21f1c1579b901d0cc400811c43c (patch)
tree7988345586ba44531ed971f2444d23d6ebf73fa7 /openpgp/examples/decrypt-with.rs
parentf0944f2e18485dfa693a252956efe0896d225ab7 (diff)
openpgp: Reduce the number of explicit key conversions.
Diffstat (limited to 'openpgp/examples/decrypt-with.rs')
-rw-r--r--openpgp/examples/decrypt-with.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index 860c4a56..c4b9f56a 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -62,15 +62,11 @@ impl Helper {
// Map (sub)KeyIDs to secrets.
let mut keys = HashMap::new();
for cert in certs {
- for ka in cert.keys().with_policy(p, None)
+ for ka in cert.keys().unencrypted_secret().with_policy(p, 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()
- {
- keys.insert(ka.key().keyid(), keypair);
- }
+ keys.insert(ka.key().keyid(),
+ ka.key().clone().into_keypair().unwrap());
}
}