summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-10-12 11:49:29 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2021-10-12 13:01:43 +0200
commit08b8cd56a6b97e7d9f60a5835ebd305b1049ca5f (patch)
treeb07911af9caf6dcd2227b33bd8515d2e605a5647
parent68feed70046fd21ea4ec0ce0e6ff71652c511fd8 (diff)
openpgp: Add notations to CertRevocationBuilder.nora/476
-rw-r--r--openpgp/src/cert/revoke.rs81
1 files changed, 81 insertions, 0 deletions
diff --git a/openpgp/src/cert/revoke.rs b/openpgp/src/cert/revoke.rs
index 7ecb5787..72f9661c 100644
--- a/openpgp/src/cert/revoke.rs
+++ b/openpgp/src/cert/revoke.rs
@@ -19,6 +19,7 @@ use crate::packet::{
UserAttribute,
UserID,
};
+use crate::packet::signature::subpacket::NotationDataFlags;
use crate::cert::prelude::*;
/// A builder for revocation certificates for OpenPGP certificates.
@@ -183,6 +184,86 @@ impl CertRevocationBuilder {
})
}
+ /// Adds a notation to the revocation certificate.
+ ///
+ /// Unlike the [`CertRevocationBuilder::set_notation`] method, this function
+ /// does not first remove any existing notation with the specified name.
+ ///
+ /// See [`SignatureBuilder::add_notation`] for further documentation.
+ ///
+ /// [`SignatureBuilder::add_notation`]: crate::packet::signature::SignatureBuilder::add_notation()
+ ///
+ /// # Examples
+ ///
+ /// ```rust
+ /// use sequoia_openpgp as openpgp;
+ /// # use openpgp::Result;
+ /// use openpgp::cert::prelude::*;
+ /// use openpgp::packet::signature::subpacket::NotationDataFlags;
+ ///
+ /// # fn main() -> Result<()> {
+ ///
+ /// let builder = CertRevocationBuilder::new().add_notation(
+ /// "notation_name",
+ /// &[0; 8],
+ /// NotationDataFlags::empty().set_human_readable(),
+ /// false,
+ /// );
+ /// # Ok(())
+ /// # }
+ pub fn add_notation<N, V, F>(self, name: N, value: V, flags: F,
+ critical: bool)
+ -> Result<Self>
+ where
+ N: AsRef<str>,
+ V: AsRef<[u8]>,
+ F: Into<Option<NotationDataFlags>>,
+ {
+ Ok(Self {
+ builder: self.builder.add_notation(name, value, flags, critical)?
+ })
+ }
+
+ /// Sets a notation to the revocation certificate.
+ ///
+ /// Unlike the [`CertRevocationBuilder::add_notation`] method, this function
+ /// first removes any existing notation with the specified name.
+ ///
+ /// See [`SignatureBuilder::set_notation`] for further documentation.
+ ///
+ /// [`SignatureBuilder::set_notation`]: crate::packet::signature::SignatureBuilder::set_notation()
+ ///
+ /// # Examples
+ ///
+ /// ```rust
+ /// use sequoia_openpgp as openpgp;
+ /// # use openpgp::Result;
+ /// use openpgp::cert::prelude::*;
+ /// use openpgp::packet::signature::subpacket::NotationDataFlags;
+ ///
+ /// # fn main() -> Result<()> {
+ ///
+ /// let builder = CertRevocationBuilder::new().set_notation(
+ /// "notation_name",
+ /// &[0; 8],
+ /// NotationDataFlags::empty().set_human_readable(),
+ /// false,
+ /// );
+ /// # Ok(())
+ /// # }
+ pub fn set_notation<N, V, F>(self, name: N, value: V, flags: F,
+ critical: bool)
+ -> Result<Self>
+ where
+ N: AsRef<str>,
+ V: AsRef<[u8]>,
+ F: Into<Option<NotationDataFlags>>,
+ {
+ Ok(Self {
+ builder: self.builder.set_notation(name, value, flags, critical)?
+ })
+ }
+
/// Returns a signed revocation certificate.
///
/// A revocation certificate is generated for `cert` and signed