diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-07-31 17:43:30 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-07-31 18:18:08 +0200 |
commit | 9a34a60df931358d35ea88c32afe3f044548d3c0 (patch) | |
tree | fc6f76ade51f28ecb8958bb3d8a0379f428e652a | |
parent | 9fc4b84a0d01e2bb398a58bd9585fc51d12fd531 (diff) |
openpgp: Add variants to SignatureBuilder to add issuer subpackets.
- `SignatureBuilder::set_issuer` and
`SignatureBuilder::set_issuer_fingerprint` first clear the
unhashed area of any existing Issuer or Issuer Fingerprint
subpackets, respectively.
- Add a variant to add an additional Issuer or Issuer Fingerprint
subpacket.
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 158202ee..4d33377b 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -2595,6 +2595,25 @@ impl signature::SignatureBuilder { Ok(self) } + /// Adds an Issuer subpacket. + /// + /// Adds an [Issuer subpacket] to the unhashed subpacket area. + /// Unlike [`set_issuer`], this function does not first remove any + /// Issuer subpackets from the unhashed subpacket area. + /// + /// Caution: By default, the issuer is set correctly when creating + /// the signature. Only use this function to override it. + /// + /// [Issuer subpacket]: https://tools.ietf.org/html/rfc4880#section-5.2.3.5 + /// [`set_issuer`]: #method.set_issuer + pub fn add_issuer(mut self, id: KeyID) -> Result<Self> { + self.unhashed_area.add(Subpacket::new( + SubpacketValue::Issuer(id), + false)?)?; + + Ok(self) + } + /// Sets the value of the Notation Data subpacket with the given /// name. /// @@ -2828,6 +2847,23 @@ impl signature::SignatureBuilder { Ok(self) } + /// Adds an Issuer Fingerprint subpacket. + /// + /// Adds an [Issuer Fingerprint subpacket] to the unhashed + /// subpacket area. Unlike [`set_issuer_fingerprint`], this + /// function does not first remove any existing Issuer Fingerprint + /// subpackets from the unhashed subpacket area. + /// + /// [Issuer Fingerprint subpacket]: https://www.ietf.org/id/draft-ietf-openpgp-rfc4880bis-09.html#section-5.2.3.28 + /// [`set_issuer_fingerprint`]: #method.set_issuer_fingerprint + pub fn add_issuer_fingerprint(mut self, fp: Fingerprint) -> Result<Self> { + self.unhashed_area.add(Subpacket::new( + SubpacketValue::IssuerFingerprint(fp), + false)?)?; + + Ok(self) + } + /// Sets the value of the Preferred AEAD Algorithms subpacket, /// which contains the list of AEAD algorithms that the key holder /// prefers, ordered according by the key holder's preference. |