From bbbc6da375d6584c7b2bcc74e838fff943f489d4 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 28 Nov 2019 15:27:33 +0100 Subject: Call TPKs Certificates, update identifiers, documentation. - Fixes #387. --- ipc/examples/gpg-agent-decrypt.rs | 40 +++++++++++++++++++-------------------- ipc/examples/gpg-agent-sign.rs | 14 +++++++------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'ipc/examples') diff --git a/ipc/examples/gpg-agent-decrypt.rs b/ipc/examples/gpg-agent-decrypt.rs index 345cdd74..e418e8c1 100644 --- a/ipc/examples/gpg-agent-decrypt.rs +++ b/ipc/examples/gpg-agent-decrypt.rs @@ -29,7 +29,7 @@ fn main() { .arg(clap::Arg::with_name("homedir").value_name("PATH") .long("homedir") .help("Use this GnuPG home directory, default: $GNUPGHOME")) - .arg(clap::Arg::with_name("tpk").value_name("TPK") + .arg(clap::Arg::with_name("cert").value_name("Cert") .required(true) .multiple(true) .help("Public part of the secret keys managed by gpg-agent")) @@ -41,16 +41,16 @@ fn main() { Context::new().unwrap() }; - // Read the TPKs from the given files. - let tpks = - matches.values_of("tpk").expect("required").map(|f| { - openpgp::TPK::from_file(f) + // Read the Certs from the given files. + let certs = + matches.values_of("cert").expect("required").map(|f| { + openpgp::Cert::from_file(f) .expect("Failed to read key") }).collect(); - // Now, create a decryptor with a helper using the given TPKs. + // Now, create a decryptor with a helper using the given Certs. let mut decryptor = - Decryptor::from_reader(io::stdin(), Helper::new(&ctx, tpks), None) + Decryptor::from_reader(io::stdin(), Helper::new(&ctx, certs), None) .unwrap(); // Finally, stream the decrypted data to stdout. @@ -67,12 +67,12 @@ struct Helper<'a> { } impl<'a> Helper<'a> { - /// Creates a Helper for the given TPKs with appropriate secrets. - fn new(ctx: &'a Context, tpks: Vec) -> Self { + /// Creates a Helper for the given Certs with appropriate secrets. + fn new(ctx: &'a Context, certs: Vec) -> Self { // Map (sub)KeyIDs to secrets. let mut keys = HashMap::new(); - for tpk in tpks { - for (sig, _, key) in tpk.keys_all() { + for cert in certs { + for (sig, _, key) in cert.keys_all() { if sig.map(|s| (s.key_flags().can_encrypt_at_rest() || s.key_flags().can_encrypt_for_transport())) .unwrap_or(false) @@ -106,15 +106,15 @@ impl<'a> DecryptionHelper for Helper<'a> { } } // XXX: In production code, return the Fingerprint of the - // recipient's TPK here + // recipient's Cert here Ok(None) } } impl<'a> VerificationHelper for Helper<'a> { fn get_public_keys(&mut self, _ids: &[openpgp::KeyHandle]) - -> failure::Fallible> { - Ok(Vec::new()) // Feed the TPKs to the verifier here. + -> failure::Fallible> { + Ok(Vec::new()) // Feed the Certs to the verifier here. } fn check(&mut self, structure: &MessageStructure) -> failure::Fallible<()> { @@ -133,18 +133,18 @@ impl<'a> VerificationHelper for Helper<'a> { MessageLayer::SignatureGroup { ref results } => for result in results { match result { - GoodChecksum { tpk, .. } => { - eprintln!("Good signature from {}", tpk); + GoodChecksum { cert, .. } => { + eprintln!("Good signature from {}", cert); }, - NotAlive { tpk, .. } => { + NotAlive { cert, .. } => { eprintln!("Good, but not alive signature from {}", - tpk); + cert); }, MissingKey { .. } => { eprintln!("No key to check signature"); }, - BadChecksum { tpk, .. } => { - eprintln!("Bad signature from {}", tpk); + BadChecksum { cert, .. } => { + eprintln!("Bad signature from {}", cert); }, } } diff --git a/ipc/examples/gpg-agent-sign.rs b/ipc/examples/gpg-agent-sign.rs index 923657bd..f6b4d1ff 100644 --- a/ipc/examples/gpg-agent-sign.rs +++ b/ipc/examples/gpg-agent-sign.rs @@ -18,7 +18,7 @@ fn main() { .arg(clap::Arg::with_name("homedir").value_name("PATH") .long("homedir") .help("Use this GnuPG home directory, default: $GNUPGHOME")) - .arg(clap::Arg::with_name("tpk").value_name("TPK") + .arg(clap::Arg::with_name("cert").value_name("Cert") .required(true) .multiple(true) .help("Public part of the secret keys managed by gpg-agent")) @@ -30,16 +30,16 @@ fn main() { Context::new().unwrap() }; - // Read the TPKs from the given files. - let tpks = - matches.values_of("tpk").expect("required").map(|f| { - openpgp::TPK::from_file(f) + // Read the Certs from the given files. + let certs = + matches.values_of("cert").expect("required").map(|f| { + openpgp::Cert::from_file(f) .expect("Failed to read key") }).collect::>(); // Construct a KeyPair for every signing-capable (sub)key. - let mut signers = tpks.iter().flat_map(|tpk| { - tpk.keys_valid().signing_capable().filter_map(|(_, _, key)| { + let mut signers = certs.iter().flat_map(|cert| { + cert.keys_valid().signing_capable().filter_map(|(_, _, key)| { KeyPair::new(&ctx, key).ok() }) }).collect::>>(); -- cgit v1.2.3