diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-01 18:10:08 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-01 19:35:56 +0200 |
commit | 432a7898265cf4b64ebee7a1c2e722204c9b0eea (patch) | |
tree | 5a39d24eaf7ef489161572b1719cf2f5868516df /openpgp/src/crypto | |
parent | cdc640c577089cbf755be388cacd0974857b6578 (diff) |
openpgp: Implement From<KeyPair> for packet::Key.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index e23c3c73..ea8896e9 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -2,7 +2,7 @@ use nettle::{dsa, ecc, ecdsa, ed25519, rsa, Yarrow}; -use packet::Key; +use packet::{self, Key}; use crypto::SessionKey; use crypto::mpis::{self, MPI}; use constants::{Curve, HashAlgorithm}; @@ -246,3 +246,14 @@ impl Decryptor for KeyPair { }.into()) } } + +impl From<KeyPair> for packet::Key { + fn from(p: KeyPair) -> Self { + let (mut key, secret) = (p.public, p.secret); + key.set_secret(Some(packet::key::SecretKey::Unencrypted { + mpis: secret, + })); + key + } + +} |