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

converts messages and timing intervals back and forth (used by TimingCovertChannel) More...

Public Member Functions

 MorseCoder (unsigned int delay_short, unsigned int delay_long, unsigned int delay_letter, unsigned int delay_space)
 Constructor. More...
 
vector< unsigned int > encodeMessage (string message)
 
string decodeMessage (vector< unsigned int > delays)
 
vector< char > checkString (string message)
 

Private Member Functions

vector< bool > encodeLetter (char letter)
 
char decodeLetter (vector< bool > morse_code)
 

Private Attributes

unsigned int m_delay_short
 Represents a short signal (in milliseconds)
 
unsigned int m_delay_long
 Represents a long signal (in milliseconds)
 
unsigned int m_delay_letter
 Represents a short pause (in milliseconds)
 
unsigned int m_delay_space
 Represents a long pause (in milliseconds)
 
morse_map m_morse_map
 Contains the mapping between characters and morse.
 

Detailed Description

converts messages and timing intervals back and forth (used by TimingCovertChannel)

MorseCoder converts a message into time intervals using morse and decodes morse back to a message. To do so, call 'encodeMessage' with the message or 'decodeMessage' with time intervals. Use 'checkString' to check if the given message contains characters, that are not supported by morse.

Constructor & Destructor Documentation

whisper_library::MorseCoder::MorseCoder ( unsigned int  delay_short,
unsigned int  delay_long,
unsigned int  delay_letter,
unsigned int  delay_space 
)

Constructor.

Parameters
delay_shortis used to encode a short signal (in milliseconds)
delay_longis used to encode a long signal (in milliseconds)
delay_letteris used to encode the end of a letter (in milliseconds)
delay_spaceis used to encode space between words (in milliseconds)

Member Function Documentation

vector< char > whisper_library::MorseCoder::checkString ( string  message)

Checks the given string for characters, that are not supported by morse. If none were found, the returned vector is empty. Otherwise it contains unsupported characters.

Parameters
messagethe string that is checked
Returns
all unsupported characters in the message
char whisper_library::MorseCoder::decodeLetter ( vector< bool >  morse_code)
private

Decodes morse for a single character The passed vector of bool has to contain the encoded letter in which 0 (false) means short and 1 (true) means long.

Parameters
morse_codethe morse of a single letter
Returns
the letter as char
string whisper_library::MorseCoder::decodeMessage ( vector< unsigned int >  delays)

decodeMessage takes a sequence of delays representing morse and converts them back to a message. The delays have to be exactly the ones set in the constructor.

Parameters
delaysa vector containing delays
vector< bool > whisper_library::MorseCoder::encodeLetter ( char  letter)
private

Encodes a single character to morse.

Parameters
letterthe character to decode
Returns
the morse of the letter, 0 (false) means short and 1 (true) means long
vector< unsigned int > whisper_library::MorseCoder::encodeMessage ( string  message)

encodeMessage converts a message into a sequence of delays using morse. Unsupported characters are encoded as '#'.

Parameters
messagethe message as string