diff options
Diffstat (limited to 'openpgp/src')
65 files changed, 749 insertions, 749 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 16b2f965..d83c231b 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -34,10 +34,10 @@ use std::cmp::min; use std::str; use quickcheck::{Arbitrary, Gen}; -use packet::prelude::*; -use packet::BodyLength; -use packet::ctb::{CTBNew, CTBOld}; -use serialize::SerializeInto; +use crate::packet::prelude::*; +use crate::packet::BodyLength; +use crate::packet::ctb::{CTBNew, CTBOld}; +use crate::serialize::SerializeInto; /// The encoded output stream must be represented in lines of no more /// than 76 characters each (see (see [RFC 4880, section @@ -1367,7 +1367,7 @@ mod test { #[test] fn dearmor_yuge() { - let yuge_key = ::tests::key("yuge-key-so-yuge-the-yugest.asc"); + let yuge_key = crate::tests::key("yuge-key-so-yuge-the-yugest.asc"); let mut r = Reader::new(Cursor::new(&yuge_key[..]), ReaderMode::VeryTolerant); let mut dearmored = Vec::<u8>::new(); diff --git a/openpgp/src/autocrypt.rs b/openpgp/src/autocrypt.rs index e2176a35..4f3d0ebb 100644 --- a/openpgp/src/autocrypt.rs +++ b/openpgp/src/autocrypt.rs @@ -19,23 +19,23 @@ use std::path::Path; use std::fs::File; use std::str; -use armor; - -use Error; -use Result; -use Packet; -use packet::SKESK; -use TPK; -use parse::{ +use crate::armor; + +use crate::Error; +use crate::Result; +use crate::Packet; +use crate::packet::SKESK; +use crate::TPK; +use crate::parse::{ Parse, PacketParserResult, PacketParser, }; -use serialize::Serialize; -use serialize::stream::{ +use crate::serialize::Serialize; +use crate::serialize::stream::{ Message, LiteralWriter, Encryptor, EncryptionMode, }; -use constants::DataFormat; -use crypto::Password; +use crate::constants::DataFormat; +use crate::crypto::Password; /// Version of Autocrypt to use. `Autocrypt::default()` always returns the /// latest version. @@ -101,7 +101,7 @@ impl AutocryptHeader { -> Result<Self> where P: Into<Option<&'a str>> { - use packet::Tag; + use crate::packet::Tag; // Minimize TPK. let mut acc = Vec::new(); @@ -406,7 +406,7 @@ impl AutocryptSetupMessage { // approximately 119 bits of information. 120 bits = 15 // bytes. let mut p_as_vec = vec![0; 15]; - ::crypto::random(&mut p_as_vec[..]); + crate::crypto::random(&mut p_as_vec[..]); let p = Password::from(p_as_vec); // Turn it into a 128-bit number. @@ -774,7 +774,7 @@ impl<'a> AutocryptSetupMessageParser<'a> { mod test { use super::*; - use Fingerprint; + use crate::Fingerprint; #[test] fn decode_test() { @@ -1032,7 +1032,7 @@ In the light of the Efail vulnerability I am asking myself if it's fn autocrypt_setup_message() { // Try the example autocrypt setup message. let mut asm = AutocryptSetupMessage::from_bytes( - ::tests::file("autocrypt/setup-message.txt")).unwrap(); + crate::tests::file("autocrypt/setup-message.txt")).unwrap(); // A bad passcode. assert!(asm.decrypt(&"123".into()).is_err()); @@ -1052,7 +1052,7 @@ In the light of the Efail vulnerability I am asking myself if it's // Create an ASM for testy-private. Then decrypt it and make // sure the TPK, etc. survived the round trip. let tpk = - TPK::from_bytes(::tests::key("testy-private.pgp")).unwrap(); + TPK::from_bytes(crate::tests::key("testy-private.pgp")).unwrap(); let mut asm = AutocryptSetupMessage::new(tpk) .set_prefer_encrypt("mutual"); @@ -1067,7 +1067,7 @@ In the light of the Efail vulnerability I am asking myself if it's #[test] fn autocrypt_header_new() { - let tpk = TPK::from_bytes(::tests::key("testy.pgp")).unwrap(); + let tpk = TPK::from_bytes(crate::tests::key("testy.pgp")).unwrap(); let header = AutocryptHeader::new_sender(&tpk, "testy@example.org", "mutual").unwrap(); let mut buf = Vec::new(); diff --git a/openpgp/src/constants.rs b/openpgp/src/constants.rs index 4d5761f7..b3e3c265 100644 --- a/openpgp/src/constants.rs +++ b/openpgp/src/constants.rs @@ -9,8 +9,8 @@ use std::result; use quickcheck::{Arbitrary, Gen}; -use Error; -use Result; +use crate::Error; +use crate::Result; /// The OpenPGP public key algorithms as defined in [Section 9.1 of /// RFC 4880], and [Section 5 of RFC 6637]. @@ -88,7 +88,7 @@ impl PublicKeyAlgorithm { impl From<u8> for PublicKeyAlgorithm { fn from(u: u8) -> Self { - use PublicKeyAlgorithm::*; + use crate::PublicKeyAlgorithm::*; #[allow(deprecated)] match u { 1 => RSAEncryptSign, @@ -108,7 +108,7 @@ impl From<u8> for PublicKeyAlgorithm { impl From<PublicKeyAlgorithm> for u8 { fn from(p: PublicKeyAlgorithm) -> u8 { - use PublicKeyAlgorithm::*; + use crate::PublicKeyAlgorithm::*; #[allow(deprecated)] match p { RSAEncryptSign => 1, @@ -128,7 +128,7 @@ impl From<PublicKeyAlgorithm> for u8 { impl fmt::Display for PublicKeyAlgorithm { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PublicKeyAlgorithm::*; + use crate::PublicKeyAlgorithm::*; #[allow(deprecated)] match *self { RSAEncryptSign => f.write_str("RSA (Encrypt or Sign)"), diff --git a/openpgp/src/conversions.rs b/openpgp/src/conversions.rs index 07ab85ee..5c76fb1d 100644 --- a/openpgp/src/conversions.rs +++ b/openpgp/src/conversions.rs @@ -2,13 +2,13 @@ use time; -use Error; -use Result; +use crate::Error; +use crate::Result; /// Conversions for OpenPGP time stamps. pub trait Time { /// Converts an OpenPGP time stamp to broken-down time. - fn from_pgp(u32) -> Self; + fn from_pgp(_: u32) -> Self; /// Converts broken-down time to an OpenPGP time stamp. fn to_pgp(&self) -> Result<u32>; /// Strips off any subseconds that OpenPGP cannot represent, and @@ -40,7 +40,7 @@ impl Time for time::Tm { /// Conversions for OpenPGP durations. pub trait Duration { /// Converts an OpenPGP duration to ISO 8601 time duration. - fn from_pgp(u32) -> Self; + fn from_pgp(_: u32) -> Self; /// Converts ISO 8601 time duration to an OpenPGP duration. fn to_pgp(&self) -> Result<u32>; /// Strips off any subseconds that OpenPGP cannot represent. @@ -82,12 +82,12 @@ pub mod hex { } /// Decodes the given hexadecimal number. - pub fn decode<H: AsRef<str>>(hex: H) -> ::Result<Vec<u8>> { + pub fn decode<H: AsRef<str>>(hex: H) -> crate::Result<Vec<u8>> { super::from_hex(hex.as_ref(), false) } /// Decodes the given hexadecimal number, ignoring whitespace. - pub fn decode_pretty<H: AsRef<str>>(hex: H) -> ::Result<Vec<u8>> { + pub fn decode_pretty<H: AsRef<str>>(hex: H) -> crate::Result<Vec<u8>> { super::from_hex(hex.as_ref(), true) } diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 2c16ffc0..9b70c812 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -5,17 +5,17 @@ use std::io::{self, Read}; use nettle::{aead, cipher}; use buffered_reader::BufferedReader; -use constants::{ +use crate::constants::{ AEADAlgorithm, SymmetricAlgorithm, }; -use conversions::{ +use crate::conversions::{ write_be_u64, }; -use Error; -use Result; -use crypto::SessionKey; -use crypto::mem::secure_cmp; +use crate::Error; +use crate::Result; +use crate::crypto::SessionKey; +use crate::crypto::mem::secure_cmp; impl AEADAlgorithm { /// Returns the digest size of the AEAD algorithm. @@ -766,10 +766,10 @@ mod tests { let version = 1; let chunk_size = 64; let mut key = vec![0; sym_algo.key_size().unwrap()]; - ::crypto::random(&mut key); + crate::crypto::random(&mut key); let key: SessionKey = key.into(); let mut iv = vec![0; aead.iv_size().unwrap()]; - ::crypto::random(&mut iv); + crate::crypto::random(&mut iv); let mut ciphertext = Vec::new(); { @@ -779,7 +779,7 @@ mod tests { &mut ciphertext) .unwrap(); - encryptor.write_all(::tests::manifesto()).unwrap(); + encryptor.write_all(crate::tests::manifesto()).unwrap(); } let mut plaintext = Vec::new(); @@ -793,7 +793,7 @@ mod tests { decryptor.read_to_end(&mut plaintext).unwrap(); } - assert_eq!(&plaintext[..], ::tests::manifesto()); + assert_eq!(&plaintext[..], crate::tests::manifesto()); } } } diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index 050d83a9..60b7d6b0 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -2,13 +2,13 @@ use nettle::{dsa, ecc, ecdsa, ed25519, rsa, Yarrow}; -use packet::{self, Key}; -use crypto::SessionKey; -use crypto::mpis::{self, MPI}; -use constants::{Curve, HashAlgorithm}; +use crate::packet::{self, Key}; +use crate::crypto::SessionKey; +use crate::crypto::mpis::{self, MPI}; +use crate::constants::{Curve, HashAlgorithm}; -use Error; -use Result; +use crate::Error; +use crate::Result; /// Creates a signature. /// @@ -82,8 +82,8 @@ impl Signer for KeyPair { fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) -> Result<mpis::Signature> { - use PublicKeyAlgorithm::*; - use crypto::mpis::PublicKey; + use crate::PublicKeyAlgorithm::*; + use crate::crypto::mpis::PublicKey; use memsec; let mut rng = Yarrow::default(); @@ -211,8 +211,8 @@ impl Decryptor for KeyPair { fn decrypt(&mut self, ciphertext: &mpis::Ciphertext) -> Result<SessionKey> { - use PublicKeyAlgorithm::*; - use crypto::mpis::PublicKey; + use crate::PublicKeyAlgorithm::*; + use crate::crypto::mpis::PublicKey; use nettle::rsa; Ok(match (self.public.mpis(), &self.secret.mpis(), ciphertext) @@ -237,7 +237,7 @@ impl Decryptor for KeyPair { (PublicKey::ECDH{ .. }, mpis::SecretKey::ECDH { .. }, mpis::Ciphertext::ECDH { .. }) => - ::crypto::ecdh::decrypt(&self.public, &self.secret.mpis(), + crate::crypto::ecdh::decrypt(&self.public, &self.secret.mpis(), ciphertext)?, (public, secret, ciphertext) => diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 23ec9026..eddd65e3 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -1,21 +1,21 @@ //! Elliptic Curve Diffie-Hellman. -use Error; -use packet::Key; -use Result; -use constants::{ +use crate::Error; +use crate::packet::Key; +use crate::Result; +use crate::constants::{ Curve, HashAlgorithm, SymmetricAlgorithm, PublicKeyAlgorithm, }; -use conversions::{ +use crat |