Skip to content

Commit 4bfebbd

Browse files
author
Threepwood-7
committed
RUST-BUG-087: dump secure-ident signatures
1 parent e92006a commit 4bfebbd

5 files changed

Lines changed: 59 additions & 17 deletions

File tree

crates/emulebb-ed2k/src/ed2k_tcp/dump.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,23 @@ pub(super) fn dump_ed2k_tcp_download_recv(
568568

569569
#[cfg(test)]
570570
mod tests {
571-
use super::ED2K_TCP_DUMP_FILE_PREFIX;
571+
use super::{ED2K_TCP_DUMP_FILE_PREFIX, OP_EMULEPROT, OP_SIGNATURE, canonical_ed2k_send_phase};
572572

573573
#[test]
574574
fn tcp_dump_prefix_uses_emulebb_rust_name() {
575575
assert_eq!(ED2K_TCP_DUMP_FILE_PREFIX, "emulebb-rust-ed2k-tcp-dump-");
576576
}
577+
578+
#[test]
579+
fn secure_ident_signature_send_phase_matches_mfc_oracle() {
580+
assert_eq!(
581+
canonical_ed2k_send_phase(
582+
"native_download",
583+
"fallback",
584+
Some(OP_EMULEPROT),
585+
Some(OP_SIGNATURE)
586+
),
587+
"signature"
588+
);
589+
}
577590
}

crates/emulebb-ed2k/src/ed2k_tcp/identity.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use sha1::Sha1;
1717

1818
use super::{
1919
ED2K_SECURE_IDENT_KEY_AND_SIGNATURE_NEEDED, ED2K_SECURE_IDENT_KEY_BITS, Ed2kTransport,
20-
OP_EMULEPROT, OP_SECIDENTSTATE, OP_SIGNATURE, encode_packet,
20+
OP_EMULEPROT, OP_SECIDENTSTATE, OP_SIGNATURE, dump_ed2k_tcp_download_send, encode_packet,
2121
};
2222

2323
/// Stock eMule `MAXPUBKEYSIZE` (`ClientCredits.h`): the secure-ident public-key
@@ -442,6 +442,7 @@ pub(super) async fn try_send_secure_ident_signature(
442442
challenge_ip,
443443
)?,
444444
);
445+
dump_ed2k_tcp_download_send(peer_addr, transport.mode, "signature", &signature);
445446
transport
446447
.write_all(&signature)
447448
.await

crates/emulebb-ed2k/src/ed2k_tcp/tests/download/startup_secure_ident.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

33
#[tokio::test]
4-
async fn small_file_download_waits_for_peer_signature_before_start_upload() {
4+
async fn small_file_download_starts_after_local_secure_ident_signature() {
55
let root = unique_test_dir("ed2k-small-file-capture");
66
let transfer_runtime = Ed2kTransferRuntime::load_or_create(&root).unwrap();
77
let payload = vec![0x5A; 2_409_452];
@@ -65,20 +65,6 @@ async fn small_file_download_waits_for_peer_signature_before_start_upload() {
6565
assert_eq!(signature[0], OP_EMULEPROT);
6666
assert_eq!(signature[5], super::OP_SIGNATURE);
6767

68-
// Oracle-shaped sessions keep file startup traffic behind the full
69-
// secure-ident roundtrip, so no filename/upload request should
70-
// arrive before the peer signature closes the exchange.
71-
assert!(
72-
tokio::time::timeout(Duration::from_millis(150), read_packet(&mut stream))
73-
.await
74-
.is_err(),
75-
"startup requests must wait for peer OP_SIGNATURE"
76-
);
77-
78-
let peer_signature =
79-
encode_packet(OP_EMULEPROT, super::OP_SIGNATURE, &peer_signature_payload());
80-
stream.write_all(&peer_signature).await.unwrap();
81-
8268
let startup_request = read_packet(&mut stream).await;
8369
assert_startup_multipacket_ext2(
8470
startup_request[0],

docs/active/INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ items.
9898
| [RUST-BUG-084](items/RUST-BUG-084.md) | Major | DONE | Use MFC common-file SX2 reask timing |
9999
| [RUST-BUG-085](items/RUST-BUG-085.md) | Major | DONE | Apply MFC SX2 answer cooldown per file |
100100
| [RUST-BUG-086](items/RUST-BUG-086.md) | Major | DONE | Do not block download startup on peer secure-ident signature |
101+
| [RUST-BUG-087](items/RUST-BUG-087.md) | Minor | DONE | Dump outgoing secure-ident signatures |
101102

102103
## Refactors (`REF`)
103104

docs/active/items/RUST-BUG-087.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: RUST-BUG-087
3+
title: Dump outgoing secure-ident signatures
4+
status: done
5+
priority: Minor
6+
category: bug
7+
workflow: local
8+
---
9+
10+
# RUST-BUG-087: Dump outgoing secure-ident signatures
11+
12+
## Problem
13+
14+
The hide.me live-wire run `rust-hideme-20260619T034125Z` confirmed that Rust now
15+
continues startup after secure-ident key exchange, but packet diagnostics did
16+
not include outgoing `OP_SIGNATURE` records. That made secure-ident parity
17+
analysis weaker than the MFC diagnostics surface: eMuleBB MFC has an explicit
18+
`SendSignaturePacket` path, and Rust should expose the same outbound packet in
19+
diagnostic packet dumps without changing wire behavior.
20+
21+
## Acceptance
22+
23+
- [x] Outgoing secure-ident signatures are written to the ED2K TCP packet dump.
24+
- [x] The diagnostic phase remains the canonical `signature` phase used by the
25+
MFC comparison oracle.
26+
- [x] The emitted wire packet remains unchanged.
27+
28+
## Implementation Notes
29+
30+
- Added the packet-dump send wrapper beside the existing `OP_SIGNATURE` write in
31+
`try_send_secure_ident_signature`.
32+
- Added a unit guard for the canonical outgoing signature phase mapping.
33+
34+
## Evidence
35+
36+
- Live behavior exposing the diagnostics gap:
37+
`EMULEBB_WORKSPACE_OUTPUT_ROOT\live-wire\rust-hideme-20260619T034125Z`.
38+
- MFC comparison: `BaseClient.cpp` `SendSignaturePacket` and
39+
`ListenSocket.cpp` secure-ident packet handling.
40+
- `cargo test -p emulebb-ed2k secure_ident -- --nocapture`
41+
- `python tools/rust_quality_gate.py quick`

0 commit comments

Comments
 (0)