Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public final class

KeyPairGeneratorSpec

extends Object
implements AlgorithmParameterSpec
java.lang.Object
   ↳ android.security.KeyPairGeneratorSpec

Class Overview

This provides the required parameters needed for initializing the KeyPairGenerator that works with Android KeyStore facility . The Android KeyStore facility is accessed through a KeyPairGenerator API using the AndroidKeyStore provider. The context passed in may be used to pop up some UI to ask the user to unlock or initialize the Android KeyStore facility.

After generation, the keyStoreAlias is used with the getEntry(String, java.security.KeyStore.ProtectionParameter) interface to retrieve the PrivateKey and its associated Certificate chain.

The KeyPair generator will create a self-signed certificate with the subject as its X.509v3 Subject Distinguished Name and as its X.509v3 Issuer Distinguished Name along with the other parameters specified with the KeyPairGeneratorSpec.Builder .

The self-signed X.509 certificate may be replaced at a later time by a certificate signed by a real Certificate Authority.

Summary

Nested Classes
class KeyPairGeneratorSpec.Builder Builder class for KeyPairGeneratorSpec objects. 
Public Methods
AlgorithmParameterSpec getAlgorithmParameterSpec ()
Returns the AlgorithmParameterSpec that will be used for creation of the key pair.
Context getContext ()
Gets the Android context used for operations with this instance.
Date getEndDate ()
Gets the end date to be used on the X.509 certificate that will be put in the KeyStore .
int getKeySize ()
Returns the key size specified by this parameter.
String getKeyType ()
Returns the key type (e.g., "RSA", "DSA", "EC") specified by this parameter.
String getKeystoreAlias ()
Returns the alias that will be used in the java.security.KeyStore in conjunction with the AndroidKeyStore .
BigInteger getSerialNumber ()
Gets the serial number to be used on the X.509 certificate that will be put in the KeyStore .
Date getStartDate ()
Gets the start date to be used on the X.509 certificate that will be put in the KeyStore .
X500Principal getSubjectDN ()
Gets the subject distinguished name to be used on the X.509 certificate that will be put in the KeyStore .
boolean isEncryptionRequired ()
Returns true if this parameter will require generated keys to be encrypted in the KeyStore .
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public AlgorithmParameterSpec getAlgorithmParameterSpec ()

Returns the AlgorithmParameterSpec that will be used for creation of the key pair.

public Context getContext ()

Gets the Android context used for operations with this instance.

public Date getEndDate ()

Gets the end date to be used on the X.509 certificate that will be put in the KeyStore .

public int getKeySize ()

Returns the key size specified by this parameter. For instance, for RSA this will return the modulus size and for EC it will return the field size.

public String getKeyType ()

Returns the key type (e.g., "RSA", "DSA", "EC") specified by this parameter.

public String getKeystoreAlias ()

Returns the alias that will be used in the java.security.KeyStore in conjunction with the AndroidKeyStore .

public BigInteger getSerialNumber ()

Gets the serial number to be used on the X.509 certificate that will be put in the KeyStore .

public Date getStartDate ()

Gets the start date to be used on the X.509 certificate that will be put in the KeyStore .

public X500Principal getSubjectDN ()

Gets the subject distinguished name to be used on the X.509 certificate that will be put in the KeyStore .

public boolean isEncryptionRequired ()

Returns true if this parameter will require generated keys to be encrypted in the KeyStore .