message
Class ChannelEstablishMessage

java.lang.Object
  extended by message.Message
      extended by message.ChannelEstablishMessage
All Implemented Interfaces:
java.lang.Comparable<Message>, BasicMessage, ExternalMessage, Request

public final class ChannelEstablishMessage
extends Message
implements Request, ExternalMessage

ExternalMessage used to establish a channel, which can transmit ChannelMessages and Replyies. The parts this message consists of are defined in the enumeration ChannelEstablishMessagePart. A pair of set and get methods is present for each defined part.

Author:
Karl-Peter Fuchs

Field Summary
static byte IDENTIFIER
          Identifier for this type of message.
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPort.
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
private  int NUMBER_OF_FURTHER_HOPS
          Number of further hops (= mixes), this message must pass to reach its destination.
 
Constructor Summary
ChannelEstablishMessage(byte[] byteMesssage, int numberOfFurtherHops)
          Message constructor used by client.
ChannelEstablishMessage(byte[] byteMesssage, User channel, int numberOfFurtherHops)
          Message constructor used by a mix.
 
Method Summary
 byte[] getAsymmetricPart()
          Returns the MessagePart ASYMMETRIC_PART = The asymmetrically encrypted part of the message.
 byte getLeadingZero()
          Returns the MessagePart LEADING_ZERO.
 byte[] getMAC()
          Returns the MessagePart MAC = The Message Authentication Code (MAC) of this message.
 javax.crypto.SecretKey getMACKey()
          Returns the MessagePart MAC_KEY = Key used to generate Message Authentication Code (MAC).
 int getMessageID()
          Returns the MessagePart MESSAGE_ID = An identifieing number, which is the same for every envelope of a mix message.
private  byte[] getPart(ChannelEstablishMessagePart messagePart)
          Returns a byte representation of a MessagePart.
 Payload getPayload()
          Returns the MessagePart PAYLOAD.
 javax.crypto.spec.IvParameterSpec getSessionIV()
          Returns the MessagePart SYMMETRIC_IV = Initialization vector used to decrypt the symmetrically encryptet message part.
 javax.crypto.spec.SecretKeySpec getSessionKey()
          Returns the MessagePart SYMMETRIC_KEY = Key used to decrypt the symmetrically encrypted message part.
 byte[] getSignedData()
          Returns the MessagePart SIGNED_DATA.
 byte[] getSymmetricPart()
          Returns the MessagePart SYMMETRIC_PART = The symmetrically encrypted part of the message.
 long getTimestamp()
          Returns the MessagePart TIMESTAMP = Point of time, the message was created.
 void setAsymmetricPart(byte[] newAsymmetricPart)
          Sets the MessagePart ASYMMETRIC_PART to the bypassed value.
 void setLeadingZero()
          Sets the MessagePart LEADING_ZERO to 01000000.
 void setMAC(byte[] mac)
          Sets the MessagePart MAC to the bypassed value.
 void setMACKey(javax.crypto.SecretKey key)
          Sets the MessagePart MAC_KEY to the bypassed value.
 void setMessageID(int newID)
          Sets the MessagePart MESSAGE_ID to the bypassed value.
private  void setPart(ChannelEstablishMessagePart messagePart, byte[] data)
          Saves a byte representation of a MessagePart.
 void setPayload(Payload newPayload)
          Sets the MessagePart PAYLOAD to the bypassed value.
 void setSessionIV(byte[] sessionIV)
          Sets the MessagePart SYMMETRIC_IV to the bypassed value.
 void setSessionKey(javax.crypto.SecretKey key)
          Sets the MessagePart SYMMETRIC_KEY to the bypassed value.
 void setSignedData(byte[] newSignedData)
          Sets the MessagePart SIGNED_DATA to the bypassed value.
 void setSymmetricPart(byte[] newSymmetricPart)
          Sets the MessagePart SYMMETRIC_PART to the bypassed value.
 void setTimestamp(long newTimestamp)
          Sets the MessagePart TIMESTAMP to the bypassed value.
 java.lang.String toString()
          Returns a simple String representation of this class featuring several message parts.
 
Methods inherited from class message.Message
compareTo, getByteMessage, getChannel, getChannelID, getNextMixChannelID, getTimeOfReceival, setByteMessage, setPayloadRange, setTimeOfReceival
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface message.BasicMessage
getByteMessage, getChannel, getChannelID, getNextMixChannelID, getTimeOfReceival, setByteMessage, setPayloadRange, setTimeOfReceival
 

Field Detail

internalInformationPort

private static InternalInformationPortController internalInformationPort
Reference on component InternalInformationPort. Used to display and/or log data and read general settings.


LOGGER

private static final java.util.logging.Logger LOGGER
Logger used to log and display information.


IDENTIFIER

public static final byte IDENTIFIER
Identifier for this type of message. Necessary since messages are transmitted as byte streams which don't support the instanceOf operator.

See Also:
Constant Field Values

NUMBER_OF_FURTHER_HOPS

private final int NUMBER_OF_FURTHER_HOPS
Number of further hops (= mixes), this message must pass to reach its destination. Used to find a MessagePart's position in the byteMessage which has (a) dynamic start- and/or end-position(s). Note: Message length isn't constant in a cascade.

See Also:
Message.byteMessage, ChannelEstablishMessagePart
Constructor Detail

ChannelEstablishMessage

public ChannelEstablishMessage(byte[] byteMesssage,
                               User channel,
                               int numberOfFurtherHops)
Message constructor used by a mix.

Constructs a new ChannelEstablishMessage with the submitted content (byteMesssage) for the specified user/channel.

Parameters:
byteMesssage - Byte representation of the message (as received from the client/previous mix).
channel - User/channel the message shall be created for.
numberOfFurtherHops - Number of further hops (= mixes), this message must pass.

ChannelEstablishMessage

public ChannelEstablishMessage(byte[] byteMesssage,
                               int numberOfFurtherHops)
Message constructor used by client.

Constructs a new ChannelEstablishMessage with the submitted content (byteMesssage).

Parameters:
byteMesssage - Byte representation of the message (can be empty).
numberOfFurtherHops - Number of mixes in the cascade.
Method Detail

getLeadingZero

public byte getLeadingZero()
Returns the MessagePart LEADING_ZERO.

Returns:
MessagePart LEADING_ZERO.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.LEADING_ZERO

setLeadingZero

public void setLeadingZero()
Sets the MessagePart LEADING_ZERO to 01000000.

See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.LEADING_ZERO

getMAC

public byte[] getMAC()
Returns the MessagePart MAC = The Message Authentication Code (MAC) of this message.

Returns:
MessagePart MAC.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MAC

setMAC

public void setMAC(byte[] mac)
            throws MessagePartHasWrongSizeException
Sets the MessagePart MAC to the bypassed value.

Parameters:
mac - The Message Authentication Code (MAC) of this message.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MAC

getMessageID

public int getMessageID()
Returns the MessagePart MESSAGE_ID = An identifieing number, which is the same for every envelope of a mix message. Used to trace messages for debugging. Can only be read correctly, when current envelope is decrypted! Note: For testing only (MAKES MIX INSECURE)!

Specified by:
getMessageID in interface BasicMessage
Overrides:
getMessageID in class Message
Returns:
MessagePart MESSAGE_ID.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MESSAGE_ID

setMessageID

public void setMessageID(int newID)
Sets the MessagePart MESSAGE_ID to the bypassed value.

Specified by:
setMessageID in interface BasicMessage
Overrides:
setMessageID in class Message
Parameters:
newID - An identifieing number, which is the same for every envelope of a mix message. Used to trace messages for debugging. Can only be set correctly, when current envelope is decrypted! Note: For testing only (MAKES MIX INSECURE)!
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MESSAGE_ID

getMACKey

public javax.crypto.SecretKey getMACKey()
Returns the MessagePart MAC_KEY = Key used to generate Message Authentication Code (MAC).

Returns:
MessagePart MAC_KEY.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MAC_KEY

setMACKey

public void setMACKey(javax.crypto.SecretKey key)
Sets the MessagePart MAC_KEY to the bypassed value.

Parameters:
key - Key used to generate Message Authentication Code (MAC).
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.MAC_KEY

getSessionKey

public javax.crypto.spec.SecretKeySpec getSessionKey()
Returns the MessagePart SYMMETRIC_KEY = Key used to decrypt the symmetrically encrypted message part.

Returns:
MessagePart SYMMETRIC_KEY.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SESSION_KEY

setSessionKey

public void setSessionKey(javax.crypto.SecretKey key)
Sets the MessagePart SYMMETRIC_KEY to the bypassed value.

Parameters:
key - Key used to decrypt the symmetrically encrypted message part.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SESSION_KEY

getSessionIV

public javax.crypto.spec.IvParameterSpec getSessionIV()
Returns the MessagePart SYMMETRIC_IV = Initialization vector used to decrypt the symmetrically encryptet message part.

Returns:
MessagePart SYMMETRIC_IV.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SESSION_IV

setSessionIV

public void setSessionIV(byte[] sessionIV)
Sets the MessagePart SYMMETRIC_IV to the bypassed value.

Parameters:
sessionIV - Initialization vector used to decrypt the symmetrically encryptet message part.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SESSION_IV

getTimestamp

public long getTimestamp()
Returns the MessagePart TIMESTAMP = Point of time, the message was created.

Returns:
MessagePart TIMESTAMP.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.TIMESTAMP

setTimestamp

public void setTimestamp(long newTimestamp)
Sets the MessagePart TIMESTAMP to the bypassed value.

Parameters:
newTimestamp - Point of time, the message was created.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.TIMESTAMP

getPayload

public Payload getPayload()
Returns the MessagePart PAYLOAD.

Returns:
MessagePart PAYLOAD.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.PAYLOAD

setPayload

public void setPayload(Payload newPayload)
                throws MessagePartHasWrongSizeException
Sets the MessagePart PAYLOAD to the bypassed value.

Parameters:
newPayload - Payload to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.PAYLOAD

getSignedData

public byte[] getSignedData()
Returns the MessagePart SIGNED_DATA.

Returns:
MessagePart SIGNED_DATA.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SIGNED_DATA

setSignedData

public void setSignedData(byte[] newSignedData)
                   throws MessagePartHasWrongSizeException
Sets the MessagePart SIGNED_DATA to the bypassed value.

Parameters:
newSignedData - The signed data to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SIGNED_DATA

getAsymmetricPart

public byte[] getAsymmetricPart()
Returns the MessagePart ASYMMETRIC_PART = The asymmetrically encrypted part of the message.

Returns:
MessagePart ASYMMETRIC_PART.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.ASYMMETRIC_PART

setAsymmetricPart

public void setAsymmetricPart(byte[] newAsymmetricPart)
                       throws MessagePartHasWrongSizeException
Sets the MessagePart ASYMMETRIC_PART to the bypassed value.

Parameters:
newAsymmetricPart - The asymmetric part of the message to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.ASYMMETRIC_PART

getSymmetricPart

public byte[] getSymmetricPart()
Returns the MessagePart SYMMETRIC_PART = The symmetrically encrypted part of the message.

Returns:
MessagePart SYMMETRIC_PART.
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SYMMETRIC_PART

setSymmetricPart

public void setSymmetricPart(byte[] newSymmetricPart)
                      throws MessagePartHasWrongSizeException
Sets the MessagePart SYMMETRIC_PART to the bypassed value.

Parameters:
newSymmetricPart - The symmetric part of the message to be set.
Throws:
MessagePartHasWrongSizeException
See Also:
ChannelEstablishMessagePart, ChannelEstablishMessagePart.SYMMETRIC_PART

getPart

private byte[] getPart(ChannelEstablishMessagePart messagePart)
Returns a byte representation of a MessagePart. Example of usage: getPart(ChannelEstablishMessagePart.NAME_OF_ENUM_CONSTANT);

Parameters:
messagePart - Enum constant who's byte representation shall be retrieved (= "type" of the part).
Returns:
Byte representation of the MessagePart suiting the bypassed enum constant.
See Also:
ChannelEstablishMessagePart

setPart

private void setPart(ChannelEstablishMessagePart messagePart,
                     byte[] data)
              throws MessagePartHasWrongSizeException
Saves a byte representation of a MessagePart. Example of usage: setPart(ChannelEstablishMessagePart.NAME_OF_ENUM_CONSTANT, data);

Parameters:
messagePart - Enum constant who's byte representation shall be saved.
data - Byte representation of the MessagePart to be saved.
Throws:
MessagePartHasWrongSizeException - Thrown when a MessagePart that shall be assigned is of wrong size.
See Also:
ChannelEstablishMessagePart

toString

public java.lang.String toString()
Returns a simple String representation of this class featuring several message parts. Note: Output is only correct for decrypted messages.

Overrides:
toString in class java.lang.Object
Returns:
A simple String representation of this class featuring several message parts.