au.net.aba.crypto.provider
Class DESMac

java.lang.Object
  |
  +--javax.crypto.MacSpi
        |
        +--au.net.aba.crypto.provider.DESMac
Direct Known Subclasses:
DESedeMac, IDEAMac

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.
protected DESMac(java.lang.String alg)
           
 
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.

DESMac

protected DESMac(java.lang.String alg)
Method Detail

engineGetMacLength

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

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.
Overrides:
engineInit in class MacSpi
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.

engineUpdate

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

engineUpdate

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

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.
Overrides:
engineDoFinal in class MacSpi
Returns:
the MAC result.

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