SignatureHelper

class SignatureHelper(val alias: String, val requireBiometricAuth: Boolean = false, val dsaAlgorithm: DsaAlgorithm = DsaAlgorithms.SHA384_WITH_ECDSA, val keyPairProvider: String = "AndroidKeyStore")

SignatureHelper provides utility methods to generate and manage key pairs in the Android KeyStore. This class supports generating hardware-backed key pairs, signing data, verifying signatures, and managing KeyStore entries.

Parameters

alias

The alias of the key entry in the KeyStore.

requireBiometricAuth

Indicates if strong biometric authentication is required for accessing the key.

dsaAlgorithm

The algorithm to be used for signing data. Default is DsaAlgorithms.SHA384_WITH_ECDSA.

keyPairProvider

The provider for the KeyStore. Default is "AndroidKeyStore".

Constructors

Link copied to clipboard
constructor(alias: String, requireBiometricAuth: Boolean = false, dsaAlgorithm: DsaAlgorithm = DsaAlgorithms.SHA384_WITH_ECDSA, keyPairProvider: String = "AndroidKeyStore")

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Deletes the key entry with the specified alias from the KeyStore.

Link copied to clipboard
fun exists(): Boolean?

Checks if a key entry with the specified alias exists in the KeyStore.

Link copied to clipboard

Generates and returns key pair and if the pair is inside secure hardware or returns null and removes the entry if the key pair isn't hardware backed or any error is occurred.

Link copied to clipboard

Generates a key pair.

Link copied to clipboard

Encodes the public key of the given key pair to a Base64 string.

Link copied to clipboard

Converts a Base64 encoded public key string to a PublicKey object.

Link copied to clipboard

Signs the given data using the private key associated with the specified alias, returns null if an error occurs. If biometric authentication is required, it must be performed before signing the data.

Link copied to clipboard
fun verifyData(publicKey: PublicKey, data: String, signature: String): Boolean
fun verifyData(publicKey: String, data: String, signature: String): Boolean

Verifies the given signature using the provided public key and data.