hypercast
Class SecInfoExchange_Message

java.lang.Object
  |
  +--hypercast.SecInfoExchange_Message
All Implemented Interfaces:
I_Message

public class SecInfoExchange_Message
extends java.lang.Object
implements I_Message

This class defines the format for security information exchange messages, including key request, ket reply, certificate request and certificate reply. It also provides a wrap message for plaintext protocol messages so that they can be exchanged between different overlay nodes when security policy (privacy or integrity) is applied. The format of a SecInfoExchange_Message instance in byte array format is: ----------------------------------------------------------------------------- |Proto number|Payload Length | Type | Sequence Num | OverlayID hash | | 8 bits | 16 bits | 8 bits | 32 bits | 32 bits | ----------------------------------------------------------------------------- | Src Addr Pair / Dest Addr Pair / | LA size+PA size / LA size+PA size / ------------------------------------- (only for a wrap message, i.e. type is ProtoMsg) ---------------------------------------------------------------------- /Payload Mac Len/ Payload MacType / Sender key timestamp / / 16 bits / variable / 64 bits / -------------------------------------------------------------- (except key request message) ------------------- / Payload / / / ------------------- The payload is a certificate for certificate request or reply message, a key timestamp and key for key update message, or the byte array of plaintext protocol message for a ProtoMsg message.


Field Summary
static byte CertReply
           
static byte CertRequest
          Constants for the type of a SecInfoExchange_Message instance.
static byte KeyRequest
           
static byte KeyUpdate
           
static byte ProtoMsg
           
static byte PROTONUM_SIE30
          Protocol Number value in Protocol field for SecInfoExchange message
 
Constructor Summary
SecInfoExchange_Message(byte[] A, int[] beginValidBytes, hypercast.I_UnicastAdapter adapter, hypercast.SecurityProcessor sp)
          Constructor.
SecInfoExchange_Message(int type, int gh, hypercast.I_AddressPair _src, hypercast.I_AddressPair _dst, hypercast.SecurityProcessor sp)
          Constructor.
 
Method Summary
 java.security.cert.X509Certificate getCertificate()
          Get the certificate stored in this object.
 javax.crypto.spec.SecretKeySpec getKey()
          Get the key stored in this object.
 long getKeyTimestamp()
          Get the creation time of the key in the KeyUpdate or ProtoMsg message
 int getOverlayHash()
          Get the overlay ID hash value carried in this object.
 int getPayloadLength()
          Get the length of the payload
 hypercast.I_Message getProtoMsg()
          Get the plaintext protocol message stored in this object.
 byte[] getProtoMsgBytes()
          Get the byte array converted from the plaintext protocol message stored in this object.
 int getSequenceNum()
           
 hypercast.I_AddressPair getSrc()
          Get the source address pair of this message.
 byte getType()
          Query the type of this SecInfoExchange_Message instance.
static hypercast.SecInfoExchange_Message restoreMessage(byte[] A, int[] beginValidBytes, int endValidBytes, hypercast.I_UnicastAdapter adapter, int thisOverlayHash, hypercast.SecurityProcessor sp)
          Re-construct a SecInfoExchange_Message instance from byte array.
 void setCertificate(java.security.cert.X509Certificate _cert)
          Set the certificate variable.
 void setKey(javax.crypto.spec.SecretKeySpec _key)
          Set the key variable.
 void setKeyTimestamp(long timestamp)
          Set the creation time for the sender's key
 void setProtoMsg(hypercast.I_Message _protoMsg)
          Set the plaintext protocol message stored in this object.
 void setProtoMsgBytes(byte[] msgBytes)
          Set the byte array converted from the plaintext protocol message stored in this object.
 void setSequenceNum(int sequenceNum)
           
 byte[] toByteArray()
          Converts this object to byte array.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CertRequest

public static final byte CertRequest
Constants for the type of a SecInfoExchange_Message instance.

See Also:
Constant Field Values

CertReply

public static final byte CertReply
See Also:
Constant Field Values

KeyRequest

public static final byte KeyRequest
See Also:
Constant Field Values

KeyUpdate

public static final byte KeyUpdate
See Also:
Constant Field Values

ProtoMsg

public static final byte ProtoMsg
See Also:
Constant Field Values

PROTONUM_SIE30

public static final byte PROTONUM_SIE30
Protocol Number value in Protocol field for SecInfoExchange message

See Also:
Constant Field Values
Constructor Detail

SecInfoExchange_Message

public SecInfoExchange_Message(int type,
                               int gh,
                               hypercast.I_AddressPair _src,
                               hypercast.I_AddressPair _dst,
                               hypercast.SecurityProcessor sp)
Constructor.

Parameters:
type - type of this message.
gh - overlay ID hash value.
_src - source address of this message.
_dst - destination address of this message.
sp - security processor which handles secure message sending/ receiving issues in this overlay socket.

SecInfoExchange_Message

public SecInfoExchange_Message(byte[] A,
                               int[] beginValidBytes,
                               hypercast.I_UnicastAdapter adapter,
                               hypercast.SecurityProcessor sp)
Constructor. It constructs a SecInfoExchange_Message instance from byte array.

Parameters:
A - packet, i.e., a SecInfoExchange_Message message in byte array format.
beginValidBytes - start point for reading available data in the packet.
adapter - node adapter.
sp - security processor.
Method Detail

restoreMessage

public static hypercast.SecInfoExchange_Message restoreMessage(byte[] A,
                                                               int[] beginValidBytes,
                                                               int endValidBytes,
                                                               hypercast.I_UnicastAdapter adapter,
                                                               int thisOverlayHash,
                                                               hypercast.SecurityProcessor sp)
Re-construct a SecInfoExchange_Message instance from byte array.

Parameters:
A - packet, i.e., a SecInfoExchange_Message message in byte array format.
beginValidBytes - start point for reading available data in the packet.
endValidBytes - end point of available data in the packet.
adapter - node adapter.
thisOverlayHash - overlay ID hash.
Returns:
a SecInfoExchange_Message instance.
Throws:
java.lang.IllegalArgumentException - when an error occurs in creating or decoding security parameters

toByteArray

public byte[] toByteArray()
Converts this object to byte array.

Specified by:
toByteArray in interface I_Message
See Also:
I_Message.toByteArray()

getType

public byte getType()
Query the type of this SecInfoExchange_Message instance.

Returns:
The type defined in SecInfoExchange_Message corresponding with this message

getSrc

public hypercast.I_AddressPair getSrc()
Get the source address pair of this message.

Returns:
source address pair.

getOverlayHash

public int getOverlayHash()
Get the overlay ID hash value carried in this object.

Returns:
the overlay ID hash.

getCertificate

public java.security.cert.X509Certificate getCertificate()
Get the certificate stored in this object.

Returns:
the certificate.

setCertificate

public void setCertificate(java.security.cert.X509Certificate _cert)
Set the certificate variable.

Parameters:
_cert - a certificate instance.

getKey

public javax.crypto.spec.SecretKeySpec getKey()
Get the key stored in this object.

Returns:
the key.

setKey

public void setKey(javax.crypto.spec.SecretKeySpec _key)
Set the key variable.

Parameters:
_key - a key instance.

getProtoMsg

public hypercast.I_Message getProtoMsg()
Get the plaintext protocol message stored in this object.

Returns:
the plaintext protocol message.

setProtoMsg

public void setProtoMsg(hypercast.I_Message _protoMsg)
Set the plaintext protocol message stored in this object.

Parameters:
_protoMsg - a plaintext protocol message.

setProtoMsgBytes

public void setProtoMsgBytes(byte[] msgBytes)
Set the byte array converted from the plaintext protocol message stored in this object.

Parameters:
msgBytes - the byte array of plaintext protocol message.

getProtoMsgBytes

public byte[] getProtoMsgBytes()
Get the byte array converted from the plaintext protocol message stored in this object.

Returns:
the byte array of plaintext protocol message.

getPayloadLength

public int getPayloadLength()
Get the length of the payload

Returns:
The payload length

setKeyTimestamp

public void setKeyTimestamp(long timestamp)
Set the creation time for the sender's key

Parameters:
timestamp - the creation time of the key

getKeyTimestamp

public long getKeyTimestamp()
Get the creation time of the key in the KeyUpdate or ProtoMsg message

Returns:
the creation time of the key contained in the message

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSequenceNum

public int getSequenceNum()
Returns:
Returns the sequenceNum.

setSequenceNum

public void setSequenceNum(int sequenceNum)
Parameters:
sequenceNum - The sequenceNum to set.