39 static const unsigned c_rlpxVersion = 4;
111 virtual void transition(boost::system::error_code _ech = boost::system::error_code());
114 boost::posix_time::milliseconds
const c_timeout = boost::posix_time::milliseconds(1800);
142 std::unique_ptr<RLPXFrameCoder>
m_io;
bytes m_ackCipher
Ciphertext of egress or ingress Ack message.
std::shared_ptr< RLPXSocket > m_socket
Socket.
bytes m_ack
Plaintext of egress or ingress Ack message.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Host * m_host
Host which provides m_alias, protocolVersion(), m_clientVersion, caps(), and TCP listenPort().
void cancel()
Aborts the handshake.
void readAuthEIP8()
Continues reading Auth message in EIP-8 format and transitions to AckAuthEIP8.
RLPXHandshake(Host *_host, std::shared_ptr< RLPXSocket > const &_socket, NodeID _remote)
Setup outbound connection.
vector_ref< _T const > ref(_T const &_t)
bool m_cancel
Will be set to true if connection was canceled.
h256 m_nonce
Nonce generated by this host for handshake.
NodeID m_remote
Node id of remote host for socket.
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not t...
boost::asio::deadline_timer m_idleTimer
Timer which enforces c_timeout.
static Secret get()
Returns the next nonce (might be read from a file).
bytes m_authCipher
Ciphertext of egress or ingress Auth message.
crypto::ECDHE m_ecdhe
Ephemeral ECDH secret and agreement.
bytesConstRef ref() const
virtual void transition(boost::system::error_code _ech=boost::system::error_code())
Performs transition for m_nextState.
void readAck()
Reads Auth message from socket and transitions to WriteHello.
std::vector< byte > bytes
Public m_remoteEphemeral
Remote ephemeral public key.
void setAuthValues(Signature const &sig, Public const &remotePubk, h256 const &remoteNonce, uint64_t remoteVersion)
Derives ephemeral secret from signature and sets members after Auth has been decrypted.
bytes m_handshakeInBuffer
Frame buffer for ingress Hello packet.
void writeAuth()
Write Auth message to socket and transitions to AckAuth.
boost::posix_time::milliseconds const c_timeout
Timeout for remote to respond to transition events. Enforced by m_idleTimer and refreshed by transiti...
void error()
Closes connection and ends transitions.
void writeAck()
Write Ack message to socket and transitions to WriteHello.
bool m_originated
True if connection is outbound.
State m_nextState
Current or expected state of transition.
RLPXHandshake(Host *_host, std::shared_ptr< RLPXSocket > const &_socket)
Setup incoming connection.
void copyTo(vector_ref< typename std::remove_const< _T >::type > _t) const
Copies the contents of this vector_ref to the contents of _t, up to the max size of _t...
void readAckEIP8()
Continues reading Ack message in EIP-8 format and transitions to WriteHello.
void writeAckEIP8()
Write Ack message in EIP-8 format to socket and transitions to WriteHello.
h256 m_remoteNonce
Nonce generated by remote host for handshake.
State
Sequential states of handshake.
std::unique_ptr< RLPXFrameCoder > m_io
Used to read and write RLPx encrypted frames for last step of handshake authentication.
void readAuth()
Reads Auth message from socket and transitions to AckAuth.
bytes m_auth
Buffers for encoded and decoded handshake phases.
void start()
Start handshake.
bytes m_handshakeOutBuffer
Frame buffer for egress Hello packet.
Derive DH shared secret from EC keypairs.
Encoder/decoder transport for RLPx connection established by RLPXHandshake.
Setup inbound or outbound connection for communication over RLPXFrameCoder.