Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#pubctors) \| [Protected Methods](https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#promethods) \| [Inherited Methods](https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#inhmethods)

# ExemptionMechanismSpi

` public abstract class ExemptionMechanismSpi `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.crypto.ExemptionMechanismSpi |

<br />

*** ** * ** ***

This class defines the *Service Provider Interface* (**SPI** ) for the `ExemptionMechanism` 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 exemption mechanism.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#ExemptionMechanismSpi()() ` |

| ### Protected methods ||
|---|---|
| ` abstract byte[]` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGenExemptionBlob()() ` Generates the exemption mechanism key blob. |
| ` abstract int` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGenExemptionBlob(byte[],%20int)(byte[] output, int outputOffset) ` Generates the exemption mechanism key blob, and stores the result in the `output` buffer, starting at `outputOffset` inclusive. |
| ` abstract int` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGetOutputSize(int)(int inputLen) ` Returns the length in bytes that an output buffer would need to be in order to hold the result of the next `https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGenExemptionBlob(byte[],%20int)` operation, given the input length `inputLen` (in bytes). |
| ` abstract void` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineInit(java.security.Key)(https://developer.android.com/reference/java/security/Key key) ` Initializes this exemption mechanism with a key. |
| ` abstract void` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineInit(java.security.Key,%20java.security.spec.AlgorithmParameterSpec)(https://developer.android.com/reference/java/security/Key key, https://developer.android.com/reference/java/security/spec/AlgorithmParameterSpec params) ` Initializes this exemption mechanism with a key and a set of algorithm parameters. |
| ` abstract void` | ` https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineInit(java.security.Key,%20java.security.AlgorithmParameters)(https://developer.android.com/reference/java/security/Key key, https://developer.android.com/reference/java/security/AlgorithmParameters params) ` Initializes this exemption mechanism with a key and a set of algorithm parameters. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### ExemptionMechanismSpi

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ExemptionMechanismSpi ()
```

<br />

<br />

## Protected methods

### engineGenExemptionBlob

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract byte[] engineGenExemptionBlob ()
```

Generates the exemption mechanism key blob.

<br />

| Returns ||
|---|---|
| `byte[]` | the new buffer with the result key blob. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/crypto/ExemptionMechanismException` | if problem(s) encountered in the process of generating. |

### engineGenExemptionBlob

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract int engineGenExemptionBlob (byte[] output, 
                int outputOffset)
```

Generates the exemption mechanism key blob, and stores the result in the `output` buffer, starting at `outputOffset` inclusive.

If the `output` buffer is too small to hold the result, a `ShortBufferException` is thrown. In this case, repeat this call with a larger output buffer. Use `https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGetOutputSize(int)` to determine how big the output buffer should be.

<br />

| Parameters ||
|---|---|
| `output` | `byte`: the buffer for the result <br /> |
| `outputOffset` | `int`: the offset in `output` where the result is stored <br /> |

| Returns ||
|---|---|
| `int` | the number of bytes stored in `output` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/crypto/ExemptionMechanismException` | if problem(s) encountered in the process of generating. |
| `https://developer.android.com/reference/javax/crypto/ShortBufferException` | if the given output buffer is too small to hold the result. |

### engineGetOutputSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract int engineGetOutputSize (int inputLen)
```

Returns the length in bytes that an output buffer would need to be in order to hold the result of the next `https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGenExemptionBlob(byte[],%20int)` operation, given the input length `inputLen` (in bytes).

The actual output length of the next `https://developer.android.com/reference/javax/crypto/ExemptionMechanismSpi#engineGenExemptionBlob(byte[],%20int)` call may be smaller than the length returned by this method.

<br />

| Parameters ||
|---|---|
| `inputLen` | `int`: the input length (in bytes) <br /> |

| Returns ||
|---|---|
| `int` | the required output buffer size (in bytes) <br /> |

### engineInit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract void engineInit (Key key)
```

Initializes this exemption mechanism with a key.

If this exemption mechanism requires any algorithm parameters that cannot be derived from the given `key`, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an `InvalidKeyException` is raised.

<br />

| Parameters ||
|---|---|
| `key` | `Key`: the key for this exemption mechanism <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key is inappropriate for this exemption mechanism. |
| `https://developer.android.com/reference/javax/crypto/ExemptionMechanismException` | if problem(s) encountered in the process of initializing. |

### engineInit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract void engineInit (Key key, 
                AlgorithmParameterSpec params)
```

Initializes this exemption mechanism with a key and a set of algorithm parameters.

If this exemption mechanism requires any algorithm parameters and `params` is null, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an `InvalidAlgorithmParameterException` is raised.

<br />

| Parameters ||
|---|---|
| `key` | `Key`: the key for this exemption mechanism <br /> |
| `params` | `AlgorithmParameterSpec`: the algorithm parameters <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException` | if the given algorithm parameters are inappropriate for this exemption mechanism. |
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key is inappropriate for this exemption mechanism. |
| `https://developer.android.com/reference/javax/crypto/ExemptionMechanismException` | if problem(s) encountered in the process of initializing. |

### engineInit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected abstract void engineInit (Key key, 
                AlgorithmParameters params)
```

Initializes this exemption mechanism with a key and a set of algorithm parameters.

If this exemption mechanism requires any algorithm parameters and `params` is null, the underlying exemption mechanism implementation is supposed to generate the required parameters itself (using provider-specific default values); in the case that algorithm parameters must be specified by the caller, an `InvalidAlgorithmParameterException` is raised.

<br />

| Parameters ||
|---|---|
| `key` | `Key`: the key for this exemption mechanism <br /> |
| `params` | `AlgorithmParameters`: the algorithm parameters <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException` | if the given algorithm parameters are inappropriate for this exemption mechanism. |
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key is inappropriate for this exemption mechanism. |
| `https://developer.android.com/reference/javax/crypto/ExemptionMechanismException` | if problem(s) encountered in the process of initializing. |