diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-12-12 16:43:56 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-12-12 16:43:56 +0100 |
commit | a0c09773b915305e325bb001c29591ecc976ad1a (patch) | |
tree | 45ef4216cec84b6dd91c979ccd3a51f641236ca9 | |
parent | e3d31910c565bac59f9adc8681c341771fe45ec7 (diff) |
openpgp: Move SecretKey to packet::key.
-rw-r--r-- | ffi/src/openpgp.rs | 2 | ||||
-rw-r--r-- | guide/src/chapter_01.md | 12 | ||||
-rw-r--r-- | openpgp/examples/decrypt-with.rs | 3 | ||||
-rw-r--r-- | openpgp/examples/generate-encrypt-decrypt.rs | 3 | ||||
-rw-r--r-- | openpgp/src/lib.rs | 1 | ||||
-rw-r--r-- | openpgp/src/message/mod.rs | 5 | ||||
-rw-r--r-- | openpgp/src/packet/key.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse/parse.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize/mod.rs | 1 | ||||
-rw-r--r-- | openpgp/src/serialize/stream.rs | 2 | ||||
-rw-r--r-- | openpgp/src/tpk/builder.rs | 6 | ||||
-rw-r--r-- | openpgp/src/tpk/mod.rs | 6 | ||||
-rw-r--r-- | tool/src/commands/decrypt.rs | 4 |
17 files changed, 35 insertions, 26 deletions
diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs index cd158d85..ef796144 100644 --- a/ffi/src/openpgp.rs +++ b/ffi/src/openpgp.rs @@ -26,8 +26,8 @@ use self::openpgp::{ Signature, PKESK, SKESK, + key::SecretKey, }, - SecretKey, crypto::Password, }; use self::openpgp::tpk::{ diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md index e81354e5..5db1cbdc 100644 --- a/guide/src/chapter_01.md +++ b/guide/src/chapter_01.md @@ -14,6 +14,7 @@ use std::io::{self, Write}; extern crate sequoia_openpgp as openpgp; use openpgp::serialize::stream::*; use openpgp::parse::stream::*; +use openpgp::packet::key::SecretKey; const MESSAGE: &'static str = "дружба"; @@ -119,7 +120,7 @@ fn main() { # # // The secret key is not encrypted. # let secret = -# if let Some(openpgp::SecretKey::Unencrypted { +# if let Some(SecretKey::Unencrypted { # ref mpis, # }) = key.secret() { # mpis.clone() @@ -150,6 +151,7 @@ create it: # extern crate sequoia_openpgp as openpgp; # use openpgp::serialize::stream::*; # use openpgp::parse::stream::*; +# use openpgp::packet::key::SecretKey; # # const MESSAGE: &'static str = "дружба"; # @@ -255,7 +257,7 @@ fn generate() -> openpgp::Result<openpgp::TPK> { # # // The secret key is not encrypted. # let secret = -# if let Some(openpgp::SecretKey::Unencrypted { +# if let Some(SecretKey::Unencrypted { # ref mpis, # }) = key.secret() { # mpis.clone() @@ -286,6 +288,7 @@ implements [`io::Write`], and we simply write the plaintext to it. # extern crate sequoia_openpgp as openpgp; # use openpgp::serialize::stream::*; # use openpgp::parse::stream::*; +# use openpgp::packet::key::SecretKey; # # const MESSAGE: &'static str = "дружба"; # @@ -391,7 +394,7 @@ fn encrypt(sink: &mut Write, plaintext: &str, recipient: &openpgp::TPK) # # // The secret key is not encrypted. # let secret = -# if let Some(openpgp::SecretKey::Unencrypted { +# if let Some(SecretKey::Unencrypted { # ref mpis, # }) = key.secret() { # mpis.clone() @@ -436,6 +439,7 @@ Decrypted data can be read from this using [`io::Read`]. # extern crate sequoia_openpgp as openpgp; # use openpgp::serialize::stream::*; # use openpgp::parse::stream::*; +# use openpgp::packet::key::SecretKey; # # const MESSAGE: &'static str = "дружба"; # @@ -541,7 +545,7 @@ impl<'a> DecryptionHelper for Helper<'a> { // The secret key is not encrypted. let secret = - if let Some(openpgp::SecretKey::Unencrypted { + if let Some(SecretKey::Unencrypted { ref mpis, }) = key.secret() { mpis.clone() diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs index 84f333db..bd8a2b13 100644 --- a/openpgp/examples/decrypt-with.rs +++ b/openpgp/examples/decrypt-with.rs @@ -8,6 +8,7 @@ use std::io; extern crate failure; extern crate sequoia_openpgp as openpgp; +use openpgp::packet::key::SecretKey; use openpgp::parse::stream::{ Decryptor, DecryptionHelper, Secret, VerificationHelper, VerificationResult, }; @@ -55,7 +56,7 @@ impl Helper { .unwrap_or(false) { // Only handle unencrypted secret keys. - if let Some(openpgp::SecretKey::Unencrypted { ref mpis }) = + if let Some(SecretKey::Unencrypted { ref mpis }) = key.secret() { keys.insert(key.fingerprint().to_keyid(), diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index 64b6cfab..3fb00103 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -5,6 +5,7 @@ use std::io::{self, Write}; extern crate sequoia_openpgp as openpgp; use openpgp::serialize::stream::*; use openpgp::parse::stream::*; +use openpgp::packet::key::SecretKey; const MESSAGE: &'static str = "дружба"; @@ -110,7 +111,7 @@ impl<'a> DecryptionHelper for Helper<'a> { // The secret key is not encrypted. let secret = - if let Some(openpgp::SecretKey::Unencrypted { + if let Some(SecretKey::Unencrypted { ref mpis, }) = key.secret() { mpis.clone() diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index 753aa6c7..39fea26a 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -104,7 +104,6 @@ pub mod crypto; pub mod packet; use packet::{BodyLength, Header, Container}; use packet::ctb::{CTB, CTBOld, CTBNew}; -pub use packet::key::SecretKey; pub mod parse; diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index 1bf147d0..cee9d4c1 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -410,6 +410,7 @@ mod tests { use packet::PKESK; use packet::SEIP; use packet::MDC; + use packet::key::SecretKey; use KeyID; use Container; @@ -753,7 +754,7 @@ mod tests { let hash = ::constants::HashAlgorithm::SHA512; let key = ::packet::Key::new(PublicKeyAlgorithm::EdDSA).unwrap(); let sec = - if let Some(::SecretKey::Unencrypted { ref mpis }) = key.secret() { + if let Some(SecretKey::Unencrypted { ref mpis }) = key.secret() { mpis.clone() } else { panic!() @@ -868,7 +869,7 @@ mod tests { let hash = ::constants::HashAlgorithm::SHA512; let key = ::packet::Key::new(PublicKeyAlgorithm::EdDSA).unwrap(); let sec = - if let Some(::SecretKey::Unencrypted { ref mpis }) = key.secret() { + if let Some(SecretKey::Unencrypted { ref mpis }) = key.secret() { mpis.clone() } else { panic!() diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index b987c376..a8c04818 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -1,3 +1,5 @@ +//! Public key, public subkey, private key and private subkey packets. + use std::fmt; use time; @@ -304,7 +306,7 @@ impl SecretKey { mod tests { use packet::Tag; use TPK; - use SecretKey; + use packet::key::SecretKey; use std::path::PathBuf; use super::*; use PacketPile; @@ -385,7 +387,7 @@ mod tests { #[test] fn encryption_roundtrip() { - use SecretKey; + use packet::key::SecretKey; use crypto::SessionKey; use packet::PKESK; diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index c1f74d71..03708c7d 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -27,7 +27,7 @@ pub mod signature; pub use self::signature::Signature; mod one_pass_sig; pub use self::one_pass_sig::OnePassSig; -pub(crate) mod key; +pub mod key; pub use self::key::Key; mod userid; pub use self::userid::UserID; diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index d949503d..5099d060 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -211,7 +211,7 @@ impl From<PKESK> for Packet { mod tests { use TPK; use PacketPile; - use SecretKey; + use packet::key::SecretKey; use Packet; use std::path::PathBuf; diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index d65eb615..547c1a93 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -991,7 +991,7 @@ mod test { #[test] fn sign_verify() { - use SecretKey; + use packet::key::SecretKey; let hash_algo = HashAlgorithm::SHA512; let mut hash = vec![0; hash_algo.context().unwrap().digest_size()]; diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 16eeed1b..eece2fe9 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -2237,7 +2237,7 @@ impl signature::Builder { #[test] fn accessors() { - use SecretKey; + use packet::key::SecretKey; let pk_algo = PublicKeyAlgorithm::EdDSA; let hash_algo = HashAlgorithm::SHA512; diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index b1e4abf9..08647db9 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -37,7 +37,7 @@ use { packet::AED, Packet, KeyID, - SecretKey, + packet::key::SecretKey, crypto::SessionKey, packet::PKESK, }; diff --git a/openpgp/src/serialize/mod.rs b/openpgp/src/serialize/mod.rs index 2543c3e6..a814afdc 100644 --- a/openpgp/src/serialize/mod.rs +++ b/openpgp/src/serialize/mod.rs @@ -32,6 +32,7 @@ use packet::{ Signature, OnePassSig, Key, + key::SecretKey, UserID, UserAttribute, Literal, diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index cb354cb2..3beb23dc 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -27,7 +27,7 @@ use { packet::PKESK, Result, crypto::Password, - SecretKey, + packet::key::SecretKey, crypto::SessionKey, packet::SKESK4, packet::SKESK5, diff --git a/openpgp/src/tpk/builder.rs b/openpgp/src/tpk/builder.rs index 48d7fbb9..74915e4d 100644 --- a/openpgp/src/tpk/builder.rs +++ b/openpgp/src/tpk/builder.rs @@ -227,7 +227,7 @@ impl TPKBuilder { -> Result<(Key, Signature)> { use SignatureType; - use SecretKey; + use packet::key::SecretKey; let key = cs.generate_key(&KeyFlags::default().set_certify(true))?; let mut sig = if uid.is_some() { @@ -269,7 +269,7 @@ impl TPKBuilder { -> Result<(Key, Signature)> { use SignatureType; - use SecretKey; + use packet::key::SecretKey; let subkey = cs.generate_key(&blueprint.flags)?; let mut sig = signature::Builder::new(SignatureType::SubkeyBinding); @@ -333,7 +333,7 @@ impl TPKBuilder { fn userid(uid: &UserID, key: &Key) -> Result<Signature> { use SignatureType; - use SecretKey; + use packet::key::SecretKey; let mut sig = signature::Builder::new(SignatureType::PositiveCertificate); diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs index a1d3b33e..ef6bbf5c 100644 --- a/openpgp/src/tpk/mod.rs +++ b/openpgp/src/tpk/mod.rs @@ -17,7 +17,7 @@ use { SignatureType, HashAlgorithm, packet::Tag, - SecretKey, + packet::key::SecretKey, packet::{signature, Signature}, packet::Key, packet::UserID, @@ -357,7 +357,7 @@ impl SubkeyBinding { use packet::KeyFlags; use constants::HashAlgorithm; use SignatureType; - use SecretKey; + use packet::key::SecretKey; let mut sig = signature::Builder::new(SignatureType::SubkeyBinding); @@ -478,7 +478,7 @@ impl UserIDBinding { use packet::KeyFlags; use constants::HashAlgorithm; use SignatureType; - use SecretKey; + use packet::key::SecretKey; let mut sig = signature::Builder::new(SignatureType::PositiveCertificate); diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs index 2998c616..f128bb17 100644 --- a/tool/src/commands/decrypt.rs +++ b/tool/src/commands/decrypt.rs @@ -5,8 +5,8 @@ use rpassword; extern crate sequoia_openpgp as openpgp; use sequoia_core::Context; -use openpgp::{Fingerprint, TPK, KeyID, SecretKey, Result}; -use openpgp::packet::{Key, Signature, PKESK, SKESK}; +use openpgp::{Fingerprint, TPK, KeyID, Result}; +use openpgp::packet::{Key, key::SecretKey, Signature, PKESK, SKESK}; use openpgp::parse::PacketParser; use openpgp::parse::stream::{ VerificationHelper, VerificationResult, DecryptionHelper, Decryptor, Secret, |