diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-27 17:12:26 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-27 17:12:26 +0200 |
commit | 0e026f8ac794a70012d36e662a0b54ad0888d890 (patch) | |
tree | 0c905dc768cea33dd3cd416398c00f489af953e9 /openpgp/src/parse | |
parent | 9ce35cc2c757fae1338a356354608cf1d6fa563f (diff) |
openpgp: Rework secret key handling.
- Introduce two new types, `Encrypted` and `Unencrypted`, to make
the fields of enum `SecretKey` private. Add accessors, implement
From<..> to make the new types ergonomic to use, update callsites.
Diffstat (limited to 'openpgp/src/parse')
-rw-r--r-- | openpgp/src/parse/parse.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index 9d05bc66..8df103e8 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -26,7 +26,6 @@ use { packet::prelude::*, Packet, KeyID, - packet::key::SecretKey, crypto::SessionKey, }; use constants::{ @@ -1354,7 +1353,7 @@ impl Key4 { return php.fail("wrong secret key checksum"); } - SecretKey::Unencrypted{ mpis: sec } + sec.into() } // Encrypted & MD5 for key derivation: unsupported 1...253 => { @@ -1366,11 +1365,8 @@ impl Key4 { let s2k = php_try!(S2K::parse(&mut php)); let mut cipher = php_try!(php.parse_bytes_eof("encrypted_mpis")); - SecretKey::Encrypted{ - s2k: s2k, - algorithm: sk, - ciphertext: cipher.into_boxed_slice(), - } + ::packet::key::Encrypted::new( + s2k, sk, cipher.into_boxed_slice()).into() } // Encrypted, S2K & mod 65536 checksum: unsupported 255 => { |