Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/security/KeyStoreSpi#pubctors) \| [Methods](https://developer.android.com/reference/java/security/KeyStoreSpi#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/security/KeyStoreSpi#inhmethods)

# KeyStoreSpi


`
public


abstract
class
KeyStoreSpi
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.security.KeyStoreSpi |

<br />

*** ** * ** ***

This class defines the *Service Provider Interface* (**SPI** )
for the `KeyStore` class.
All the abstract methods in this class must be implemented by each
cryptographic service provider who wishes to supply the implementation
of a keystore for a particular keystore type.
**See also:**

- `https://developer.android.com/reference/java/security/KeyStore`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/KeyStoreSpi#KeyStoreSpi()() ` |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/util/Enumeration<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineAliases()() ` Lists all the alias names of this keystore. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineContainsAlias(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Checks if the given alias exists in this keystore. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineDeleteEntry(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Deletes the entry identified by the given alias from this keystore. |
| ` boolean` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineEntryInstanceOf(java.lang.String,%20java.lang.Class<?%20extends%20java.security.KeyStore.Entry>)(https://developer.android.com/reference/java/lang/String alias, https://developer.android.com/reference/java/lang/Class<? extends https://developer.android.com/reference/java/security/KeyStore.Entry> entryClass) ` Determines if the keystore `Entry` for the specified `alias` is an instance or subclass of the specified `entryClass`. |
| ` abstract https://developer.android.com/reference/java/security/cert/Certificate` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetCertificate(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Returns the certificate associated with the given alias. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetCertificateAlias(java.security.cert.Certificate)(https://developer.android.com/reference/java/security/cert/Certificate cert) ` Returns the (alias) name of the first keystore entry whose certificate matches the given certificate. |
| ` abstract https://developer.android.com/reference/java/security/cert/Certificate` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetCertificateChain(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Returns the certificate chain associated with the given alias. |
| ` abstract https://developer.android.com/reference/java/util/Date` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetCreationDate(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Returns the creation date of the entry identified by the given alias. |
| ` https://developer.android.com/reference/java/security/KeyStore.Entry` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetEntry(java.lang.String,%20java.security.KeyStore.ProtectionParameter)(https://developer.android.com/reference/java/lang/String alias, https://developer.android.com/reference/java/security/KeyStore.ProtectionParameter protParam) ` Gets a `KeyStore.Entry` for the specified alias with the specified protection parameter. |
| ` abstract https://developer.android.com/reference/java/security/Key` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineGetKey(java.lang.String,%20char[])(https://developer.android.com/reference/java/lang/String alias, char[] password) ` Returns the key associated with the given alias, using the given password to recover it. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineIsCertificateEntry(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Returns true if the entry identified by the given alias was created by a call to `setCertificateEntry`, or created by a call to `setEntry` with a `TrustedCertificateEntry`. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineIsKeyEntry(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Returns true if the entry identified by the given alias was created by a call to `setKeyEntry`, or created by a call to `setEntry` with a `PrivateKeyEntry` or a `SecretKeyEntry`. |
| ` void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineLoad(java.security.KeyStore.LoadStoreParameter)(https://developer.android.com/reference/java/security/KeyStore.LoadStoreParameter param) ` Loads the keystore using the given `KeyStore.LoadStoreParameter`. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineLoad(java.io.InputStream,%20char[])(https://developer.android.com/reference/java/io/InputStream stream, char[] password) ` Loads the keystore from the given input stream. |
| ` boolean` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineProbe(java.io.InputStream)(https://developer.android.com/reference/java/io/InputStream stream) ` Probes the specified input stream to determine whether it contains a keystore that is supported by this implementation, or not. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineSetCertificateEntry(java.lang.String,%20java.security.cert.Certificate)(https://developer.android.com/reference/java/lang/String alias, https://developer.android.com/reference/java/security/cert/Certificate cert) ` Assigns the given certificate to the given alias. |
| ` void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineSetEntry(java.lang.String,%20java.security.KeyStore.Entry,%20java.security.KeyStore.ProtectionParameter)(https://developer.android.com/reference/java/lang/String alias, https://developer.android.com/reference/java/security/KeyStore.Entry entry, https://developer.android.com/reference/java/security/KeyStore.ProtectionParameter protParam) ` Saves a `KeyStore.Entry` under the specified alias. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineSetKeyEntry(java.lang.String,%20java.security.Key,%20char[],%20java.security.cert.Certificate[])(https://developer.android.com/reference/java/lang/String alias, https://developer.android.com/reference/java/security/Key key, char[] password, https://developer.android.com/reference/java/security/cert/Certificate chain) ` Assigns the given key to the given alias, protecting it with the given password. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineSetKeyEntry(java.lang.String,%20byte[],%20java.security.cert.Certificate[])(https://developer.android.com/reference/java/lang/String alias, byte[] key, https://developer.android.com/reference/java/security/cert/Certificate chain) ` Assigns the given key (that has already been protected) to the given alias. |
| ` abstract int` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineSize()() ` Retrieves the number of entries in this keystore. |
| ` void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineStore(java.security.KeyStore.LoadStoreParameter)(https://developer.android.com/reference/java/security/KeyStore.LoadStoreParameter param) ` Stores this keystore using the given `KeyStore.LoadStoreParmeter`. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/KeyStoreSpi#engineStore(java.io.OutputStream,%20char[])(https://developer.android.com/reference/java/io/OutputStream stream, char[] password) ` Stores this keystore to the given output stream, and protects its integrity with the given password. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### KeyStoreSpi

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public KeyStoreSpi ()
```

<br />

<br />

## Public methods

### engineAliases

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Enumeration<String> engineAliases ()
```

Lists all the alias names of this keystore.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Enumeration<https://developer.android.com/reference/java/lang/String>` | enumeration of the alias names <br /> |

### engineContainsAlias

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean engineContainsAlias (String alias)
```

Checks if the given alias exists in this keystore.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |

| Returns ||
|---|---|
| `boolean` | true if the alias exists, false otherwise <br /> |

### engineDeleteEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineDeleteEntry (String alias)
```

Deletes the entry identified by the given alias from this keystore.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if the entry cannot be removed. |

### engineEntryInstanceOf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean engineEntryInstanceOf (String alias, 
                Class<? extends KeyStore.Entry> entryClass)
```

Determines if the keystore `Entry` for the specified
`alias` is an instance or subclass of the specified
`entryClass`.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |
| `entryClass` | `Class`: the entry class <br /> |

| Returns ||
|---|---|
| `boolean` | true if the keystore `Entry` for the specified `alias` is an instance or subclass of the specified `entryClass`, false otherwise <br /> |

### engineGetCertificate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Certificate engineGetCertificate (String alias)
```

Returns the certificate associated with the given alias.

If the given alias name identifies an entry
created by a call to `setCertificateEntry`,
or created by a call to `setEntry` with a
`TrustedCertificateEntry`,
then the trusted certificate contained in that entry is returned.

If the given alias name identifies an entry
created by a call to `setKeyEntry`,
or created by a call to `setEntry` with a
`PrivateKeyEntry`,
then the first element of the certificate chain in that entry
(if a chain exists) is returned.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/Certificate` | the certificate, or null if the given alias does not exist or does not contain a certificate. <br /> |

### engineGetCertificateAlias

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String engineGetCertificateAlias (Certificate cert)
```

Returns the (alias) name of the first keystore entry whose certificate
matches the given certificate.

This method attempts to match the given certificate with each
keystore entry. If the entry being considered was
created by a call to `setCertificateEntry`,
or created by a call to `setEntry` with a
`TrustedCertificateEntry`,
then the given certificate is compared to that entry's certificate.

If the entry being considered was
created by a call to `setKeyEntry`,
or created by a call to `setEntry` with a
`PrivateKeyEntry`,
then the given certificate is compared to the first
element of that entry's certificate chain.

<br />

| Parameters ||
|---|---|
| `cert` | `Certificate`: the certificate to match with. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the alias name of the first entry with matching certificate, or null if no such entry exists in this keystore. <br /> |

### engineGetCertificateChain

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Certificate[] engineGetCertificateChain (String alias)
```

Returns the certificate chain associated with the given alias.
The certificate chain must have been associated with the alias
by a call to `setKeyEntry`,
or by a call to `setEntry` with a
`PrivateKeyEntry`.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/Certificate` | the certificate chain (ordered with the user's certificate first and the root certificate authority last), or null if the given alias does not exist or does not contain a certificate chain <br /> |

### engineGetCreationDate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Date engineGetCreationDate (String alias)
```

Returns the creation date of the entry identified by the given alias.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Date` | the creation date of this entry, or null if the given alias does not exist <br /> |

### engineGetEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public KeyStore.Entry engineGetEntry (String alias, 
                KeyStore.ProtectionParameter protParam)
```

Gets a `KeyStore.Entry` for the specified alias
with the specified protection parameter.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: get the `KeyStore.Entry` for this alias <br /> |
| `protParam` | `KeyStore.ProtectionParameter`: the `ProtectionParameter` used to protect the `Entry`, which may be `null` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStore.Entry` | the `KeyStore.Entry` for the specified alias, or `null` if there is no such entry <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if the operation failed |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the algorithm for recovering the entry cannot be found |
| `https://developer.android.com/reference/java/security/UnrecoverableEntryException` | if the specified `protParam` were insufficient or invalid |
| `https://developer.android.com/reference/java/security/UnrecoverableKeyException` | if the entry is a `PrivateKeyEntry` or `SecretKeyEntry` and the specified `protParam` does not contain the information needed to recover the key (e.g. wrong password) |

### engineGetKey

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Key engineGetKey (String alias, 
                char[] password)
```

Returns the key associated with the given alias, using the given
password to recover it. The key must have been associated with
the alias by a call to `setKeyEntry`,
or by a call to `setEntry` with a
`PrivateKeyEntry` or `SecretKeyEntry`.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |
| `password` | `char`: the password for recovering the key <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Key` | the requested key, or null if the given alias does not exist or does not identify a key-related entry. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the algorithm for recovering the key cannot be found |
| `https://developer.android.com/reference/java/security/UnrecoverableKeyException` | if the key cannot be recovered (e.g., the given password is wrong). |

### engineIsCertificateEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean engineIsCertificateEntry (String alias)
```

Returns true if the entry identified by the given alias
was created by a call to `setCertificateEntry`,
or created by a call to `setEntry` with a
`TrustedCertificateEntry`.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias for the keystore entry to be checked <br /> |

| Returns ||
|---|---|
| `boolean` | true if the entry identified by the given alias contains a trusted certificate, false otherwise. <br /> |

### engineIsKeyEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean engineIsKeyEntry (String alias)
```

Returns true if the entry identified by the given alias
was created by a call to `setKeyEntry`,
or created by a call to `setEntry` with a
`PrivateKeyEntry` or a `SecretKeyEntry`.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias for the keystore entry to be checked <br /> |

| Returns ||
|---|---|
| `boolean` | true if the entry identified by the given alias is a key-related, false otherwise. <br /> |

### engineLoad

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void engineLoad (KeyStore.LoadStoreParameter param)
```

Loads the keystore using the given
`KeyStore.LoadStoreParameter`.

Note that if this KeyStore has already been loaded, it is
reinitialized and loaded again from the given parameter.

<br />

| Parameters ||
|---|---|
| `param` | `KeyStore.LoadStoreParameter`: the `KeyStore.LoadStoreParameter` that specifies how to load the keystore, which may be `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if there is an I/O or format problem with the keystore data. If the error is due to an incorrect `ProtectionParameter` (e.g. wrong password) the `https://developer.android.com/reference/java/lang/Throwable#getCause()` of the `IOException` should be an `UnrecoverableKeyException` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the given `KeyStore.LoadStoreParameter` input is not recognized |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the algorithm used to check the integrity of the keystore cannot be found |
| `https://developer.android.com/reference/java/security/cert/CertificateException` | if any of the certificates in the keystore could not be loaded |

### engineLoad

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineLoad (InputStream stream, 
                char[] password)
```

Loads the keystore from the given input stream.

A password may be given to unlock the keystore
(e.g. the keystore resides on a hardware token device),
or to check the integrity of the keystore data.
If a password is not given for integrity checking,
then integrity checking is not performed.

<br />

| Parameters ||
|---|---|
| `stream` | `InputStream`: the input stream from which the keystore is loaded, or `null` <br /> |
| `password` | `char`: the password used to check the integrity of the keystore, the password used to unlock the keystore, or `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the `https://developer.android.com/reference/java/lang/Throwable#getCause()` of the `IOException` should be an `UnrecoverableKeyException` |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the algorithm used to check the integrity of the keystore cannot be found |
| `https://developer.android.com/reference/java/security/cert/CertificateException` | if any of the certificates in the keystore could not be loaded |

### engineProbe

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean engineProbe (InputStream stream)
```

Probes the specified input stream to determine whether it contains a
keystore that is supported by this implementation, or not.

<br />

##### Implementation Requirements:

- This method returns false by default. Keystore implementations should override this method to peek at the data stream directly or to use other content detection mechanisms.

| Parameters ||
|---|---|
| `stream` | `InputStream`: the keystore data to be probed <br /> |

| Returns ||
|---|---|
| `boolean` | true if the keystore data is supported, otherwise false <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if there is an I/O problem with the keystore data. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if stream is `null`. |

### engineSetCertificateEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineSetCertificateEntry (String alias, 
                Certificate cert)
```

Assigns the given certificate to the given alias.

If the given alias identifies an existing entry
created by a call to `setCertificateEntry`,
or created by a call to `setEntry` with a
`TrustedCertificateEntry`,
the trusted certificate in the existing entry
is overridden by the given certificate.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |
| `cert` | `Certificate`: the certificate <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if the given alias already exists and does not identify an entry containing a trusted certificate, or this operation fails for some other reason. |

### engineSetEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void engineSetEntry (String alias, 
                KeyStore.Entry entry, 
                KeyStore.ProtectionParameter protParam)
```

Saves a `KeyStore.Entry` under the specified alias.
The specified protection parameter is used to protect the
`Entry`.

If an entry already exists for the specified alias,
it is overridden.

<br />

| Parameters ||
|---|---|
| `alias` | `String`: save the `KeyStore.Entry` under this alias <br /> |
| `entry` | `KeyStore.Entry`: the `Entry` to save <br /> |
| `protParam` | `KeyStore.ProtectionParameter`: the `ProtectionParameter` used to protect the `Entry`, which may be `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if this operation fails |

### engineSetKeyEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineSetKeyEntry (String alias, 
                Key key, 
                char[] password, 
                Certificate[] chain)
```

Assigns the given key to the given alias, protecting it with the given
password.

If the given key is of type `java.security.PrivateKey`,
it must be accompanied by a certificate chain certifying the
corresponding public key.

If the given alias already exists, the keystore information
associated with it is overridden by the given key (and possibly
certificate chain).

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |
| `key` | `Key`: the key to be associated with the alias <br /> |
| `password` | `char`: the password to protect the key <br /> |
| `chain` | `Certificate`: the certificate chain for the corresponding public key (only required if the given key is of type `java.security.PrivateKey`). <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if the given key cannot be protected, or this operation fails for some other reason |

### engineSetKeyEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineSetKeyEntry (String alias, 
                byte[] key, 
                Certificate[] chain)
```

Assigns the given key (that has already been protected) to the given
alias.

If the protected key is of type
`java.security.PrivateKey`,
it must be accompanied by a certificate chain certifying the
corresponding public key.

If the given alias already exists, the keystore information
associated with it is overridden by the given key (and possibly
certificate chain).

<br />

| Parameters ||
|---|---|
| `alias` | `String`: the alias name <br /> |
| `key` | `byte`: the key (in protected format) to be associated with the alias <br /> |
| `chain` | `Certificate`: the certificate chain for the corresponding public key (only useful if the protected key is of type `java.security.PrivateKey`). <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyStoreException` | if this operation fails. |

### engineSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int engineSize ()
```

Retrieves the number of entries in this keystore.

<br />

| Returns ||
|---|---|
| `int` | the number of entries in this keystore <br /> |

### engineStore

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void engineStore (KeyStore.LoadStoreParameter param)
```

Stores this keystore using the given
`KeyStore.LoadStoreParmeter`.

<br />

| Parameters ||
|---|---|
| `param` | `KeyStore.LoadStoreParameter`: the `KeyStore.LoadStoreParmeter` that specifies how to store the keystore, which may be `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if there was an I/O problem with data |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the given `KeyStore.LoadStoreParmeter` input is not recognized |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the appropriate data integrity algorithm could not be found |
| `https://developer.android.com/reference/java/security/cert/CertificateException` | if any of the certificates included in the keystore data could not be stored |

### engineStore

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void engineStore (OutputStream stream, 
                char[] password)
```

Stores this keystore to the given output stream, and protects its
integrity with the given password.

<br />

| Parameters ||
|---|---|
| `stream` | `OutputStream`: the output stream to which this keystore is written. <br /> |
| `password` | `char`: the password to generate the keystore integrity check <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if there was an I/O problem with data |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if the appropriate data integrity algorithm could not be found |
| `https://developer.android.com/reference/java/security/cert/CertificateException` | if any of the certificates included in the keystore data could not be stored |