1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#![allow(clippy::ptr_arg)]

use puffin::algebra::error::FnError;

use crate::ssh::message::{
    CompressionAlgorithms, EncryptionAlgorithms, KexAlgorithms, KexEcdhReplyMessage,
    KexInitMessage, MacAlgorithms, NameList, OnWireData, RawSshMessage, SignatureSchemes,
    SshMessage,
};

pub fn fn_raw_message(message: &RawSshMessage) -> Result<RawSshMessage, FnError> {
    Ok(message.clone())
}

pub fn fn_onwire_message(data: &OnWireData) -> Result<RawSshMessage, FnError> {
    Ok(RawSshMessage::OnWire(data.clone()))
}

pub fn fn_banner(banner: &String) -> Result<RawSshMessage, FnError> {
    Ok(RawSshMessage::Banner(banner.clone()))
}

pub fn fn_kex_ecdh_reply(
    public_host_key: &Vec<u8>,
    ephemeral_public_key: &Vec<u8>,
    signature: &Vec<u8>,
) -> Result<SshMessage, FnError> {
    Ok(SshMessage::KexEcdhReply(KexEcdhReplyMessage {
        public_host_key: public_host_key.clone(),
        ephemeral_public_key: ephemeral_public_key.clone(),
        signature: signature.clone(),
    }))
}

pub fn fn_kex_init(
    cookie: &[u8; 16],
    kex_algorithms: &KexAlgorithms,
    server_host_key_algorithms: &SignatureSchemes,
    encryption_algorithms_server_to_client: &EncryptionAlgorithms,
    encryption_algorithms_client_to_server: &EncryptionAlgorithms,
    mac_algorithms_client_to_server: &MacAlgorithms,
    mac_algorithms_server_to_client: &MacAlgorithms,
    compression_algorithms_client_to_server: &CompressionAlgorithms,
    compression_algorithms_server_to_client: &CompressionAlgorithms,
) -> Result<SshMessage, FnError> {
    Ok(SshMessage::KexInit(KexInitMessage {
        cookie: *cookie,
        kex_algorithms: kex_algorithms.clone(),
        server_host_key_algorithms: server_host_key_algorithms.clone(),
        encryption_algorithms_server_to_client: encryption_algorithms_server_to_client.clone(),
        encryption_algorithms_client_to_server: encryption_algorithms_client_to_server.clone(),
        mac_algorithms_client_to_server: mac_algorithms_client_to_server.clone(),
        mac_algorithms_server_to_client: mac_algorithms_server_to_client.clone(),
        compression_algorithms_client_to_server: compression_algorithms_client_to_server.clone(),
        compression_algorithms_server_to_client: compression_algorithms_server_to_client.clone(),
        languages_client_to_server: NameList::empty(),
        languages_server_to_client: NameList::empty(),
        first_kex_packet_follows: false,
    }))
}