feat: add ratchet, streaming, SU3 reseed, and router floodfill
- Add ratchet/ with ECIES-X25519-AEAD-Ratchet (Proposal 144), Garlic cloves, and ECIES DatabaseLookup replies - Add streaming/ with Ed25519-signed I2P Streaming (SYN/ACK/NACK/CLOSE/RESET, retransmit, window) and Repliable/Raw Datagrams - Add common/su3.mbt to parse and verify reseed .su3 bundles - Add Elligator2 encoding in crypto/ and OfflineSignature support in LeaseSet2 (flags bit 0) - Router: NTCP2 peer pool, floodfill NetDB crawl, transit tunnel relay, and Garlic/Streaming bridge - cmd/router: add --peer-dir, --su3, --reseed, --floodfill, --no-clock-skew - cmd/client: add --dest for persistent destination keys - Mark Phase 6 complete in README and document the transport scope (NTCP2 only, no SSU2)
This commit is contained in:
1 parent
8eafa11b22
commit
ae72b00323
54 files changed
+9607
-704
No files matched your search
+96
-3
@@ -42,10 +42,103 @@ test "Proposal 157 ShortTunnelBuild 218-byte record & reply round-trip" {
|
||||
assert_eq(dec_rec, req)
|
||||
assert_eq(hop_keys, creator_keys)
|
||||
|
||||
// Hop encrypts 218-byte accept reply (code 0); creator decrypts it
|
||||
let reply = @tunnel.encrypt_short_build_reply(hop_keys, b'\x00')
|
||||
// Hop encrypts 218-byte accept reply (code 0) at slot 0; creator decrypts it
|
||||
let reply = @tunnel.encrypt_short_build_reply(hop_keys, 0, b'\x00')
|
||||
assert_eq(reply.length(), 218)
|
||||
assert_eq(@tunnel.decrypt_short_build_reply(creator_keys, reply), b'\x00')
|
||||
assert_eq(@tunnel.decrypt_short_build_reply(creator_keys, 0, reply), b'\x00')
|
||||
}
|
||||
|
||||
///|
|
||||
test "Proposal 157 multi-hop ShortTunnelBuild onion build, hop relay, OBEP garlic keys, and reply decrypt" {
|
||||
let hops : Array[@tunnel.ShortHopBuildSpec] = []
|
||||
let hop_statics : Array[@noise.KeyPair] = []
|
||||
let hop_idents : Array[@common.Hash] = []
|
||||
for i = 0; i < 3; i = i + 1 {
|
||||
let sp = Bytes::make(32, (0x10 + i).to_byte())
|
||||
let skp = @noise.KeyPair::from_private(sp)
|
||||
let ep = Bytes::make(32, (0x20 + i).to_byte())
|
||||
let ekp = @noise.KeyPair::from_private(ep)
|
||||
let ident = @common.Hash::sha256(Bytes::make(4, (0x30 + i).to_byte()))
|
||||
let next_ident = @common.Hash::sha256(Bytes::make(4, (0x31 + i).to_byte()))
|
||||
let flag = if i == 0 {
|
||||
b'\x80' // IBGW
|
||||
} else if i == 2 {
|
||||
b'\x40' // OBEP
|
||||
} else {
|
||||
b'\x00'
|
||||
}
|
||||
let rec : @tunnel.ShortBuildRequestRecord = {
|
||||
receive_tunnel_id: (100 + i).reinterpret_as_uint(),
|
||||
next_tunnel_id: (200 + i).reinterpret_as_uint(),
|
||||
next_ident,
|
||||
flag,
|
||||
layer_enc_type: b'\x00',
|
||||
request_time_min: 28333333U,
|
||||
request_expiration_sec: 600U,
|
||||
send_message_id: (500 + i).reinterpret_as_uint(),
|
||||
options: @common.Mapping::new(),
|
||||
}
|
||||
hop_statics.push(skp)
|
||||
hop_idents.push(ident)
|
||||
hops.push({
|
||||
slot_idx: (i + 1) % 4, // scrambled slot positions (1, 2, 3) with slot 0 dummy
|
||||
hop_ident: ident,
|
||||
hop_static_pub: skp.public_key,
|
||||
ephemeral: ekp,
|
||||
record: rec,
|
||||
padding: Bytes::make(16, (0x40 + i).to_byte()),
|
||||
})
|
||||
}
|
||||
let (req_records, creator_hop_keys) = @tunnel.build_short_tunnel_request(
|
||||
4,
|
||||
hops,
|
||||
[Bytes::make(218, b'\xde')],
|
||||
)
|
||||
assert_eq(req_records.length(), 4)
|
||||
assert_true(creator_hop_keys[0].1.garlic_key is None)
|
||||
assert_true(creator_hop_keys[2].1.garlic_key is Some(_))
|
||||
assert_true(creator_hop_keys[2].1.garlic_tag is Some(_))
|
||||
|
||||
let mut wire_records = req_records
|
||||
for i = 0; i < 3; i = i + 1 {
|
||||
let (rec, keys, slot, next_records) = @tunnel.process_short_tunnel_build_hop(
|
||||
wire_records,
|
||||
hop_idents[i],
|
||||
hop_statics[i],
|
||||
b'\x00',
|
||||
reply_padding=Bytes::make(16, b'\x77'),
|
||||
)
|
||||
assert_eq(slot, hops[i].slot_idx)
|
||||
assert_eq(rec, hops[i].record)
|
||||
assert_eq(keys, creator_hop_keys[i].1)
|
||||
wire_records = next_records
|
||||
}
|
||||
let codes = @tunnel.decrypt_short_tunnel_replies(
|
||||
wire_records, creator_hop_keys,
|
||||
)
|
||||
assert_eq(codes, [b'\x00', b'\x00', b'\x00'])
|
||||
}
|
||||
|
||||
///|
|
||||
test "TunnelData FragmentReassembler handles out-of-order FollowOn before First" {
|
||||
let iv = Bytes::make(16, b'\x33')
|
||||
let payload = Bytes::make(2200, b'\xab')
|
||||
let cells = @tunnel.fragment_message_to_cells(
|
||||
Local,
|
||||
777U,
|
||||
payload,
|
||||
iv,
|
||||
padding=Bytes::make(64, b'\x00'), // zeros sanitized to 0x01
|
||||
)
|
||||
assert_eq(cells.length(), 3)
|
||||
let r = @tunnel.FragmentReassembler::new()
|
||||
// Deliver cell 2, then cell 1, then cell 0
|
||||
assert_eq(r.push(@tunnel.unpack_tunnel_cell(cells[2])[0]), None)
|
||||
assert_eq(r.push(@tunnel.unpack_tunnel_cell(cells[1])[0]), None)
|
||||
assert_eq(
|
||||
r.push(@tunnel.unpack_tunnel_cell(cells[0])[0]),
|
||||
Some((Local, payload)),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
Reference in new issue
Block a user