summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2024-04-18 14:25:28 +0200
committerJustus Winter <justus@sequoia-pgp.org>2024-05-07 09:10:33 +0200
commit8dae8f22382f92a1aafb01b7be26af6b81bea859 (patch)
tree12e8ec89ff2957bdc0d7dfe766e991470308de72
parent978c73968b3eb180e2c4ed24593adf736d713beb (diff)
openpgp: Correctly file signatures on unknown components.
- Instead of splitting them again. Filing them into the correct bucket is a bit faster, and avoids us to make parser::split_sigs pub(crate).
-rw-r--r--openpgp/src/cert.rs28
-rw-r--r--openpgp/src/cert/parser/mod.rs3
2 files changed, 19 insertions, 12 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index d6dce9cb..8106bf7b 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -2008,14 +2008,28 @@ impl Cert {
}
// Keep them for later.
- t!("{} {:02X}{:02X}, {:?} doesn't belong \
- to any known component or is bad.",
+ t!("{} {:02X}{:02X}, {:?}, originally found on {:?} \
+ doesn't belong to any known component or is bad.",
if is_selfsig { "Self-sig" } else { "3rd-party-sig" },
sig.digest_prefix()[0], sig.digest_prefix()[1],
- sig.typ());
+ sig.typ(), unknown_idx);
if let Some(i) = unknown_idx {
- self.unknowns[i].certifications.push(sig);
+ let is_revocation = match sig.typ() {
+ CertificationRevocation | KeyRevocation | SubkeyRevocation
+ => true,
+ _ => false,
+ };
+ match (is_selfsig, is_revocation) {
+ (false, false) =>
+ self.unknowns[i].certifications.push(sig),
+ (false, true) =>
+ self.unknowns[i].other_revocations.push(sig),
+ (true, false) =>
+ self.unknowns[i].self_signatures.push(sig),
+ (true, true) =>
+ self.unknowns[i].self_revocations.push(sig),
+ }
} else {
self.bad.push(sig);
}
@@ -2026,12 +2040,6 @@ impl Cert {
self.keyid(), self.bad.len());
}
- // Split signatures on unknown components.
- let primary_fp: KeyHandle = self.key_handle();
- for c in self.unknowns.iter_mut() {
- parser::split_sigs(&primary_fp, c);
- }
-
// Sort again. We may have moved signatures to the right
// component, and we need to ensure they are in the right spot
// (i.e. newest first).
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs
index 4ac58ca1..6100b92c 100644
--- a/openpgp/src/cert/parser/mod.rs
+++ b/openpgp/src/cert/parser/mod.rs
@@ -922,8 +922,7 @@ impl<'a> CertParser<'a> {
/// Splits the signatures in b.certifications into the correct
/// vectors.
-pub(crate) fn split_sigs<C>(primary: &KeyHandle,
- b: &mut ComponentBundle<C>)
+fn split_sigs<C>(primary: &KeyHandle, b: &mut ComponentBundle<C>)
{
let mut self_signatures = Vec::with_capacity(0);
let mut certifications = Vec::with_capacity(0);