public final class

HmacSHA1

extends MacSpi
implements Cloneable
java.lang.Object
   ↳ javax.crypto.MacSpi
     ↳ com.sun.crypto.provider.HmacSHA1

Class Overview

This is an implementation of the HMAC-SHA1 algorithm.

Summary

Public Constructors
HmacSHA1()
Standard constructor, creates a new HmacSHA1 instance.
Public Methods
Object clone()
Returns a clone if the implementation is cloneable.
Protected Methods
byte[] engineDoFinal()
Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
int engineGetMacLength()
Returns the length of the HMAC in bytes.
void engineInit(Key key, AlgorithmParameterSpec params)
Initializes the HMAC with the given secret key and algorithm parameters.
void engineReset()
Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
void engineUpdate(byte[] input, int offset, int len)
Processes the first len bytes in input, starting at offset.
void engineUpdate(byte input)
Processes the given byte.
void engineUpdate(ByteBuffer input)
Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().
[Expand]
Inherited Methods
From class javax.crypto.MacSpi
From class java.lang.Object

Public Constructors

public HmacSHA1 ()

Standard constructor, creates a new HmacSHA1 instance. Verify the SunJCE provider in the constructor.

Throws
SecurityException if fails to verify its own integrity
NoSuchAlgorithmException

Public Methods

public Object clone ()

Returns a clone if the implementation is cloneable.

Returns
  • a clone if the implementation is cloneable.

Protected Methods

protected byte[] engineDoFinal ()

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.

protected int engineGetMacLength ()

Returns the length of the HMAC in bytes.

Returns
  • the HMAC length in bytes.

protected void engineInit (Key key, AlgorithmParameterSpec params)

Initializes the HMAC with the given secret key and algorithm parameters.

Parameters
key the secret key.
params the algorithm parameters.
Throws
InvalidKeyException if the given key is inappropriate for initializing this MAC.
InvalidAlgorithmParameterException if the given algorithm parameters are inappropriate for this MAC.

protected void engineReset ()

Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.

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.

protected void engineUpdate (byte input)

Processes the given byte.

Parameters
input the input byte to be processed.

protected void engineUpdate (ByteBuffer input)

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position(). Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

Subclasses should consider overriding this method if they can process ByteBuffers more efficiently than byte arrays.

Parameters
input the ByteBuffer