For the latest news and information visit
The GNU Crypto project

gnu.crypto.mac
Class MacInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bygnu.crypto.mac.MacInputStream

public class MacInputStream
extends java.io.FilterInputStream

A filtering input stream that computes a MAC (message authentication code) over all data read from the stream.

Version:
$Revision: 1.2 $

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MacInputStream(java.io.InputStream in, IMac mac)
          Creates a new MacInputStream.
 
Method Summary
 IMac getMac()
          Returns the MAC this stream is updating.
 void on(boolean flag)
          Turns the digesting state on or off.
 int read()
           
 int read(byte[] buf, int off, int len)
           
 void setMac(IMac mac)
          Sets the MAC this stream is updating, which must have already been initialized.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MacInputStream

public MacInputStream(java.io.InputStream in,
                      IMac mac)
Creates a new MacInputStream. The stream is initially set to digest data written, the mac argument must have already been initialized, and the mac argument is not cloned.

Parameters:
in - The underlying input stream.
mac - The mac instance to use.
Method Detail

getMac

public IMac getMac()
Returns the MAC this stream is updating.

Returns:
The MAC.

setMac

public void setMac(IMac mac)
Sets the MAC this stream is updating, which must have already been initialized. The argument is not cloned by this method.

Parameters:
mac - The new MAC.
Throws:
java.lang.NullPointerException - If the argument is null.

on

public void on(boolean flag)
Turns the digesting state on or off. When off, the MAC will not be updated when data is written to the stream.

Parameters:
flag - The new digesting state.

read

public int read()
         throws java.io.IOException
Throws:
java.io.IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws java.io.IOException
Throws:
java.io.IOException

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.