FileDocCategorySizeDatePackage
MacSpi.javaAPI DocAndroid 1.5 API5150Wed May 06 22:41:02 BST 2009javax.crypto

MacSpi

public abstract class MacSpi extends Object
The Service-Provider Interface (SPI) definition for the {@code Mac} class.
see
Mac
since
Android 1.0

Fields Summary
Constructors Summary
public MacSpi()
Creates a new {@code MacSpi} instance.

since
Android 1.0

    
Methods Summary
public java.lang.Objectclone()
Clones this {@code MacSpi} instance.

return
the cloned instance.
throws
CloneNotSupportedException if cloning is not supported.
since
Android 1.0

        return super.clone();
    
protected abstract byte[]engineDoFinal()
Computes the digest of this MAC based on the data previously specified in {@link #engineUpdate} calls.

This {@code MacSpi} instance is reverted to its initial state and can be used to start the next MAC computation with the same parameters or initialized with different parameters.

return
the generated digest.
since
Android 1.0

protected abstract intengineGetMacLength()
Returns the length of this MAC (in bytes).

return
the length of this MAC (in bytes).
since
Android 1.0

protected abstract voidengineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
Initializes this {@code MacSpi} instance with the specified key and algorithm parameters.

param
key the key to initialize this algorithm.
param
params the parameters for this algorithm.
throws
InvalidKeyException if the specified key cannot be used to initialize this algorithm, or it is {@code null}.
throws
InvalidAlgorithmParameterException if the specified parameters cannot be used to initialize this algorithm.
since
Android 1.0

protected abstract voidengineReset()
Resets this {@code MacSpi} instance to its initial state.

This {@code MacSpi} instance is reverted to its initial state and can be used to start the next MAC computation with the same parameters or initialized with different parameters.

since
Android 1.0

protected abstract voidengineUpdate(byte input)
Updates this {@code MacSpi} instance with the specified byte.

param
input the byte.
since
Android 1.0

protected abstract voidengineUpdate(byte[] input, int offset, int len)
Updates this {@code MacSpi} instance with the data from the specified buffer {@code input} from the specified {@code offset} and length {@code len}.

param
input the buffer.
param
offset the offset in the buffer.
param
len the length of the data in the buffer.
since
Android 1.0

protected voidengineUpdate(java.nio.ByteBuffer input)
Updates this {@code MacSpi} instance with the data from the specified buffer, starting at {@link ByteBuffer#position()}, including the next {@link ByteBuffer#remaining()} bytes.

param
input the buffer.
since
Android 1.0

        if (!input.hasRemaining()) {
            return;
        }
        byte[] bInput;
        if (input.hasArray()) {
            bInput = input.array();
            int offset = input.arrayOffset();
            int position = input.position();
            int limit = input.limit();
            engineUpdate(bInput, offset + position, limit - position);
            input.position(limit);
        } else {
            bInput = new byte[input.limit() - input.position()];
            input.get(bInput);
            engineUpdate(bInput, 0, bInput.length);
        }