diff options
-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(()) } |