Add Noise IK encrypted stream over Arti.
M3: framed Noise_IK_25519_ChaChaPoly_BLAKE2s on the onion pipe, QR-pinned identity proofs, plaintext only in sqlite. Live two_node send of hello wire.
This commit is contained in:
parent
4fb4648552
commit
a2dfe3b2b8
12 changed files with 1208 additions and 47 deletions
75
tests/two_node.rs
Normal file
75
tests/two_node.rs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//! M3: two live Arti nodes, encrypted send, plaintext only in sqlite.
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use onionwire::node::{self, Node};
|
||||
|
||||
const HELLO: &[u8] = b"hello wire";
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore = "needs live Tor network"]
|
||||
async fn alice_sends_hello_wire_bob_sqlite_has_plaintext() {
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()),
|
||||
)
|
||||
.with_test_writer()
|
||||
.try_init();
|
||||
|
||||
let root = tempfile::tempdir().expect("tempdir");
|
||||
let alice_home = root.path().join("alice");
|
||||
let bob_home = root.path().join("bob");
|
||||
|
||||
eprintln!("starting alice + bob nodes…");
|
||||
let (alice, bob) = tokio::join!(
|
||||
Node::start(alice_home.clone()),
|
||||
Node::start(bob_home.clone())
|
||||
);
|
||||
let alice = alice.expect("alice node");
|
||||
let bob = bob.expect("bob node");
|
||||
eprintln!("alice onion={}", alice.onion());
|
||||
eprintln!("bob onion={}", bob.onion());
|
||||
assert_ne!(alice.onion(), bob.onion());
|
||||
|
||||
let a_qr = alice.qr_payload().expect("alice qr");
|
||||
let b_qr = bob.qr_payload().expect("bob qr");
|
||||
alice.add_friend_from_qr(&b_qr).expect("alice adds bob");
|
||||
bob.add_friend_from_qr(&a_qr).expect("bob adds alice");
|
||||
|
||||
eprintln!("alice → bob hello wire");
|
||||
alice
|
||||
.send(&bob.identity_pk(), HELLO)
|
||||
.await
|
||||
.expect("alice send");
|
||||
|
||||
let deadline = Instant::now() + Duration::from_secs(30);
|
||||
loop {
|
||||
let msgs = bob
|
||||
.list_messages(&alice.identity_pk())
|
||||
.expect("bob messages");
|
||||
if msgs.iter().any(|m| m.dir == "in" && m.plaintext == HELLO) {
|
||||
break;
|
||||
}
|
||||
if Instant::now() >= deadline {
|
||||
panic!("bob sqlite missing incoming hello wire; got {msgs:?}");
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
}
|
||||
|
||||
assert!(
|
||||
!node::dir_contains_bytes(&alice.arti_dir(), HELLO),
|
||||
"plaintext leaked into alice arti dir"
|
||||
);
|
||||
assert!(
|
||||
!node::dir_contains_bytes(&bob.arti_dir(), HELLO),
|
||||
"plaintext leaked into bob arti dir"
|
||||
);
|
||||
assert!(
|
||||
!node::dir_contains_bytes(&alice.cache_dir(), HELLO),
|
||||
"plaintext leaked into alice cache dir"
|
||||
);
|
||||
assert!(
|
||||
!node::dir_contains_bytes(&bob.cache_dir(), HELLO),
|
||||
"plaintext leaked into bob cache dir"
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue