> For the complete documentation index, see [llms.txt](https://docs.inji.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inji.io/inji-wallet/inji-mobile/technical-overview/integration-guide/building-verifiable-credentials-wallet-with-inji-libraries/secure-keystore.md).

# Secure Keystore Library

Secure Keystore is a cross-platform cryptographic key management library for **Android** and **iOS**, supporting secure key generation, encryption/decryption, HMAC, and digital signatures using native platform security features (Android Keystore and iOS Keychain/Secure Enclave).

### Platforms Supported

* Android 6.0+ (Hardware-backed keystore)
* iOS 13.0+ (Secure Enclave + Keychain)

### Artifacts

* Maven Snapshots are available [here](https://central.sonatype.com/artifact/io.mosip/secure-keystore)

### Installation

#### iOS (Swift)

Using Swift Package Manager:

1. Open Xcode
2. Go to `File > Swift Packages > Add Package Dependency`
3. Use the URL: <https://github.com/mosip/secure-keystore-ios-swift.git>

#### Android (Kotlin)

Add the following in your `settings.gradle.kts`:

```kotlin
dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
  }
}
```

In `build.gradle.kts`:

```kotlin
dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    maven("https://oss.sonatype.org/content/repositories/snapshots/")
  }
}

---


## 📘 API Documentation

- `deviceSupportsHardware() => boolean`  
   Checks if the device supports secure hardware-backed keystore.

- `generateKey(alias, isAuthRequired, authTimeout?)`  
   Generates a symmetric key for encryption/decryption with optional biometric auth.

- `generateKeyPair(type, alias, isAuthRequired, authTimeout?)`  
   Creates a public-private key pair (RSA or EC) with optional authentication.

- `encryptData(alias, data, onSuccess, onFailure)`  
   Encrypts data using a symmetric key associated with the given alias.

- `decryptData(alias, encryptedText, onSuccess, onFailure)`  
   Decrypts previously encrypted data using the associated key alias.

- `sign(signAlgorithm, alias, data, onSuccess, onFailure)`  
   Signs data using the specified key and signature algorithm (RSA, ECDSA are supported).

- `generateHmacSha(alias, data, onSuccess, onFailure)`  
   Generates an HMAC signature using the specified alias and data.

- `generateHmacSha256Key(alias)`  
   Creates a symmetric key suitable for HMAC-SHA256 operations.

- `hasAlias(alias) => boolean`  
   Checks if a key exists for the specified alias.

- `removeKey(alias)`  
   Deletes the key associated with the given alias from the keystore.

- `removeAllKeys()`  
   Clears all keys stored in the keystore.

- `retrieveKey(alias)`  
   Retrieves the public key for the specified alias.

- `storeGenericKey(publicKey, privateKey, account)`  
   Stores a custom key pair in the keychain/keystore linked to an account.

- `retrieveGenericKey(account)`  
   Retrieves the stored key pair associated with the specified account.
---
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.inji.io/inji-wallet/inji-mobile/technical-overview/integration-guide/building-verifiable-credentials-wallet-with-inji-libraries/secure-keystore.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
