Fix secure tunnel session handling

This commit is contained in:
RWDai
2026-05-22 14:35:43 +08:00
parent b05f2a270a
commit 33633637e5
11 changed files with 40 additions and 67 deletions

View File

@@ -242,4 +242,25 @@ mod tests {
Err(TunnelSecurityError::Decrypt)
));
}
#[test]
fn secure_frame_uses_session_in_key_derivation() {
let session_a = "node-1:connection-a";
let session_b = "node-1:connection-b";
let client_a = SecureFrameCodec::new(&test_key(), session_a, TunnelSecurityRole::Client)
.expect("client codec a");
let client_b = SecureFrameCodec::new(&test_key(), session_b, TunnelSecurityRole::Client)
.expect("client codec b");
let frame = Frame::new(
7,
MsgType::RequestBody,
0,
Bytes::from_static(b"same payload"),
);
let encrypted_a = client_a.encrypt_frame(frame.clone()).expect("encrypt a");
let encrypted_b = client_b.encrypt_frame(frame).expect("encrypt b");
assert_ne!(encrypted_a, encrypted_b);
}
}