com.ibm.crypto.fips.provider
Class HmacSHA1

java.lang.Object
  |
  +--javax.crypto.MacSpi
        |
        +--com.ibm.crypto.fips.provider.HmacSHA1
All Implemented Interfaces:
AlgorithmStatus, java.lang.Cloneable

public final class HmacSHA1
extends javax.crypto.MacSpi
implements java.lang.Cloneable, AlgorithmStatus

This is an implementation of the HMAC-SHA1 algorithm.

Version:
1.6, 11/09/99
Author:
Jan Luehe

Constructor Summary
HmacSHA1()
          Standard constructor, creates a new HmacSHA1 instance.
 
Method Summary
 java.lang.Object clone()
           
protected  byte[] engineDoFinal()
          Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
protected  int engineGetMacLength()
          Returns the length of the HMAC in bytes.
protected  void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
          Initializes the HMAC with the given secret key and algorithm parameters.
protected  void engineReset()
          Resets the HMAC for further use, maintaining the secret key that the HMAC 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.
 java.lang.Object internalClone()
           
protected  byte[] internalDoFinal()
          Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
protected  int internalGetMacLength()
          Returns the length of the HMAC in bytes.
protected  void internalInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
          Initializes the HMAC with the given secret key and algorithm parameters.
protected  void internalReset()
          Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
protected  void internalUpdate(byte input)
          Processes the given byte.
protected  void internalUpdate(byte[] input, int offset, int len)
          Processes the first len bytes in input, starting at offset.
 boolean isFipsApproved()
          Module identifies if the cryptographic operation (algorithm) is FIPS certified
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HmacSHA1

public HmacSHA1()
         throws java.security.NoSuchAlgorithmException
Standard constructor, creates a new HmacSHA1 instance. Verify the JCE framework in the constructor.
Throws:
java.lang.SecurityException - if fails to verify the JCE framework.
Method Detail

isFipsApproved

public boolean isFipsApproved()
Description copied from interface: AlgorithmStatus
Module identifies if the cryptographic operation (algorithm) is FIPS certified
Specified by:
isFipsApproved in interface AlgorithmStatus
See Also:
AlgorithmStatus.isFipsApproved()

engineGetMacLength

protected int engineGetMacLength()
Returns the length of the HMAC in bytes.
Overrides:
engineGetMacLength in class javax.crypto.MacSpi
Returns:
the HMAC length in bytes.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalGetMacLength

protected int internalGetMacLength()
Returns the length of the HMAC in bytes.
Returns:
the HMAC length in bytes.

engineInit

protected void engineInit(java.security.Key key,
                          java.security.spec.AlgorithmParameterSpec params)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Initializes the HMAC with the given secret key and algorithm parameters.
Overrides:
engineInit in class javax.crypto.MacSpi
Parameters:
key - the secret key.
params - the algorithm parameters.
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for initializing this MAC.
java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this MAC.
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalInit

protected void internalInit(java.security.Key key,
                            java.security.spec.AlgorithmParameterSpec params)
                     throws java.security.InvalidKeyException,
                            java.security.InvalidAlgorithmParameterException
Initializes the HMAC with the given secret key and algorithm parameters.
Parameters:
key - the secret key.
params - the algorithm parameters.
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for initializing 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 javax.crypto.MacSpi
Parameters:
input - the input byte to be processed.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalUpdate

protected void internalUpdate(byte input)
Processes the given byte.
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 javax.crypto.MacSpi
Parameters:
input - the input buffer.
offset - the offset in input where the input starts.
len - the number of bytes to process.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalUpdate

protected void internalUpdate(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.

engineDoFinal

protected byte[] engineDoFinal()
Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
Overrides:
engineDoFinal in class javax.crypto.MacSpi
Returns:
the HMAC result.
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalDoFinal

protected byte[] internalDoFinal()
Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
Returns:
the HMAC result.

engineReset

protected void engineReset()
Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
Overrides:
engineReset in class javax.crypto.MacSpi
Throws:
FIPSRuntimeException - if SelfTest.isFipsRunnable returns false.

internalReset

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

clone

public java.lang.Object clone()
Overrides:
clone in class javax.crypto.MacSpi

internalClone

public java.lang.Object internalClone()