message
Enum ChannelEstablishMessagePart

java.lang.Object
  extended by java.lang.Enum<ChannelEstablishMessagePart>
      extended by message.ChannelEstablishMessagePart
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ChannelEstablishMessagePart>

public enum ChannelEstablishMessagePart
extends java.lang.Enum<ChannelEstablishMessagePart>

Defines the message format/message parts of a ChannelEstablishMessage. Common message parts are for example "session key" and "payload". The entire message format can be specified within the enum fields. Any ChannelEstablishMessagePart can be retrieved or manipulated using the methods getPart(ChannelEstablishMessagePart messagePart) and setPart(ChannelEstablishMessagePart messagePart, byte[] data) in class ChannelEstablishMessage.

Overlapping message parts are supported (e. g. a field "asymmetric part", which consists of several message parts itself). If a ChannelEstablishMessagePart is of dynamic length (= its length depends on the current mix' position in the cascade (Note: Message length isn't constant in a cascade)), the correct length is calculated automatically.

Note: A MessagePart is "dynamic", when its start and/or end position (=index) is/are equal to, or behind the end position of the last mix' payload (since the payload's size differs from mix to mix (and therefore is a dynamic part as well)).

Each MessagePart provides the following information: It's start offset (= index), it's end offset and whether the part is "part of the header" or not. A MessagePart is considered a "part of the header", when it is exclusive for each mix of the cascade and therefore will be dropped by the corresponding mix. For example a "session key" is "part of the header", since it must be different for each mix and secret to all others (and therefore won't be sent forward). In contrast, the "payload" is not "part of the header", since it is sent from one mix to another (after recoding). Overlapping message parts can't be headers, of course.

See Enum Types Tutorial for information on how to use enumerations in Java.

Note: This enumeration contains the field "MESSAGE_ID" which makes messages TRACEABLE (for debugging)!

Author:
Karl-Peter Fuchs
See Also:
Message

Enum Constant Summary
ASYMMETRIC_PART
          The asymmetrically encrypted part of the message.
LEADING_ZERO
          Leading zero due to (plain) RSA (first bit must be zero).
MAC
          The Message Authentication Code (MAC) of this message.
MAC_KEY
          Key used to generate Message Authentication Code (MAC).
MESSAGE_ID
          Note: For testing only (MAKES MIX INSECURE): An identifieing number, which is the same for every envelope of a mix message.
PAYLOAD
          The payload.
RESERVED
          Reserved space (used to fill up header's size to a multiple of the block size).
SESSION_IV
          Initialization vector used to decrypt the symmetrically encryptet message part.
SESSION_KEY
          Key used to decrypt the symmetrically encrypted message part.
SIGNED_DATA
          The signed data of this message.
SYMMETRIC_PART
          The symmetrically encrypted part of the message.
TIMESTAMP
          Point of time, the message was created.
 
Field Summary
private  int basicEndPosition
          Basic end position (= offset) of this MessagePart.
private static int basicEndPositionOfPayload
          The end position (=index) of the last mix' payload (Note: Message length isn't constant in a cascade).
private  int basicLength
          Basic length of this MessagePart in byte.
private static int basicMessageLength
          The length of a mix message, as it arrives at the last mix of a cascade (in byte).
private  int basicStartPosition
          Basic start position (= offset) of this MessagePart.
private  boolean hasDynamicEndPosition
          Indicates whether this MessagePart's end position depends on the calling mix' position in the cascade or not.
private  boolean hasDynamicStartPosition
          Indicates whether this MessagePart's start position depends on the calling mix' position in the cascade or not.
private static int headerLength
          The length of a Message's header as defined above (in byte).
private static InternalInformationPortController internalInformationPort
          Reference on component InternalInformationPort.
private  boolean isDynamicPart
          Indicates whether this MessagePart's length or position depends on the calling mix' position in the cascade or not.
private  boolean isPartOfHeader
          Indicates whether this MessagePart is part of a mix message's header or not (used to calculate appropriate message lengths for a mix' cascade position).
private static java.util.logging.Logger LOGGER
          Logger used to log and display information.
 
Method Summary
 int getBasicLength()
          Returns the "basic" length of this MessagePart in byte.
 int getEndPosition(int numberOfFurtherHops)
          Returns this MessagePart's (possibly dynamic) end position (= offset), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass).
static int getHeaderLength()
          Returns the length of a Message's header as defined above (see static initializer) in byte.
 int getLength(int numberOfFurtherHops)
          Returns the length of this (possibly dynamic) MessagePart (in byte), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass).
static int getMessageLength(int numberOfFurtherHops)
          Returns the (dynamic) length of a mix message, according to the specified mix position in the cascade (in byte).
 int getStartPosition(int numberOfFurtherHops)
          Returns this MessagePart's (possibly dynamic) start position (= offset), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass).
static ChannelEstablishMessagePart valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ChannelEstablishMessagePart[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

LEADING_ZERO

public static final ChannelEstablishMessagePart LEADING_ZERO
Leading zero due to (plain) RSA (first bit must be zero). (The other 7 bits of the first byte are not used in this implementation due to readability issues).


MAC

public static final ChannelEstablishMessagePart MAC
The Message Authentication Code (MAC) of this message.


MESSAGE_ID

public static final ChannelEstablishMessagePart MESSAGE_ID
Note: For testing only (MAKES MIX INSECURE): An identifieing number, which is the same for every envelope of a mix message. Used to trace messages for debugging. Can (as all other header-field) only be read correctly, when current envelope is decrypted!


MAC_KEY

public static final ChannelEstablishMessagePart MAC_KEY
Key used to generate Message Authentication Code (MAC).


SESSION_KEY

public static final ChannelEstablishMessagePart SESSION_KEY
Key used to decrypt the symmetrically encrypted message part.


SESSION_IV

public static final ChannelEstablishMessagePart SESSION_IV
Initialization vector used to decrypt the symmetrically encryptet message part.


TIMESTAMP

public static final ChannelEstablishMessagePart TIMESTAMP
Point of time, the message was created.


RESERVED

public static final ChannelEstablishMessagePart RESERVED
Reserved space (used to fill up header's size to a multiple of the block size).


PAYLOAD

public static final ChannelEstablishMessagePart PAYLOAD
The payload.

See Also:
Payload

SIGNED_DATA

public static final ChannelEstablishMessagePart SIGNED_DATA
The signed data of this message.


ASYMMETRIC_PART

public static final ChannelEstablishMessagePart ASYMMETRIC_PART
The asymmetrically encrypted part of the message.


SYMMETRIC_PART

public static final ChannelEstablishMessagePart SYMMETRIC_PART
The symmetrically encrypted part of the message.

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.


basicEndPositionOfPayload

private static final int basicEndPositionOfPayload
The end position (=index) of the last mix' payload (Note: Message length isn't constant in a cascade). Used to calculate dynamic message lengths. Must be set to the same value as the highest end position of all message parts. Note: basicEndPositionOfPayload + (numberOfMixesInCascade * hesaderSize) should be smaller than the Maximum Transmission Unit of the underlying network for performance reasons!

See Also:
Constant Field Values

basicMessageLength

private static final int basicMessageLength
The length of a mix message, as it arrives at the last mix of a cascade (in byte). Used as starting point to calculate mix message lengths and start- and end positions of dynamic message parts according to the calling mix' position in the cascade (Note: there's no fixed message length in a cascade).


headerLength

private static final int headerLength
The length of a Message's header as defined above (in byte). Used as incrementation factor to calculate a calling mix' message length according to it's position in the cascade (Note: there's no fixed message length in a cascade).


basicStartPosition

private final int basicStartPosition
Basic start position (= offset) of this MessagePart. "Basic" means, the start position is only valid for the last mix of a cascade. Dynamic MessageParts need additional calculation (which is done automatically).


basicEndPosition

private final int basicEndPosition
Basic end position (= offset) of this MessagePart. "Basic" means, the end position is only valid for the last mix of a cascade. Dynamic MessageParts need additional calculation (which is done automatically).


basicLength

private final int basicLength
Basic length of this MessagePart in byte. "Basic" means, the length is only valid for the last mix of a cascade. Dynamic MessageParts need additional calculation (which is done automatically).

See Also:
getLength(int), hasDynamicStartPosition, hasDynamicEndPosition

isPartOfHeader

private final boolean isPartOfHeader
Indicates whether this MessagePart is part of a mix message's header or not (used to calculate appropriate message lengths for a mix' cascade position).

A MessagePart is considered as "part of the header", when it is exclusive for each mix of the cascade and therefore will be dropped by the corresponding mix. For example a "session key" is "part of the header", since it must be different for each mix and secret to all others (and therefore won't be sent forward). In contrast, the "payload" is not "part of the header", since it is sent from one mix to another (after recoding). Overlapping message parts can't be headers, of course.


hasDynamicStartPosition

private final boolean hasDynamicStartPosition
Indicates whether this MessagePart's start position depends on the calling mix' position in the cascade or not. Note: there's no fixed message length in a cascade).


hasDynamicEndPosition

private final boolean hasDynamicEndPosition
Indicates whether this MessagePart's end position depends on the calling mix' position in the cascade or not. Note: there's no fixed message length in a cascade).


isDynamicPart

private final boolean isDynamicPart
Indicates whether this MessagePart's length or position depends on the calling mix' position in the cascade or not. Note: there's no fixed message length in a cascade).

See Also:
hasDynamicStartPosition, hasDynamicEndPosition
Method Detail

values

public static ChannelEstablishMessagePart[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ChannelEstablishMessagePart c : ChannelEstablishMessagePart.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ChannelEstablishMessagePart valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getStartPosition

public int getStartPosition(int numberOfFurtherHops)
Returns this MessagePart's (possibly dynamic) start position (= offset), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass).

Note: Every further hop needs it's own header. Therefore, the message size is not constant.

Parameters:
numberOfFurtherHops - The number of further hops (=number of mixes this MessagePart's Message still must come to pass).
Returns:
This MessagePart's start position (= offset).

getEndPosition

public int getEndPosition(int numberOfFurtherHops)
Returns this MessagePart's (possibly dynamic) end position (= offset), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass).

Note: Every further hop needs it's own header. Therefore, the message size is not constant.

Parameters:
numberOfFurtherHops - The number of further hops (=number of mixes this MessagePart's Message still must come to pass).
Returns:
This MessagePart's end position (= offset).

getLength

public int getLength(int numberOfFurtherHops)
Returns the length of this (possibly dynamic) MessagePart (in byte), according to the number of further hops (=number of mixes this MessagePart's Message still must come to pass). Note: Every further hop needs it's own header. Therefore, the message size is not constant.

Parameters:
numberOfFurtherHops - The number of further hops (=number of mixes this MessagePart's Message still must come to pass).
Returns:
The length of this MessagePart in byte.

getBasicLength

public int getBasicLength()
Returns the "basic" length of this MessagePart in byte. "Basic" means, the length is only valid for the last mix of a cascade.

Returns:
The "basic" length of this MessagePart in byte.

getMessageLength

public static int getMessageLength(int numberOfFurtherHops)
Returns the (dynamic) length of a mix message, according to the specified mix position in the cascade (in byte). (Note: there's no fixed message length in a cascade).

Parameters:
numberOfFurtherHops - The number of further hops (=number of mixes this MessagePart's Message still must come to pass).
Returns:
The (dynamic) length of a mix message for the specified mix position in the cascade.

getHeaderLength

public static int getHeaderLength()
Returns the length of a Message's header as defined above (see static initializer) in byte. Used as incrementation factor to calculate a calling mix' message length according to it's position in the cascade (Note: there's no fixed message length in a cascade).

Returns:
The length of a Message's header (in byte).