net.ninthtest.crypto.provider.helix
Class HelixMac

java.lang.Object
  extended by javax.crypto.MacSpi
      extended by net.ninthtest.crypto.provider.helix.HelixMac

public final class HelixMac
extends MacSpi

This class provides the MAC generation operation for the Helix stream cipher.

Version:
1.0
Author:
Matthew Zipay (mattz@ninthtest.info)

Constructor Summary
HelixMac()
          Creates a new HelixMac and performs the provider self-integrity check.
 
Method Summary
protected  byte[] engineDoFinal()
          Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialized with.
protected  int engineGetMacLength()
          Returns the length of the MAC in bytes.
protected  void engineInit(Key key, AlgorithmParameterSpec params)
          Initializes 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 initialized 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 inclusive.
 
Methods inherited from class javax.crypto.MacSpi
clone, engineUpdate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelixMac

public HelixMac()
Creates a new HelixMac and performs the provider self-integrity check.

Method Detail

engineGetMacLength

protected int engineGetMacLength()
Returns the length of the MAC in bytes.

Specified by:
engineGetMacLength in class MacSpi
Returns:
the length of a Helix MAC expressed in bytes (always 16 )
See Also:
MacSpi.engineGetMacLength()

engineInit

protected void engineInit(Key key,
                          AlgorithmParameterSpec params)
                   throws InvalidKeyException,
                          InvalidAlgorithmParameterException
Initializes the MAC with the given (secret) key and algorithm parameters.

If a MAC is non-null in params, it is ignored.

Specified by:
engineInit in class MacSpi
Parameters:
key - the secret key for an MAC generation (encryption) operation (must be a Helix SecretKey)
params - the algorithm parameters (must be a HelixParameterSpec )
Throws:
InvalidKeyException - if key is null or not a Helix SecretKey
InvalidAlgorithmParameterException - if params is null or not a HelixParameterSpec
See Also:
MacSpi.engineInit(java.security.Key, java.security.spec.AlgorithmParameterSpec)

engineUpdate

protected void engineUpdate(byte input)
Processes the given byte.

Specified by:
engineUpdate in class MacSpi
Parameters:
input - the input byte to be processed
See Also:
MacSpi.engineUpdate(byte)

engineUpdate

protected void engineUpdate(byte[] input,
                            int offset,
                            int len)
Processes the first len bytes in input, starting at offset inclusive.

Specified by:
engineUpdate in class MacSpi
Parameters:
input - the input buffer
offset - the index into input where the input bytes begin
len - the number of bytes to be used from input (beginning at offset)
See Also:
MacSpi.engineUpdate(byte[], int, int)

engineDoFinal

protected byte[] engineDoFinal()
Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialized with.

Specified by:
engineDoFinal in class MacSpi
Returns:
the generated 16-byte MAC
See Also:
MacSpi.engineDoFinal()

engineReset

protected void engineReset()
Resets the MAC for further use, maintaining the secret key that the MAC was initialized with.

The Helix nonce is also maintained. Re-using a HelixMac in this manner is not recommended; instead, re-initialize the Mac instance with a new nonce.

Specified by:
engineReset in class MacSpi
See Also:
MacSpi.engineReset()


Copyright © 2010-2014 Matthew Zipay. All Rights Reserved.