iaik.utils
Class MacOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--iaik.utils.MacOutputStream

public class MacOutputStream
extends FilterOutputStream

A stream implementation for MACing the data written to an output stream. This is similar to the java.security.DigestOutputStream.

Version:
File Revision 5
See Also:
MacInputStream, java.security.DigestOutputStream

Field Summary
protected  Mac macEngine_
          The MAC engine to use for MACing the data.
protected  boolean macingActive_
          Indicates, if this objects sends data written to this stream to the Mac engine.
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
MacOutputStream(OutputStream stream, Mac macEngine)
          Creates a MAC output stream, using the specified output stream and MAC engine.
 
Method Summary
 Mac getMac()
          Get the MAC engine used for MACing the data.
 void on(boolean macingActive)
          Turns the MACing on or off.
 void setMac(Mac macEngine)
          Set the MAC engine to use for MACing the data.
 String toString()
          Returns a string representation of this MAC output stream.
 void write(byte[] dataByteArray, int offset, int length)
          This methods updates the MAC, if the MACing is active.
 void write(int dataByte)
          This methods updates the MAC, if the MACing is active.
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

macingActive_

protected boolean macingActive_
Indicates, if this objects sends data written to this stream to the Mac engine.

macEngine_

protected Mac macEngine_
The MAC engine to use for MACing the data.
Constructor Detail

MacOutputStream

public MacOutputStream(OutputStream stream,
                       Mac macEngine)
Creates a MAC output stream, using the specified output stream and MAC engine.
Parameters:
stream - The output stream to write the data though.
macEngine - The MAC engine to use for MACing the data.
Method Detail

getMac

public Mac getMac()
Get the MAC engine used for MACing the data.
Returns:
The MAC engine used for MACing the data.

setMac

public void setMac(Mac macEngine)
Set the MAC engine to use for MACing the data.
Parameters:
macEngine - The MAC engine to use for MACing the data.

write

public void write(int dataByte)
           throws IOException
This methods updates the MAC, if the MACing is active. Susequently, this method writes the data to the underlying stream.
Overrides:
write in class FilterOutputStream
Parameters:
dataByte - A single data byte.
Throws:
IOException - If writing to the underlaying stream fails.

write

public void write(byte[] dataByteArray,
                  int offset,
                  int length)
           throws IOException
This methods updates the MAC, if the MACing is active. Susequently, this method writes the data to the underlying stream.
Overrides:
write in class FilterOutputStream
Parameters:
dataByteArray - The array containing the data bytes.
offset - The offset in the data byte array to start reading the data bytes.
length - The number of bytes to read the array starting from offset.
Throws:
IOException - If writing to the underlaying stream fails.

on

public void on(boolean macingActive)
Turns the MACing on or off. If set to false, all data is just written through to the underlying stream but not to the MAC. Otherwise, if set to true, this object writes all data to the MAC as well as to the underlying stream.
Parameters:
macingActive - True, to MAC all data before writing to the underlying stream.

toString

public String toString()
Returns a string representation of this MAC output stream.
Overrides:
toString in class Object
Returns:
A string representation of this MAC output stream.

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK