# KeyPairGeneratorSpi

public abstract class **KeyPairGeneratorSpi** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  

|---|---|---|
| Known Direct Subclasses [KeyPairGenerator](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGenerator.html) |---|---| | [KeyPairGenerator](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGenerator.html) | The KeyPairGenerator class is used to generate pairs of public and private keys. | |||

<br />

This class defines the *Service Provider Interface* (**SPI** )
for the `KeyPairGenerator` class, which is used to generate
pairs of public and private keys.

All the abstract methods in this class must be implemented by each
cryptographic service provider who wishes to supply the implementation
of a key pair generator for a particular algorithm.

In case the client does not explicitly initialize the KeyPairGenerator
(via a call to an `initialize` method), each provider must
supply (and document) a default initialization.
For example, the *Sun* provider uses a default modulus size (keysize)
of 1024 bits.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGenerator.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html`

### Public Constructor Summary

|---|---|
|   | [KeyPairGeneratorSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGeneratorSpi.html#KeyPairGeneratorSpi())() |

### Public Method Summary

|---|---|
| abstract [KeyPair](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPair.html) | [generateKeyPair](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGeneratorSpi.html#generateKeyPair())() Generates a key pair. |
| void | [initialize](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGeneratorSpi.html#initialize(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 pair generator using the specified parameter set and user-provided source of randomness. |
| abstract void | [initialize](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGeneratorSpi.html#initialize(int,%20java.security.SecureRandom))(int keysize, [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) random) Initializes the key pair generator for a certain keysize, using the default parameter set. |

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

<br />

## Public Methods

#### public abstract [KeyPair](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPair.html)
**generateKeyPair**
()

Generates a key pair. Unless an initialization method is called
using a KeyPairGenerator interface, algorithm-specific defaults
will be used. This will generate a new key pair every time it
is called.

##### Returns

- the newly generated `KeyPair`

#### public void
**initialize**
([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 pair generator using the specified parameter
set and user-provided source of randomness.

This concrete method has been added to this previously-defined
abstract class. (For backwards compatibility, it cannot be abstract.)
It may be overridden by a provider to initialize the key pair
generator. Such an override
is expected to throw an InvalidAlgorithmParameterException if
a parameter is inappropriate for this key pair generator.
If this method is not overridden, it always throws an
UnsupportedOperationException.

##### Parameters

| params | the parameter set used to generate the keys. |
| random | the source of randomness for this generator. |
|---|---|

##### Throws

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

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

Initializes the key pair generator for a certain keysize, using
the default parameter set.

##### Parameters

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

##### Throws

| [InvalidParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidParameterException.html) | if the `keysize` is not supported by this KeyPairGeneratorSpi object. |
|---|---|