summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-19 16:16:19 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-19 16:19:41 +0100
commit77126481d2ce21d70869004d784ee0de6b5062bf (patch)
tree4a04182e21905a78259ecb9ab10f3ae205bb40ac
parent864bea75d9ca795d032cf145015068756fdf3799 (diff)
openpgp: Return &[Signature] from TPK accessors.
- Fixes #196.
-rw-r--r--examples/guide-exploring-openpgp.rs8
-rw-r--r--openpgp/src/packet/signature/mod.rs2
-rw-r--r--openpgp/src/tpk/mod.rs68
-rw-r--r--tool/src/commands/inspect.rs10
4 files changed, 44 insertions, 44 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs
index 409475ef..358c1922 100644
--- a/examples/guide-exploring-openpgp.rs
+++ b/examples/guide-exploring-openpgp.rs
@@ -55,15 +55,15 @@ fn main() {
for (i, u) in tpk.userids().enumerate() {
println!("{}: UID: {}, {} self-signature(s), {} certification(s)",
i, u.userid(),
- u.selfsigs().count(),
- u.certifications().count());
+ u.selfsigs().len(),
+ u.certifications().len());
}
// List subkeys.
for (i, s) in tpk.subkeys().enumerate() {
println!("{}: Fingerprint: {}, {} self-signature(s), {} certification(s)",
i, s.subkey().fingerprint(),
- s.selfsigs().count(),
- s.certifications().count());
+ s.selfsigs().len(),
+ s.certifications().len());
}
}
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs
index af1af7f1..35f75dae 100644
--- a/openpgp/src/packet/signature/mod.rs
+++ b/openpgp/src/packet/signature/mod.rs
@@ -1103,7 +1103,7 @@ mod test {
let test2 = TPK::from_file(
path_to("keys/test2-signed-by-test1.pgp")).unwrap();
let uid_binding = &test2.primary_key_signature_full().unwrap().0.unwrap();
- let cert = uid_binding.certifications().next().unwrap();
+ let cert = &uid_binding.certifications()[0];
assert_eq!(cert.verify_userid_binding(cert_key1, test2.primary(), uid_binding.userid()).ok(), Some(true));
}
diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs
index 1b49aa8b..61bb388f 100644
--- a/openpgp/src/tpk/mod.rs
+++ b/openpgp/src/tpk/mod.rs
@@ -566,29 +566,29 @@ impl SubkeyBinding {
///
/// All self-signatures have been validated, and the newest
/// self-signature is first.
- pub fn selfsigs(&self) -> slice::Iter<Signature> {
- self.selfsigs.iter()
+ pub fn selfsigs(&self) -> &[Signature] {
+ &self.selfsigs
}
/// Any third-party certifications.
///
/// The signatures have *not* been validated.
- pub fn certifications(&self) -> slice::Iter<Signature> {
- self.certifications.iter()
+ pub fn certifications(&self) -> &[Signature] {
+ &self.certifications
}
/// Revocations issued by the key itself.
///
/// The revocations have been validated, and the newest is first.
- pub fn self_revocations(&self) -> slice::Iter<Signature> {
- self.self_revocations.iter()
+ pub fn self_revocations(&self) -> &[Signature] {
+ &self.self_revocations
}
/// Revocations issued by other keys.
///
/// The revocations have *not* been validated.
- pub fn other_revocations(&self) -> slice::Iter<Signature> {
- self.other_revocations.iter()
+ pub fn other_revocations(&self) -> &[Signature] {
+ &self.other_revocations
}
/// Returns the subkey's revocation status.
@@ -685,29 +685,29 @@ impl UserIDBinding {
///
/// The self-signatures have been validated, and the newest
/// self-signature is first.
- pub fn selfsigs(&self) -> slice::Iter<Signature> {
- self.selfsigs.iter()
+ pub fn selfsigs(&self) -> &[Signature] {
+ &self.selfsigs
}
/// Any third-party certifications.
///
/// The signatures have *not* been validated.
- pub fn certifications(&self) -> slice::Iter<Signature> {
- self.certifications.iter()
+ pub fn certifications(&self) -> &[Signature] {
+ &self.certifications
}
/// Revocations issued by the key itself.
///
/// The revocations have been validated, and the newest is first.
- pub fn self_revocations(&self) -> slice::Iter<Signature> {
- self.self_revocations.iter()
+ pub fn self_revocations(&self) -> &[Signature] {
+ &self.self_revocations
}
/// Revocations issued by other keys.
///
/// The revocations have *not* been validated.
- pub fn other_revocations(&self) -> slice::Iter<Signature> {
- self.other_revocations.iter()
+ pub fn other_revocations(&self) -> &[Signature] {
+ &self.other_revocations
}
/// Returns the user id's revocation status at time `t`. If `t` is None,
@@ -795,29 +795,29 @@ impl UserAttributeBinding {
///
/// The self-signatures have been validated, and the newest
/// self-signature is first.
- pub fn selfsigs(&self) -> slice::Iter<Signature> {
- self.selfsigs.iter()
+ pub fn selfsigs(&self) -> &[Signature] {
+ &self.selfsigs
}
/// Any third-party certifications.
///
/// The signatures have *not* been validated.
- pub fn certifications(&self) -> slice::Iter<Signature> {
- self.certifications.iter()
+ pub fn certifications(&self) -> &[Signature] {
+ &self.certifications
}
/// Revocations issued by the key itself.
///
/// The revocations have been validated, and the newest is first.
- pub fn self_revocations(&self) -> slice::Iter<Signature> {
- self.self_revocations.iter()
+ pub fn self_revocations(&self) -> &[Signature] {
+ &self.self_revocations
}
/// Revocations issued by other keys.
///
/// The revocations have *not* been validated.
- pub fn other_revocations(&self) -> slice::Iter<Signature> {
- self.other_revocations.iter()
+ pub fn other_revocations(&self) -> &[Signature] {
+ &self.other_revocations
}
/// Returns the `UserAttribute`'s revocation status.
@@ -1444,29 +1444,29 @@ impl TPK {
///
/// All self-signatures have been validated, and the newest
/// self-signature is first.
- pub fn selfsigs(&self) -> slice::Iter<Signature> {
- self.primary_selfsigs.iter()
+ pub fn selfsigs(&self) -> &[Signature] {
+ &self.primary_selfsigs
}
/// Any third-party certifications.
///
/// The signatures have *not* been validated.
- pub fn certifications(&self) -> slice::Iter<Signature> {
- self.primary_certifications.iter()
+ pub fn certifications(&self) -> &[Signature] {
+ &self.primary_certifications
}
/// Revocations issued by the key itself.primary_
///
/// The revocations have been validated, and the newest is first.
- pub fn self_revocations(&self) -> slice::Iter<Signature> {
- self.primary_self_revocations.iter()
+ pub fn self_revocations(&self) -> &[Signature] {
+ &self.primary_self_revocations
}
/// Revocations issued by other keys.
///
/// The revocations have *not* been validated.
- pub fn other_revocations(&self) -> slice::Iter<Signature> {
- self.primary_other_revocations.iter()
+ pub fn other_revocations(&self) -> &[Signature] {
+ &self.primary_other_revocations
}
/// Returns the TPK's revocation status.
@@ -1755,7 +1755,7 @@ impl TPK {
None => Vec::default(),
Some((None, sig)) => vec![sig],
Some((Some(uid), sig)) =>
- uid.selfsigs().chain(iter::once(sig)).collect(),
+ uid.selfsigs().iter().chain(iter::once(sig)).collect(),
};
let prim = Some(&self.primary)
.filter(|k| is_usable(k, prim_sigs.iter(), now, &cap));
@@ -1763,7 +1763,7 @@ impl TPK {
.iter()
.filter(|sb| {
sb.revoked(None) == RevocationStatus::NotAsFarAsWeKnow &&
- is_usable(sb.subkey(), sb.selfsigs(), now, &cap)
+ is_usable(sb.subkey(), sb.selfsigs().iter(), now, &cap)
})
.map(|sb| sb.subkey())
.collect::<Vec<_>>();
diff --git a/tool/src/commands/inspect.rs b/tool/src/commands/inspect.rs
index ae5a4f81..4a09dcab 100644
--- a/tool/src/commands/inspect.rs
+++ b/tool/src/commands/inspect.rs
@@ -123,7 +123,7 @@ fn inspect_tpk(output: &mut io::Write, tpk: &openpgp::TPK,
writeln!(output, " Fingerprint: {}", tpk.fingerprint())?;
inspect_revocation(output, "", tpk.revoked(None))?;
inspect_key(output, "", tpk.primary(), tpk.primary_key_signature(),
- &tpk.certifications().collect::<Vec<_>>()[..],
+ tpk.certifications(),
print_keygrips, print_certifications)?;
writeln!(output)?;
@@ -131,7 +131,7 @@ fn inspect_tpk(output: &mut io::Write, tpk: &openpgp::TPK,
writeln!(output, " Subkey: {}", skb.subkey().fingerprint())?;
inspect_revocation(output, "", skb.revoked(None))?;
inspect_key(output, "", skb.subkey(), skb.binding_signature(),
- &skb.certifications().collect::<Vec<_>>()[..],
+ skb.certifications(),
print_keygrips, print_certifications)?;
writeln!(output)?;
}
@@ -147,7 +147,7 @@ fn inspect_tpk(output: &mut io::Write, tpk: &openpgp::TPK,
}
}
inspect_certifications(output,
- &uidb.certifications().collect::<Vec<_>>()[..],
+ uidb.certifications(),
print_certifications)?;
writeln!(output)?;
}
@@ -159,7 +159,7 @@ fn inspect_key(output: &mut io::Write,
indent: &str,
key: &openpgp::packet::Key,
binding_signature: Option<&openpgp::packet::Signature>,
- certs: &[&openpgp::packet::Signature],
+ certs: &[openpgp::packet::Signature],
print_keygrips: bool,
print_certifications: bool)
-> Result<()> {
@@ -263,7 +263,7 @@ fn inspect_signatures(output: &mut io::Write,
}
fn inspect_certifications(output: &mut io::Write,
- certs: &[&openpgp::packet::Signature],
+ certs: &[openpgp::packet::Signature],
print_certifications: bool) -> Result<()> {
if print_certifications {
for sig in certs {