summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-07-09 12:51:10 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-07-15 12:47:53 +0200
commit775f0c039349335df880d35db7df6c131419f0eb (patch)
tree2d16928f3a629b7afae95cf1b9d518c5603a9f93 /openpgp/src/crypto
parentcaec575e3c44e6045e29aa452ad31f91d04ec139 (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/crypto')
-rw-r--r--openpgp/src/crypto/aead.rs20
-rw-r--r--openpgp/src/crypto/asymmetric.rs22
-rw-r--r--openpgp/src/crypto/ecdh.rs20
-rw-r--r--openpgp/src/crypto/hash.rs36
-rw-r--r--openpgp/src/crypto/keygrip.rs22
-rw-r--r--openpgp/src/crypto/mod.rs12
-rw-r--r--openpgp/src/crypto/mpis.rs38
-rw-r--r--openpgp/src/crypto/s2k.rs28
-rw-r--r--openpgp/src/crypto/sexp.rs28
-rw-r--r--openpgp/src/crypto/symmetric.rs20
10 files changed, 123 insertions, 123 deletions
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 crate::conversions::{
write_be_u64,
read_be_u64,
};
-use crypto::SessionKey;
-use crypto::mem::Protected;
-use crypto::mpis::{MPI, PublicKey, SecretKey, Ciphertext};
+use crate::crypto::SessionKey;
+use crate::crypto::mem::Protected;
+use crate::crypto::mpis::{MPI, PublicKey, SecretKey, Ciphertext};
use nettle::{cipher, curve25519, mode, Mode, ecc, ecdh, Yarrow};
/// Wraps a session key using Elliptic Curve Diffie-Hellman.
@@ -426,7 +426,7 @@ pub fn pkcs5_unpad(sk: Protected, target_len: usize) -> Result<Protected> {
pub fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected,
plaintext: &Protected)
-> Result<Vec<u8>> {
- use SymmetricAlgorithm::*;
+ use crate::SymmetricAlgorithm::*;
if plaintext.len() % 8 != 0 {
return Err(Error::InvalidArgument(
@@ -512,7 +512,7 @@ pub fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected,
pub fn aes_key_unwrap(algo: SymmetricAlgorithm, key: &Protected,
ciphertext: &[u8])
-> Result<Protected> {
- use SymmetricAlgorithm::*;
+ use crate::SymmetricAlgorithm::*;
if ciphertext.len() % 8 != 0 {
return Err(Error::InvalidArgument(
diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs
index b9d7170b..85ffd51f 100644
--- a/openpgp/src/crypto/hash.rs
+++ b/openpgp/src/crypto/hash.rs
@@ -1,15 +1,15 @@
//! Functionality to hash packets, and generate hashes.
-use HashAlgorithm;
-use packet::UserID;
-use packet::UserAttribute;
-use packet::Key;
-use packet::key::Key4;
-use packet::Signature;
-use packet::signature::{self, Signature4};
-use Error;
-use Result;
-use conversions::Time;
+use crate::HashAlgorithm;
+use crate::packet::UserID;
+use crate::packet::UserAttribute;
+use crate::packet::Key;
+use crate::packet::key::Key4;
+use crate::packet::Signature;
+use crate::packet::signature::{self, Signature4};
+use crate::Error;
+use crate::Result;
+use crate::conversions::Time;
use nettle;
use nettle::Hash as NettleHash;
@@ -409,8 +409,8 @@ impl Signature {
#[cfg(test)]
mod test {
use super::*;
- use TPK;
- use parse::Parse;
+ use crate::TPK;
+ use crate::parse::Parse;
#[test]
fn hash_verification() {
@@ -467,13 +467,13 @@ mod test {
(userid_sigs, ua_sigs, subkey_sigs)
}
- check(TPK::from_bytes(::tests::key("hash-algos/SHA224.gpg")).unwrap());
- check(TPK::from_bytes(::tests::key("hash-algos/SHA256.gpg")).unwrap());
- check(TPK::from_bytes(::tests::key("hash-algos/SHA384.gpg")).unwrap());
- check(TPK::from_bytes(::tests::key("hash-algos/SHA512.gpg")).unwrap());
- check(TPK::from_bytes(::tests::key("bannon-all-uids-subkeys.gpg")).unwrap());
+ check(TPK::from_bytes(crate::tests::key("hash-algos/SHA224.gpg")).unwrap());
+ check(TPK::from_bytes(crate::tests::key("hash-algos/SHA256.gpg")).unwrap());
+ check(TPK::from_bytes(crate::tests::key("hash-algos/SHA384.gpg")).unwrap());
+ check(TPK::from_bytes(crate::tests::key("hash-algos/SHA512.gpg")).unwrap());
+ check(TPK::from_bytes(crate::tests::key("bannon-all-uids-subkeys.gpg")).unwrap());
let (_userid_sigs, ua_sigs, _subkey_sigs)
- = check(TPK::from_bytes(::tests::key("dkg.gpg")).unwrap());
+ = check(TPK::from_bytes(crate::tests::key("dkg.gpg")).unwrap());
assert!(ua_sigs > 0);
}
}
diff --git a/openpgp/src/crypto/keygrip.rs b/openpgp/src/crypto/keygrip.rs
index a1d457e2..9bf4bf5b 100644
--- a/openpgp/src/crypto/keygrip.rs
+++ b/openpgp/src/crypto/keygrip.rs
@@ -1,9 +1,9 @@
use std::fmt;
-use Error;
-use Result;
-use constants::{Curve, HashAlgorithm};
-use crypto::mpis::{MPI, PublicKey};
+use crate::Error;
+use crate::Result;
+use crate::constants::{Curve, HashAlgorithm};
+use crate::crypto::mpis::{MPI, PublicKey};
/// A proprietary, protocol agnostic identifier for public keys.
///
@@ -32,7 +32,7 @@ impl fmt::Display for Keygrip {
impl Keygrip {
/// Parses a keygrip.
pub fn from_hex(hex: &str) -> Result<Self> {
- let bytes = ::conversions::from_hex(hex, true)?;
+ let bytes = crate::conversions::from_hex(hex, true)?;
if bytes.len() != 20 {
return Err(Error::InvalidArgument(
format!("Expected 20 bytes, got {}", bytes.len())).into());
@@ -47,7 +47,7 @@ impl Keygrip {
impl PublicKey {
/// Computes the keygrip.
pub fn keygrip(&self) -> Result<Keygrip> {
- use crypto::hash;
+ use crate::crypto::hash;
use std::io::Write;
use self::PublicKey::*;
let mut hash = HashAlgorithm::SHA1.context().unwrap();
@@ -204,13 +204,13 @@ fn ecc_param(curve: &Curve, i: usize) -> MPI {
(_, _) => unreachable!(),
};
- ::conversions::from_hex(hex, true).unwrap().into()
+ crate::conversions::from_hex(hex, true).unwrap().into()
}
#[cfg(test)]
mod tests {
use super::*;
- use ::conversions::from_hex;
+ use crate::conversions::from_hex;
/// Test vectors from libgcrypt/tests/basic.c.
#[test]
@@ -276,9 +276,9 @@ mod tests {
#[test]
fn our_keys() {
use std::collections::HashMap;
- use ::Fingerprint as FP;
+ use crate::Fingerprint as FP;
use super::Keygrip as KG;
- use ::parse::Parse;
+ use crate::parse::Parse;
let keygrips: HashMap<FP, KG> = [
// testy.pgp
@@ -329,7 +329,7 @@ mod tests {
"erika-corinna-daniela-simone-antonia-nistp384.pgp",
"erika-corinna-daniela-simone-antonia-nistp521.pgp",
]
- .iter().map(|n| (n, ::TPK::from_bytes(::tests::key(n)).unwrap()))
+ .iter().map(|n| (n, crate::TPK::from_bytes(crate::tests::key(n)).unwrap()))
{
eprintln!("{}", name);
for key in tpk.keys_all() {
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 6645ecdc..2757dfba 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -6,8 +6,8 @@ use std::fmt;
use nettle::{Random, Yarrow};
-use constants::HashAlgorithm;
-use Result;
+use crate::constants::HashAlgorithm;
+use crate::Result;
pub(crate) mod aead;
mod asymmetric;
@@ -169,8 +169,8 @@ pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm])
{
use std::mem;
- use ::parse::HashedReader;
- use ::parse::HashesFor;
+ use crate::parse::HashedReader;
+ use crate::parse::HashesFor;
use buffered_reader::BufferedReader;
@@ -202,7 +202,7 @@ fn hash_file_test() {
].iter().cloned().collect();
let result =
- hash_file(::std::io::Cursor::new(::tests::manifesto()),
+ hash_file(::std::io::Cursor::new(crate::tests::manifesto()),
&expected.keys().cloned().collect::<Vec<HashAlgorithm>>())
.unwrap();
@@ -211,6 +211,6 @@ fn hash_file_test() {
hash.digest(&mut digest);
assert_eq!(*expected.get(&algo).unwrap(),
- &::conversions::to_hex(&digest[..], false));
+ &crate::conversions::to_hex(&digest[..], false));
}
}
diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpis.rs
index ed7bf8ef..347fd3c8 100644
--- a/openpgp/src/crypto/mpis.rs
+++ b/openpgp/src/crypto/mpis.rs
@@ -6,18 +6,18 @@ use std::cmp::Ordering;
use quickcheck::{Arbitrary, Gen};
use rand::Rng;
-use constants::{
+use crate::constants::{
Curve,
HashAlgorithm,
PublicKeyAlgorithm,
SymmetricAlgorithm,
};
-use crypto::hash::{self, Hash};
-use crypto::mem::{secure_cmp, Protected};
-use serialize::Serialize;
+use crate::crypto::hash::{self, Hash};
+use crate::crypto::mem::{secure_cmp, Protected};
+use crate::serialize::Serialize;
-use Error;
-use Result;
+use crate::Error;
+use crate::Result;
/// Holds a single MPI.
#[derive(Clone, Hash)]
@@ -170,7 +170,7 @@ impl fmt::Debug for MPI {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_fmt(format_args!(
"{} bits: {}", self.bits(),
- ::conversions::to_hex(&*self.value, true)))
+ crate::conversions::to_hex(&*self.value, true)))
}
}
@@ -264,7 +264,7 @@ impl fmt::Debug for ProtectedMPI {
if cfg!(debug_assertions) {
f.write_fmt(format_args!(
"{} bits: {}", self.bits(),
- ::conversions::to_hex(&*self.value, true)))
+ crate::conversions::to_hex(&*self.value, true)))
} else {
f.write_str("<Redacted>")
}
@@ -984,8 +984,8 @@ impl Arbitrary for Signature {
#[cfg(test)]
mod tests {
use super::*;
- use parse::Parse;
- use serialize::Serialize;
+ use crate::parse::Parse;
+ use crate::serialize::Serialize;
quickcheck! {
fn mpi_roundtrip(mpi: MPI) -> bool {
@@ -998,8 +998,8 @@ mod tests {
quickcheck! {
fn pk_roundtrip(pk: PublicKey) -> bool {
use std::io::Cursor;
- use PublicKeyAlgorithm::*;
- use serialize::Serialize;
+ use crate::PublicKeyAlgorithm::*;
+ use crate::serialize::Serialize;
let buf = Vec::<u8>::default();
let mut cur = Cursor::new(buf);
@@ -1046,7 +1046,7 @@ mod tests {
("erika-corinna-daniela-simone-antonia-nistp384.pgp", 0, 384),
("erika-corinna-daniela-simone-antonia-nistp521.pgp", 0, 521),
] {
- let tpk = ::TPK::from_bytes(::tests::key(name)).unwrap();
+ let tpk = crate::TPK::from_bytes(crate::tests::key(name)).unwrap();
let key = tpk.keys_all().nth(*key_no).unwrap().2;
assert_eq!(key.mpis().bits().unwrap(), *bits,
"TPK {}, key no {}", name, *key_no);
@@ -1056,8 +1056,8 @@ mod tests {
quickcheck! {
fn sk_roundtrip(sk: SecretKey) -> bool {
use std::io::Cursor;
- use PublicKeyAlgorithm::*;
- use serialize::Serialize;
+ use crate::PublicKeyAlgorithm::*;
+ use crate::serialize::Serialize;
let buf = Vec::<u8>::default();
let mut cur = Cursor::new(buf);
@@ -1095,8 +1095,8 @@ mod tests {
quickcheck! {
fn ct_roundtrip(ct: Ciphertext) -> bool {
use std::io::Cursor;
- use PublicKeyAlgorithm::*;
- use serialize::Serialize;
+ use crate::PublicKeyAlgorithm::*;
+ use crate::serialize::Serialize;
let buf = Vec::<u8>::default();
let mut cur = Cursor::new(buf);
@@ -1125,8 +1125,8 @@ mod tests {
quickcheck! {
fn signature_roundtrip(sig: Signature) -> bool {
use std::io::Cursor;
- use PublicKeyAlgorithm::*;
- use serialize::Serialize;
+ use crate::PublicKeyAlgorithm::*;
+ use crate::serialize::Serialize;
let buf = Vec::<u8>::default();
let mut cur = Cursor::new(buf);
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index b2b95f68..72b790e5 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -6,11 +6,11 @@
//!
//! [Section 3.7 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-3.7
-use Error;
-use Result;
-use HashAlgorithm;
-use crypto::Password;
-use crypto::SessionKey;
+use crate::Error;
+use crate::Result;
+use crate::HashAlgorithm;
+use crate::crypto::Password;
+use crate::crypto::SessionKey;
use std::fmt;
@@ -56,7 +56,7 @@ pub enum S2K {
impl Default for S2K {
fn default() -> Self {
let mut salt = [0u8; 8];
- ::crypto::random(&mut salt);
+ crate::crypto::random(&mut salt);
S2K::Iterated {
// SHA2-256, being optimized for implementations on
// architectures with a word size of 32 bit, has a more
@@ -286,15 +286,15 @@ impl Arbitrary for S2K {
mod tests {
use super::*;
- use conversions::to_hex;
- use SymmetricAlgorithm;
- use Packet;
- use parse::{Parse, PacketParser};
- use serialize::Serialize;
+ use crate::conversions::to_hex;
+ use crate::SymmetricAlgorithm;
+ use crate::Packet;
+ use crate::parse::{Parse, PacketParser};
+ use crate::serialize::Serialize;
#[test]
fn s2k_parser_test() {
- use packet::SKESK;
+ use crate::packet::SKESK;
struct Test<'a> {
filename: &'a str,
@@ -396,7 +396,7 @@ mod tests {
];
for test in tests.iter() {
- let path = ::tests::message(&format!("s2k/{}", test.filename));
+ let path = crate::tests::message(&format!("s2k/{}", test.filename));
let mut pp = PacketParser::from_bytes(path).unwrap().unwrap();
if let Packet::SKESK(SKESK::V4(ref skesk)) = pp.packet {
assert_eq!(skesk.symmetric_algo(), test.cipher_algo);
@@ -423,7 +423,7 @@ mod tests {
quickcheck! {
fn s2k_roundtrip(s2k: S2K) -> bool {
- use serialize::SerializeInto;
+ use crate::serialize::SerializeInto;
eprintln!("in {:?}", s2k);
use std::io::Cursor;
diff --git a/openpgp/src/crypto/sexp.rs b/openpgp/src/crypto/sexp.rs
index 8bd958a6..454ed5e7 100644
--- a/openpgp/src/crypto/sexp.rs
+++ b/openpgp/src/crypto/sexp.rs
@@ -10,11 +10,11 @@ use std::fmt;
use std::ops::Deref;
use quickcheck::{Arbitrary, Gen};
-use crypto::{self, mpis, SessionKey};
-use crypto::mem::Protected;
+use crate::crypto::{self, mpis, SessionKey};
+use crate::crypto::mem::Protected;
-use Error;
-use Result;
+use crate::Error;
+use crate::Result;
/// An *S-Expression*.
///
@@ -42,7 +42,7 @@ impl Sexp {
/// The resulting expression is suitable for gpg-agent's `INQUIRE
/// CIPHERTEXT` inquiry.
pub fn from_ciphertext(ciphertext: &mpis::Ciphertext) -> Result<Self> {
- use crypto::mpis::Ciphertext::*;
+ use crate::crypto::mpis::Ciphertext::*;
match ciphertext {
RSA { ref c } =>
Ok(Sexp::List(vec![
@@ -91,11 +91,11 @@ impl Sexp {
/// command. `padding` must be set according to the status
/// messages sent.
pub fn finish_decryption(&self,
- recipient: &::packet::Key,
+ recipient: &crate::packet::Key,
ciphertext: &mpis::Ciphertext,
padding: bool)
-> Result<SessionKey> {
- use crypto::mpis::PublicKey;
+ use crate::crypto::mpis::PublicKey;
let not_a_session_key = || -> failure::Error {
Error::MalformedMPI(
format!("Not a session key: {:?}", self)).into()
@@ -386,8 +386,8 @@ impl Arbitrary for String_ {
#[cfg(test)]
mod tests {
use super::*;
- use parse::Parse;
- use serialize::Serialize;
+ use crate::parse::Parse;
+ use crate::serialize::Serialize;
quickcheck! {
fn roundtrip(s: Sexp) -> bool {
@@ -401,18 +401,18 @@ mod tests {
#[test]
fn to_signature() {
- use crypto::mpis::Signature::*;
+ use crate::crypto::mpis::Signature::*;
assert_match!(DSA { .. } = Sexp::from_bytes(
- ::tests::file("sexp/dsa-signature.sexp")).unwrap()
+ crate::tests::file("sexp/dsa-signature.sexp")).unwrap()
.to_signature().unwrap());
assert_match!(ECDSA { .. } = Sexp::from_bytes(
- ::tests::file("sexp/ecdsa-signature.sexp")).unwrap()
+ crate::tests::file("sexp/ecdsa-signature.sexp")).unwrap()
.to_signature().unwrap());
assert_match!(EdDSA { .. } = Sexp::from_bytes(
- ::tests::file("sexp/eddsa-signature.sexp")).unwrap()
+ crate::tests::file("sexp/eddsa-signature.sexp")).unwrap()
.to_signature().unwrap());
assert_match!(RSA { .. } = Sexp::from_bytes(
- ::tests::file("sexp/rsa-signature.sexp")).unwrap()
+ crate::tests::file("sexp/rsa-signature.sexp")).unwrap()
.to_signature().unwrap());
}
}
diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs
index 32183163..681dd88f 100644
--- a/openpgp/src/crypto/symmetric.rs
+++ b/openpgp/src/crypto/symmetric.rs
@@ -4,9 +4,9 @@ use std::io;
use std::cmp;
use std::fmt;
-use Result;
-use Error;
-use SymmetricAlgorithm;
+use crate::Result;
+use crate::Error;
+use crate::SymmetricAlgorithm;
use buffered_reader::BufferedReader;
@@ -532,7 +532,7 @@ mod tests {
let filename = &format!(
"raw/a-cypherpunks-manifesto.aes{}.key_ascending_from_0",
algo.key_size().unwrap() * 8);
- let ciphertext = Cursor::new(::tests::file(filename));
+ let ciphertext = Cursor::new(crate::tests::file(filename));
let decryptor = Decryptor::new(*algo, &key, ciphertext).unwrap();
// Read bytewise to test the buffer logic.
@@ -541,7 +541,7 @@ mod tests {
plaintext.push(b.unwrap());
}
- assert_eq!(::tests::manifesto(), &plaintext[..]);
+ assert_eq!(crate::tests::manifesto(), &plaintext[..]);
}
}
@@ -564,7 +564,7 @@ mod tests {
.unwrap();
// Write bytewise to test the buffer logic.
- for b in ::tests::manifesto().chunks(1) {
+ for b in crate::tests::manifesto().chunks(1) {
encryptor.write_all(b).unwrap();
}
}
@@ -572,7 +572,7 @@ mod tests {
let filename = format!(
"raw/a-cypherpunks-manifesto.aes{}.key_ascending_from_0",
algo.key_size().unwrap() * 8);
- let mut cipherfile = Cursor::new(::tests::file(&filename));
+ let mut cipherfile = Cursor::new(crate::tests::file(&filename));
let mut reference = Vec::new();
cipherfile.read_to_end(&mut reference).unwrap();
assert_eq!(&reference[..], &ciphertext[..]);
@@ -595,14 +595,14 @@ mod tests {
SymmetricAlgorithm::Camellia192,
SymmetricAlgorithm::Camellia256].iter() {
let mut key = vec![0; algo.key_size().unwrap()];
- ::crypto::random(&mut key);
+ crate::crypto::random(&mut key);
let mut ciphertext = Vec::new();
{
let mut encryptor = Encryptor::new(*algo, &key, &mut ciphertext)
.unwrap();
- encryptor.write_all(::tests::manifesto()).unwrap();
+ encryptor.write_all(crate::tests::manifesto()).unwrap();
}
let mut plaintext = Vec::new();
@@ -614,7 +614,7 @@ mod tests {
decryptor.read_to_end(&mut plaintext).unwrap();
}
- assert_eq!(&plaintext[..], &::tests::manifesto()[..]);
+ assert_eq!(&plaintext[..], &crate::tests::manifesto()[..]);
}
}
}