diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-08-12 15:48:36 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-08-12 15:55:09 +0200 |
commit | d4fe2832c9bf1d49b87a301bd0a46caa45018477 (patch) | |
tree | 2dbdf9b430456aec4a7878cc6ab53abe92166876 /tool/src | |
parent | 2aa8c003a99afef4e8199e92cfa403a5048cdf7c (diff) |
openpgp: Change accessors to return all issuers.
- Unlike the `Signature Creation Time` subpacket, there are
legitimate reasons to have multiple `Issuer` subpackets and
`Issuer Fingerprint` subpackets.
- Rename `SubpacketAreas::issuer` to `SubpacketAreas::issuers` and
return all `Issuer` subpackets.
- Likewise, Rename `SubpacketAreas::issuer_fingerprint` to
`SubpacketAreas::issuer_fingerprints` and return all `Issuer
Fingerprint` subpackets.
- Change `sq` to list all issuers. Deduplicate first, however.
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/commands/inspect.rs | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/tool/src/commands/inspect.rs b/tool/src/commands/inspect.rs index 6f5d080c..c1f12120 100644 --- a/tool/src/commands/inspect.rs +++ b/tool/src/commands/inspect.rs @@ -4,7 +4,7 @@ use std::io::{self, Read}; use clap; extern crate sequoia_openpgp as openpgp; -use crate::openpgp::{Packet, Result}; +use crate::openpgp::{KeyHandle, Packet, Result}; use crate::openpgp::cert::prelude::*; use openpgp::packet::{ Signature, @@ -351,10 +351,20 @@ fn inspect_signatures(output: &mut dyn io::Write, writeln!(output, " Kind: {}", signature_type)?, } - if let Some(fp) = sig.issuer_fingerprint() { - writeln!(output, " Signed by: {}", fp)?; - } else if let Some(kid) = sig.issuer() { - writeln!(output, " Signed by: {}", kid)?; + let mut fps: Vec<_> = sig.issuer_fingerprints().collect(); + fps.sort(); + fps.dedup(); + let fps: Vec<KeyHandle> = fps.into_iter().map(|fp| fp.into()).collect(); + for fp in fps.iter() { + writeln!(output, " Alleged signer: {}", fp)?; + } + let mut keyids: Vec<_> = sig.issuers().collect(); + keyids.sort(); + keyids.dedup(); + for keyid in keyids { + if ! fps.iter().any(|fp| fp.aliases(&keyid.into())) { + writeln!(output, " Alleged signer: {}", keyid)?; + } } } if ! sigs.is_empty() { @@ -370,10 +380,20 @@ fn inspect_certifications(output: &mut dyn io::Write, print_certifications: bool) -> Result<()> { if print_certifications { for sig in certs { - if let Some(fp) = sig.issuer_fingerprint() { - writeln!(output, " Certified by: {}", fp)?; - } else if let Some(kid) = sig.issuer() { - writeln!(output, " Certified by: {}", kid)?; + let mut fps: Vec<_> = sig.issuer_fingerprints().collect(); + fps.sort(); + fps.dedup(); + let fps: Vec<KeyHandle> = fps.into_iter().map(|fp| fp.into()).collect(); + for fp in fps.iter() { + writeln!(output, "Alleged certifier: {}", fp)?; + } + let mut keyids: Vec<_> = sig.issuers().collect(); + keyids.sort(); + keyids.dedup(); + for keyid in keyids { + if ! fps.iter().any(|fp| fp.aliases(&keyid.into())) { + writeln!(output, "Alleged certifier: {}", keyid)?; + } } } if ! certs.is_empty() { |