APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.crypto.provider

pack-priv abstract Class HmacCore

extends MacSpi
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
com.sun.crypto.provider.HmacCore.HmacSHA224, com.sun.crypto.provider.HmacCore.HmacSHA256, com.sun.crypto.provider.HmacCore.HmacSHA384, com.sun.crypto.provider.HmacCore.HmacSHA512, com.sun.crypto.provider.HmacCore.HmacSHA512_224, com.sun.crypto.provider.HmacCore.HmacSHA512_256, com.sun.crypto.provider.HmacCore.HmacSHA3_224, com.sun.crypto.provider.HmacCore.HmacSHA3_256, com.sun.crypto.provider.HmacCore.HmacSHA3_384, com.sun.crypto.provider.HmacCore.HmacSHA3_512, com.sun.crypto.provider.HmacMD5, com.sun.crypto.provider.HmacPKCS12PBECore, com.sun.crypto.provider.HmacSHA1, com.sun.crypto.provider.PBMAC1Core
Imports
java.nio.ByteBuffer, java.security.*, java.security.spec.AlgorithmParameterSpec, java.util.Arrays, javax.crypto.MacSpi, .SecretKey

This class constitutes the core of HMAC-<MD> algorithms, where <MD> is the digest algorithm used by HMAC as in RFC 2104 "HMAC: Keyed-Hashing for Message Authentication". It also contains implementation classes for: - HmacMD5 - HmacSHA1 - HMAC with SHA-2 family of digests, i.e. HmacSHA224, HmacSHA256, HmacSHA384, HmacSHA512, HmacSHA512/224, HmacSHA512/256, and - HMAC with SHA-3 family of digests, i.e. HmacSHA3-224, HmacSHA3-256, HmacSHA3-384, HmacSHA3-512
Author
Jan Luehe

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private final int
private boolean
private byte[]
private byte[]
private MessageDigest

Constructor Summary

AccessConstructor and Description
pack-priv
HmacCore(String digestAlgo, int bl)

Standard constructor, creates a new HmacCore instance instantiating a MessageDigest of the specified name.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides javax.crypto.MacSpi.clone.

Returns a clone if the implementation is cloneable.

protected byte[]

Returns:

the HMAC result.
engineDoFinal
()

Implements abstract javax.crypto.MacSpi.engineDoFinal.

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 HMAC length in bytes.
engineGetMacLength
()

Implements abstract javax.crypto.MacSpi.engineGetMacLength.

Returns the length of the HMAC in bytes.

protected void
engineInit(Key
the secret key.
key
,
AlgorithmParameterSpec
the algorithm parameters.
params
)

Implements abstract javax.crypto.MacSpi.engineInit.

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

protected void
engineReset()

Implements abstract javax.crypto.MacSpi.engineReset.

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

protected void
engineUpdate(byte
the input byte to be processed.
input
)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

protected void
engineUpdate(byte[]
the input buffer.
input
,
int
the offset in input where the input starts.
offset
,
int
the number of bytes to process.
len
)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the first len bytes in input, starting at offset.

protected void
engineUpdate(ByteBuffer
the input byte buffer.
input
)

Overrides javax.crypto.MacSpi.engineUpdate.

Processes the input.remaining() bytes in the ByteBuffer input.

Field Detail

blockLenback to summary
private final int blockLen
firstback to summary
private boolean first
k_ipadback to summary
private byte[] k_ipad
k_opadback to summary
private byte[] k_opad
mdback to summary
private MessageDigest md

Constructor Detail

HmacCoreback to summary
pack-priv HmacCore(String digestAlgo, int bl) throws NoSuchAlgorithmException

Standard constructor, creates a new HmacCore instance instantiating a MessageDigest of the specified name.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides javax.crypto.MacSpi.clone.

Doc from javax.crypto.MacSpi.clone.

Returns a clone if the implementation is cloneable.

Exceptions
CloneNotSupportedException:
if this is called on an implementation that does not support Cloneable.
engineDoFinalback to summary
protected byte[] engineDoFinal()

Implements abstract javax.crypto.MacSpi.engineDoFinal.

Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.

Returns:byte[]

the HMAC result.

engineGetMacLengthback to summary
protected int engineGetMacLength()

Implements abstract javax.crypto.MacSpi.engineGetMacLength.

Returns the length of the HMAC in bytes.

Returns:int

the HMAC length in bytes.

engineInitback to summary
protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.MacSpi.engineInit.

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

Parameters
key:Key

the secret key.

params:AlgorithmParameterSpec

the algorithm parameters.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this MAC.
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this MAC.
engineResetback to summary
protected void engineReset()

Implements abstract javax.crypto.MacSpi.engineReset.

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

engineUpdateback to summary
protected void engineUpdate(byte input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

Parameters
input:byte

the input byte to be processed.

engineUpdateback to summary
protected void engineUpdate(byte[] input, int offset, int len)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the first len bytes in input, starting at offset.

Parameters
input:byte[]

the input buffer.

offset:int

the offset in input where the input starts.

len:int

the number of bytes to process.

engineUpdateback to summary
protected void engineUpdate(ByteBuffer input)

Overrides javax.crypto.MacSpi.engineUpdate.

Processes the input.remaining() bytes in the ByteBuffer input.

Parameters
input:ByteBuffer

the input byte buffer.

com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA224

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA224back to summary
public HmacSHA224() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA256

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA256back to summary
public HmacSHA256() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA384

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA384back to summary
public HmacSHA384() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA3_224

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA3_224back to summary
public HmacSHA3_224() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA3_256

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA3_256back to summary
public HmacSHA3_256() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA3_384

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA3_384back to summary
public HmacSHA3_384() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA3_512

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA3_512back to summary
public HmacSHA3_512() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA512

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA512back to summary
public HmacSHA512() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA512_224

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA512_224back to summary
public HmacSHA512_224() throws NoSuchAlgorithmException
com.sun.crypto.provider back to summary

public final Class HmacCore.HmacSHA512_256

extends HmacCore
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from com.sun.crypto.provider.HmacCore:
cloneengineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA512_256back to summary
public HmacSHA512_256() throws NoSuchAlgorithmException