feat: add public I2P network mode to router daemon
- Add `--public`, `--hops`, `--hosts`, and `--debug` router flags; `--public` auto-reseeds from the live network and keeps a status loop running. - Route NetDB lookups through tunnels with Noise_N garlic wrapping, fan out to two floodfills, and fetch unknown RouterInfos in the background. - Back off failed NTCP2 peers and fall back to IPv6 addresses when no IPv4 NTCP2 address is available. - Size session LeaseSet2 expiry from lease end dates and use the destination's X25519 key when present. - Add canonical Ed25519 Destination KeyCertificate constructors with round-trip tests. - Fix DatabaseStore gzip handling to honor the length prefix, and send `Wget/1.11.4` as the reseed User-Agent.
This commit is contained in:
1 parent
ae72b00323
commit
54cfb2faa9
25 files changed
+2033
-191
No files matched your search
@@ -25,6 +25,59 @@ test "Proposal 157 ShortTunnelBuild 218-byte record & reply round-trip" {
|
||||
)
|
||||
assert_eq(enc_rec.length(), 218)
|
||||
|
||||
// Verify canonical non-OBEP key derivation: iv_key == ck2 (no TunnelLayerIVKey step)
|
||||
let sym = @noise.SymmetricState::initialize(
|
||||
b"Noise_N_25519_ChaChaPoly_SHA256",
|
||||
)
|
||||
sym.mix_hash(b"")
|
||||
sym.mix_hash(hop_static.public_key)
|
||||
sym.mix_hash(ephem.public_key)
|
||||
let dh = @crypto.x25519(ephem.private_key, hop_static.public_key)
|
||||
sym.mix_key(dh)
|
||||
let pt = req.encode_154()
|
||||
let _ = sym.encrypt_and_hash(pt)
|
||||
let kd1 = @crypto.hkdf(sym.chaining_key(), b"", b"SMTunnelReplyKey", 64)
|
||||
let ck1 = kd1[:32].to_owned()
|
||||
let kd2 = @crypto.hkdf(ck1, b"", b"SMTunnelLayerKey", 64)
|
||||
let ck2 = kd2[:32].to_owned()
|
||||
assert_eq(creator_keys.iv_key, ck2)
|
||||
assert_eq(creator_keys.garlic_key, None)
|
||||
assert_eq(creator_keys.garlic_tag, None)
|
||||
|
||||
// Verify canonical OBEP key derivation: TunnelLayerIVKey + RGarlicKeyAndTag (tag=0..8, key=32..64)
|
||||
let obep_req : @tunnel.ShortBuildRequestRecord = {
|
||||
receive_tunnel_id: 1001U,
|
||||
next_tunnel_id: 2002U,
|
||||
next_ident: next_hash,
|
||||
flag: b'\x40', // OBEP
|
||||
layer_enc_type: b'\x00',
|
||||
request_time_min: 28333333U,
|
||||
request_expiration_sec: 600U,
|
||||
send_message_id: 5555U,
|
||||
options: @common.Mapping::new(),
|
||||
}
|
||||
let (_, obep_keys) = @tunnel.encrypt_short_build_record(
|
||||
obep_req,
|
||||
hop_hash,
|
||||
hop_static.public_key,
|
||||
ephem,
|
||||
)
|
||||
let sym2 = @noise.SymmetricState::initialize(
|
||||
b"Noise_N_25519_ChaChaPoly_SHA256",
|
||||
)
|
||||
sym2.mix_hash(b"")
|
||||
sym2.mix_hash(hop_static.public_key)
|
||||
sym2.mix_hash(ephem.public_key)
|
||||
sym2.mix_key(dh)
|
||||
let _ = sym2.encrypt_and_hash(obep_req.encode_154())
|
||||
let ok1 = @crypto.hkdf(sym2.chaining_key(), b"", b"SMTunnelReplyKey", 64)
|
||||
let ok2 = @crypto.hkdf(ok1[:32].to_owned(), b"", b"SMTunnelLayerKey", 64)
|
||||
let ok3 = @crypto.hkdf(ok2[:32].to_owned(), b"", b"TunnelLayerIVKey", 64)
|
||||
let ok4 = @crypto.hkdf(ok3[:32].to_owned(), b"", b"RGarlicKeyAndTag", 64)
|
||||
assert_eq(obep_keys.iv_key, ok3[32:64].to_owned())
|
||||
assert_eq(obep_keys.garlic_tag, Some(ok4[:8].to_owned()))
|
||||
assert_eq(obep_keys.garlic_key, Some(ok4[32:64].to_owned()))
|
||||
|
||||
// Wrong hop rejects with RecordNotForUs
|
||||
let mut rejected = false
|
||||
try {
|
||||
@@ -99,6 +152,22 @@ test "Proposal 157 multi-hop ShortTunnelBuild onion build, hop relay, OBEP garli
|
||||
assert_true(creator_hop_keys[2].1.garlic_key is Some(_))
|
||||
assert_true(creator_hop_keys[2].1.garlic_tag is Some(_))
|
||||
|
||||
// Verify Proposal 157 canonical ChaCha20 initial block counter 1U on downstream slot 1
|
||||
let (raw_hop1, _) = @tunnel.encrypt_short_build_record(
|
||||
hops[1].record,
|
||||
hops[1].hop_ident,
|
||||
hops[1].hop_static_pub,
|
||||
hops[1].ephemeral,
|
||||
padding=hops[1].padding,
|
||||
)
|
||||
let expected_slot1 = @crypto.chacha20_xor(
|
||||
creator_hop_keys[0].1.reply_key,
|
||||
1U,
|
||||
@tunnel.make_slot_nonce(hops[1].slot_idx),
|
||||
raw_hop1,
|
||||
)
|
||||
assert_eq(req_records[hops[1].slot_idx], expected_slot1)
|
||||
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user