# MacSpi

public abstract class **MacSpi** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
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.

### Public Constructor Summary

|---|---|
|   | [MacSpi](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#MacSpi())() |

### Public Method Summary

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#clone())() Returns a clone if the implementation is cloneable. |

### Protected Method Summary

|---|---|
| abstract byte\[\] | [engineDoFinal](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineDoFinal())() Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialized with. |
| abstract int | [engineGetMacLength](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineGetMacLength())() Returns the length of the MAC in bytes. |
| abstract void | [engineInit](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineInit(java.security.Key,%20java.security.spec.AlgorithmParameterSpec))([Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key, [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params) Initializes the MAC with the given (secret) key and algorithm parameters. |
| abstract void | [engineReset](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineReset())() Resets the MAC for further use, maintaining the secret key that the MAC was initialized with. |
| void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineUpdate(java.nio.ByteBuffer))([ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) input) Processes `input.remaining()` bytes in the ByteBuffer `input`, starting at `input.position()`. |
| abstract void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineUpdate(byte))(byte input) Processes the given byte. |
| abstract void | [engineUpdate](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/MacSpi.html#engineUpdate(byte[],%20int,%20int))(byte\[\] input, int offset, int len) Processes the first `len` bytes in `input`, starting at `offset` inclusive. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**MacSpi**
()

<br />

## Public Methods

#### public [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**clone**
()

Returns a clone if the implementation is cloneable.

##### Returns

- a clone if the implementation is cloneable.

##### Throws

| [CloneNotSupportedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CloneNotSupportedException.html) | if this is called on an implementation that does not support `Cloneable`. |
|---|---|

## Protected Methods

#### 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

- the MAC result.

#### protected abstract int
**engineGetMacLength**
()

Returns the length of the MAC in bytes.

##### Returns

- the MAC length in bytes.

#### protected abstract void
**engineInit**
([Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key, [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params)

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

##### Parameters

| key | the (secret) key. |
| params | the algorithm parameters. |
|---|---|

##### Throws

| [InvalidKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | if the given key is inappropriate for initializing this MAC. |
| [InvalidAlgorithmParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidAlgorithmParameterException.html) | if the given algorithm parameters are inappropriate for this MAC. |
|---|---|

#### protected abstract void
**engineReset**
()

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

#### protected void
**engineUpdate**
([ByteBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/ByteBuffer.html) 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 |
|---|---|

#### protected abstract void
**engineUpdate**
(byte input)

Processes the given byte.

##### Parameters

| input | the input byte to be processed. |
|---|---|

#### protected abstract void
**engineUpdate**
(byte\[\] input, int offset, int len)

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

##### Parameters

| input | the input buffer. |
| offset | the offset in `input` where the input starts. |
| len | the number of bytes to process. |
|---|---|