diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-03-25 14:58:52 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-03-26 14:43:53 +0100 |
commit | 20958510330dd54758585e991be3e23f17ec2fa3 (patch) | |
tree | 67dbbccf687633d8f875846ca6324b7feb1a88ce | |
parent | 03f141c7625dcea40ca54bd28e3ad6db949b3241 (diff) |
openpgp: Have validated components return a validated cert.
- Change ValidAmalgamation::cert to return a `&ValidCert` instead of
a `Cert`.
- Fixes #454.
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 4 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 10 | ||||
-rw-r--r-- | openpgp/src/cert/key_amalgamation.rs | 10 |
3 files changed, 12 insertions, 12 deletions
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs index 86a3a307..996c5b58 100644 --- a/openpgp-ffi/src/parse/stream.rs +++ b/openpgp-ffi/src/parse/stream.rs @@ -201,7 +201,7 @@ fn pgp_verification_result_good_checksum<'a>( *unsafe { p.as_mut() } = sig.move_into_raw(); } if let Some(mut p) = cert_r { - *unsafe { p.as_mut() } = ka.cert().move_into_raw(); + *unsafe { p.as_mut() } = ka.cert().cert().move_into_raw(); } if let Some(mut p) = key_r { *unsafe { p.as_mut() } = { @@ -329,7 +329,7 @@ fn $fn_name<'a>( *unsafe { p.as_mut() } = sig.move_into_raw(); } if let Some(mut p) = cert_r { - *unsafe { p.as_mut() } = ka.cert().move_into_raw(); + *unsafe { p.as_mut() } = ka.cert().cert().move_into_raw(); } if let Some(mut p) = key_r { *unsafe { p.as_mut() } = { diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index b3f4cef9..c6c00cd6 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -64,7 +64,7 @@ pub trait ValidateAmalgamation<'a, C: 'a> { pub trait ValidAmalgamation<'a, C: 'a> { /// Returns the certificate. - fn cert(&self) -> &'a Cert; + fn cert(&self) -> &ValidCert<'a>; /// Returns the amalgamation's reference time. /// @@ -97,13 +97,13 @@ pub trait ValidAmalgamation<'a, C: 'a> /// Returns the certificate's revocation status as of the /// amalgamation's reference time. fn cert_revoked(&self) -> RevocationStatus<'a> { - self.cert().revoked(self.policy(), self.time()) + self.cert().revoked() } /// Returns whether the certificate is alive as of the /// amalgamation's reference time. fn cert_alive(&self) -> Result<()> { - self.cert().alive(self.policy(), self.time()) + self.cert().alive() } /// Maps the given function over binding and direct key signature. @@ -584,9 +584,9 @@ impl<'a, C> ValidateAmalgamation<'a, C> for ValidComponentAmalgamation<'a, C> { } impl<'a, C> ValidAmalgamation<'a, C> for ValidComponentAmalgamation<'a, C> { - fn cert(&self) -> &'a Cert { + fn cert(&self) -> &ValidCert<'a> { assert!(std::ptr::eq(self.ca.cert(), self.cert.cert())); - self.ca.cert() + &self.cert } /// Returns the amalgamation's reference time. diff --git a/openpgp/src/cert/key_amalgamation.rs b/openpgp/src/cert/key_amalgamation.rs index 851ca528..ce8b2aa7 100644 --- a/openpgp/src/cert/key_amalgamation.rs +++ b/openpgp/src/cert/key_amalgamation.rs @@ -662,9 +662,9 @@ impl<'a, P, R, R2> ValidAmalgamation<'a, Key<P, R>> R2: Copy, Self: Primary<'a, P, R>, { - fn cert(&self) -> &'a Cert { + fn cert(&self) -> &ValidCert<'a> { assert!(std::ptr::eq(self.ka.cert(), self.cert.cert())); - self.ka.cert() + &self.cert } fn time(&self) -> SystemTime { @@ -681,12 +681,12 @@ impl<'a, P, R, R2> ValidAmalgamation<'a, Key<P, R>> } fn direct_key_signature(&self) -> Option<&'a Signature> { - self.cert().primary.binding_signature(self.policy(), self.time()) + self.cert.cert.primary.binding_signature(self.policy(), self.time()) } fn revoked(&self) -> RevocationStatus<'a> { if self.primary() { - self.cert().revoked(self.policy(), self.time()) + self.cert.revoked() } else { self.bundle()._revoked(self.policy(), self.time(), true, Some(self.binding_signature)) @@ -825,7 +825,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2> | SignatureType::PersonaCertification | SignatureType::CasualCertification | SignatureType::PositiveCertification => - self.cert().primary_userid(self.policy(), self.time()) + self.cert.primary_userid() .expect("this type must be from a userid binding, \ hence there must be a userid valid at `now`") .userid().hash(&mut hash), |