summaryrefslogtreecommitdiffstats
path: root/openpgp/examples
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-12-19 21:47:19 +0100
committerNeal H. Walfield <neal@pep.foundation>2019-12-19 21:51:19 +0100
commitb3ba97146f534ac5cf67db7f72d8a633112d0a18 (patch)
tree581c64936f0a857dd1f0fbf75c7a4ddf243d8656 /openpgp/examples
parent2b2b5c8905d0e823d03b5ba2a115298e80e08b74 (diff)
openpgp: Change KeyIter to return a struct instead of a tuple.
- A tuple is just an unnamed, inflexible struct. Use a struct instead. - Fixes #400.
Diffstat (limited to 'openpgp/examples')
-rw-r--r--openpgp/examples/decrypt-with.rs11
-rw-r--r--openpgp/examples/encrypt-for.rs2
-rw-r--r--openpgp/examples/generate-encrypt-decrypt.rs2
-rw-r--r--openpgp/examples/generate-sign-verify.rs4
-rw-r--r--openpgp/examples/notarize.rs2
-rw-r--r--openpgp/examples/pad.rs2
-rw-r--r--openpgp/examples/sign-detached.rs2
-rw-r--r--openpgp/examples/sign.rs2
8 files changed, 14 insertions, 13 deletions
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index 224a8726..7c924cc9 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -58,16 +58,17 @@ impl Helper {
// Map (sub)KeyIDs to secrets.
let mut keys = HashMap::new();
for cert in certs {
- for (sig, _, key) in cert.keys_all() {
- if sig.map(|s| (s.key_flags().for_storage_encryption()
- || s.key_flags().for_transport_encryption()))
+ for ka in cert.keys_all() {
+ if ka.binding_signature(None)
+ .map(|s| (s.key_flags().for_storage_encryption()
+ || s.key_flags().for_transport_encryption()))
.unwrap_or(false)
{
// This only works for unencrypted secret keys.
if let Ok(keypair) =
- key.clone().mark_parts_secret().unwrap().into_keypair()
+ ka.key().clone().mark_parts_secret().unwrap().into_keypair()
{
- keys.insert(key.keyid(), keypair);
+ keys.insert(ka.key().keyid(), keypair);
}
}
}
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs
index f3004532..eceec5b3 100644
--- a/openpgp/examples/encrypt-for.rs
+++ b/openpgp/examples/encrypt-for.rs
@@ -38,7 +38,7 @@ fn main() {
let mut recipients =
certs.iter()
.flat_map(|cert| cert.keys_valid().key_flags(mode.clone()))
- .map(|(_, _, key)| key.into())
+ .map(|ka| ka.key().into())
.collect::<Vec<_>>();
// Compose a writer stack corresponding to the output format and
diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs
index 55ea89d6..01782b47 100644
--- a/openpgp/examples/generate-encrypt-decrypt.rs
+++ b/openpgp/examples/generate-encrypt-decrypt.rs
@@ -44,7 +44,7 @@ fn encrypt(sink: &mut dyn Write, plaintext: &str, recipient: &openpgp::Cert)
let mut recipients =
recipient.keys_valid()
.for_transport_encryption()
- .map(|(_, _, key)| key.into())
+ .map(|ka| ka.key().into())
.collect::<Vec<_>>();
// Start streaming an OpenPGP message.
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index 6e3d8084..1cccac44 100644
--- a/openpgp/examples/generate-sign-verify.rs
+++ b/openpgp/examples/generate-sign-verify.rs
@@ -40,8 +40,8 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
fn sign(sink: &mut dyn Write, plaintext: &str, tsk: &openpgp::Cert)
-> openpgp::Result<()> {
// Get the keypair to do the signing from the Cert.
- let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().2
- .clone().mark_parts_secret().unwrap().into_keypair()?;
+ let keypair = tsk.keys_valid().for_signing().nth(0).unwrap()
+ .key().clone().mark_parts_secret().unwrap().into_keypair()?;
// Start streaming an OpenPGP message.
let message = Message::new(sink);
diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs
index ce007968..f52466f4 100644
--- a/openpgp/examples/notarize.rs
+++ b/openpgp/examples/notarize.rs
@@ -28,7 +28,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().for_signing().secret() {
+ for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs
index a13e53d5..32583a42 100644
--- a/openpgp/examples/pad.rs
+++ b/openpgp/examples/pad.rs
@@ -40,7 +40,7 @@ fn main() {
let mut recipients =
certs.iter()
.flat_map(|cert| cert.keys_valid().key_flags(mode.clone()))
- .map(|(_, _, key)| Recipient::new(KeyID::wildcard(), key))
+ .map(|ka| Recipient::new(KeyID::wildcard(), ka.key()))
.collect::<Vec<_>>();
// Compose a writer stack corresponding to the output format and
diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs
index 0fee0e36..20d4150b 100644
--- a/openpgp/examples/sign-detached.rs
+++ b/openpgp/examples/sign-detached.rs
@@ -24,7 +24,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().for_signing().secret() {
+ for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/examples/sign.rs b/openpgp/examples/sign.rs
index 195ac508..7fae29ef 100644
--- a/openpgp/examples/sign.rs
+++ b/openpgp/examples/sign.rs
@@ -23,7 +23,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().for_signing().secret() {
+ for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {