1
0
Fork 0
mirror of https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git synced 2025-12-28 19:02:19 +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:
Laurenz 2024-09-26 13:37:16 +02:00
parent be02f2a25f
commit 1103eb0eec
Signed by: C0ffeeCode
SSH key fingerprint: SHA256:jnEltBNftC3wUZESLSMvM9zVPOkkevGRzqqoW2k2ORI
9 changed files with 25 additions and 25 deletions

View file

@ -57,7 +57,7 @@ pub enum KeyExchangeAlgorithm {
} }
impl KeyExchangeAlgorithm { impl KeyExchangeAlgorithm {
pub fn instance(&self) -> Option<Box<KeyExchange>> { pub fn instance(&self) -> Option<Box<dyn KeyExchange>> {
use self::KeyExchangeAlgorithm::*; use self::KeyExchangeAlgorithm::*;
match self match self
{ {

View file

@ -143,7 +143,7 @@ impl Channel {
.stdin(unsafe { Stdio::from_raw_fd(stdin) }) .stdin(unsafe { Stdio::from_raw_fd(stdin) })
.stdout(unsafe { Stdio::from_raw_fd(stdout) }) .stdout(unsafe { Stdio::from_raw_fd(stdout) })
.stderr(unsafe { Stdio::from_raw_fd(stderr) }) .stderr(unsafe { Stdio::from_raw_fd(stderr) })
.before_exec(|| sys::before_exec()) .before_exec(|| sys::before_exec()) // TODO: listen to compiler warning
.spawn() .spawn()
.unwrap(); .unwrap();
} }

View file

@ -36,10 +36,10 @@ pub struct Connection {
pub conn_type: ConnectionType, pub conn_type: ConnectionType,
pub hash_data: HashData, pub hash_data: HashData,
state: ConnectionState, state: ConnectionState,
key_exchange: Option<Box<KeyExchange>>, key_exchange: Option<Box<dyn KeyExchange>>,
session_id: Option<Vec<u8>>, session_id: Option<Vec<u8>>,
encryption: Option<(Box<Encryption>, Box<Encryption>)>, encryption: Option<(Box<dyn Encryption>, Box<dyn Encryption>)>,
mac: Option<(Box<MacAlgorithm>, Box<MacAlgorithm>)>, mac: Option<(Box<dyn MacAlgorithm>, Box<dyn MacAlgorithm>)>,
seq: (u32, u32), seq: (u32, u32),
tx_queue: VecDeque<Packet>, tx_queue: VecDeque<Packet>,
channels: BTreeMap<ChannelId, Channel>, 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 packet = if let Some((ref mut c2s, _)) = self.encryption {
let mut decryptor = Decryptor::new(&mut **c2s, &mut stream); let mut decryptor = Decryptor::new(&mut **c2s, &mut stream);
Packet::read_from(&mut decryptor)? Packet::read_from(&mut decryptor)?
@ -114,7 +114,7 @@ impl<'a> Connection {
Ok(packet) 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<()> { -> io::Result<()> {
debug!("Sending packet {}: {:?}", self.seq.1, packet); debug!("Sending packet {}: {:?}", self.seq.1, packet);
@ -142,7 +142,7 @@ impl<'a> Connection {
Ok(()) 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")); let id = format!("SSH-2.0-RedoxSSH_{}", env!("CARGO_PKG_VERSION"));
info!("Identifying as {:?}", id); info!("Identifying as {:?}", id);
@ -155,7 +155,7 @@ impl<'a> Connection {
Ok(()) 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; use std::str;
let mut buf = [0; 255]; let mut buf = [0; 255];

View file

@ -4,7 +4,7 @@ use crypto::symmetriccipher::SynchronousStreamCipher;
use encryption::Encryption; use encryption::Encryption;
pub struct AesCtr { pub struct AesCtr {
cipher: Box<SynchronousStreamCipher + 'static>, cipher: Box<dyn SynchronousStreamCipher + 'static>,
} }
impl AesCtr { impl AesCtr {

View file

@ -10,12 +10,12 @@ pub trait Encryption {
} }
pub struct Decryptor<'a> { pub struct Decryptor<'a> {
encryption: &'a mut Encryption, encryption: &'a mut dyn Encryption,
stream: &'a mut Read, stream: &'a mut dyn Read,
} }
impl<'a> Decryptor<'a> { 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<'a> {
Decryptor { Decryptor {
encryption: encryption, encryption: encryption,

View file

@ -18,7 +18,7 @@ struct Ed25519KeyPair {
} }
impl Ed25519KeyPair { impl Ed25519KeyPair {
fn generate(_: Option<u32>) -> Box<KeyPair> { fn generate(_: Option<u32>) -> Box<dyn KeyPair> {
let mut seed = [0u8; 32]; let mut seed = [0u8; 32];
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
rng.fill_bytes(&mut seed); 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; use packet::ReadPacketExt;
if r.read_utf8()? != "ssh-ed25519" { 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; use packet::ReadPacketExt;
if r.read_uint32()? != 32 { 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; use packet::WritePacketExt;
w.write_string("ssh-ed25519")?; w.write_string("ssh-ed25519")?;
w.write_bytes(&self.public) 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; use packet::WritePacketExt;
w.write_string("ssh-ed25519")?; w.write_string("ssh-ed25519")?;
w.write_bytes(&self.public)?; w.write_bytes(&self.public)?;

View file

@ -15,13 +15,13 @@ pub trait KeyPair: Sync + Send {
fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, ()>; fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, ()>;
fn sign(&self, data: &[u8]) -> Result<Vec<u8>, ()>; fn sign(&self, data: &[u8]) -> Result<Vec<u8>, ()>;
fn write_public(&self, w: &mut Write) -> io::Result<()>; fn write_public(&self, w: &mut dyn Write) -> io::Result<()>;
fn export(&self, w: &mut Write) -> io::Result<()>; fn export(&self, w: &mut dyn Write) -> io::Result<()>;
} }
pub struct CryptoSystem { pub struct CryptoSystem {
pub id: &'static str, pub id: &'static str,
pub generate_key_pair: fn(bits: Option<u32>) -> Box<KeyPair>, pub generate_key_pair: fn(bits: Option<u32>) -> Box<dyn KeyPair>,
pub import: fn(r: &mut Read) -> io::Result<Box<KeyPair>>, pub import: fn(r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>>,
pub read_public: fn(r: &mut Read) -> io::Result<Box<KeyPair>>, pub read_public: fn(r: &mut dyn Read) -> io::Result<Box<dyn KeyPair>>,
} }

View file

@ -9,7 +9,7 @@ use public_key::KeyPair;
pub struct ServerConfig { pub struct ServerConfig {
pub host: String, pub host: String,
pub port: u16, pub port: u16,
pub key: Box<KeyPair>, pub key: Box<dyn KeyPair>,
} }
pub struct Server { pub struct Server {

View file

@ -6,7 +6,7 @@ use std::io::Cursor;
use rand::{Rng, RngCore}; use rand::{Rng, RngCore};
use ssh::public_key::{self, CryptoSystem, KeyPair}; 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 // Export the keypair to a vector and import it again
let mut buffer = Vec::new(); let mut buffer = Vec::new();
keypair.export(&mut buffer).unwrap(); keypair.export(&mut buffer).unwrap();