@@ -17,10 +17,13 @@ pub async fn perform_handshake(
1717 rd : StreamReader ,
1818 wt : StreamWriter ,
1919) -> Result < ( String , Vec < u8 > , RsaPublicKey ) , Box < dyn std:: error:: Error + Send + Sync > > {
20+ println ! ( "Trying to receive handshake packet..." ) ;
2021 // Step: 0
2122 // Receive handshake packet from client with username and public_key
2223 let packet: HandshakePacket = read_packet ( rd. clone ( ) ) . await ?;
24+ println ! ( "\n Received handshake packet: {:?}\n " , packet) ;
2325 if packet. step != 0 {
26+ eprintln ! ( "❗️ Invalid handshake step: expected 0, got {}" , packet. step) ;
2427 let _ = close_connection ( wt. clone ( ) , "Invalid handshake step" ) . await ;
2528 return Err ( "Invalid handshake step" . into ( ) ) ;
2629 }
@@ -33,6 +36,7 @@ pub async fn perform_handshake(
3336 None => return Err ( "❗️Missing Public Key" . into ( ) ) ,
3437 } ;
3538
39+ println ! ( "Received handshake packet from client: {}" , user_name) ;
3640 // Step: 1
3741 // Generate session data (nonce & session_key)
3842 // Send handshake packet from server with nonce
@@ -46,12 +50,14 @@ pub async fn perform_handshake(
4650 signature : None ,
4751 session_key : None ,
4852 } ;
53+ println ! ( "\n Sending handshake packet with nonce: {:?}\n " , nonce) ;
4954 write_packet ( wt. clone ( ) , packet) . await ?;
5055
5156 // Step: 2
5257 // Receive signature and verify it
5358 let packet: HandshakePacket = read_packet ( rd. clone ( ) ) . await ?;
5459 if packet. step != 2 {
60+ eprintln ! ( "❗️ Invalid handshake step: expected 2, got {}" , packet. step) ;
5561 let _ = close_connection ( wt. clone ( ) , "Invalid handshake step" ) . await ;
5662 return Err ( "Invalid handshake step" . into ( ) ) ;
5763 }
@@ -61,6 +67,7 @@ pub async fn perform_handshake(
6167 } ;
6268
6369 if !verify_nonce_signature ( & public_key, & nonce, & signature) {
70+ eprintln ! ( "❗️ Invalid signature!" ) ;
6471 let _ = close_connection ( wt. clone ( ) , "Invalid signature!" ) . await ;
6572 return Err ( "Invalid signature!" . into ( ) ) ;
6673 }
0 commit comments