summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-07-31 18:30:06 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-07-31 18:33:45 +0200
commited740f824abd7159f30bf9deaee2a6023432ba31 (patch)
treef579d0fc086e449d16ecc250a19a468d03e7f832
parent9a34a60df931358d35ea88c32afe3f044548d3c0 (diff)
openpgp: Make it easier to add an Intended Recipient.
- `SignatureBuilder::set_intended_recipients` sets multiple Intended Recipient subpackets at once. However, if we want to build the intended recipients gradually, it is not appropriate: it first clears any existing Intended Recipient subpackets. - Add `SignatureBuilder::add_intended_recipient` to add an Intended Recipient subpacket without first clearing any existing Intended Recipient subpackets.
-rw-r--r--openpgp/src/packet/signature/subpacket.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index 4d33377b..a67cf7d0 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -2888,6 +2888,26 @@ impl signature::SignatureBuilder {
Ok(self)
}
+
+ /// Adds an Intended Recipient subpacket.
+ ///
+ /// Adds any [Intended Recipient subpacket] to the hashed
+ /// subpacket area. Unlike [`set_intended_recipients`], this
+ /// function does not first removes any Intended Recipient
+ /// subpackets from the hashed subpacket area.
+ ///
+ /// [Intended Recipient subpacket]: https://www.ietf.org/id/draft-ietf-openpgp-rfc4880bis-09.html#section-5.2.3.29
+ /// [`set_intended_recipients`]: #method.set_intended_recipients
+ pub fn add_intended_recipient<T>(mut self, recipient: T)
+ -> Result<Self>
+ where T: AsRef<Fingerprint>
+ {
+ self.hashed_area.add(
+ Subpacket::new(SubpacketValue::IntendedRecipient(
+ recipient.as_ref().clone()), false)?)?;
+
+ Ok(self)
+ }
}
#[test]