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/SecretKeyFactorySpi#pubctors) \| [Protected Methods](https://developer.android.com/reference/javax/crypto/SecretKeyFactorySpi#promethods) \| [Inherited Methods](https://developer.android.com/reference/javax/crypto/SecretKeyFactorySpi#inhmethods)

# SecretKeyFactorySpi


`
public


abstract
class
SecretKeyFactorySpi
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

This class defines the *Service Provider Interface* (**SPI** )
for the `SecretKeyFactory` class.
All the abstract methods in this class must be implemented by each
cryptographic service provider who wishes to supply the implementation
of a secret-key factory for a particular algorithm.

A provider should document all the key specifications supported by its
secret key factory.
For example, the DES secret-key factory supplied by the "SunJCE" provider
supports `DESKeySpec` as a transparent representation of DES
keys, and that provider's secret-key factory for Triple DES keys supports
`DESedeKeySpec` as a transparent representation of Triple DES
keys.
**See also:**

- `https://developer.android.com/reference/javax/crypto/SecretKey`
- `https://developer.android.com/reference/javax/crypto/spec/DESKeySpec`
- `https://developer.android.com/reference/javax/crypto/spec/DESedeKeySpec`

## Summary

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

| ### Protected methods ||
|---|---|
| ` abstract https://developer.android.com/reference/javax/crypto/SecretKey` | ` https://developer.android.com/reference/javax/crypto/SecretKeyFactorySpi#engineGenerateSecret(java.security.spec.KeySpec)(https://developer.android.com/reference/java/security/spec/KeySpec keySpec) ` Generates a `SecretKey` object from the provided key specification (key material). |
| ` abstract https://developer.android.com/reference/java/security/spec/KeySpec` | ` https://developer.android.com/reference/javax/crypto/SecretKeyFactorySpi#engineGetKeySpec(javax.crypto.SecretKey,%20java.lang.Class<?>)(https://developer.android.com/reference/javax/crypto/SecretKey key, https://developer.android.com/reference/java/lang/Class<?> keySpec) ` Returns a specification (key material) of the given key object in the requested format. |
| ` abstract https://developer.android.com/reference/javax/crypto/SecretKey` | ` https://developer.android.com/reference/javax/crypto/SecretKeyFactorySpi#engineTranslateKey(javax.crypto.SecretKey)(https://developer.android.com/reference/javax/crypto/SecretKey key) ` Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret-key factory. |

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

### SecretKeyFactorySpi

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

```
public SecretKeyFactorySpi ()
```

<br />

<br />

## Protected methods

### engineGenerateSecret

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

```
protected abstract SecretKey engineGenerateSecret (KeySpec keySpec)
```

Generates a `SecretKey` object from the
provided key specification (key material).

<br />

| Parameters ||
|---|---|
| `keySpec` | `KeySpec`: the specification (key material) of the secret key <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/crypto/SecretKey` | the secret key <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/spec/InvalidKeySpecException` | if the given key specification is inappropriate for this secret-key factory to produce a secret key. |

### engineGetKeySpec

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

```
protected abstract KeySpec engineGetKeySpec (SecretKey key, 
                Class<?> keySpec)
```

Returns a specification (key material) of the given key
object in the requested format.

<br />

| Parameters ||
|---|---|
| `key` | `SecretKey`: the key <br /> |
| `keySpec` | `Class`: the requested format in which the key material shall be returned <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/spec/KeySpec` | the underlying key specification (key material) in the requested format <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/spec/InvalidKeySpecException` | if the requested key specification is inappropriate for the given key (e.g., the algorithms associated with `key` and `keySpec` do not match, or `key` references a key on a cryptographic hardware device whereas `keySpec` is the specification of a software-based key), or the given key cannot be dealt with (e.g., the given key has an algorithm or format not supported by this secret-key factory). |

### engineTranslateKey

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

```
protected abstract SecretKey engineTranslateKey (SecretKey key)
```

Translates a key object, whose provider may be unknown or
potentially untrusted, into a corresponding key object of this
secret-key factory.

<br />

| Parameters ||
|---|---|
| `key` | `SecretKey`: the key whose provider is unknown or untrusted <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/crypto/SecretKey` | the translated key <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key cannot be processed by this secret-key factory. |