diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2024-04-15 20:00:40 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2024-04-15 20:03:33 +0200 |
commit | 24ed1534d89c31b8dfaf9b3f26f75d6bf81ef088 (patch) | |
tree | 802c28ed817ffe084a5c01ec36ddbcc2e85db61e | |
parent | 317a6b39030da4bfd93dbe3a68821157fe45ae76 (diff) |
openpgp: Fix adding authenticated issuer information.
- When we discover issuer information not yet recorded in the
signature, we insert this information when we get the chance.
However, previously this failed to set the authenticated flag
because it was cleared in SubpacketArea::add. Fix that.
-rw-r--r-- | openpgp/src/packet/signature.rs | 17 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 12 |
2 files changed, 16 insertions, 13 deletions
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index 630874f5..510134fe 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -2472,24 +2472,19 @@ impl crate::packet::Signature { "cannot add information to v3 signature".into()).into()); } - /// Makes an authenticated subpacket. - fn authenticated_subpacket(v: SubpacketValue) -> Result<Subpacket> { - let mut p = Subpacket::new(v, false)?; - p.set_authenticated(true); - Ok(p) - } - let issuers = self.get_issuers(); for id in std::mem::replace(&mut self.additional_issuers, Vec::with_capacity(0)) { if ! issuers.contains(&id) { match id { KeyHandle::KeyID(id) => - self.unhashed_area_mut().add(authenticated_subpacket( - SubpacketValue::Issuer(id))?)?, + self.unhashed_area_mut().add_internal( + Subpacket::new(SubpacketValue::Issuer(id), false)?, + true)?, KeyHandle::Fingerprint(fp) => - self.unhashed_area_mut().add(authenticated_subpacket( - SubpacketValue::IssuerFingerprint(fp))?)?, + self.unhashed_area_mut().add_internal( + Subpacket::new(SubpacketValue::IssuerFingerprint(fp), false)?, + true)?, } } } diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index e85e1019..2a9df958 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -1007,7 +1007,15 @@ impl SubpacketArea { /// # Ok(()) /// # } /// ``` - pub fn add(&mut self, mut packet: Subpacket) -> Result<()> { + pub fn add(&mut self, packet: Subpacket) -> Result<()> { + self.add_internal(packet, false) + } + + /// Adds `packet`, setting its authenticated flag to `authenticated`. + pub(super) fn add_internal(&mut self, mut packet: Subpacket, + authenticated: bool) + -> Result<()> + { if self.serialized_len() + packet.serialized_len() > ::std::u16::MAX as usize { @@ -1016,7 +1024,7 @@ impl SubpacketArea { } self.cache_invalidate(); - packet.set_authenticated(false); + packet.set_authenticated(authenticated); self.packets.push(packet); Ok(()) } |