# SecretKeyFactorySpi

public abstract class **SecretKeyFactorySpi** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
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://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/DESKeySpec.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/DESedeKeySpec.html`

### Public Constructor Summary

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

### Protected Method Summary

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

### 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
**SecretKeyFactorySpi**
()

<br />

## Protected Methods

#### protected abstract [SecretKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html)
**engineGenerateSecret**
([KeySpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/KeySpec.html) keySpec)

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

##### Parameters

| keySpec | the specification (key material) of the secret key |
|---|---|

##### Returns

- the secret key

##### Throws

| [InvalidKeySpecException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/InvalidKeySpecException.html) | if the given key specification is inappropriate for this secret-key factory to produce a secret key. |
|---|---|

#### protected abstract [KeySpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/KeySpec.html)
**engineGetKeySpec**
([SecretKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html) key, [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> keySpec)

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

##### Parameters

| key | the key |
| keySpec | the requested format in which the key material shall be returned |
|---|---|

##### Returns

- the underlying key specification (key material) in the requested format

##### Throws

| [InvalidKeySpecException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/InvalidKeySpecException.html) | 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). |
|---|---|

#### protected abstract [SecretKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html)
**engineTranslateKey**
([SecretKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html) key)

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

##### Parameters

| key | the key whose provider is unknown or untrusted |
|---|---|

##### Returns

- the translated key

##### Throws

| [InvalidKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | if the given key cannot be processed by this secret-key factory. |
|---|---|