Skip to content

Commit

Permalink
feat: improve auth & automatic padding
Browse files Browse the repository at this point in the history
  • Loading branch information
3andne committed Feb 22, 2023
1 parent 66f8efb commit d1a1cce
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 114 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ sha1 = "*"
hmac = "*"
tokio-util = { version = "*", features = ["full"] }
futures-util = "0.3.26"
sha2 = "*"
sha2 = "*"
rand = "0.8.5"
10 changes: 10 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ pub struct Opt {
/// the password to authenticate connections
#[structopt(short = "p", long, parse(from_str = make_password))]
pub password: Password,

/// The target length of early server data. Packets that exceed this
/// will be truncated.
#[structopt(long, default_value = "1385")]
pub mtu: u16,

/// The minimal length of server data. Packets that below this
/// will be padded.
#[structopt(long, default_value = "15")]
pub min_record_len: u16,
}

// #[derive(Debug)]
Expand Down
7 changes: 7 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pub const REQUIRED_SESSION_ID_LEN: usize = 32;
pub const RESTLS_HANDSHAKE_HMAC_LEN: usize = 16;
pub const RESTLS_APPDATA_HMAC_LEN: usize = 8;
pub const RESTLS_APPDATA_LEN_OFFSET: usize = 5 + RESTLS_APPDATA_HMAC_LEN;
pub const RESTLS_APPDATA_OFFSET: usize = 5 + RESTLS_APPDATA_HMAC_LEN + 2;

// record type
pub const RECORD_HANDSHAKE: u8 = 0x16;
Expand All @@ -25,3 +27,8 @@ pub const HELLO_RETRY_RANDOM: [u8; 32] = [
0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91,
0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, 0x07, 0x9E, 0x09, 0xE2, 0xC8, 0xA8, 0x33, 0x9C,
];

pub const TO_CLIENT_MAGIC: &'static [u8] = "server-to-client".as_bytes();
pub const TO_SERVER_MAGIC: &'static [u8] = "client-to-server".as_bytes();

pub const BUF_SIZE: usize = 0x2000;
Loading

0 comments on commit d1a1cce

Please sign in to comment.