Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel/timing diagnostic #7

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
paths = ["./"] # path dependency overrides

[alias] # command aliases
b = "build"
c = "check"
t = "test"
r = "run"
rr = "run --release"
recursive_example = "rr --example recursions"
space_example = ["run", "--release", "--", "\"command list\""]

[build]
# target = "x86_64-unknown-linux-musl" # this was worse
rustflags = [
"-C", "code-model=kernel",
"-C", "target-cpu=native", # Enable CPU-specific optimizations for your machine
#"-C", "target-feature=+adx,+aes,+avx,+avx2,+bmi1,+bmi2,+cmpxchg16b,+f16c,+fma,+fxsr,+lzcnt,+movbe,+pclmulqdq,+popcnt,+rdrand,+rdseed,+sha,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsavec,+xsaveopt,+xsaves",
"-C", "llvm-args=--inline-threshold=25", # Adjust inlining behavior
"-C", "link-arg=-flto", # Additional linker optimization flags
#"-C", "llvm-args=-mem2reg",
"-C", "passes=inline function-attrs argpromotion simplifycfg dce adce sroa gvn early-cse sccp sink tailcallelim mem2reg",
]
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/target
*.swp
user_list.txt
user_list.txt
flamegraph.svg
perf.data
perf.data.old
121 changes: 121 additions & 0 deletions Cargo.lock

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

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ keywords = ["tacacs", "security", "identity"]
categories = ["Network programming"]

[profile.release]
incremental = true
opt-level = 3
lto = "fat"
codegen-units = 1
panic = 'abort'
incremental = false
debug = false

[profile.dev]
incremental = true

[dependencies]
md5 = "0.7.0"
precis-profiles = "0.1.11"
ctrlc = "3.4.5"
libc = "0.2"

[lints.rust]
non_camel_case_types = "allow"
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl RTHeader {
return Err("Client wants to send unreasonably large password or something");
}

println!("Ratchet Debug: Parsed header: {:#?}", ret);
//println!("Ratchet Debug: Parsed header: {:#?}", ret);
Ok(ret)
}

Expand All @@ -121,14 +121,14 @@ impl RTHeader {
return Err("Segment too short, check client implementation.");
}

println!("Ratchet Debug: Comparing buf: {} and pad: {}", pck_buf.len(), md5pad.len());
//println!("Ratchet Debug: Comparing buf: {} and pad: {}", pck_buf.len(), md5pad.len());

let pck_buf = md5_xor(&pck_buf, &md5pad);

let ret = match RTAuthenStartPacket::from_raw_packet(&pck_buf){
Ok(r) => r,
Err(e) => {
println!("Ratchet Error: Invalid packet field processed {}", e);
//println!("Ratchet Error: Invalid packet field processed {}", e);
return Err("Packet field error in authentication.");
}
};
Expand Down Expand Up @@ -282,7 +282,7 @@ const RT_AUTH_TEXT_START: usize = RT_AUTHENTICATION_START_PACKET_INDEXES.data_le
impl RTAuthenStartPacket {
#[allow(clippy::indexing_slicing)]
pub fn from_raw_packet(pck_buf : &[u8]) -> Result<Self, &str> {
println!("Ratchet Debug: Hey, check out this: {:#?}", String::from_utf8_lossy(pck_buf));
//println!("Ratchet Debug: Hey, check out this: {:#?}", String::from_utf8_lossy(pck_buf));

// it seems risky to have the protocol do this unchecked.
if pck_buf.len() < 8 {
Expand All @@ -295,7 +295,7 @@ impl RTAuthenStartPacket {
(pck_buf[RT_AUTHENTICATION_START_PACKET_INDEXES.data_len] as usize) + 8;
let expected_size = pck_buf.len();
if purported_size != expected_size {
println!("Malformed packet size! {} {}", purported_size, expected_size);
//println!("Malformed packet size! {} {}", purported_size, expected_size);
return Err("Malformed packet size (doesn't add up)");
}

Expand Down
Loading