ssh/algorithm/
mod.rs

1pub(crate) mod compression;
2pub(crate) mod encryption;
3pub(crate) mod hash;
4pub(crate) mod key_exchange;
5pub(crate) mod mac;
6pub(crate) mod public_key;
7
8use strum_macros::{AsRefStr, EnumString};
9
10use self::{hash::HashCtx, key_exchange::KeyExchange};
11
12/// symmetrical encryption algorithm
13#[derive(Copy, Clone, PartialEq, Eq, AsRefStr, EnumString)]
14pub enum Enc {
15    #[strum(serialize = "chacha20-poly1305@openssh.com")]
16    Chacha20Poly1305Openssh,
17    #[strum(serialize = "aes128-ctr")]
18    Aes128Ctr,
19    #[strum(serialize = "aes192-ctr")]
20    Aes192Ctr,
21    #[strum(serialize = "aes256-ctr")]
22    Aes256Ctr,
23    #[cfg(feature = "deprecated-aes-cbc")]
24    #[strum(serialize = "aes128-cbc")]
25    Aes128Cbc,
26    #[cfg(feature = "deprecated-aes-cbc")]
27    #[strum(serialize = "aes192-cbc")]
28    Aes192Cbc,
29    #[cfg(feature = "deprecated-aes-cbc")]
30    #[strum(serialize = "aes256-cbc")]
31    Aes256Cbc,
32    #[cfg(feature = "deprecated-des-cbc")]
33    #[strum(serialize = "3des-cbc")]
34    TripleDesCbc,
35}
36
37/// key exchange algorithm
38#[derive(Copy, Clone, PartialEq, Eq, AsRefStr, EnumString)]
39pub enum Kex {
40    #[strum(serialize = "curve25519-sha256")]
41    Curve25519Sha256,
42    #[strum(serialize = "ecdh-sha2-nistp256")]
43    EcdhSha2Nistrp256,
44    #[cfg(feature = "deprecated-dh-group1-sha1")]
45    #[strum(serialize = "diffie-hellman-group1-sha1")]
46    DiffieHellmanGroup1Sha1,
47    #[strum(serialize = "diffie-hellman-group14-sha1")]
48    DiffieHellmanGroup14Sha1,
49    #[strum(serialize = "diffie-hellman-group14-sha256")]
50    DiffieHellmanGroup14Sha256,
51}
52
53/// pubkey hash algorithm
54#[derive(Copy, Clone, PartialEq, Eq, AsRefStr, EnumString)]
55pub enum PubKey {
56    #[strum(serialize = "ssh-ed25519")]
57    SshEd25519,
58    #[cfg(feature = "deprecated-rsa-sha1")]
59    #[strum(serialize = "ssh-rsa")]
60    SshRsa,
61    #[strum(serialize = "rsa-sha2-256")]
62    RsaSha2_256,
63    #[strum(serialize = "rsa-sha2-512")]
64    RsaSha2_512,
65    #[cfg(feature = "deprecated-dss-sha1")]
66    #[strum(serialize = "ssh-dss")]
67    SshDss,
68}
69
70/// MAC(message authentication code) algorithm
71#[derive(Copy, Clone, PartialEq, Eq, AsRefStr, EnumString)]
72pub enum Mac {
73    #[strum(serialize = "hmac-sha1")]
74    HmacSha1,
75    #[strum(serialize = "hmac-sha2-256")]
76    HmacSha2_256,
77    #[strum(serialize = "hmac-sha2-512")]
78    HmacSha2_512,
79}
80
81/// compression algorithm
82#[derive(Copy, Clone, PartialEq, Eq, AsRefStr, EnumString)]
83pub enum Compress {
84    #[strum(serialize = "none")]
85    None,
86    #[cfg(feature = "deprecated-zlib")]
87    #[strum(serialize = "zlib")]
88    Zlib,
89    #[strum(serialize = "zlib@openssh.com")]
90    ZlibOpenSsh,
91}
92
93#[derive(Default)]
94pub(crate) struct Digest {
95    pub hash_ctx: HashCtx,
96    pub key_exchange: Option<Box<dyn KeyExchange>>,
97}
98
99impl Digest {
100    pub fn new() -> Self {
101        Self {
102            ..Default::default()
103        }
104    }
105}