summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-01-24 19:05:51 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-01-24 19:12:37 +0100
commitb816125d0e1449de060542166e251d2706f11d8d (patch)
tree2c2104070650b7c5f8c2e3575b74d1fe3f5c93c4
parentdc0769bc1e04347365593c7a50fbf8770446e7b5 (diff)
openpgp: Make 'direct_key_signature' a part of trait Amalgamation.
-rw-r--r--openpgp/src/cert/amalgamation.rs16
-rw-r--r--openpgp/src/cert/key_amalgamation.rs18
-rw-r--r--openpgp/src/serialize/cert.rs1
3 files changed, 26 insertions, 9 deletions
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index ea07031f..205099c1 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -212,6 +212,13 @@ pub trait Amalgamation<'a> {
/// Returns the component's binding signature as of the reference time.
fn binding_signature(&self) -> &'a Signature;
+ /// Returns the Certificate's direct key signature as of the
+ /// reference time, if any.
+ ///
+ /// Subpackets on direct key signatures apply to all components of
+ /// the certificate.
+ fn direct_key_signature(&self) -> Option<&'a Signature>;
+
/// Returns the component's revocation status as of the amalgamation's
/// reference time.
///
@@ -264,6 +271,15 @@ impl<'a, C> Amalgamation<'a> for ValidComponentAmalgamation<'a, C> {
self.binding_signature
}
+ /// Returns the Certificate's direct key signature as of the
+ /// reference time, if any.
+ ///
+ /// Subpackets on direct key signatures apply to all components of
+ /// the certificate.
+ fn direct_key_signature(&self) -> Option<&'a Signature> {
+ self.cert.primary.binding_signature(self.time())
+ }
+
/// Returns the component's revocation status as of the amalgamation's
/// reference time.
///
diff --git a/openpgp/src/cert/key_amalgamation.rs b/openpgp/src/cert/key_amalgamation.rs
index 17d3fa2b..55605ee1 100644
--- a/openpgp/src/cert/key_amalgamation.rs
+++ b/openpgp/src/cert/key_amalgamation.rs
@@ -440,6 +440,15 @@ impl<'a, P: 'a + key::KeyParts> Amalgamation<'a> for ValidKeyAmalgamation<'a, P>
self.binding_signature
}
+ /// Returns the Certificate's direct key signature as of the
+ /// reference time, if any.
+ ///
+ /// Subpackets on direct key signatures apply to all components of
+ /// the certificate.
+ fn direct_key_signature(&self) -> Option<&'a Signature> {
+ self.cert.primary.binding_signature(self.time())
+ }
+
/// Returns the key's revocation status as of the amalgamation's
/// reference time.
///
@@ -457,15 +466,6 @@ impl<'a, P: 'a + key::KeyParts> Amalgamation<'a> for ValidKeyAmalgamation<'a, P>
}
impl<'a, P: 'a + key::KeyParts> ValidKeyAmalgamation<'a, P> {
- /// Returns the Certificate's direct key signature as of the
- /// reference time, if any.
- ///
- /// Subpackets on direct key signatures apply to all components of
- /// the certificate.
- pub fn direct_key_signature(&self) -> Option<&'a Signature> {
- self.cert.primary.binding_signature(self.time())
- }
-
/// Returns this key's binding.
pub fn binding(&self) -> &'a KeyBinding<P, key::UnspecifiedRole>
where &'a KeyBinding<P, key::UnspecifiedRole>:
diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs
index 5aa0ccec..70a8a1b5 100644
--- a/openpgp/src/serialize/cert.rs
+++ b/openpgp/src/serialize/cert.rs
@@ -647,6 +647,7 @@ impl<'a> SerializeInto for TSK<'a> {
mod test {
use super::*;
use crate::vec_truncate;
+ use crate::cert::components::Amalgamation;
use crate::parse::Parse;
use crate::serialize::Serialize;
use crate::packet::key;