CryptoKey

class CryptoKey(keyId: String)

Manages cryptographic key operations using the Android KeyStore system.

This class provides a secure abstraction for creating, storing, and accessing RSA key pairs within the Android KeyStore. It handles key generation with configurable security parameters, automatic key aliasing through hashing, and secure key lifecycle management.

Key features:

  • Automatic key alias generation using SHA-256 hashing of the key ID

  • RSA 2048-bit key pairs with signing, encryption, and decryption capabilities

  • Integration with Android KeyStore for hardware-backed security

  • Support for multiple digest algorithms (SHA-256, SHA-384, SHA-512)

  • Certificate chain access for attestation purposes

  • Lazy initialization for performance optimization

The class is designed to work with Android's hardware security features when available, providing enhanced protection for cryptographic keys.

Parameters

keyId

The unique identifier used to generate the key alias through hashing

See also

Constructors

Link copied to clipboard
constructor(keyId: String)

Properties

Link copied to clipboard

The unique key alias generated from the key ID using SHA-256 hashing.

Link copied to clipboard
val timeout: Int = 5

The timeout value in seconds for cryptographic operations. Used for operations that may require user authentication.