A React Native module to create and store keys in android hardware keystore and helps to do encryption, decryption, hmac calculation.
note: This library only supported for android.
npm install @mosip/secure-keystore
- for RSA based Key Pair
import SecureKeyStore from "@mosip/secure-keystore";
// ...
if(!SecureKeyStore.deviceSupportsHardware) {
return
}
const alias = "1234ab";
const data = "any data";
const publicKey = await SecureKeyStore.generateKeyPair(alias);
const signature = await SecureKeyStore.sign(alias, data)
- for symmetric key
import SecureKeyStore from "@mosip/secure-keystore";
// ...
if(!SecureKeyStore.deviceSupportsHardware) {
return
}
const alias = "1234ab";
const data = "any data";
await SecureKeyStore.generateKey(alias);
const encryptedData = await SecureKeyStore.encryptData(alias, data)
const decryptedData = await SecureKeyStore.decryptData(alias, encryptedData)
deviceSupportsHardware() => boolean
Check if the device supports hardware key store
generateKey(alias: string) => void
generates a symmetric key for encryption and decryption
generateKey(alias: string) => string
generates a asymmetric RSA key Pair for signing
encryptData(alias: string, data: string) => string
Encrypts the given data using the key that is assigned to the alias. Returns back encrypted data as a string
decryptData(alias: string, encryptionText: string) => string
Decrypts the given encryptionText using the key that is assigned to the alias. Returns back the data as a string
sign(alias: string, data: string) => string
Create a signature for the given data using the key that is assigned to the alias. Returns back the signature as a string
hasAlias(alias: string) => boolean
Check if the given alias is present in the key store
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library