Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions crates/networking/p2p/rlpx/connection/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async fn receive_auth<S: AsyncRead + std::marker::Unpin>(
public_key: auth.public_key,
nonce: auth.nonce,
ephemeral_key: remote_ephemeral_key,
init_message: msg_bytes.to_owned(),
init_message: msg_bytes,
})
}

Expand All @@ -239,7 +239,7 @@ async fn receive_ack<S: AsyncRead + std::marker::Unpin>(
public_key: remote_public_key,
nonce: ack.nonce,
ephemeral_key: remote_ephemeral_key,
init_message: msg_bytes.to_owned(),
init_message: msg_bytes,
})
}

Expand All @@ -258,15 +258,9 @@ async fn receive_handshake_msg<S: AsyncRead + std::marker::Unpin>(
buf.resize(msg_size + 2, 0);

// Read the rest of the message
// Guard unwrap
if buf.len() < msg_size + 2 {
return Err(PeerConnectionError::CryptographyError(String::from(
"bad buf size",
)));
}
stream.read_exact(&mut buf[2..msg_size + 2]).await?;
let ack_bytes = &buf[..msg_size + 2];
Ok(ack_bytes.to_vec())
stream.read_exact(&mut buf[2..]).await?;
buf.truncate(msg_size + 2);
Ok(buf)
}

/// Encodes an Auth message, to start a handshake.
Expand Down