ostore.mac
Class MACedQS

java.lang.Object
  |
  +--ostore.mac.MACedQS
All Implemented Interfaces:
QuickSerializable

public class MACedQS
extends Object
implements QuickSerializable

MACedQS

Pronounced: "mack'd kue ess"

This class contains two major items:
(1) A QuickSerializable object and
(2) the MAC of (1)

How to use:

(1) Construct a new MACedQS: This will automatically generate the byte encoding of the user_data.

(2) Pass this MACedQS object to a MacHandler using MacHandler.doMAC(ostore.util.QuickSerializable, ostore.util.SecureHash) to generate the MAC. (Internal Note: What the MacHandler typically does is grab the getBytes() compute the MAC and, using setMAC(byte[]), sets the MAC.)

(3) To verify: Pass this MACedQS object to a MacHandler through MacHandler.authenticate(ostore.util.QuickSerializable, ostore.util.QSByteArray, ostore.util.SecureHash)

What you cannot do:

+ You cannot alter the user_data and user_bytes contents once this object has been constructed.

Version:
$Id: MACedQS.java,v 1.4 2001/10/26 23:51:29 srhea Exp $
Author:
Gifford Cheung

Constructor Summary
MACedQS(byte[] data, int[] offset)
          The deserialization constructor.
MACedQS(QuickSerializable user_data)
           
 
Method Summary
 byte[] getBytes()
          The bytes of the data MAC'd
 byte[] getMAC()
          The MAC of the user_data
protected  void setMAC(byte[] MAC)
          Sets the MAC value for user_data, meant for MacHandler to use.
 void to_bytes(byte[] data, int[] offset)
          Store the object in its "on the wire" form in the byte array data, starting at index offset [0], and increment offset [0] by the number of bytes written; if data == null, increment offset [0] by the number of bytes that would have been written otherwise.
 int type_code()
          Returns the unique integer associated with this class in the TypeTable.
 QuickSerializable user_data()
          The data which this object MAC'd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MACedQS

public MACedQS(QuickSerializable user_data)
Parameters:
user_data - the message to MAC

MACedQS

public MACedQS(byte[] data,
               int[] offset)
        throws QSException
The deserialization constructor. See the comments at the top of QuickSerializable for details.
Method Detail

user_data

public QuickSerializable user_data()
The data which this object MAC'd
Returns:
the data which is MAC'd

getBytes

public byte[] getBytes()
The bytes of the data MAC'd
Returns:
the to_bytes of user_data

getMAC

public byte[] getMAC()
The MAC of the user_data
Returns:
the bytes of the (precomputed) MAC of the data

setMAC

protected void setMAC(byte[] MAC)
Sets the MAC value for user_data, meant for MacHandler to use.

to_bytes

public void to_bytes(byte[] data,
                     int[] offset)
Description copied from interface: QuickSerializable
Store the object in its "on the wire" form in the byte array data, starting at index offset [0], and increment offset [0] by the number of bytes written; if data == null, increment offset [0] by the number of bytes that would have been written otherwise.
Specified by:
to_bytes in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Parameters:
data - The byte array to store into, or null.
offset - A single element array whose first element is the index in data to begin writing at on function entry, and which on function exit has been incremented by the number of bytes written.

type_code

public int type_code()
Description copied from interface: QuickSerializable
Returns the unique integer associated with this class in the TypeTable.
Specified by:
type_code in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Returns:
an integer unique to this class