client
Class MessageGenerator

java.lang.Object
  extended by client.MessageGenerator

final class MessageGenerator
extends java.lang.Object

Provides methods for generating messages (the mixes are capable of processing) from byte arrays.

Author:
Karl-Peter Fuchs

Constructor Summary
protected MessageGenerator(int numberOfMixesInCascade, Cryptography cryptography)
          Generates a new MessageGenerator for generating messages (the mixes are capable of processing) from byte arrays.
 
Method Summary
protected  byte[] generateChannelEstablishMessage(byte[] bytePayload)
          Generates a message which consists of one or more (encrypted) layers, the cascade's mixes are capable of processing from the bypassed data (Type: ChannelEstablishMessage).
protected  byte[] generateChannelMessage(byte[] bytePayload)
          Generates a message which consists of one or more (encrypted) layers, the cascade's mixes are capable of processing from the bypassed data (Type: ChannelMessage).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageGenerator

protected MessageGenerator(int numberOfMixesInCascade,
                           Cryptography cryptography)
Generates a new MessageGenerator for generating messages (the mixes are capable of processing) from byte arrays.

Parameters:
numberOfMixesInCascade - Number of mixes in the cascade this Client shall use.
cryptography - Reference on Cryptography object that shall be used to encrypt messages.
Method Detail

generateChannelEstablishMessage

protected byte[] generateChannelEstablishMessage(byte[] bytePayload)
                                          throws MessageTooLongException
Generates a message which consists of one or more (encrypted) layers, the cascade's mixes are capable of processing from the bypassed data (Type: ChannelEstablishMessage). A layer is added for each mix in the cascade.

Parameters:
bytePayload - Data to generate the mix message from.
Returns:
The generated ChannelEstablishMessage as a byte array.
Throws:
MessageTooLongException - Thrown when the bypassed message is larger than the maximum message size.

generateChannelMessage

protected byte[] generateChannelMessage(byte[] bytePayload)
                                 throws MessageTooLongException
Generates a message which consists of one or more (encrypted) layers, the cascade's mixes are capable of processing from the bypassed data (Type: ChannelMessage). A layer is added for each mix in the cascade.

Parameters:
bytePayload - Data to generate the mix message from.
Returns:
The generated ChannelMessage as a byte array.
Throws:
MessageTooLongException - Thrown when the bypassed message is larger than the maximum message size.