java.lang.Object
javax.crypto.MacSpi
com.ibm.crypto.hdwrCCA.provider.HmacSHA1
- All Implemented Interfaces:
Cloneable
This is an implementation of the HMAC-SHA1 algorithm.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
protected byte[]
computeHMACUsingCCA
(byte[] text, int length, com.ibm.crypto.hdwrCCA.provider.HmacSHA.Segment segment) This method computes a partial ( or full ) HMACE on a given piece of text with a particular key used to initialize this instance of the HMAC.protected byte[]
Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.protected int
Returns the length of the HMAC in bytes.protected void
engineInit
(Key key, AlgorithmParameterSpec params) Initializes the HMAC with the given secret key and algorithm parameters.protected void
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 firstlen
bytes ininput
, starting atoffset
.Methods inherited from class javax.crypto.MacSpi
engineUpdate
-
Constructor Details
-
HmacSHA1
Standard constructor, creates a new HmacSHA1 instance.- Throws:
SecurityException
- if fails to verify the JCE framework.NoSuchAlgorithmException
-
-
Method Details
-
engineGetMacLength
protected int engineGetMacLength()Returns the length of the HMAC in bytes.- Specified by:
engineGetMacLength
in classMacSpi
- Returns:
- the HMAC length in bytes.
-
engineInit
protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException Initializes the HMAC with the given secret key and algorithm parameters.- Specified by:
engineInit
in classMacSpi
- Parameters:
key
- the secret key, must be an instance ofSecretKey
params
- the algorithm parameters. This parameter is ignored- Throws:
InvalidKeyException
- if the given key is inappropriate for initializing this MAC.InvalidAlgorithmParameterException
- if the given algorithm parameters are inappropriate for this MAC. This should not occur, since theparams
parameter is currently ignored.
-
engineUpdate
protected void engineUpdate(byte input) Processes the given byte.- Specified by:
engineUpdate
in classMacSpi
- Parameters:
input
- the input byte to be processed.
-
engineUpdate
protected void engineUpdate(byte[] input, int offset, int len) Processes the firstlen
bytes ininput
, starting atoffset
.- Specified by:
engineUpdate
in classMacSpi
- Parameters:
input
- the input buffer.offset
- the offset ininput
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.- Specified by:
engineDoFinal
in classMacSpi
- Returns:
- the HMAC result.
-
engineReset
protected void engineReset()Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.- Specified by:
engineReset
in classMacSpi
-
clone
-
computeHMACUsingCCA
protected byte[] computeHMACUsingCCA(byte[] text, int length, com.ibm.crypto.hdwrCCA.provider.HmacSHA.Segment segment) This method computes a partial ( or full ) HMACE on a given piece of text with a particular key used to initialize this instance of the HMAC.- Parameters:
text
- The clear text you wish to perform a HMAC upon.length
- The length of clear text you wish to perform a HMAC upon.segment
- TheSegment
that you wish to use.
- Returns:
- A byte array containing the computed mac if the segment is LAST or ONLY. A null value will be returned otherwise.
-