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
/*
 * Created on Sat Nov 28 2020
 *
 * Copyright (c) storycraft. Licensed under the MIT Licence.
 */

use serde::{Deserialize, Serialize};

use crate::command::Command;

pub mod crypto;
pub mod layer;
pub mod session;
pub mod stream;

pub const SECURE_HEADER_SIZE: usize = 20;

#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct SecureHeader {
    pub data_size: u32,
    pub iv: [u8; 16],
}

#[derive(Debug)]
pub struct SecureCommand {
    pub header: SecureHeader,
    pub command: Command,
}

pub const SECURE_HANDSHAKE_HEADER_SIZE: usize = 12;

#[derive(Debug, Serialize, Deserialize)]
pub struct SecureHandshakeHeader {
    pub encrypted_key_len: u32,
    pub key_encrypt_type: u32,
    pub encrypt_type: u32,
}