summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-09-16 11:58:19 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-09-16 11:58:19 +0200
commitb3ca035d5bcb9146f0baadf7a682fe4828669b6c (patch)
treeb0ad103adc99e2b3d3a7f743c728734c47105ec1
parent0c82c605e930f2eaf6212d87af9322e0bc60772e (diff)
openpgp: Generalize ValidKeyAmalgamation conversions to references.
-rw-r--r--openpgp/src/cert/amalgamation/key.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index 397c7a0c..555f8d21 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -980,6 +980,19 @@ impl<'a, P: 'a + key::KeyParts> From<ValidPrimaryKeyAmalgamation<'a, P>>
}
}
+impl<'a, P: 'a + key::KeyParts> From<&ValidPrimaryKeyAmalgamation<'a, P>>
+ for ValidErasedKeyAmalgamation<'a, P>
+{
+ fn from(vka: &ValidPrimaryKeyAmalgamation<'a, P>) -> Self {
+ assert!(std::ptr::eq(vka.ka.cert(), vka.cert.cert()));
+ ValidErasedKeyAmalgamation {
+ ka: vka.ka.clone().into(),
+ cert: vka.cert.clone(),
+ binding_signature: vka.binding_signature,
+ }
+ }
+}
+
impl<'a, P: 'a + key::KeyParts> From<ValidSubordinateKeyAmalgamation<'a, P>>
for ValidErasedKeyAmalgamation<'a, P>
{
@@ -993,6 +1006,19 @@ impl<'a, P: 'a + key::KeyParts> From<ValidSubordinateKeyAmalgamation<'a, P>>
}
}
+impl<'a, P: 'a + key::KeyParts> From<&ValidSubordinateKeyAmalgamation<'a, P>>
+ for ValidErasedKeyAmalgamation<'a, P>
+{
+ fn from(vka: &ValidSubordinateKeyAmalgamation<'a, P>) -> Self {
+ assert!(std::ptr::eq(vka.ka.cert(), vka.cert.cert()));
+ ValidErasedKeyAmalgamation {
+ ka: vka.ka.clone().into(),
+ cert: vka.cert.clone(),
+ binding_signature: vka.binding_signature,
+ }
+ }
+}
+
// We can infallibly convert part X to part Y for everything but
// Public -> Secret and Unspecified -> Secret.
macro_rules! impl_conversion {
@@ -1009,6 +1035,19 @@ macro_rules! impl_conversion {
}
}
}
+
+ impl<'a> From<&$s<'a, $p1>>
+ for ValidErasedKeyAmalgamation<'a, $p2>
+ {
+ fn from(vka: &$s<'a, $p1>) -> Self {
+ assert!(std::ptr::eq(vka.ka.cert(), vka.cert.cert()));
+ ValidErasedKeyAmalgamation {
+ ka: vka.ka.clone().into(),
+ cert: vka.cert.clone(),
+ binding_signature: vka.binding_signature,
+ }
+ }
+ }
}
}