Whisper Library
 All Classes Functions Variables Typedefs Enumerations Friends
whisper_library::LengthCoder Class Reference

Converts between messages and packet lengths (used by PacketLengthCovertChannel) More...

Public Member Functions

 LengthCoder (int baselength)
 Constructor of LengthCoder. More...
 
std::vector< unsigned int > encodeMessage (std::string message)
 encodes a message to packet lengths More...
 
std::string decodeMessage (std::vector< unsigned int > lengths)
 decodes packet lengths More...
 

Private Attributes

int m_baselength
 gets added/substracted from the packet lengths
 

Detailed Description

Converts between messages and packet lengths (used by PacketLengthCovertChannel)

A LengthCoder can be used to encode messages into udp packet lengths and decode udp packet lengths into a message. A base length/offset for the packet lengths can be set to avoid packets with no data payload (length = 8).

The LengthCoder uses the BitSetCoder to split the message into parts

See Also
BitSetCoder

Constructor & Destructor Documentation

whisper_library::LengthCoder::LengthCoder ( int  baselength)
inline

Constructor of LengthCoder.

Creates an LengthCoder and sets the base length, which is added to every packet length

Parameters
baselengthlength offset for every packet

Member Function Documentation

std::string whisper_library::LengthCoder::decodeMessage ( std::vector< unsigned int >  lengths)

decodes packet lengths

The lengths from the given vector get decoded into a string. The lengths should be between baseLength and baseLength + 15

Parameters
lengthsa vector containing received udp packet lengths
Returns
a string with the decoded message
std::vector< unsigned int > whisper_library::LengthCoder::encodeMessage ( std::string  message)

encodes a message to packet lengths

The given message gets translated to packet lengths variing from baseLength to baseLength + 15.

Parameters
messagethe message that gets encoded
Returns
an vector containing udp packet Length in the range of baseLength to baseLength + 15.