diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-07-09 12:51:10 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-07-15 12:47:53 +0200 |
commit | 775f0c039349335df880d35db7df6c131419f0eb (patch) | |
tree | 2d16928f3a629b7afae95cf1b9d518c5603a9f93 /openpgp/src/packet | |
parent | caec575e3c44e6045e29aa452ad31f91d04ec139 (diff) |
Prepare for Rust 2018.
- This is the result of running `cargo fix --edition`, with some
manual adjustments.
- The vast majority of changes merely qualify module paths with
'crate::'.
- Two instances of adding an anonymous pattern to a trait's
function.
- `async` is a keyword in Rust 2018, and hence it needs to be
escaped (e.g. in the case of the net::r#async module).
- The manual adjustments were needed due to various shortcomings of
the analysis employed by `cargo fix`, e.g. unexpanded macros,
procedural macros, lalrpop grammars.
Diffstat (limited to 'openpgp/src/packet')
-rw-r--r-- | openpgp/src/packet/aed.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/compressed_data.rs | 8 | ||||
-rw-r--r-- | openpgp/src/packet/ctb.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/header.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/key.rs | 88 | ||||
-rw-r--r-- | openpgp/src/packet/literal.rs | 16 | ||||
-rw-r--r-- | openpgp/src/packet/marker.rs | 8 | ||||
-rw-r--r-- | openpgp/src/packet/mdc.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/mod.rs | 12 | ||||
-rw-r--r-- | openpgp/src/packet/one_pass_sig.rs | 24 | ||||
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 74 | ||||
-rw-r--r-- | openpgp/src/packet/prelude.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/seip.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 84 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 40 | ||||
-rw-r--r-- | openpgp/src/packet/skesk.rs | 24 | ||||
-rw-r--r-- | openpgp/src/packet/tag.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/trust.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/unknown.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/user_attribute.rs | 18 | ||||
-rw-r--r-- | openpgp/src/packet/userid.rs | 12 |
21 files changed, 230 insertions, 230 deletions
diff --git a/openpgp/src/packet/aed.rs b/openpgp/src/packet/aed.rs index 6fb8f630..745e925c 100644 --- a/openpgp/src/packet/aed.rs +++ b/openpgp/src/packet/aed.rs @@ -2,14 +2,14 @@ use std::ops::{Deref, DerefMut}; -use constants::{ +use crate::constants::{ AEADAlgorithm, SymmetricAlgorithm, }; -use packet::{self, Common}; -use Packet; -use Error; -use Result; +use crate::packet::{self, Common}; +use crate::Packet; +use crate::Error; +use crate::Result; /// Holds an AEAD encrypted data packet. /// diff --git a/openpgp/src/packet/compressed_data.rs b/openpgp/src/packet/compressed_data.rs index 8a2af0fc..a66fa7a8 100644 --- a/openpgp/src/packet/compressed_data.rs +++ b/openpgp/src/packet/compressed_data.rs @@ -1,10 +1,10 @@ use std::fmt; use std::ops::{Deref, DerefMut}; -use packet::{self, Common}; -use Packet; -use Container; -use constants::CompressionAlgorithm; +use crate::packet::{self, Common}; +use crate::Packet; +use crate::Container; +use crate::constants::CompressionAlgorithm; /// Holds a compressed data packet. /// diff --git a/openpgp/src/packet/ctb.rs b/openpgp/src/packet/ctb.rs index 3223ca6f..b5a0bffc 100644 --- a/openpgp/src/packet/ctb.rs +++ b/openpgp/src/packet/ctb.rs @@ -6,12 +6,12 @@ use std::ops::Deref; -use { +use crate::{ packet::Tag, Error, Result }; -use packet::BodyLength; +use crate::packet::BodyLength; /// OpenPGP defines two packet formats: the old and the new format. /// They both include the packet's so-called tag. diff --git a/openpgp/src/packet/header.rs b/openpgp/src/packet/header.rs index 55e7001e..d1660040 100644 --- a/openpgp/src/packet/header.rs +++ b/openpgp/src/packet/header.rs @@ -1,12 +1,12 @@ //! OpenPGP Header. -use { +use crate::{ Error, Result, BodyLength, }; -use packet::tag::Tag; -use packet::ctb::CTB; +use crate::packet::tag::Tag; +use crate::packet::ctb::CTB; /// An OpenPGP packet's header. #[derive(Clone, Debug)] diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 5237079e..441f10d1 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -5,21 +5,21 @@ use std::mem; use std::cmp::Ordering; use time; -use Error; -use crypto::{self, mem::Protected, mpis, hash::Hash, KeyPair}; -use packet::Tag; -use packet; -use Packet; -use PublicKeyAlgorithm; -use SymmetricAlgorithm; -use HashAlgorithm; -use constants::Curve; -use crypto::s2k::S2K; -use Result; -use conversions::Time; -use crypto::Password; -use KeyID; -use Fingerprint; +use crate::Error; +use crate::crypto::{self, mem::Protected, mpis, hash::Hash, KeyPair}; +use crate::packet::Tag; +use crate::packet; +use crate::Packet; +use crate::PublicKeyAlgorithm; +use crate::SymmetricAlgorithm; +use crate::HashAlgorithm; +use crate::constants::Curve; +use crate::crypto::s2k::S2K; +use crate::Result; +use crate::conversions::Time; +use crate::crypto::Password; +use crate::KeyID; +use crate::Fingerprint; /// Holds a public key, public subkey, private key or private subkey packet. /// @@ -267,7 +267,7 @@ impl Key4 { /// Generates a new RSA key with a public modulos of size `bits`. pub fn generate_rsa(bits: usize) -> Result<Self> { use nettle::{rsa, Yarrow}; - use crypto::mpis::{self, MPI, PublicKey}; + use crate::crypto::mpis::{self, MPI, PublicKey}; let mut rng = Yarrow::default(); let (public, private) = rsa::generate_keypair(&mut rng, bits as u32)?; @@ -307,10 +307,10 @@ impl Key4 { curve25519, curve25519::CURVE25519_SIZE, ecc, ecdh, ecdsa, }; - use crypto::mpis::{self, MPI, PublicKey}; - use constants::{HashAlgorithm, SymmetricAlgorithm, Curve}; - use PublicKeyAlgorithm::*; - use Error; + use crate::crypto::mpis::{self, MPI, PublicKey}; + use crate::constants::{HashAlgorithm, SymmetricAlgorithm, Curve}; + use crate::PublicKeyAlgorithm::*; + use crate::Error; let mut rng = Yarrow::default(); @@ -541,7 +541,7 @@ impl Key4 { /// /// Fails if the secret key is missing, or encrypted. pub fn into_keypair(mut self) -> Result<KeyPair> { - use packet::key::SecretKey; + use crate::packet::key::SecretKey; let secret = match self.set_secret(None) { Some(SecretKey::Unencrypted(secret)) => secret, Some(SecretKey::Encrypted(_)) => @@ -659,7 +659,7 @@ impl Unencrypted { pub fn encrypt(&self, password: &Password) -> Result<Encrypted> { use std::io::Write; - use crypto::symmetric::Encryptor; + use crate::crypto::symmetric::Encryptor; let s2k = S2K::default(); let algo = SymmetricAlgorithm::AES256; @@ -721,7 +721,7 @@ impl Encrypted { pub fn decrypt(&self, pk_algo: PublicKeyAlgorithm, password: &Password) -> Result<Unencrypted> { use std::io::{Cursor, Read}; - use crypto::symmetric::Decryptor; + use crate::crypto::symmetric::Decryptor; let key = self.s2k.derive_key(password, self.algo.key_size()?)?; let cur = Cursor::new(&self.ciphertext); @@ -737,19 +737,19 @@ impl Encrypted { #[cfg(test)] mod tests { - use packet::Key; - use TPK; - use packet::pkesk::PKESK3; - use packet::key::SecretKey; + use crate::packet::Key; + use crate::TPK; + use crate::packet::pkesk::PKESK3; + use crate::packet::key::SecretKey; use super::*; - use PacketPile; - use serialize::Serialize; - use parse::Parse; + use crate::PacketPile; + use crate::serialize::Serialize; + use crate::parse::Parse; #[test] fn encrypted_rsa_key() { let mut tpk = TPK::from_bytes( - ::tests::key("testy-new-encrypted-with-123.pgp")).unwrap(); + crate::tests::key("testy-new-encrypted-with-123.pgp")).unwrap(); let pair = tpk.primary_mut(); let pk_algo = pair.pk_algo(); let secret = pair.secret.as_mut().unwrap(); @@ -769,7 +769,7 @@ mod tests { #[test] fn eq() { - use constants::Curve::*; + use crate::constants::Curve::*; for curve in vec![NistP256, NistP384, NistP521] { let sign_key = Key4::generate_ecc(true, curve.clone()).unwrap(); @@ -790,7 +790,7 @@ mod tests { #[test] fn roundtrip() { - use constants::Curve::*; + use crate::constants::Curve::*; let keys = vec![NistP256, NistP384, NistP521].into_iter().flat_map(|cv| { let sign_key = Key4::generate_ecc(true, cv.clone()).unwrap(); @@ -839,8 +839,8 @@ mod tests { #[test] fn encryption_roundtrip() { - use crypto::SessionKey; - use constants::Curve::*; + use crate::crypto::SessionKey; + use crate::constants::Curve::*; let keys = vec![NistP256, NistP384, NistP521].into_iter().map(|cv| { Key4::generate_ecc(false, cv).unwrap() @@ -864,7 +864,7 @@ mod tests { #[test] fn secret_encryption_roundtrip() { - use constants::Curve::*; + use crate::constants::Curve::*; let keys = vec![NistP256, NistP384, NistP521].into_iter().map(|cv| { Key4::generate_ecc(false, cv).unwrap() @@ -892,7 +892,7 @@ mod tests { #[test] fn import_cv25519() { - use crypto::{ecdh, mem, SessionKey}; + use crate::crypto::{ecdh, mem, SessionKey}; use self::mpis::{MPI, Ciphertext}; use time::{at, Timespec}; @@ -925,7 +925,7 @@ mod tests { #[test] fn import_cv25519_sec() { - use crypto::ecdh; + use crate::crypto::ecdh; use self::mpis::{MPI, Ciphertext}; use time::{at, Timespec}; @@ -965,7 +965,7 @@ mod tests { #[test] fn import_rsa() { - use crypto::SessionKey; + use crate::crypto::SessionKey; use self::mpis::{MPI, Ciphertext}; use time::{at, Timespec}; @@ -999,10 +999,10 @@ mod tests { #[test] fn import_ed25519() { use time::{at, Timespec}; - use {Fingerprint, KeyID}; - use constants::SignatureType; - use packet::signature::Signature4; - use packet::signature::subpacket::{ + use crate::{Fingerprint, KeyID}; + use crate::constants::SignatureType; + use crate::packet::signature::Signature4; + use crate::packet::signature::subpacket::{ Subpacket, SubpacketValue, SubpacketArea}; // Ed25519 key @@ -1035,7 +1035,7 @@ mod tests { #[test] fn fingerprint_test() { let pile = - PacketPile::from_bytes(::tests::key("public-key.gpg")).unwrap(); + PacketPile::from_bytes(crate::tests::key("public-key.gpg")).unwrap(); // The blob contains a public key and a three subkeys. let mut pki = 0; diff --git a/openpgp/src/packet/literal.rs b/openpgp/src/packet/literal.rs index e892ea2b..4b3aa4fe 100644 --- a/openpgp/src/packet/literal.rs +++ b/openpgp/src/packet/literal.rs @@ -3,12 +3,12 @@ use std::cmp; use time; use quickcheck::{Arbitrary, Gen}; -use constants::DataFormat; -use conversions::Time; -use Error; -use packet; -use Packet; -use Result; +use crate::constants::DataFormat; +use crate::conversions::Time; +use crate::Error; +use crate::packet; +use crate::Packet; +use crate::Result; /// Holds a literal packet. /// @@ -195,8 +195,8 @@ impl Arbitrary for Literal { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: Literal) -> bool { diff --git a/openpgp/src/packet/marker.rs b/openpgp/src/packet/marker.rs index 21be2443..04de483d 100644 --- a/openpgp/src/packet/marker.rs +++ b/openpgp/src/packet/marker.rs @@ -1,7 +1,7 @@ use quickcheck::{Arbitrary, Gen}; -use packet; -use Packet; +use crate::packet; +use crate::Packet; /// Holds a Marker packet. /// @@ -41,8 +41,8 @@ impl Arbitrary for Marker { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; #[test] fn roundtrip() { diff --git a/openpgp/src/packet/mdc.rs b/openpgp/src/packet/mdc.rs index 9a0b7d6c..d6628479 100644 --- a/openpgp/src/packet/mdc.rs +++ b/openpgp/src/packet/mdc.rs @@ -1,6 +1,6 @@ -use crypto; -use packet; -use Packet; +use crate::crypto; +use crate::packet; +use crate::Packet; /// Holds an MDC packet. /// diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index 2f4572ce..b258a61b 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -10,8 +10,8 @@ use std::slice; use std::vec; use std::io; -use Result; -use Packet; +use crate::Result; +use crate::Packet; pub mod prelude; @@ -540,8 +540,8 @@ impl<'a> Iterator for PacketPathIter<'a> { // Tests the `paths`() iter and `path_ref`(). #[test] fn packet_path_iter() { - use parse::Parse; - use PacketPile; + use crate::parse::Parse; + use crate::PacketPile; fn paths(iter: slice::Iter<Packet>) -> Vec<Vec<usize>> { let mut lpaths : Vec<Vec<usize>> = Vec::new(); @@ -562,7 +562,7 @@ fn packet_path_iter() { for i in 1..5 { let pile = PacketPile::from_bytes( - ::tests::message(&format!("recursive-{}.gpg", i)[..])).unwrap(); + crate::tests::message(&format!("recursive-{}.gpg", i)[..])).unwrap(); let mut paths1 : Vec<Vec<usize>> = Vec::new(); for path in paths(pile.children()).iter() { @@ -812,7 +812,7 @@ impl Key { /// # Errors /// /// Fails if the secret key is missing, or encrypted. - pub fn into_keypair(self) -> Result<::crypto::KeyPair> { + pub fn into_keypair(self) -> Result<crate::crypto::KeyPair> { match self { Key::V4(p) => p.into_keypair(), } diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs index 88a8845d..58230ed9 100644 --- a/openpgp/src/packet/one_pass_sig.rs +++ b/openpgp/src/packet/one_pass_sig.rs @@ -7,16 +7,16 @@ use std::fmt; use quickcheck::{Arbitrary, Gen}; -use Error; -use Packet; -use packet; -use packet::Signature; -use Result; -use KeyID; -use HashAlgorithm; -use PublicKeyAlgorithm; -use SignatureType; -use serialize::SerializeInto; +use crate::Error; +use crate::Packet; +use crate::packet; +use crate::packet::Signature; +use crate::Result; +use crate::KeyID; +use crate::HashAlgorithm; +use crate::PublicKeyAlgorithm; +use crate::SignatureType; +use crate::serialize::SerializeInto; /// Holds a one-pass signature packet. /// @@ -185,8 +185,8 @@ impl Arbitrary for OnePassSig3 { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: OnePassSig3) -> bool { diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index bf36e35c..0ec2d4f2 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -7,19 +7,19 @@ use quickcheck::{Arbitrary, Gen}; -use Error; -use packet::Key; -use KeyID; -use crypto::Decryptor; -use crypto::mpis::{self, MPI, Ciphertext}; -use Packet; -use PublicKeyAlgorithm; -use Result; -use SymmetricAlgorithm; -use crypto::SessionKey; -use crypto::ecdh; +use crate::Error; +use crate::packet::Key; +use crate::KeyID; +use crate::crypto::Decryptor; +use crate::crypto::mpis::{self, MPI, Ciphertext}; +use crate::Packet; +use crate::PublicKeyAlgorithm; +use crate::Result; +use crate::SymmetricAlgorithm; +use crate::crypto::SessionKey; +use crate::crypto::ecdh; use nettle::{rsa, Yarrow}; -use packet; +use crate::packet; /// Holds an asymmetrically encrypted session key. /// @@ -59,7 +59,7 @@ impl PKESK3 { pub fn for_recipient(algo: SymmetricAlgorithm, session_key: &SessionKey, recipient: &Key) -> Result<PKESK3> { - use PublicKeyAlgorithm::*; + use crate::PublicKeyAlgorithm::*; let mut rng = Yarrow::default(); // We need to prefix the cipher specifier to the session key, @@ -202,11 +202,11 @@ impl Arbitrary for PKESK3 { #[cfg(test)] mod tests { use super::*; - use TPK; - use PacketPile; - use Packet; - use parse::Parse; - use serialize::SerializeInto; + use crate::TPK; + use crate::PacketPile; + use crate::Packet; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: PKESK3) -> bool { @@ -219,9 +219,9 @@ mod tests { #[test] fn decrypt_rsa() { let tpk = TPK::from_bytes( - ::tests::key("testy-private.pgp")).unwrap(); + crate::tests::key("testy-private.pgp")).unwrap(); let pile = PacketPile::from_bytes( - ::tests::message("encrypted-to-testy.gpg")).unwrap(); + crate::tests::message("encrypted-to-testy.gpg")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() .subkey().clone().into_keypair().unwrap(); @@ -240,9 +240,9 @@ mod tests { #[test] fn decrypt_ecdh_cv25519() { let tpk = TPK::from_bytes( - ::tests::key("testy-new-private.pgp")).unwrap(); + crate::tests::key("testy-new-private.pgp")).unwrap(); let pile = PacketPile::from_bytes( - ::tests::message("encrypted-to-testy-new.pgp")).unwrap(); + crate::tests::message("encrypted-to-testy-new.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() .subkey().clone().into_keypair().unwrap(); @@ -261,9 +261,9 @@ mod tests { #[test] fn decrypt_ecdh_nistp256() { let tpk = TPK::from_bytes( - ::tests::key("testy-nistp256-private.pgp")).unwrap(); + crate::tests::key("testy-nistp256-private.pgp")).unwrap(); let pile = PacketPile::from_bytes( - ::tests::message("encrypted-to-testy-nistp256.pgp")).unwrap(); + crate::tests::message("encrypted-to-testy-nistp256.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() .subkey().clone().into_keypair().unwrap(); @@ -282,9 +282,9 @@ mod tests { #[test] fn decrypt_ecdh_nistp384() { let tpk = TPK::from_bytes( - ::tests::key("testy-nistp384-private.pgp")).unwrap(); + crate::tests::key("testy-nistp384-private.pgp")).unwrap(); let pile = PacketPile::from_bytes( - ::tests::message("encrypted-to-testy-nistp384.pgp")).unwrap(); + crate::tests::message("encrypted-to-testy-nistp384.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() .subkey().clone().into_keypair().unwrap(); @@ -303,9 +303,9 @@ mod tests { #[test] fn decrypt_ecdh_nistp521() { let tpk = TPK::from_bytes( - ::tests::key("testy-nistp521-private.pgp")).unwrap(); + crate::tests::key("testy-nistp521-private.pgp")).unwrap(); let pile = PacketPile::from_bytes( - ::tests::message("encrypted-to-testy-nistp521.pgp")).unwrap(); + crate::tests::message("encrypted-to-testy-nistp521.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() .subkey().clone().into_keypair().unwrap(); @@ -324,16 +324,16 @@ mod tests { #[test] fn decrypt_with_short_cv25519_secret_key() { - use conversions::Time; + use crate::conversions::Time; use super::PKESK3; - use crypto::SessionKey; - use crypto::mpis::{self, MPI}; - use PublicKeyAlgorithm; - use SymmetricAlgorithm; - use HashAlgorithm; - use constants::Curve; - use packet::Key; - use packet::key::Key4; + use crate::crypto::SessionKey; + use crate::crypto::mpis::{self, MPI}; + use crate::PublicKeyAlgorithm; + use crate::SymmetricAlgorithm; + use crate::HashAlgorithm; + use crate::constants::Curve; + use crate::packet::Key; + use crate::packet::key::Key4; use nettle::curve25519; use time; diff --git a/openpgp/src/packet/prelude.rs b/openpgp/src/packet/prelude.rs index 805a27ed..23c7dd97 100644 --- a/openpgp/src/packet/prelude.rs +++ b/openpgp/src/packet/prelude.rs @@ -1,7 +1,7 @@ //! Conveniently re-exports everything below openpgp::packet. -pub use Packet; |