misc improvements

This commit is contained in:
nora 2024-08-26 19:50:24 +02:00
parent ca4213ba81
commit 26cdcd0524
7 changed files with 39 additions and 31 deletions

View file

@ -33,6 +33,7 @@ impl Debug for PlaintextPrivateKey {
}
#[derive(Clone)]
#[allow(clippy::large_enum_variant)]
pub enum PrivateKey {
Ed25519 {
public_key: ed25519_dalek::VerifyingKey,

View file

@ -24,8 +24,7 @@ use crate::{Channel, ChannelState, PendingChannel};
pub struct ServerListener {
listener: TcpListener,
auth_verify: ServerAuthVerify,
transport_config: cluelessh_transport::server::ServerConfig
// TODO ratelimits etc
transport_config: cluelessh_transport::server::ServerConfig, // TODO ratelimits etc
}
pub struct ServerConnection<S> {
@ -80,7 +79,11 @@ impl From<eyre::Report> for Error {
}
impl ServerListener {
pub fn new(listener: TcpListener, auth_verify: ServerAuthVerify, transport_config: cluelessh_transport::server::ServerConfig) -> Self {
pub fn new(
listener: TcpListener,
auth_verify: ServerAuthVerify,
transport_config: cluelessh_transport::server::ServerConfig,
) -> Self {
Self {
listener,
auth_verify,
@ -101,7 +104,12 @@ impl ServerListener {
}
impl<S: AsyncRead + AsyncWrite> ServerConnection<S> {
pub fn new(stream: S, peer_addr: SocketAddr, auth_verify: ServerAuthVerify, transport_config: cluelessh_transport::server::ServerConfig) -> Self {
pub fn new(
stream: S,
peer_addr: SocketAddr,
auth_verify: ServerAuthVerify,
transport_config: cluelessh_transport::server::ServerConfig,
) -> Self {
let (operations_send, operations_recv) = tokio::sync::mpsc::channel(15);
let (channel_ops_send, channel_ops_recv) = tokio::sync::mpsc::channel(15);

View file

@ -110,7 +110,7 @@ impl AlgorithmName for EncryptionAlgorithm {
pub struct EncodedSshSignature(pub Vec<u8>);
pub struct HostKeySigningAlgorithm {
private_key: PrivateKey,
private_key: Box<PrivateKey>,
}
impl AlgorithmName for HostKeySigningAlgorithm {
@ -121,7 +121,9 @@ impl AlgorithmName for HostKeySigningAlgorithm {
impl HostKeySigningAlgorithm {
pub fn new(private_key: PrivateKey) -> Self {
Self { private_key }
Self {
private_key: Box::new(private_key),
}
}
pub fn sign(&self, data: &[u8]) -> Signature {
self.private_key.sign(data)

View file

@ -145,8 +145,9 @@ impl ServerConnection {
let kex_algorithm = sup_algs.key_exchange.find(kex.kex_algorithms.0)?;
debug!(name = %kex_algorithm.name(), "Using KEX algorithm");
let server_host_key_algorithm =
sup_algs.hostkey_sign.find(kex.server_host_key_algorithms.0)?;
let server_host_key_algorithm = sup_algs
.hostkey_sign
.find(kex.server_host_key_algorithms.0)?;
debug!(name = %server_host_key_algorithm.name(), "Using host key algorithm");
// TODO: Implement aes128-ctr