sheave_core/handshake/
encryption_algorithm.rs

1/// Representation of first 1 byte in handshake.
2///
3/// Variants correspond to respectively following numbers: 
4///
5/// |Pattern|Number|
6/// | :- | :- |
7/// |`NotEncrypted` (Default)|`3`|
8/// |`DiffieHellman`|`6`|
9/// |`Xtea`|`8`|
10/// |`Blowfish`|`9`|
11/// |`Other`|other numbers|
12///
13/// Because of the design policy, the variant to be used actually will only be `NotEncrypted`.
14/// Other variants are prepared to keep their meaning of known numbers.
15#[repr(u8)]
16#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
17pub enum EncryptionAlgorithm {
18    #[default]
19    NotEncrypted = 3,
20    DiffieHellman = 6,
21    Xtea = 8,
22    Blowfish = 9,
23    Other = 0xff
24}
25
26impl From<u8> for EncryptionAlgorithm {
27    fn from(encryption_algorithm: u8) -> Self {
28        use EncryptionAlgorithm::*;
29
30        match encryption_algorithm {
31            3 => NotEncrypted,
32            6 => DiffieHellman,
33            8 => Xtea,
34            9 => Blowfish,
35            _ => Other
36        }
37    }
38}
39
40impl From<EncryptionAlgorithm> for u8 {
41    fn from(encryption_algorithm: EncryptionAlgorithm) -> Self {
42        encryption_algorithm as u8
43    }
44}