message
Enum ChannelMessagePart

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

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

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

Overlapping message parts are supported (e. g. a field "signed data", which consists of several message parts itself). If a ChannelMessagePart 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 "message authentication code" 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
MAC
          The message authentication code (MAC) of this message.
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).
SIGNED_DATA
          The signed data of this message.
 
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 ChannelMessagePart valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ChannelMessagePart[] 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

MAC

public static final ChannelMessagePart MAC
The message authentication code (MAC) of this message.


MESSAGE_ID

public static final ChannelMessagePart 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!


RESERVED

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


PAYLOAD

public static final ChannelMessagePart PAYLOAD
The payload.

See Also:
Payload

SIGNED_DATA

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

Method Detail

values

public static ChannelMessagePart[] 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 (ChannelMessagePart c : ChannelMessagePart.values())
    System.out.println(c);

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

valueOf

public static ChannelMessagePart 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).