diff --git a/src/algorithm.rs b/src/algorithm.rs index bde0929..a83b5f1 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -57,7 +57,7 @@ pub enum KeyExchangeAlgorithm { } impl KeyExchangeAlgorithm { - pub fn instance(&self) -> Option> { + pub fn instance(&self) -> Option> { use self::KeyExchangeAlgorithm::*; match self { diff --git a/src/channel.rs b/src/channel.rs index ea5322d..f602895 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -143,7 +143,7 @@ impl Channel { .stdin(unsafe { Stdio::from_raw_fd(stdin) }) .stdout(unsafe { Stdio::from_raw_fd(stdout) }) .stderr(unsafe { Stdio::from_raw_fd(stderr) }) - .before_exec(|| sys::before_exec()) + .before_exec(|| sys::before_exec()) // TODO: listen to compiler warning .spawn() .unwrap(); } diff --git a/src/connection.rs b/src/connection.rs index 0197a84..8813c71 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -36,10 +36,10 @@ pub struct Connection { pub conn_type: ConnectionType, pub hash_data: HashData, state: ConnectionState, - key_exchange: Option>, + key_exchange: Option>, session_id: Option>, - encryption: Option<(Box, Box)>, - mac: Option<(Box, Box)>, + encryption: Option<(Box, Box)>, + mac: Option<(Box, Box)>, seq: (u32, u32), tx_queue: VecDeque, channels: BTreeMap, @@ -85,7 +85,7 @@ impl<'a> Connection { } } - fn recv(&mut self, mut stream: &mut Read) -> Result { + fn recv(&mut self, mut stream: &mut dyn Read) -> Result { let packet = if let Some((ref mut c2s, _)) = self.encryption { let mut decryptor = Decryptor::new(&mut **c2s, &mut stream); Packet::read_from(&mut decryptor)? @@ -114,7 +114,7 @@ impl<'a> Connection { Ok(packet) } - fn send(&mut self, mut stream: &mut Write, packet: Packet) + fn send(&mut self, mut stream: &mut dyn Write, packet: Packet) -> io::Result<()> { debug!("Sending packet {}: {:?}", self.seq.1, packet); @@ -142,7 +142,7 @@ impl<'a> Connection { Ok(()) } - fn send_id(&mut self, stream: &mut Write) -> io::Result<()> { + fn send_id(&mut self, stream: &mut dyn Write) -> io::Result<()> { let id = format!("SSH-2.0-RedoxSSH_{}", env!("CARGO_PKG_VERSION")); info!("Identifying as {:?}", id); @@ -155,7 +155,7 @@ impl<'a> Connection { Ok(()) } - fn read_id(&mut self, stream: &mut Read) -> io::Result<()> { + fn read_id(&mut self, stream: &mut dyn Read) -> io::Result<()> { use std::str; let mut buf = [0; 255]; diff --git a/src/encryption/aes_ctr.rs b/src/encryption/aes_ctr.rs index 36d812a..3388602 100644 --- a/src/encryption/aes_ctr.rs +++ b/src/encryption/aes_ctr.rs @@ -4,7 +4,7 @@ use crypto::symmetriccipher::SynchronousStreamCipher; use encryption::Encryption; pub struct AesCtr { - cipher: Box, + cipher: Box, } impl AesCtr { diff --git a/src/encryption/mod.rs b/src/encryption/mod.rs index e5892ca..d88f5aa 100644 --- a/src/encryption/mod.rs +++ b/src/encryption/mod.rs @@ -10,12 +10,12 @@ pub trait Encryption { } pub struct Decryptor<'a> { - encryption: &'a mut Encryption, - stream: &'a mut Read, + encryption: &'a mut dyn Encryption, + stream: &'a mut dyn Read, } impl<'a> Decryptor<'a> { - pub fn new(encryption: &'a mut Encryption, stream: &'a mut Read) + pub fn new(encryption: &'a mut dyn Encryption, stream: &'a mut dyn Read) -> Decryptor<'a> { Decryptor { encryption: encryption, diff --git a/src/public_key/ed25519.rs b/src/public_key/ed25519.rs index 33faabf..9987d1c 100644 --- a/src/public_key/ed25519.rs +++ b/src/public_key/ed25519.rs @@ -18,7 +18,7 @@ struct Ed25519KeyPair { } impl Ed25519KeyPair { - fn generate(_: Option) -> Box { + fn generate(_: Option) -> Box { let mut seed = [0u8; 32]; let mut rng = rand::thread_rng(); rng.fill_bytes(&mut seed); @@ -30,7 +30,7 @@ impl Ed25519KeyPair { }) } - fn import(mut r: &mut Read) -> io::Result> { + fn import(mut r: &mut dyn Read) -> io::Result> { use packet::ReadPacketExt; if r.read_utf8()? != "ssh-ed25519" { @@ -57,7 +57,7 @@ impl Ed25519KeyPair { })) } - fn read_public(mut r: &mut Read) -> io::Result> { + fn read_public(mut r: &mut dyn Read) -> io::Result> { use packet::ReadPacketExt; if r.read_uint32()? != 32 { @@ -112,13 +112,13 @@ impl KeyPair for Ed25519KeyPair { } } - fn write_public(&self, w: &mut Write) -> io::Result<()> { + fn write_public(&self, w: &mut dyn Write) -> io::Result<()> { use packet::WritePacketExt; w.write_string("ssh-ed25519")?; w.write_bytes(&self.public) } - fn export(&self, w: &mut Write) -> io::Result<()> { + fn export(&self, w: &mut dyn Write) -> io::Result<()> { use packet::WritePacketExt; w.write_string("ssh-ed25519")?; w.write_bytes(&self.public)?; diff --git a/src/public_key/mod.rs b/src/public_key/mod.rs index 9bbb4d1..f8686b7 100644 --- a/src/public_key/mod.rs +++ b/src/public_key/mod.rs @@ -15,13 +15,13 @@ pub trait KeyPair: Sync + Send { fn verify(&self, data: &[u8], signature: &[u8]) -> Result; fn sign(&self, data: &[u8]) -> Result, ()>; - fn write_public(&self, w: &mut Write) -> io::Result<()>; - fn export(&self, w: &mut Write) -> io::Result<()>; + fn write_public(&self, w: &mut dyn Write) -> io::Result<()>; + fn export(&self, w: &mut dyn Write) -> io::Result<()>; } pub struct CryptoSystem { pub id: &'static str, - pub generate_key_pair: fn(bits: Option) -> Box, - pub import: fn(r: &mut Read) -> io::Result>, - pub read_public: fn(r: &mut Read) -> io::Result>, + pub generate_key_pair: fn(bits: Option) -> Box, + pub import: fn(r: &mut dyn Read) -> io::Result>, + pub read_public: fn(r: &mut dyn Read) -> io::Result>, } diff --git a/src/server.rs b/src/server.rs index 590e279..aca18cb 100644 --- a/src/server.rs +++ b/src/server.rs @@ -9,7 +9,7 @@ use public_key::KeyPair; pub struct ServerConfig { pub host: String, pub port: u16, - pub key: Box, + pub key: Box, } pub struct Server { diff --git a/tests/public_key.rs b/tests/public_key.rs index 330349a..3d17a69 100644 --- a/tests/public_key.rs +++ b/tests/public_key.rs @@ -6,7 +6,7 @@ use std::io::Cursor; use rand::{Rng, RngCore}; use ssh::public_key::{self, CryptoSystem, KeyPair}; -fn test_export_import(keypair: &Box) -> Box { +fn test_export_import(keypair: &Box) -> Box { // Export the keypair to a vector and import it again let mut buffer = Vec::new(); keypair.export(&mut buffer).unwrap();