In file /home/eternity/Source/Mix/MessageCreator/H/messageCreator.h:

class MessageCreator : public Debugable

Message Creator

Inheritance:

MessageCreator < Debugable


Public Methods

Err MessageCreator::AddLocalCertifs ( GMessage *callBackOnionInfo)
Adds local certificates to the certificates that are used for onion creation
void MessageCreator::AnnotateWith4ByteLength (GMessage *onion, char **onionBottomStream, Size *onionBottomStreamLen)
Add Size integer as a header denoting the lenght of data
GMessage* MessageCreator::CreateChunk (GMessage * chunkProperties)
Creates a chunk
GMessage* MessageCreator::CreateOnion (GMessage *onionProperties)
Creates the onion with owner identification in the bottom
GMessage* MessageCreator::CreateOnionBottom ( char *xOrigin, GMessage *symKeys, GMessage **pubKeyInfo)
Creates an onion bottom with Six's identification (or Mix's sometimes)
GMessage* MessageCreator::CreateOnionFromMixCertificate ( GMessage *onionProperties)
Creates the onion with Mix's identification in the bottom
Err MessageCreator::MakeMoreOnionLayers (GMessage *properties, GMessage *callBackOnionInfo, GMessage *onion)
Add some peels on the top of given onion
GMessage* MessageCreator::MakeRecipientGMessage (GMessage *mixCertif, GMessage *symKey)
Makes GMessage with recipient's identification
MessageCreator::MessageCreator (ConfigFile *mcConfigFile, LogFile * messageCreatorLogFile, CertificateRepository * certificateRepository, Cipherer * cipherer, KeyManager * keyManager)
Message Creator constructor
char* MessageCreator::PaddOnionRestOfPath (char *restOfPath, Size restOfPathLen, Size fixedSize)
Padd the rest of path field to the original length
Err MessageCreator::ReturnCallBackOnionInfo (GMessage *onionProperties, GMessage **callBackOnionInfo)
Returns GMessage full of useful stuff for creating onions or adding new peels onto the top of them
Err MessageCreator::ReturnGMsgFullOfMixCertifs (int tupleWidth, Size hopCount, GMessage **certificates)
Returns Mixs' certificates
MessageCreator::~MessageCreator ()
Message Creator destructor

Public

methods
MessageCreator (ConfigFile * mcConfigFile, LogFile * messageCreatorLogFile, CertificateRepository * certificateRepositorya, Cipherer * cipherer, KeyManager * keyManager)
Constructor.
GMessage* CreateChunk (GMessage *message)
Creates a chunk in a format that is suitable for Sender.
GMessage* CreateOnion (GMessage *request)
Creates an onion. The recipient is in the bottom.
GMessage* CreateOnionFromMixCertificate (GMessage *request)
For the need of Mix only. When asking for certificates for Acs.
~MessageCreator ()
Desctructor.

Protected

attributes
KeyManager* keyManager
We ask him for Mix's asymetric keys.
Cipherer* cipherer
Needed when creating chunks and onions.
CertificateRepository* certificateRepository
Repository containing certificates.
ConfigFile* configFile
Configuration file.

Private

methods2
Err ReturnGMsgFullOfMixCertifs ( int tupleWidth, Size hopCount, GMessage **cerfifsGMsg)
Returns Mix's certificates that we use for onion or chunk creation.
GMessage* CreateOnionBottom ( char *xOrigin, GMessage *symKeys, GMessage **pubKeyInfo)
Creates the onion bottom with symetric keys and recipient identification
GMessage* MakeRecipientGMessage ( GMessage *mixCertif, GMessage *SymKey)
Creates recipient's GMessage that is in each onion peel.
void AnnotateWith4ByteLength ( GMessage *onion, char **onionBottomStream, Size *onionBottomStreamLen)
Add Size type integer before the data (it's denotes the data length).
Err MakeMoreOnionLayers ( GMessage *properties, GMessage *callBackOnionInfo, GMessage *onion)
Add additional peels on the top of an onion.
Err ReturnCallBackOnionInfo ( GMessage *onionProperties, GMessage **callBackOnionInfo)
Returns certificates and symetric keys for onion and chunk creation.
char* PaddOnionRestOfPath (char *restOfPath, Size restOfPathLen, Size requestedLen)
Padd ,,rest of path'' field to the original length.

Inherited from Debugable:

Public Methods

string* Debugable::CreateString(char *firstStr, int firstInt, int secondInt)
Debugable::Debugable(LogFile * debugLogFile)
int Debugable::SetDebugOptions(int newLogOptions)
void Debugable::SetLogFile(LogFile *aLogFile)
void Debugable::WriteString(LogLevel debugLevel, char * format, ...)
Debugable::~Debugable()

Public

attributes

int debugOptions
What messages should be logged
LogFile* logFile
Log file for debug messages

Documentation

Message Creator. Specializes in creation of messages, chunks onions and similar things. Understands structure of onions and messages.
attributes

KeyManager* keyManager
We ask him for Mix's asymetric keys.

Cipherer* cipherer
Needed when creating chunks and onions.

CertificateRepository* certificateRepository
Repository containing certificates.

ConfigFile* configFile
Configuration file.

methods

MessageCreator(ConfigFile * mcConfigFile, LogFile * messageCreatorLogFile, CertificateRepository * certificateRepositorya, Cipherer * cipherer, KeyManager * keyManager)
Constructor.

GMessage* CreateChunk(GMessage *message)
Creates a chunk in a format that is suitable for Sender.

GMessage* CreateOnion(GMessage *request)
Creates an onion. The recipient is in the bottom.

GMessage* CreateOnionFromMixCertificate(GMessage *request)
For the need of Mix only. When asking for certificates for Acs.

~MessageCreator()
Desctructor.

methods2

Err ReturnGMsgFullOfMixCertifs( int tupleWidth, Size hopCount, GMessage **cerfifsGMsg)
Returns Mix's certificates that we use for onion or chunk creation.

GMessage* CreateOnionBottom( char *xOrigin, GMessage *symKeys, GMessage **pubKeyInfo)
Creates the onion bottom with symetric keys and recipient identification

GMessage* MakeRecipientGMessage( GMessage *mixCertif, GMessage *SymKey)
Creates recipient's GMessage that is in each onion peel.

void AnnotateWith4ByteLength( GMessage *onion, char **onionBottomStream, Size *onionBottomStreamLen)
Add Size type integer before the data (it's denotes the data length).

Err MakeMoreOnionLayers( GMessage *properties, GMessage *callBackOnionInfo, GMessage *onion)
Add additional peels on the top of an onion.

Err ReturnCallBackOnionInfo( GMessage *onionProperties, GMessage **callBackOnionInfo)
Returns certificates and symetric keys for onion and chunk creation.

char* PaddOnionRestOfPath(char *restOfPath, Size restOfPathLen, Size requestedLen)
Padd ,,rest of path'' field to the original length.

Err MessageCreator::AddLocalCertifs( GMessage *callBackOnionInfo)
Adds local certificates to the certificates that are used for onion creation. When we create the onion, the onion's bottom identifies the recipient. For not to create the onion in the two steps, we add local mix certificates to the certificates that are used for onion creation. The new local certificates are the first certificates that are used when the onion is created (identifiing the Mix as a final Mix).
Returns:
KO when Mix certificate can't be returned, OK otherwise.
Parameters:
callBackOnionInfo - Contains the certificates.
Author:
Pechy
See Also:
MakeMoreOnionLayers()

void MessageCreator::AnnotateWith4ByteLength(GMessage *onion, char **onionBottomStream, Size *onionBottomStreamLen)
Add Size integer as a header denoting the lenght of data. When we layer particular peels, we need convert the upper new onion peel (the peel without GM_REST_OF_PATH) into a stream. To be able to recognize how long is the onion, we have to include 4 bytes header as a length of the onion.
Returns:
void
Parameters:
onion - This onion is converted to an octet stream and annotated with the header.
onionBottomStream - The stream that is returned.
onionBottomStreamLen - Size of returned stream.
Author:
Pechy
See Also:
MakeMoreOnionLayers()

GMessage* MessageCreator::CreateChunk(GMessage * chunkProperties)
Creates a chunk. Chunk is a part of message, is of fixed size. When anybody wants to send a message, the message can be of any size. To make traffic analysis harder, we send the message in fix sized chunks. The method creates one chunk.
Returns:
Cooked chunk:
GM_RECIPIENT_1		- see CreateOnion() above for discussion on
on recipients in a peel
GM_RECIPIENT_2
GM_CHUNK
GM_DEBUG			- some string, for debugging purpose
GM_PROTOCOL_VERSION	- Mix-Mix protocol identification
GM_DATA			- encrypted data 
GM_REST_OF_PATH		- rest of path
Parameters:
chunkProperties - Information needed to create the chunk:
GM_ONION		- chunk's recipient idenfification
GM_ADD_HOPS	- how many peels to add on the top of the onion
GM_DATA		- the data thas are to be transmitted inside 
the chunk, we are not interested in its structure
here.

Author:
Pechy
See Also:
CreateOnion(), MessageIDRepository, Receiver, Sender.

GMessage* MessageCreator::CreateOnion(GMessage *onionProperties)
Creates the onion with owner identification in the bottom. Onion is a parallel for ,,an address''. It is the identification of some service that is running somewhere. The onion carries the information about the chain of Mixes through the chunk has to go to the recipient. In each peel, there can be several recipients (in the last one, only the final recipient has to be included). This redundancy is useful for reliability (when one Mix in a peel failes, we have still some Mixes which we can try to connect to) as well as for security enhancement. This security enhancement is in the fact that the message consisted of many chunks is not feeded through the one exact channel only, but is spreaded a bit. It is more difficult to tail this stream of chunks for enemy.
Returns:
Onion.
Parameters:
onionProperties - What is needed for onion creation:
GM_HOP_COUNT		- how many peels we are to create
GM_ORIGIN		- whose idenfification will be in the very bottom (eg.
eso_johny, joes_acs etc., the important fact is
that this string identifies the Six above the final
Mix, so is is not the Internet address)

Author:
Pechy
See Also:
CreateChunk(), CreateOnionFromMixCertificate(), certificates, sixs' identification, image of onion and message on our www site

GMessage* MessageCreator::CreateOnionBottom( char *xOrigin, GMessage *symKeys, GMessage **pubKeyInfo)
Creates an onion bottom with Six's identification (or Mix's sometimes). In the bottom there is an identification of the recipient running above the final Mix (sometimes the recipient can be Mix itself). The bottom also includes all symetric keys that were used to encrypt the data part of chunk as the chunk went along the Mixes from this onion. The sym keys are included because we needn't assign a unique ID to the onion and store symetric keys with this ID. Freshly generated public key is also included to the bottom, to make future middle attack harder.
Returns:
Bottom GMessage:
GM_FINAL_STOP			- a nonempty field, identifies 
that the peel is tha last one
GM_RECIPIENT_1
GM_ADDRESS			- a name of the recipient
GM_PRIVATE_KEY_INFO		- private key for data decryption
GM_SYMETRIC_DATA_KEY_INFOS		- symetric keys for data decryption
Parameters:
xOrigin - The name of the recipient.
symKeys - Symetric keys we have to insert into the bottom.
pubKeyInfo - Symetric keys we have to insert into the bottom.
Author:
Pechy
See Also:
CreateOnion(), CreateChunk(), middle attack discussion.

GMessage* MessageCreator::CreateOnionFromMixCertificate( GMessage *onionProperties)
Creates the onion with Mix's identification in the bottom. Sometimes Mix is the one that asks for something another server (eg. Acs, on the behalf of a Six or Mix himself), so we need an onion, whose recipient in the bottom is directly Mix.
Returns:
Onion.
Parameters:
onionProperties - What is needed for the onion creation.
GM_DESTINATION		- which Mix object will get the answer
GM_MIX_CERTIFICATE		- local identification of Mix
M_HOP_COUNT		- how many peels to create

Author:
Pechy
See Also:
CreateOnion(), MessageIDRepository

Err MessageCreator::MakeMoreOnionLayers(GMessage *properties, GMessage *callBackOnionInfo, GMessage *onion)
Add some peels on the top of given onion. It gets an onion (recipient's identification) and should add some peels. The onion an be a real onion (real Six's identifification) or an onion bottom created with CreateOnionBottom() method (in this case onion bottom simulates actuall onion.

We add layers in a loop, in each loop we do:

Note: if onion is just an onionBottom, we add in the first step a symetric key that is never used.. This is just that we didn't want to add any additional if, the best programmers are lazy programmers :-).

Returns:
Onion.
GM_RECIPIENT_1			- see MakeRecipientGMessage()
GM_RECIPIENT_2
GM_REST_OF_PATH			- is an encrypted GMessage
<>
<>
<>
<>
<>
<>
<>
<>
...
...
Parameters:
callBackOnionInfo -
GM_SYMETRIC_DATA_KEY_INFOS		- used for encryption in particular
peels
GM_MIX_CERTIFICATES		- used for creation recipients' 
GMessages in particular peels

properties - Contains:
GM_ADD_HOPS			- when we create a chunk

or

GM_HOP_COUNT			- when we create a onion

onion - Onion on which we have to add additional peels.
Author:
Pechy
See Also:
CreateOnion(), CreateChunk, Cipherer.

GMessage* MessageCreator::MakeRecipientGMessage(GMessage *mixCertif, GMessage *symKey)
Makes GMessage with recipient's identification. When creating onions and chunks, is each peel there are two recipients' GMessages. Each can be used to send the chunk to.
Returns:
Recipient's GMessage:
GM_PUBLIC_KEY_INFO
GM_SYMETRIC_PATH_KEY_INFO
GM_ADDRESS
GM_PORT
Parameters:
mixCertif - Contains the recipient's data (address and port).
symKey - This symKey is used somewhere else for path encryption. For recipient to be able to use it, we encrypt the symetric key with recipient's public key.
Author:
Pechy
See Also:
MakeMoreOnionLayers()

MessageCreator::MessageCreator(ConfigFile *mcConfigFile, LogFile * messageCreatorLogFile, CertificateRepository * certificateRepository, Cipherer * cipherer, KeyManager * keyManager)
Message Creator constructor. Saves object pointers he gets in parameters for future use.
Parameters:
mcConfigFile - Configuration file.
messageCreatorLogFile - Log file.
certificateRepository - Certificate repository object.
Author:
Pechy
See Also:
Translator, Cipherer, ~MessageCreator()

char* MessageCreator::PaddOnionRestOfPath(char *restOfPath, Size restOfPathLen, Size fixedSize)
Padd the rest of path field to the original length. When the chunk goes through the chain of Mixes, the recipient's identification (rest of path) is going down in size. This fact would enable the onion length attack (the enemy could estimate how many hops is the chunk to go to the final Mix), so this method padds the rest of path field with randomly generated bytes.
Returns:
fixedSize Size to which we padd the restOfPath parameter.
Parameters:
restOfPath - Rest of path, downsized by the current peel.
restOfPathLen - Rest of path length.
Author:
Pechy
See Also:
MakeMoreOnionLayers(), Translator methods

Err MessageCreator::ReturnCallBackOnionInfo(GMessage *onionProperties, GMessage **callBackOnionInfo)
Returns GMessage full of useful stuff for creating onions or adding new peels onto the top of them. When we create new onions or add some peels onto the of them, we have to symetric keys for encryption and Mixs' certificates to make peels. Generating of new symetric keys and returning of mixs' certificates should be mutually related. Recipients in one tuple (peel) has to support the same symetric cipher and on the contrary, the particular symetric key cipher has to be supported by all recipients in the tuple. We do *NOT* honor this rule for now - but this method (and several others) could be easily modified to support this (onionProperties would carry more information needed).
Returns:
GMessage with the stuff:
GM_SYMETRIC_DATA_KEY_INFOS
GM_MIX_CERTIFICATES
Parameters:
onionProperties - How many peels will be created:
GM_HOP_COUNT

callBackOnionInfo - Returned parameter.
Author:
Pechy
See Also:
MakeMoreOnionLayers(), CreateChunk(), CreateOnion()

Err MessageCreator::ReturnGMsgFullOfMixCertifs(int tupleWidth, Size hopCount, GMessage **certificates)
Returns Mixs' certificates. When we create chunks or onions, we add some peels onto the top of the particular onion. Each peel means to have 2 recipients, ie. 2 Mixs' certificates.
Returns:
KO if requested count can't be satisfied, OK otherwise.
GM_MIX_CERTIFICATE_COUNT
GM_MIX_CERTIFICATE_TUPLE_1
GM_MIX_CERTIFICATE_1
GM_MIX_CERTIFICATE_2
...
...
GM_MIX_CERTIFICATE_TUPLE-"Hop-Count"
Parameters:
tupleWidth - How many recipients are in one peel.
hopCount - How many certificates' tuples to return.
certificates - Returned certificates.
Author:
Pechy
See Also:
CreateOnion(), CreateChunk()

MessageCreator::~MessageCreator()
Message Creator destructor. Now does nothing since Message Creator is stateless.
Author:
Pechy
See Also:
MessageCreator()


This class has no child classes.
Author:
Pechy
See Also:
PaddingGenerator, Mix

alphabetic index hierarchy of classes


generated by doc++