mirror of
https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git
synced 2025-12-28 15:22:18 +01:00
Fix warnings: trait objects without an explicit dyn are deprecated (not all of them)
Literally just inserts `dyn` keywords. This was deprecated but accepted in Rust 2015 but is a hard error in Rust 2021!
This commit is contained in:
parent
be02f2a25f
commit
1103eb0eec
9 changed files with 25 additions and 25 deletions
|
|
@ -57,7 +57,7 @@ pub enum KeyExchangeAlgorithm {
|
|||
}
|
||||
|
||||
impl KeyExchangeAlgorithm {
|
||||
pub fn instance(&self) -> Option<Box<KeyExchange>> {
|
||||
pub fn instance(&self) -> Option<Box<dyn KeyExchange>> {
|
||||
use self::KeyExchangeAlgorithm::*;
|
||||
match self
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ pub struct Connection {
|
|||
pub conn_type: ConnectionType,
|
||||
pub hash_data: HashData,
|
||||
state: ConnectionState,
|
||||
key_exchange: Option<Box<KeyExchange>>,
|
||||
key_exchange: Option<Box<dyn KeyExchange>>,
|
||||
session_id: Option<Vec<u8>>,
|
||||
encryption: Option<(Box<Encryption>, Box<Encryption>)>,
|
||||
mac: Option<(Box<MacAlgorithm>, Box<MacAlgorithm>)>,
|
||||
encryption: Option<(Box<dyn Encryption>, Box<dyn Encryption>)>,
|
||||
mac: Option<(Box<dyn MacAlgorithm>, Box<dyn MacAlgorithm>)>,
|
||||
seq: (u32, u32),
|
||||
tx_queue: VecDeque<Packet>,
|
||||
channels: BTreeMap<ChannelId, Channel>,
|
||||
|
|
@ -85,7 +85,7 @@ impl<'a> Connection {
|
|||
}
|
||||
}
|
||||
|
||||
fn recv(&mut self, mut stream: &mut Read) -> Result<Packet> {
|
||||
fn recv(&mut self, mut stream: &mut dyn Read) -> Result<Packet> {
|
||||
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];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crypto::symmetriccipher::SynchronousStreamCipher;
|
|||
use encryption::Encryption;
|
||||
|
||||
pub struct AesCtr {
|
||||
cipher: Box<SynchronousStreamCipher + 'static>,
|
||||
cipher: Box<dyn SynchronousStreamCipher + 'static>,
|
||||
}
|
||||
|
||||
impl AesCtr {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct Ed25519KeyPair {
|
|||
}
|
||||
|
||||
impl Ed25519KeyPair {
|
||||
fn generate(_: Option<u32>) -> Box<KeyPair> {
|
||||
fn generate(_: Option<u32>) -> Box<dyn KeyPair> {
|
||||
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<Box<KeyPair>> {
|
||||
fn import(mut r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>> {
|
||||
use packet::ReadPacketExt;
|
||||
|
||||
if r.read_utf8()? != "ssh-ed25519" {
|
||||
|
|
@ -57,7 +57,7 @@ impl Ed25519KeyPair {
|
|||
}))
|
||||
}
|
||||
|
||||
fn read_public(mut r: &mut Read) -> io::Result<Box<KeyPair>> {
|
||||
fn read_public(mut r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>> {
|
||||
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)?;
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ pub trait KeyPair: Sync + Send {
|
|||
fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, ()>;
|
||||
fn sign(&self, data: &[u8]) -> Result<Vec<u8>, ()>;
|
||||
|
||||
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<u32>) -> Box<KeyPair>,
|
||||
pub import: fn(r: &mut Read) -> io::Result<Box<KeyPair>>,
|
||||
pub read_public: fn(r: &mut Read) -> io::Result<Box<KeyPair>>,
|
||||
pub generate_key_pair: fn(bits: Option<u32>) -> Box<dyn KeyPair>,
|
||||
pub import: fn(r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>>,
|
||||
pub read_public: fn(r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use public_key::KeyPair;
|
|||
pub struct ServerConfig {
|
||||
pub host: String,
|
||||
pub port: u16,
|
||||
pub key: Box<KeyPair>,
|
||||
pub key: Box<dyn KeyPair>,
|
||||
}
|
||||
|
||||
pub struct Server {
|
||||
|
|
|
|||
|
|
@ -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<KeyPair>) -> Box<KeyPair> {
|
||||
fn test_export_import(keypair: &Box<dyn KeyPair>) -> Box<dyn KeyPair> {
|
||||
// Export the keypair to a vector and import it again
|
||||
let mut buffer = Vec::new();
|
||||
keypair.export(&mut buffer).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue