diff options
author | Jake McGinty <me@jake.su> | 2018-06-01 15:41:47 -0500 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-06-01 15:41:47 -0500 |
commit | bf960c2dd0beea1c512c67a2e18f00cdce1d514a (patch) | |
tree | c69d70e7efdca194e06d69361eb47fe84b11efb6 /src/peer.rs | |
parent | manage nonces locally (diff) | |
download | wireguard-rs-bf960c2dd0beea1c512c67a2e18f00cdce1d514a.tar.xz wireguard-rs-bf960c2dd0beea1c512c67a2e18f00cdce1d514a.zip |
finish up nonce rework
Diffstat (limited to 'src/peer.rs')
-rw-r--r-- | src/peer.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/peer.rs b/src/peer.rs index 8538e2c..c0b21eb 100644 --- a/src/peer.rs +++ b/src/peer.rs @@ -95,6 +95,7 @@ impl Session { } pub fn into_transport_mode(self) -> Result<Session, Error> { + debug!("converting to async transport mode"); Ok(Session { noise : self.noise.into_async_transport_mode()?, our_index : self.our_index, @@ -202,7 +203,7 @@ impl Peer { return true; } if let Some(ref session) = self.sessions.current { - if session.noise.sending_nonce().unwrap() >= REKEY_AFTER_MESSAGES { + if session.nonce >= REKEY_AFTER_MESSAGES { debug!("needs new handshake: nonce >= REKEY_AFTER_MESSAGES"); return true; } @@ -213,7 +214,7 @@ impl Peer { pub fn ready_for_transport(&self) -> bool { if let Some(ref current) = self.sessions.current { current.birthday.elapsed() < *REJECT_AFTER_TIME && - current.noise.sending_nonce().unwrap() < REJECT_AFTER_MESSAGES + current.nonce < REJECT_AFTER_MESSAGES } else { false } @@ -319,8 +320,10 @@ impl Peer { pub fn process_incoming_handshake_response(&mut self, addr: Endpoint, packet: &Response) -> Result<Option<u32>, Error> { let mut session = mem::replace(&mut self.sessions.next, None).ok_or_else(|| err_msg("no next session"))?; + debug!("reading handshake message"); let _ = session.noise.read_message(packet.noise_bytes(), &mut [])?; + debug!("converting to transport mode"); session = session.into_transport_mode()?; session.their_index = packet.sender_index(); session.birthday = Timestamp::now(); |