For the latest news and information visit The GNU Crypto project

## gnu.crypto.mac
Class MacOutputStream

    java.lang.Object
      |
      +--java.io.OutputStream
            |
            +--java.io.FilterOutputStream
                  |
                  +--gnu.crypto.mac.MacOutputStream

public class MacOutputStream
extends java.io.FilterOutputStream

A filtering output stream that computes a MAC (message authentication code) over all data written to the stream.

Field Summary

Fields inherited from class java.io.FilterOutputStream
`out`

Constructor Summary
`MacOutputStream(java.io.OutputStream out, IMac mac)` Creates a new `MacOutputStream`.

Method Summary
`IMac` `getMac()` Returns the MAC this stream is updating.
`void` `on(boolean flag)` Turns the digesting state on or off.
`void` `setMac(IMac mac)` Sets the MAC this stream is updating, which must have already been initialized.
`void` `write(byte[] buf, int off, int len)`
`void` `write(int b)`

Methods inherited from class java.io.FilterOutputStream
`close, flush, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MacOutputStream

    public MacOutputStream(java.io.OutputStream out,
                           IMac mac)

  Creates a new `MacOutputStream`. 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:
  `out` - The underlying output 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 non-null 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.

### write

    public void write(int b)
               throws java.io.IOException

  Overrides:
    `write` in class `java.io.FilterOutputStream`
    `java.io.IOException`

### write

    public void write(byte[] buf,
                      int off,
                      int len)
               throws java.io.IOException

  Overrides:
    `write` in class `java.io.FilterOutputStream`
    `java.io.IOException`

For the latest news and information visit The GNU Crypto project

Copyright © 2001, 2002, 2003, 2004 Free Software Foundation, Inc.