APIdia Launch Partner
Top Description Constructors Methods
javax.crypto

public abstract Class MacSpi

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.crypto.provider.HmacCore, com.sun.crypto.provider.SslMacCore.SslMacMD5, com.sun.crypto.provider.SslMacCore.SslMacSHA1
Imports
java.security.*, java.security.spec.*, java.nio.ByteBuffer

This class defines the Service Provider Interface (SPI) for the Mac class. All the abstract methods in this class must be implemented by each cryptographic service provider who wishes to supply the implementation of a particular MAC algorithm.

Implementations are free to implement the Cloneable interface.

Author
Jan Luehe
Since
1.4

Constructor Summary

AccessConstructor and Description
public
MacSpi()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a clone if the implementation is cloneable.
clone
()

Overrides java.lang.Object.clone.

Returns a clone if the implementation is cloneable.

protected abstract byte[]

Returns:

the MAC result.
engineDoFinal
()

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

protected abstract int

Returns:

the MAC length in bytes.
engineGetMacLength
()

Returns the length of the MAC in bytes.

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

Initializes the MAC with the given (secret) key and algorithm parameters.

protected abstract void
engineReset()

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

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

Processes the given byte.

protected abstract 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
)

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

protected void
engineUpdate(ByteBuffer
the ByteBuffer
input
)

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MacSpiback to summary
public MacSpi()

Constructor for subclasses to call.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Returns a clone if the implementation is cloneable.

Returns:Object

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 abstract byte[] engineDoFinal()

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

Returns:byte[]

the MAC result.

engineGetMacLengthback to summary
protected abstract int engineGetMacLength()

Returns the length of the MAC in bytes.

Returns:int

the MAC length in bytes.

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

Initializes the MAC 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 abstract void engineReset()

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

engineUpdateback to summary
protected abstract void engineUpdate(byte input)

Processes the given byte.

Parameters
input:byte

the input byte to be processed.

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

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

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)

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:ByteBuffer

the ByteBuffer

Exceptions
NullPointerException:
if input is null
Since
1.5