From 775f0c039349335df880d35db7df6c131419f0eb Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 9 Jul 2019 12:51:10 +0200 Subject: 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. --- openpgp/src/packet/aed.rs | 10 ++-- openpgp/src/packet/compressed_data.rs | 8 +-- openpgp/src/packet/ctb.rs | 4 +- openpgp/src/packet/header.rs | 6 +-- openpgp/src/packet/key.rs | 88 +++++++++++++++---------------- openpgp/src/packet/literal.rs | 16 +++--- openpgp/src/packet/marker.rs | 8 +-- openpgp/src/packet/mdc.rs | 6 +-- openpgp/src/packet/mod.rs | 12 ++--- openpgp/src/packet/one_pass_sig.rs | 24 ++++----- openpgp/src/packet/pkesk.rs | 74 +++++++++++++------------- openpgp/src/packet/prelude.rs | 4 +- openpgp/src/packet/seip.rs | 4 +- openpgp/src/packet/signature/mod.rs | 84 ++++++++++++++--------------- openpgp/src/packet/signature/subpacket.rs | 40 +++++++------- openpgp/src/packet/skesk.rs | 24 ++++----- openpgp/src/packet/tag.rs | 2 +- openpgp/src/packet/trust.rs | 10 ++-- openpgp/src/packet/unknown.rs | 6 +-- openpgp/src/packet/user_attribute.rs | 18 +++---- openpgp/src/packet/userid.rs | 12 ++--- 21 files changed, 230 insertions(+), 230 deletions(-) (limited to 'openpgp/src/packet') 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 { 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 { - 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 { 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 { 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) -> Vec> { let mut lpaths : Vec> = 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::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 { 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 { - 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; -pub use packet::{ +pub use crate::Packet; +pub use crate::packet::{ Tag, Header, Unknown, diff --git a/openpgp/src/packet/seip.rs b/openpgp/src/packet/seip.rs index fd448661..12c24efa 100644 --- a/openpgp/src/packet/seip.rs +++ b/openpgp/src/packet/seip.rs @@ -6,8 +6,8 @@ //! [Section 5.13 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.13 use std::ops::{Deref, DerefMut}; -use packet::{self, Common}; -use Packet; +use crate::packet::{self, Common}; +use crate::Packet; /// Holds an encrypted data packet. /// diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 68f3c3bf..a1e3bbd3 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -3,25 +3,25 @@ use std::fmt; use std::ops::Deref; -use constants::Curve; -use Error; -use Result; -use crypto::{ +use crate::constants::Curve; +use crate::Error; +use crate::Result; +use crate::crypto::{ mpis, hash::{self, Hash}, Signer, }; -use HashAlgorithm; -use PublicKeyAlgorithm; -use SignatureType; -use packet::Signature; -use packet::Key; -use KeyID; -use packet::UserID; -use packet::UserAttribute; -use Packet; -use packet; -use packet::signature::subpacket::SubpacketArea; +use crate::HashAlgorithm; +use crate::PublicKeyAlgorithm; +use crate::SignatureType; +use crate::packet::Signature; +use crate::packet::Key; +use crate::KeyID; +use crate::packet::UserID; +use crate::packet::UserAttribute; +use crate::Packet; +use crate::packet; +use crate::packet::signature::subpacket::SubpacketArea; use nettle::{dsa, ecc, ecdsa, ed25519, rsa}; use nettle::rsa::verify_digest_pkcs1; @@ -323,10 +323,10 @@ impl fmt::Debug for Signature4 { .field("hashed_area", self.hashed_area()) .field("unhashed_area", self.unhashed_area()) .field("hash_prefix", - &::conversions::to_hex(&self.hash_prefix, false)) + &crate::conversions::to_hex(&self.hash_prefix, false)) .field("computed_hash", &if let Some((algo, ref hash)) = self.computed_hash { - Some((algo, ::conversions::to_hex(&hash[..], false))) + Some((algo, crate::conversions::to_hex(&hash[..], false))) } else { None }) @@ -473,7 +473,7 @@ impl Signature4 { /// - the first `SubpacketValue::EmbeddedSignature` is left in /// place. pub fn normalize(&self) -> Self { - use packet::signature::subpacket::{Subpacket, SubpacketTag, + use crate::packet::signature::subpacket::{Subpacket, SubpacketTag, SubpacketValue}; let mut sig = self.clone(); { @@ -524,8 +524,8 @@ impl Signature4 { pub fn verify_hash(&self, key: &Key, hash_algo: HashAlgorithm, hash: &[u8]) -> Result { - use PublicKeyAlgorithm::*; - use crypto::mpis::PublicKey; + use crate::PublicKeyAlgorithm::*; + use crate::crypto::mpis::PublicKey; #[allow(deprecated)] match (self.pk_algo(), key.mpis(), self.mpis()) { @@ -990,19 +990,19 @@ impl From for super::Signature { #[cfg(test)] mod test { use super::*; - use crypto; - use crypto::mpis::MPI; - use TPK; - use parse::Parse; - use packet::key::Key4; + use crate::crypto; + use crate::crypto::mpis::MPI; + use crate::TPK; + use crate::parse::Parse; + use crate::packet::key::Key4; #[cfg(feature = "compression-deflate")] #[test] fn signature_verification_test() { use super::*; - use TPK; - use parse::{PacketParserResult, PacketParser}; + use crate::TPK; + use crate::parse::{PacketParserResult, PacketParser}; struct Test<'a> { key: &'a str, @@ -1083,11 +1083,11 @@ mod test { eprintln!("{}, expect {} good signatures:", test.data, test.good); - let tpk = TPK::from_bytes(::tests::key(test.key)).unwrap(); + let tpk = TPK::from_bytes(crate::tests::key(test.key)).unwrap(); let mut good = 0; let mut ppr = PacketParser::from_bytes( - ::tests::message(test.data)).unwrap(); + crate::tests::message(test.data)).unwrap(); while let PacketParserResult::Some(mut pp) = ppr { if let Packet::Signature(ref sig) = pp.packet { let result = sig.verify(tpk.primary()).unwrap_or(false); @@ -1117,9 +1117,9 @@ mod test { #[test] fn signature_level() { - use PacketPile; + use crate::PacketPile; let p = PacketPile::from_bytes( - ::tests::message("signed-1-notarized-by-ed25519.pgp")).unwrap() + crate::tests::message("signed-1-notarized-by-ed25519.pgp")).unwrap() .into_children().collect::>(); if let Packet::Signature(ref sig) = &p[3] { @@ -1149,7 +1149,7 @@ mod test { "erika-corinna-daniela-simone-antonia-nistp521-private.pgp", "emmelie-dorothea-dina-samantha-awina-ed25519-private.pgp", ] { - let tpk = TPK::from_bytes(::tests::key(key)).unwrap(); + let tpk = TPK::from_bytes(crate::tests::key(key)).unwrap(); let mut pair = tpk.primary().clone().into_keypair() .expect("secret key is encrypted/missing"); @@ -1175,7 +1175,7 @@ mod test { #[test] fn sign_message() { use time; - use constants::Curve; + use crate::constants::Curve; let key: Key = Key4::generate_ecc(true, Curve::Ed25519) .unwrap().into(); @@ -1192,11 +1192,11 @@ mod test { #[test] fn verify_message() { - let tpk = TPK::from_bytes(::tests::key( + let tpk = TPK::from_bytes(crate::tests::key( "emmelie-dorothea-dina-samantha-awina-ed25519.pgp")).unwrap(); - let msg = ::tests::manifesto(); + let msg = crate::tests::manifesto(); let p = Packet::from_bytes( - ::tests::message("a-cypherpunks-manifesto.txt.ed25519.sig")) + crate::tests::message("a-cypherpunks-manifesto.txt.ed25519.sig")) .unwrap(); let sig = if let Packet::Signature(s) = p { s @@ -1209,7 +1209,7 @@ mod test { #[test] fn sign_with_short_ed25519_secret_key() { - use conversions::Time; + use crate::conversions::Time; use nettle; use time; @@ -1246,17 +1246,17 @@ mod test { #[test] fn verify_gpg_3rd_party_cert() { - use TPK; + use crate::TPK; let test1 = TPK::from_bytes( - ::tests::key("test1-certification-key.pgp")).unwrap(); + crate::tests::key("test1-certification-key.pgp")).unwrap(); let cert_key1 = test1.keys_all() .certification_capable() .nth(0) .map(|x| x.2) .unwrap(); let test2 = TPK::from_bytes( - ::tests::key("test2-signed-by-test1.pgp")).unwrap(); + crate::tests::key("test2-signed-by-test1.pgp")).unwrap(); let uid_binding = &test2.primary_key_signature_full().unwrap().0.unwrap(); let cert = &uid_binding.certifications()[0]; @@ -1265,8 +1265,8 @@ mod test { #[test] fn normalize() { - use Fingerprint; - use packet::signature::subpacket::*; + use crate::Fingerprint; + use crate::packet::signature::subpacket::*; let mut pair = Key4::generate_ecc(true, Curve::Ed25519).unwrap() .into_keypair().unwrap(); diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 49d39abf..116dd38a 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -66,7 +66,7 @@ use quickcheck::{Arbitrary, Gen}; use buffered_reader::BufferedReader; -use { +use crate::{ Error, Result, packet::Signature, @@ -79,7 +79,7 @@ use { packet::Key, KeyID, }; -use constants::{ +use crate::constants::{ AEADAlgorithm, CompressionAlgorithm, HashAlgorithm, @@ -87,7 +87,7 @@ use constants::{ ReasonForRevocation, SymmetricAlgorithm, }; -use conversions::{ +use crate::conversions::{ Time, Duration, }; @@ -446,7 +446,7 @@ impl<'a> FromIterator<(usize, usize, Subpacket<'a>)> for SubpacketArea { fn from_iter(iter: I) -> Self where I: IntoIterator)> { - use serialize::Serialize; + use crate::serialize::Serialize; let mut data = Vec::new(); iter.into_iter().for_each(|(_, _, s)| s.serialize(&mut data).unwrap()); Self::new(data) @@ -512,7 +512,7 @@ impl SubpacketArea { /// Returns `Error::MalformedPacket` if adding the packet makes /// the subpacket area exceed the size limit. pub fn add(&mut self, packet: Subpacket) -> Result<()> { - use serialize::Serialize; + use crate::serialize::Serialize; if self.data.len() + packet.len() > ::std::u16::MAX as usize { return Err(Error::MalformedPacket( @@ -791,7 +791,7 @@ impl<'a> SubpacketValue<'a> { SignatureTarget { ref digest, .. } => 1 + 1 + digest.len(), EmbeddedSignature(p) => match p { &Packet::Signature(Signature::V4(ref sig)) => { - use serialize::Serialize; + use crate::serialize::Serialize; let mut w = Vec::new(); sig.serialize(&mut w).unwrap(); w.len() @@ -1094,13 +1094,13 @@ impl<'a> From> for Subpacket<'a> { }, SubpacketTag::EmbeddedSignature => { - use parse::Parse; + use crate::parse::Parse; // A signature packet. Some(SubpacketValue::EmbeddedSignature( match Signature::from_bytes(&raw.value) { Ok(s) => Packet::Signature(s), Err(e) => { - use packet::{Tag, Unknown}; + use crate::packet::{Tag, Unknown}; let mut u = Unknown::new(Tag::Signature, e); u.set_body(raw.value.to_vec()); Packet::Unknown(u) @@ -2411,14 +2411,14 @@ impl signature::Builder { #[test] fn accessors() { - use constants::Curve; + use crate::constants::Curve; let pk_algo = PublicKeyAlgorithm::EdDSA; let hash_algo = HashAlgorithm::SHA512; let hash = hash_algo.context().unwrap(); - let mut sig = signature::Builder::new(::constants::SignatureType::Binary); - let mut key: ::packet::Key = - ::packet::key::Key4::generate_ecc(true, Curve::Ed25519).unwrap().into(); + let mut sig = signature::Builder::new(crate::constants::SignatureType::Binary); + let mut key: crate::packet::Key = + crate::packet::key::Key4::generate_ecc(true, Curve::Ed25519).unwrap().into(); let mut keypair = key.clone().into_keypair().unwrap(); // Cook up a timestamp without ns resolution. @@ -2661,10 +2661,10 @@ fn accessors() { #[cfg(feature = "compression-deflate")] #[test] fn subpacket_test_1 () { - use PacketPile; - use parse::Parse; + use crate::PacketPile; + use crate::parse::Parse; - let pile = PacketPile::from_bytes(::tests::message("signed.gpg")).unwrap(); + let pile = PacketPile::from_bytes(crate::tests::message("signed.gpg")).unwrap(); eprintln!("PacketPile has {} top-level packets.", pile.children().len()); eprintln!("PacketPile: {:?}", pile); @@ -2714,9 +2714,9 @@ fn subpacket_test_1 () { #[test] fn subpacket_test_2() { - use conversions::Time; - use parse::Parse; - use PacketPile; + use crate::conversions::Time; + use crate::parse::Parse; + use crate::PacketPile; // Test # Subpacket // 1 2 3 4 5 6 SignatureCreationTime @@ -2747,7 +2747,7 @@ fn subpacket_test_2() { // XXX: The subpackets marked with * are not tested. let pile = PacketPile::from_bytes( - ::tests::key("subpackets/shaw.gpg")).unwrap(); + crate::tests::key("subpackets/shaw.gpg")).unwrap(); // Test #1 if let (Some(&Packet::PublicKey(ref key)), @@ -2952,7 +2952,7 @@ fn subpacket_test_2() { } let pile = PacketPile::from_bytes( - ::tests::key("subpackets/marven.gpg")).unwrap(); + crate::tests::key("subpackets/marven.gpg")).unwrap(); // Test #3 if let Some(&Packet::Signature(ref sig)) = pile.children().nth(1) { diff --git a/openpgp/src/packet/skesk.rs b/openpgp/src/packet/skesk.rs index cbc95243..0f62e948 100644 --- a/openpgp/src/packet/skesk.rs +++ b/openpgp/src/packet/skesk.rs @@ -9,18 +9,18 @@ use std::ops::{Deref, DerefMut}; use quickcheck::{Arbitrary, Gen}; -use Result; -use crypto; -use crypto::s2k::S2K; -use Error; -use constants::{ +use crate::Result; +use crate::crypto; +use crate::crypto::s2k::S2K; +use crate::Error; +use crate::constants::{ AEADAlgorithm, SymmetricAlgorithm, }; -use packet::{self, SKESK}; -use Packet; -use crypto::Password; -use crypto::SessionKey; +use crate::packet::{self, SKESK}; +use crate::Packet; +use crate::crypto::Password; +use crate::crypto::SessionKey; impl SKESK { /// Derives the key inside this SKESK from `password`. Returns a @@ -400,9 +400,9 @@ impl Arbitrary for SKESK5 { #[cfg(test)] mod test { use super::*; - use PacketPile; - use parse::Parse; - use serialize::{Serialize, SerializeInto}; + use crate::PacketPile; + use crate::parse::Parse; + use crate::serialize::{Serialize, SerializeInto}; quickcheck! { fn roundtrip(p: SKESK) -> bool { diff --git a/openpgp/src/packet/tag.rs b/openpgp/src/packet/tag.rs index 81f220f1..445bcb88 100644 --- a/openpgp/src/packet/tag.rs +++ b/openpgp/src/packet/tag.rs @@ -55,7 +55,7 @@ pub enum Tag { impl From for Tag { fn from(u: u8) -> Self { - use packet::Tag::*; + use crate::packet::Tag::*; match u { 0 => Reserved, diff --git a/openpgp/src/packet/trust.rs b/openpgp/src/packet/trust.rs index af89ca0c..fbf03569 100644 --- a/openpgp/src/packet/trust.rs +++ b/openpgp/src/packet/trust.rs @@ -1,8 +1,8 @@ use std::fmt; use quickcheck::{Arbitrary, Gen}; -use packet; -use Packet; +use crate::packet; +use crate::Packet; /// Holds a Trust packet. /// @@ -34,7 +34,7 @@ impl fmt::Display for Trust { impl fmt::Debug for Trust { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Trust") - .field("value", &::conversions::hex::encode(&self.value)) + .field("value", &crate::conversions::hex::encode(&self.value)) .finish() } } @@ -61,8 +61,8 @@ impl Arbitrary for Trust { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: Trust) -> bool { diff --git a/openpgp/src/packet/unknown.rs b/openpgp/src/packet/unknown.rs index 86dd937a..8258badd 100644 --- a/openpgp/src/packet/unknown.rs +++ b/openpgp/src/packet/unknown.rs @@ -1,9 +1,9 @@ use failure; use std::hash::{Hash, Hasher}; -use packet::Tag; -use packet; -use Packet; +use crate::packet::Tag; +use crate::packet; +use crate::Packet; /// Holds an unknown packet. /// diff --git a/openpgp/src/packet/user_attribute.rs b/openpgp/src/packet/user_attribute.rs index b5f8bf79..9e1f309a 100644 --- a/openpgp/src/packet/user_attribute.rs +++ b/openpgp/src/packet/user_attribute.rs @@ -10,15 +10,15 @@ use rand::Rng; use buffered_reader::BufferedReader; -use Error; -use Result; -use packet::{ +use crate::Error; +use crate::Result; +use crate::packet::{ self, BodyLength, }; -use Packet; -use serialize::Serialize; -use serialize::SerializeInto; +use crate::Packet; +use crate::serialize::Serialize; +use crate::serialize::SerializeInto; /// Holds a UserAttribute packet. /// @@ -240,8 +240,8 @@ impl Arbitrary for Image { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: UserAttribute) -> bool { @@ -253,7 +253,7 @@ mod tests { #[test] fn image() { - use Packet; + use crate::Packet; let p = Packet::from_bytes(b" -----BEGIN PGP ARMORED FILE----- diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index e0aa2713..df9f1809 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -3,7 +3,7 @@ use std::str; use std::hash::{Hash, Hasher}; use std::cell::RefCell; use quickcheck::{Arbitrary, Gen}; -use rfc2822::{ +use crate::rfc2822::{ AddrSpec, AddrSpecOrOther, Name, @@ -12,9 +12,9 @@ use rfc2822::{ }; use failure::ResultExt; -use Result; -use packet; -use Packet; +use crate::Result; +use crate::packet; +use crate::Packet; struct ParsedUserID { name: Option, @@ -477,8 +477,8 @@ impl Arbitrary for UserID { #[cfg(test)] mod tests { use super::*; - use parse::Parse; - use serialize::SerializeInto; + use crate::parse::Parse; + use crate::serialize::SerializeInto; quickcheck! { fn roundtrip(p: UserID) -> bool { -- cgit v1.2.3