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-25 14:51:20 +0200
commitee04aca39a234c5a54a4c1f514a3664329af0590 (patch)
treee34605c56934491c9fbb0b64cec6fbf76d10b55b
parente1fafde8fcc03886343ab194e3a4be53db244463 (diff)
openpgp: Add notation setters to RevocationBuilders.
- Closes #476.
-rw-r--r--openpgp/NEWS10
-rw-r--r--openpgp/src/cert/revoke.rs313
2 files changed, 323 insertions, 0 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index 6933baec..a8e62e11 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -2,6 +2,16 @@
#+TITLE: sequoia-openpgp NEWS – history of user-visible changes
#+STARTUP: content hidestars
+* Changes in 1.6.0
+** New functionality
+ - CertRevocationBuilder::add_notation
+ - CertRevocationBuilder::set_notation
+ - SubkeyRevocationBuilder::add_notation
+ - SubkeyRevocationBuilder::set_notation
+ - UserIDRevocationBuilder::add_notation
+ - UserIDRevocationBuilder::set_notation
+ - UserAttributeRevocationBuilder::add_notation
+ - UserAttributeRevocationBuilder::set_notation
* Changes in 1.5.0
** Notable changes
- This crate is now licensed under the LGPL 2.0 or later.
diff --git a/openpgp/src/cert/revoke.rs b/openpgp/src/cert/revoke.rs
index 7ecb5787..9b48862e 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,84 @@ 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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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
@@ -419,6 +498,84 @@ impl SubkeyRevocationBuilder {
})
}
+ /// Adds a notation to the revocation certificate.
+ ///
+ /// Unlike the [`SubkeyRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 [`SubkeyRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 `key` and
@@ -673,6 +830,84 @@ impl UserIDRevocationBuilder {
})
}
+ /// Adds a notation to the revocation certificate.
+ ///
+ /// Unlike the [`UserIDRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 [`UserIDRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 `userid`
@@ -933,6 +1168,84 @@ impl UserAttributeRevocationBuilder {
})
}
+ /// Adds a notation to the revocation certificate.
+ ///
+ /// Unlike the [`UserAttributeRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 [`UserAttributeRevocationBuilder::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(
+ /// "revocation-policy@example.org",
+ /// "https://policy.example.org/cert-revocation-policy",
+ /// 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 `ua` and