Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
dev::p2p::RLPXFrameCoder Class Reference

Encoder/decoder transport for RLPx connection established by RLPXHandshake. More...

#include <RLPXFrameCoder.h>

Public Member Functions

 RLPXFrameCoder (RLPXHandshake const &_init)
 Construct; requires instance of RLPXHandshake which has encrypted ECDH key exchange (first two phases of handshake). More...
 
 RLPXFrameCoder (bool _originated, h512 const &_remoteEphemeral, h256 const &_remoteNonce, crypto::ECDHE const &_ephemeral, h256 const &_nonce, bytesConstRef _ackCipher, bytesConstRef _authCipher)
 Construct with external key material. More...
 
 ~RLPXFrameCoder ()
 
void setup (bool _originated, h512 const &_remoteEphemeral, h256 const &_remoteNonce, crypto::ECDHE const &_ephemeral, h256 const &_nonce, bytesConstRef _ackCipher, bytesConstRef _authCipher)
 Establish shared secrets and setup AES and MAC states. More...
 
void writeFrame (uint16_t _protocolType, bytesConstRef _payload, bytes &o_bytes)
 Write single-frame payload of packet(s). More...
 
void writeFrame (uint16_t _protocolType, uint16_t _seqId, bytesConstRef _payload, bytes &o_bytes)
 Write continuation frame of segmented payload. More...
 
void writeFrame (uint16_t _protocolType, uint16_t _seqId, uint32_t _totalSize, bytesConstRef _payload, bytes &o_bytes)
 Write first frame of segmented or sequence-tagged payload. More...
 
void writeSingleFramePacket (bytesConstRef _packet, bytes &o_bytes)
 Legacy. Encrypt _packet as ill-defined legacy RLPx frame. More...
 
bool authAndDecryptHeader (bytesRef io_cipherWithMac)
 Authenticate and decrypt header in-place. More...
 
bool authAndDecryptFrame (bytesRef io_cipherWithMac)
 Authenticate and decrypt frame in-place. More...
 
h128 egressDigest ()
 Return first 16 bytes of current digest from egress mac. More...
 
h128 ingressDigest ()
 Return first 16 bytes of current digest from ingress mac. More...
 

Protected Member Functions

void writeFrame (RLPStream const &_header, bytesConstRef _payload, bytes &o_bytes)
 
void updateEgressMACWithHeader (bytesConstRef _headerCipher)
 Update state of egress MAC with frame header. More...
 
void updateEgressMACWithFrame (bytesConstRef _cipher)
 Update state of egress MAC with frame. More...
 
void updateIngressMACWithHeader (bytesConstRef _headerCipher)
 Update state of ingress MAC with frame header. More...
 
void updateIngressMACWithFrame (bytesConstRef _cipher)
 Update state of ingress MAC with frame. More...
 

Private Attributes

std::unique_ptr< class RLPXFrameCoderImplm_impl
 

Friends

class RLPXFrameIOMux
 
class Session
 

Detailed Description

Encoder/decoder transport for RLPx connection established by RLPXHandshake.

Todo:

rename to RLPXTranscoder

Remove 'Frame' nomenclature and expect caller to provide RLPXFrame

Remove handshake as friend, remove handshake-based constructor

Thread Safety Distinct Objects: Unsafe. Shared objects: Unsafe.

Definition at line 73 of file RLPXFrameCoder.h.

Constructor & Destructor Documentation

RLPXFrameCoder::RLPXFrameCoder ( RLPXHandshake const &  _init)

Construct; requires instance of RLPXHandshake which has encrypted ECDH key exchange (first two phases of handshake).

Definition at line 80 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

RLPXFrameCoder::RLPXFrameCoder ( bool  _originated,
h512 const &  _remoteEphemeral,
h256 const &  _remoteNonce,
crypto::ECDHE const &  _ephemeral,
h256 const &  _nonce,
bytesConstRef  _ackCipher,
bytesConstRef  _authCipher 
)

Construct with external key material.

Definition at line 86 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

RLPXFrameCoder::~RLPXFrameCoder ( )

Definition at line 77 of file RLPXFrameCoder.cpp.

Member Function Documentation

bool RLPXFrameCoder::authAndDecryptFrame ( bytesRef  io_cipherWithMac)

Authenticate and decrypt frame in-place.

Definition at line 220 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool RLPXFrameCoder::authAndDecryptHeader ( bytesRef  io_cipherWithMac)

Authenticate and decrypt header in-place.

Definition at line 208 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

h128 RLPXFrameCoder::egressDigest ( )

Return first 16 bytes of current digest from egress mac.

Definition at line 231 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

h128 RLPXFrameCoder::ingressDigest ( )

Return first 16 bytes of current digest from ingress mac.

Definition at line 239 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::setup ( bool  _originated,
h512 const &  _remoteEphemeral,
h256 const &  _remoteNonce,
crypto::ECDHE const &  _ephemeral,
h256 const &  _nonce,
bytesConstRef  _ackCipher,
bytesConstRef  _authCipher 
)

Establish shared secrets and setup AES and MAC states.

Definition at line 92 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::updateEgressMACWithFrame ( bytesConstRef  _cipher)
protected

Update state of egress MAC with frame.

Definition at line 252 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::updateEgressMACWithHeader ( bytesConstRef  _headerCipher)
protected

Update state of egress MAC with frame header.

Definition at line 247 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::updateIngressMACWithFrame ( bytesConstRef  _cipher)
protected

Update state of ingress MAC with frame.

Definition at line 263 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::updateIngressMACWithHeader ( bytesConstRef  _headerCipher)
protected

Update state of ingress MAC with frame header.

Definition at line 258 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::writeFrame ( uint16_t  _protocolType,
bytesConstRef  _payload,
bytes o_bytes 
)

Write single-frame payload of packet(s).

Definition at line 149 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RLPXFrameCoder::writeFrame ( uint16_t  _protocolType,
uint16_t  _seqId,
bytesConstRef  _payload,
bytes o_bytes 
)

Write continuation frame of segmented payload.

Definition at line 158 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

void RLPXFrameCoder::writeFrame ( uint16_t  _protocolType,
uint16_t  _seqId,
uint32_t  _totalSize,
bytesConstRef  _payload,
bytes o_bytes 
)

Write first frame of segmented or sequence-tagged payload.

Definition at line 167 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

void RLPXFrameCoder::writeFrame ( RLPStream const &  _header,
bytesConstRef  _payload,
bytes o_bytes 
)
protected

Definition at line 176 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

void RLPXFrameCoder::writeSingleFramePacket ( bytesConstRef  _packet,
bytes o_bytes 
)

Legacy. Encrypt _packet as ill-defined legacy RLPx frame.

Definition at line 199 of file RLPXFrameCoder.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class RLPXFrameIOMux
friend

Definition at line 75 of file RLPXFrameCoder.h.

friend class Session
friend

Definition at line 76 of file RLPXFrameCoder.h.

Member Data Documentation

std::unique_ptr<class RLPXFrameCoderImpl> dev::p2p::RLPXFrameCoder::m_impl
private

Definition at line 129 of file RLPXFrameCoder.h.


The documentation for this class was generated from the following files: