diff options
-rw-r--r-- | openpgp/NEWS | 4 | ||||
-rw-r--r-- | openpgp/src/packet/key.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/mod.rs | 8 |
3 files changed, 18 insertions, 0 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS index da2b53b3..f40537a3 100644 --- a/openpgp/NEWS +++ b/openpgp/NEWS @@ -6,6 +6,10 @@ * Changes in 1.21.0 ** New functionality + - Key::<PublicParts, _>::steal_secret + - Key::<UnknownParts, _>::steal_secret + - Key4::<PublicParts, _>::steal_secret + - Key4::<UnknownParts, _>::steal_secret - The RustCrypto backend now supports ECDH and ECDSA over the NIST curve P-384. - The RustCrypto backend now supports ECDH and ECDSA over the NIST diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index f7287f5d..112c2fa3 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -1479,6 +1479,12 @@ macro_rules! impl_common_secret_functions { let old = std::mem::replace(&mut self.secret, Some(secret)); (self.parts_into_secret().expect("secret just set"), old) } + + /// Takes the `Key`'s `SecretKeyMaterial`, if any. + pub fn steal_secret(&mut self) -> Option<SecretKeyMaterial> + { + std::mem::replace(&mut self.secret, None) + } } } } diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index 68058053..bbb8b1e4 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -1866,6 +1866,14 @@ macro_rules! impl_common_secret_functions { }, } } + + /// Takes the key packet's `SecretKeyMaterial`, if any. + pub fn steal_secret(&mut self) -> Option<key::SecretKeyMaterial> + { + match self { + Key::V4(k) => k.steal_secret(), + } + } } } } |