au.net.aba.crypto.provider
Class DESMac

java.lang.Object
  |
  +--javax.crypto.MacSpi
        |
        +--au.net.aba.crypto.provider.DESMac

public class DESMac
extends MacSpi

This class implements the DES based MAC algorithm as defined in FIPS PUB 113.

This algorithm produces a 4 byte MAC value.

Currently this class will not work correctly unless the input data size is an exact multiple of 8. Data that isnt of this length should be padded with zeros. Eventually the DES cipher class will be modified to perform this function.


Constructor Summary
DESMac()
          Default constructor, initialises the instance.
 
Method Summary
protected  byte[] engineDoFinal()
          Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialised with.
protected  int engineGetMacLength()
          Returns the length of the MAC in bytes.
protected  void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
          Initialises the MAC with the given (secret) key and algorithm parameters.
protected  void engineReset()
          Resets the MAC for further use, maintaining the secret key that the MAC was initialised with.
protected  void engineUpdate(byte input)
          Processes the given byte.
protected  void engineUpdate(byte[] input, int offset, int len)
          Processes the first len bytes in input, starting at offset.
 
Methods inherited from class javax.crypto.MacSpi
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DESMac

public DESMac()
Default constructor, initialises the instance.
Method Detail

engineGetMacLength

protected int engineGetMacLength()
Returns the length of the MAC in bytes.
Returns:
the MAC length in bytes.
Overrides:
engineGetMacLength in class MacSpi

engineInit

protected void engineInit(java.security.Key key,
                          java.security.spec.AlgorithmParameterSpec params)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Initialises the MAC with the given (secret) key and algorithm parameters. The key parameter should be a type that is compatible with the DES Cipher.
Parameters:
key - the (secret) key.
params - the algorithm parameters.
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for initialising this MAC.
java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this MAC.
Overrides:
engineInit in class MacSpi

engineUpdate

protected void engineUpdate(byte input)
Processes the given byte.
Parameters:
input - the input byte to be processed.
Overrides:
engineUpdate in class MacSpi

engineUpdate

protected void engineUpdate(byte[] input,
                            int offset,
                            int len)
Processes the first len bytes in input, starting at offset.
Parameters:
input - the input buffer.
offset - the offset in input where the input starts.
len - the number of bytes to process.
Overrides:
engineUpdate in class MacSpi

engineDoFinal

protected byte[] engineDoFinal()
Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialised with.
Returns:
the MAC result.
Overrides:
engineDoFinal in class MacSpi

engineReset

protected void engineReset()
Resets the MAC for further use, maintaining the secret key that the MAC was initialised with.
Overrides:
engineReset in class MacSpi