From 8e1a2cabd355245daa2578d2c934e955a4e2d866 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Wed, 28 Aug 2019 12:14:32 +0200 Subject: Renamed confirmed -> initator on keypair Done to reflect that the property is immutable, unlike the "confirmed" field on the decryption state. --- src/handshake/device.rs | 10 +++++----- src/handshake/noise.rs | 4 ++-- src/router/peer.rs | 4 ++-- src/router/workers.rs | 2 ++ src/types/keys.rs | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/handshake/device.rs b/src/handshake/device.rs index f439414..cf88303 100644 --- a/src/handshake/device.rs +++ b/src/handshake/device.rs @@ -442,7 +442,7 @@ mod tests { // 4. device-2 : responds with noise response let msg_response = match dev2.process(&mut rng, &msg_init, Some(&src1)).unwrap() { (Some(_), Some(msg), Some(kp)) => { - assert_eq!(kp.confirmed, false); + assert_eq!(kp.initiator, false); msg } _ => panic!("unexpected response"), @@ -469,7 +469,7 @@ mod tests { // 7. device-2 : responds with noise response let (msg_response, kp1) = match dev2.process(&mut rng, &msg_init, Some(&src1)).unwrap() { (Some(_), Some(msg), Some(kp)) => { - assert_eq!(kp.confirmed, false); + assert_eq!(kp.initiator, false); (msg, kp) } _ => panic!("unexpected response"), @@ -478,7 +478,7 @@ mod tests { // device-1 : process noise response let kp2 = match dev1.process(&mut rng, &msg_response, Some(&src2)).unwrap() { (Some(_), None, Some(kp)) => { - assert_eq!(kp.confirmed, true); + assert_eq!(kp.initiator, true); kp } _ => panic!("unexpected response"), @@ -515,7 +515,7 @@ mod tests { println!("msg2 = {} : {} bytes", hex::encode(&msg2[..]), msg2.len()); println!("msg2 = {:?}", Response::parse(&msg2[..]).unwrap()); - assert!(!ks_r.confirmed, "Responders key-pair is confirmed"); + assert!(!ks_r.initiator, "Responders key-pair is confirmed"); // process response and obtain confirmed key-pair @@ -523,7 +523,7 @@ mod tests { let ks_i = ks_i.unwrap(); assert!(msg3.is_none(), "Returned message after response"); - assert!(ks_i.confirmed, "Initiators key-pair is not confirmed"); + assert!(ks_i.initiator, "Initiators key-pair is not confirmed"); assert_eq!(ks_i.send, ks_r.recv, "KeyI.send != KeyR.recv"); assert_eq!(ks_i.recv, ks_r.send, "KeyI.recv != KeyR.send"); diff --git a/src/handshake/noise.rs b/src/handshake/noise.rs index 2f8f67e..8e8f517 100644 --- a/src/handshake/noise.rs +++ b/src/handshake/noise.rs @@ -457,7 +457,7 @@ pub fn create_response( Ok(KeyPair { birth: Instant::now(), - confirmed: false, + initiator: false, send: Key { id: sender, key: key_send.into(), @@ -532,7 +532,7 @@ pub fn consume_response( None, // no response message Some(KeyPair { birth: Instant::now(), - confirmed: true, + initiator: true, send: Key { id: sender, key: key_send.into(), diff --git a/src/router/peer.rs b/src/router/peer.rs index 9451b2c..234c353 100644 --- a/src/router/peer.rs +++ b/src/router/peer.rs @@ -243,7 +243,7 @@ impl, R: Callback, K: KeyCallback> Peer, R: Callback, K: KeyCallback> Peer, R: Callback, K: KeyCallback< peer.confirm_key(state.keypair.clone()); } + // update enpoint, TODO + // write packet to TUN device, TODO // trigger callback diff --git a/src/types/keys.rs b/src/types/keys.rs index 0b52d18..c39816c 100644 --- a/src/types/keys.rs +++ b/src/types/keys.rs @@ -20,7 +20,7 @@ impl PartialEq for Key { #[derive(Debug, Clone, Copy)] pub struct KeyPair { pub birth: Instant, // when was the key-pair created - pub confirmed: bool, // has the key-pair been confirmed? + pub initiator: bool, // has the key-pair been confirmed? pub send: Key, // key for outbound messages pub recv: Key, // key for inbound messages -} \ No newline at end of file +} -- cgit v1.2.3-59-g8ed1b