diff --git a/src/algorithm.rs b/src/algorithm.rs index 4e9996b..ecf2595 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -215,9 +215,10 @@ impl FromStr for MacAlgorithm { use self::MacAlgorithm::*; match s { - "hmac-sha1" => Ok(MacAlgorithm::HMAC_SHA1), - "hmac-sha2-256" => Ok(MacAlgorithm::HMAC_SHA2_256), - "hmac-sha2-512" => Ok(MacAlgorithm::HMAC_SHA2_512), + "hmac-sha1" => Ok(HMAC_SHA1), + "hmac-sha2-256" => Ok(HMAC_SHA2_256), + "hmac-sha2-512" => Ok(HMAC_SHA2_512), + "none" => Ok(MacAlgorithm::None), _ => { debug!("Unknown mac algorithm: {}", s); Err(()) diff --git a/src/bin/ssh-keygen.rs b/src/bin/ssh-keygen.rs index 2974297..d301d48 100644 --- a/src/bin/ssh-keygen.rs +++ b/src/bin/ssh-keygen.rs @@ -1,6 +1,5 @@ extern crate ssh; use std::fs::File; -use std::io::prelude::*; use ssh::public_key; diff --git a/src/connection.rs b/src/connection.rs index a92906a..31a9847 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -1,4 +1,3 @@ -use std::borrow::BorrowMut; use std::io::{self, BufRead, BufReader, Read, Write}; use std::sync::Arc; @@ -20,7 +19,6 @@ enum ConnectionState { #[derive(Clone)] pub enum ConnectionType { Server(Arc), - Client, } #[derive(Default, Debug)] @@ -88,7 +86,7 @@ impl<'a> Connection { trace!("Packet {} received: {:?}", self.seq.0, packet); self.process(packet)?; - self.seq.0 += 1; + self.seq.0.wrapping_add(1); } } @@ -109,7 +107,7 @@ impl<'a> Connection { packet.write_to(&mut self.stream)?; } - self.seq.1 += 1; + self.seq.1.wrapping_add(1); if let Some((_, ref mut mac)) = self.mac { let mut sig = vec![0; mac.size()]; @@ -322,7 +320,7 @@ impl<'a> Connection { if want_reply { let mut res = Packet::new(MessageType::ChannelSuccess); - res.with_writer(&|w| w.write_uint32(0)); + res.with_writer(&|w| w.write_uint32(0))?; self.send(res)?; } @@ -340,7 +338,7 @@ impl<'a> Connection { Ok(()) })?; - self.send(res); + self.send(res)?; debug!( "Channel {} Data ({} bytes): {:?}", diff --git a/src/key_exchange/curve25519.rs b/src/key_exchange/curve25519.rs index 8e3457b..f4c7481 100644 --- a/src/key_exchange/curve25519.rs +++ b/src/key_exchange/curve25519.rs @@ -86,7 +86,7 @@ impl KeyExchange for Curve25519 { buf.write_mpint(BigInt::from_bytes_be( Sign::Plus, &curve25519::curve25519(&server_secret, &client_public), - )); + )).ok(); buf }; @@ -106,10 +106,10 @@ impl KeyExchange for Curve25519 { ]; for item in items.iter() { - buf.write_bytes(item); + buf.write_bytes(item).ok(); } - buf.write_raw_bytes(&shared_secret); + buf.write_raw_bytes(&shared_secret).ok(); buf }; diff --git a/src/key_exchange/mod.rs b/src/key_exchange/mod.rs index f6c27e2..7300223 100644 --- a/src/key_exchange/mod.rs +++ b/src/key_exchange/mod.rs @@ -1,8 +1,8 @@ mod curve25519; -mod dh_group_sha1; +// mod dh_group_sha1; pub use self::curve25519::Curve25519; -pub use self::dh_group_sha1::DhGroupSha1; +// pub use self::dh_group_sha1::DhGroupSha1; use connection::Connection; use packet::Packet; diff --git a/src/public_key/ed25519.rs b/src/public_key/ed25519.rs index 8430ed0..4bacb08 100644 --- a/src/public_key/ed25519.rs +++ b/src/public_key/ed25519.rs @@ -103,8 +103,8 @@ impl KeyPair for Ed25519KeyPair { if let Some(private_key) = self.private { let mut result = Vec::new(); let sig = ed25519::signature(data, &private_key); - result.write_string("ssh-ed25519").or(Err(())); - result.write_bytes(&sig).or(Err(())); + result.write_string("ssh-ed25519").or(Err(()))?; + result.write_bytes(&sig).or(Err(()))?; Ok(result) } else {