Fabcoin Core
0.16.2
P2P Digital Currency
|
Setup inbound or outbound connection for communication over RLPXFrameCoder. More...
#include <RLPxHandshake.h>
Public Member Functions | |
RLPXHandshake (Host *_host, std::shared_ptr< RLPXSocket > const &_socket) | |
Setup incoming connection. More... | |
RLPXHandshake (Host *_host, std::shared_ptr< RLPXSocket > const &_socket, NodeID _remote) | |
Setup outbound connection. More... | |
~RLPXHandshake () | |
void | start () |
Start handshake. More... | |
void | cancel () |
Aborts the handshake. More... | |
Protected Types | |
enum | State { Error = -1, New, AckAuth, AckAuthEIP8, WriteHello, ReadHello, StartSession } |
Sequential states of handshake. More... | |
Protected Member Functions | |
void | writeAuth () |
Write Auth message to socket and transitions to AckAuth. More... | |
void | readAuth () |
Reads Auth message from socket and transitions to AckAuth. More... | |
void | readAuthEIP8 () |
Continues reading Auth message in EIP-8 format and transitions to AckAuthEIP8. More... | |
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. More... | |
void | writeAck () |
Write Ack message to socket and transitions to WriteHello. More... | |
void | writeAckEIP8 () |
Write Ack message in EIP-8 format to socket and transitions to WriteHello. More... | |
void | readAck () |
Reads Auth message from socket and transitions to WriteHello. More... | |
void | readAckEIP8 () |
Continues reading Ack message in EIP-8 format and transitions to WriteHello. More... | |
void | error () |
Closes connection and ends transitions. More... | |
virtual void | transition (boost::system::error_code _ech=boost::system::error_code()) |
Performs transition for m_nextState. More... | |
Protected Attributes | |
boost::posix_time::milliseconds const | c_timeout = boost::posix_time::milliseconds(1800) |
Timeout for remote to respond to transition events. Enforced by m_idleTimer and refreshed by transition(). More... | |
State | m_nextState = New |
Current or expected state of transition. More... | |
bool | m_cancel = false |
Will be set to true if connection was canceled. More... | |
Host * | m_host |
Host which provides m_alias, protocolVersion(), m_clientVersion, caps(), and TCP listenPort(). More... | |
NodeID | m_remote |
Node id of remote host for socket. More... | |
bool | m_originated = false |
True if connection is outbound. More... | |
bytes | m_auth |
Buffers for encoded and decoded handshake phases. More... | |
bytes | m_authCipher |
Ciphertext of egress or ingress Auth message. More... | |
bytes | m_ack |
Plaintext of egress or ingress Ack message. More... | |
bytes | m_ackCipher |
Ciphertext of egress or ingress Ack message. More... | |
bytes | m_handshakeOutBuffer |
Frame buffer for egress Hello packet. More... | |
bytes | m_handshakeInBuffer |
Frame buffer for ingress Hello packet. More... | |
crypto::ECDHE | m_ecdhe |
Ephemeral ECDH secret and agreement. More... | |
h256 | m_nonce |
Nonce generated by this host for handshake. More... | |
Public | m_remoteEphemeral |
Remote ephemeral public key. More... | |
h256 | m_remoteNonce |
Nonce generated by remote host for handshake. More... | |
uint64_t | m_remoteVersion |
std::unique_ptr< RLPXFrameCoder > | m_io |
Used to read and write RLPx encrypted frames for last step of handshake authentication. More... | |
std::shared_ptr< RLPXSocket > | m_socket |
Socket. More... | |
boost::asio::deadline_timer | m_idleTimer |
Timer which enforces c_timeout. More... | |
Friends | |
class | RLPXFrameCoder |
Setup inbound or outbound connection for communication over RLPXFrameCoder.
RLPx Spec: https://github.com/ethereum/devp2p/blob/master/rlpx.md#encrypted-handshake
Thread Safety Distinct Objects: Safe. Shared objects: Unsafe.
Definition at line 51 of file RLPxHandshake.h.
|
protected |
Sequential states of handshake.
Enumerator | |
---|---|
Error | |
New | |
AckAuth | |
AckAuthEIP8 | |
WriteHello | |
ReadHello | |
StartSession |
Definition at line 72 of file RLPxHandshake.h.
|
inline |
Setup incoming connection.
Definition at line 57 of file RLPxHandshake.h.
|
inline |
Setup outbound connection.
Definition at line 60 of file RLPxHandshake.h.
|
inline |
Definition at line 62 of file RLPxHandshake.h.
void RLPXHandshake::cancel | ( | ) |
Aborts the handshake.
Definition at line 218 of file RLPxHandshake.cpp.
|
protected |
Closes connection and ends transitions.
Definition at line 226 of file RLPxHandshake.cpp.
|
protected |
Reads Auth message from socket and transitions to WriteHello.
Definition at line 167 of file RLPxHandshake.cpp.
|
protected |
Continues reading Ack message in EIP-8 format and transitions to WriteHello.
Definition at line 188 of file RLPxHandshake.cpp.
|
protected |
Reads Auth message from socket and transitions to AckAuth.
Definition at line 110 of file RLPxHandshake.cpp.
|
protected |
Continues reading Auth message in EIP-8 format and transitions to AckAuthEIP8.
Definition at line 133 of file RLPxHandshake.cpp.
|
protected |
Derives ephemeral secret from signature and sets members after Auth has been decrypted.
Definition at line 100 of file RLPxHandshake.cpp.
|
inline |
Start handshake.
Definition at line 65 of file RLPxHandshake.h.
|
protectedvirtual |
Performs transition for m_nextState.
This pointer will be freed if there is an error otherwise it will be passed to Host which will take ownership.
authenticate and decrypt header
check frame size
rlp of header has protocol-type, sequence-id[, total-packet-size]
read padded frame and mac
Reimplemented in TestHandshake.
Definition at line 237 of file RLPxHandshake.cpp.
|
protected |
Write Ack message to socket and transitions to WriteHello.
Definition at line 57 of file RLPxHandshake.cpp.
|
protected |
Write Ack message in EIP-8 format to socket and transitions to WriteHello.
Definition at line 75 of file RLPxHandshake.cpp.
|
protected |
Write Auth message to socket and transitions to AckAuth.
Definition at line 31 of file RLPxHandshake.cpp.
|
friend |
Definition at line 53 of file RLPxHandshake.h.
|
protected |
Timeout for remote to respond to transition events. Enforced by m_idleTimer and refreshed by transition().
Definition at line 114 of file RLPxHandshake.h.
|
protected |
Plaintext of egress or ingress Ack message.
Definition at line 128 of file RLPxHandshake.h.
|
protected |
Ciphertext of egress or ingress Ack message.
Definition at line 129 of file RLPxHandshake.h.
|
protected |
Buffers for encoded and decoded handshake phases.
Plaintext of egress or ingress Auth message.
Definition at line 126 of file RLPxHandshake.h.
|
protected |
Ciphertext of egress or ingress Auth message.
Definition at line 127 of file RLPxHandshake.h.
|
protected |
Will be set to true if connection was canceled.
Definition at line 117 of file RLPxHandshake.h.
|
protected |
Ephemeral ECDH secret and agreement.
Definition at line 133 of file RLPxHandshake.h.
|
protected |
Frame buffer for ingress Hello packet.
Definition at line 131 of file RLPxHandshake.h.
|
protected |
Frame buffer for egress Hello packet.
Definition at line 130 of file RLPxHandshake.h.
|
protected |
Host which provides m_alias, protocolVersion(), m_clientVersion, caps(), and TCP listenPort().
Definition at line 119 of file RLPxHandshake.h.
|
protected |
Timer which enforces c_timeout.
Definition at line 145 of file RLPxHandshake.h.
|
protected |
Used to read and write RLPx encrypted frames for last step of handshake authentication.
Passed onto Host which will take ownership.
Definition at line 142 of file RLPxHandshake.h.
Current or expected state of transition.
Definition at line 116 of file RLPxHandshake.h.
|
protected |
Nonce generated by this host for handshake.
Definition at line 134 of file RLPxHandshake.h.
|
protected |
True if connection is outbound.
Definition at line 123 of file RLPxHandshake.h.
|
protected |
Node id of remote host for socket.
Public address of remote host.
Definition at line 122 of file RLPxHandshake.h.
|
protected |
Remote ephemeral public key.
Definition at line 136 of file RLPxHandshake.h.
|
protected |
Nonce generated by remote host for handshake.
Definition at line 137 of file RLPxHandshake.h.
|
protected |
Definition at line 138 of file RLPxHandshake.h.
|
protected |
Socket.
Definition at line 144 of file RLPxHandshake.h.