fn send_server_handshake<T,U>(&mut self, mut buf: T) -> Result<(usize, ConnectionState), OssuaryError>
    where T: std::ops::DerefMut<Target = U>,
          U: std::io::Write {
        let sig = self.sign_remote_challenge();
        // Get session encryption key, which must be known by now.
        let server_public = self.local_auth.public_key.unwrap_or_default();
        let session = self.local_key.session.as_ref().map(|s| s.as_bytes()).unwrap_or(&[0u8; KEY_LEN]);
        let chal = self.local_auth.challenge.unwrap_or([0u8; CHALLENGE_LEN]);
        let pkt = ServerHandshakePacket::new(&self.local_key.public,
                                             &self.local_key.nonce,
                                             session,
                                             server_public.as_bytes(),
                                             &chal,
                                             &sig)?;
        let w = write_packet(self, buf.deref_mut(), struct_as_slice(&pkt),
                             PacketType::ServerHandshake)?;
        increment_nonce(&mut self.local_key.nonce);
        let state = ConnectionState::ServerWaitAuthentication(std::time::SystemTime::now());
        Ok((w, state))
    }
/// Ready to send a server handshake packet
Ready to send a server handshake packet
Ready to send a server handshake packet
fn send_server_handshake<T,U>(&mut self, mut buf: T) -> Result<(usize, ConnectionState), OssuaryError>
    where T: std::ops::DerefMut<Target = U>,
          U: std::io::Write {
        let sig = self.sign_remote_challenge();
        // Get session encryption key, which must be known by now.
        let server_public = self.local_auth.public_key.unwrap_or_default();
        let session = self.local_key.session.as_ref().map(|s| s.as_bytes()).unwrap_or(&[0u8; KEY_LEN]);
        let chal = self.local_auth.challenge.unwrap_or([0u8; CHALLENGE_LEN]);
        let pkt = ServerHandshakePacket::new(&self.local_key.public,
                                             &self.local_key.nonce,
                                             session,
                                             server_public.as_bytes(),
                                             &chal,
                                             &sig)?;
        let w = write_packet(self, buf.deref_mut(), struct_as_slice(&pkt),
                             PacketType::ServerHandshake)?;
        increment_nonce(&mut self.local_key.nonce);
        let state = ConnectionState::ServerWaitAuthentication(std::time::SystemTime::now());
        Ok((w, state))
    }
fn send_server_handshake < T , U > ( & mut self , mut buf : T ) -> Result < ( usize , ConnectionState ) , OssuaryError > where T : std :: ops :: DerefMut < Target = U > , U : std :: io :: Write { let sig = self . sign_remote_challenge ( ) ; // Get session encryption key, which must be known by now. let server_public = self . local_auth . public_key . unwrap_or_default ( ) ; let session = self . local_key . session . as_ref ( ) . map ( | s | s . as_bytes ( ) ) . unwrap_or ( & [ 0u8 ; KEY_LEN ] ) ; let chal = self . local_auth . challenge . unwrap_or ( [ 0u8 ; CHALLENGE_LEN ] ) ; let pkt = ServerHandshakePacket :: new ( & self . local_key . public , & self . local_key . nonce , session , server_public . as_bytes ( ) , & chal , & sig ) ? ; let w = write_packet ( self , buf . deref_mut ( ) , struct_as_slice ( & pkt ) , PacketType :: ServerHandshake ) ? ; increment_nonce ( & mut self . local_key . nonce ) ; let state = ConnectionState :: ServerWaitAuthentication ( std :: time :: SystemTime :: now ( ) ) ; Ok ( ( w , state ) ) }
Ready to send a server handshake packet
Ready to send a server handshake packet
&mut self
buf
T
&mut self
buf
T