to top
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 ()

Added in API level 19

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

public Context getContext ()

Added in API level 18

Gets the Android context used for operations with this instance.

public Date getEndDate ()

Added in API level 18

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

public int getKeySize ()

Added in API level 19

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 ()

Added in API level 19

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

public String getKeystoreAlias ()

Added in API level 18

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

public BigInteger getSerialNumber ()

Added in API level 18

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

public Date getStartDate ()

Added in API level 18

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

public X500Principal getSubjectDN ()

Added in API level 18

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

public boolean isEncryptionRequired ()

Added in API level 18

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