# KeyGeneratorSpi

public abstract class **KeyGeneratorSpi** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
This class defines the *Service Provider Interface* (**SPI** )
for the `KeyGenerator` class.
All the abstract methods in this class must be implemented by each
cryptographic service provider who wishes to supply the implementation
of a key generator for a particular algorithm.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html`

### Public Constructor Summary

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

### Protected Method Summary

|---|---|
| abstract [SecretKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/SecretKey.html) | [engineGenerateKey](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/KeyGeneratorSpi.html#engineGenerateKey())() Generates a secret key. |
| abstract void | [engineInit](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/KeyGeneratorSpi.html#engineInit(java.security.spec.AlgorithmParameterSpec,%20java.security.SecureRandom))([AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) params, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initializes the key generator with the specified parameter set and a user-provided source of randomness. |
| abstract void | [engineInit](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/KeyGeneratorSpi.html#engineInit(java.security.SecureRandom))([SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initializes the key generator. |
| abstract void | [engineInit](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/KeyGeneratorSpi.html#engineInit(int,%20java.security.SecureRandom))(int keysize, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initializes this key generator for a certain keysize, using the given source of randomness. |

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

<br />

## Protected Methods

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

Generates a secret key.

##### Returns

- the new key

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

Initializes the key generator with the specified parameter
set and a user-provided source of randomness.

##### Parameters

| params | the key generation parameters |
| random | the source of randomness for this key generator |
|---|---|

##### Throws

| [InvalidAlgorithmParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidAlgorithmParameterException.html) | if `params` is inappropriate for this key generator |
|---|---|

#### protected abstract void
**engineInit**
([SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random)

Initializes the key generator.

##### Parameters

| random | the source of randomness for this generator |
|---|---|

#### protected abstract void
**engineInit**
(int keysize, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random)

Initializes this key generator for a certain keysize, using the given
source of randomness.

##### Parameters

| keysize | the keysize. This is an algorithm-specific metric, specified in number of bits. |
| random | the source of randomness for this key generator |
|---|---|

##### Throws

| [InvalidParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidParameterException.html) | if the keysize is wrong or not supported. |
|---|---|