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
38
tests/protocol.rs
Normal file
38
tests/protocol.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//! M3 protocol: framed Noise IK, identity pin, ciphertext on the wire.
|
||||
|
||||
use onionwire::session::{self, Keys};
|
||||
use onionwire::{frame, tui};
|
||||
|
||||
#[test]
|
||||
fn frame_roundtrip() {
|
||||
let f = frame::encode(b"hi").expect("encode");
|
||||
assert_eq!(f[0], 1, "version byte");
|
||||
assert_eq!(&f[1..5], &(2u32).to_be_bytes());
|
||||
assert_eq!(frame::decode(&f).expect("decode"), b"hi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn noise_ik_roundtrip_hides_plaintext() {
|
||||
let a = Keys::generate();
|
||||
let b = Keys::generate();
|
||||
let (mut sa, mut sb) = session::handshake(&a, &b).expect("handshake");
|
||||
let ct = sa.encrypt(b"hello wire").expect("enc");
|
||||
assert!(
|
||||
!ct.windows(10).any(|w| w == b"hello wire"),
|
||||
"plaintext must not appear in ciphertext"
|
||||
);
|
||||
assert_eq!(sb.decrypt(&ct).expect("dec"), b"hello wire");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fingerprint_mismatch_is_hard_fail() {
|
||||
let a = Keys::generate();
|
||||
let b = Keys::generate();
|
||||
let evil = Keys::generate();
|
||||
let err = match session::handshake_pinned(&a, &b, &evil.identity_pk) {
|
||||
Err(e) => e,
|
||||
Ok(_) => panic!("expected fingerprint mismatch"),
|
||||
};
|
||||
assert!(err.is_fingerprint_mismatch(), "{err}");
|
||||
assert_eq!(tui::fingerprint_mismatch_banner(), "fingerprint mismatch");
|
||||
}
|
||||
Loading…
Reference in a new issue