MasterKey
class MasterKey
kotlin.Any | |
↳ | androidx.security.crypto.MasterKey |
Wrapper for a master key used in the library. On Android M (API 23) and above, this is class references a key that's stored in the Android Keystore. On Android L (API 21, 22), there isn't a master key.
Summary
Nested classes | |
---|---|
Builder for generating a |
|
Algorithm/Cipher choices used for the master key. |
Constants | |
---|---|
static Int |
The default and recommended size for the master key. |
static String |
The default master key alias. |
Public methods | |
---|---|
static Int |
The default validity period for authentication in seconds. |
Int |
Gets the duration in seconds that the key is unlocked for following user authentication. |
Boolean |
Checks if this key is backed by the Android Keystore. |
Boolean |
Gets whether the key is backed by strong box. |
Boolean |
Gets whether user authentication is required to use this key. |
String |
toString() |
Constants
DEFAULT_AES_GCM_MASTER_KEY_SIZE
static val DEFAULT_AES_GCM_MASTER_KEY_SIZE: Int
The default and recommended size for the master key.
Value: 256
DEFAULT_MASTER_KEY_ALIAS
static val DEFAULT_MASTER_KEY_ALIAS: String
The default master key alias.
Value: "_androidx_security_master_key_"
Public methods
getDefaultAuthenticationValidityDurationSeconds
static fun getDefaultAuthenticationValidityDurationSeconds(): Int
The default validity period for authentication in seconds.
getUserAuthenticationValidityDurationSeconds
fun getUserAuthenticationValidityDurationSeconds(): Int
Gets the duration in seconds that the key is unlocked for following user authentication. The value returned for this method is only meaningful on Android M+ (API 23) when isUserAuthenticationRequired()
returns true
.
Return | |
---|---|
Int |
The duration the key is unlocked for in seconds. |
isKeyStoreBacked
fun isKeyStoreBacked(): Boolean
Checks if this key is backed by the Android Keystore.
Return | |
---|---|
Boolean |
true if the key is in Android Keystore, false otherwise. This method always returns false when called on Android Lollipop (API 21 and 22). |
isUserAuthenticationRequired
fun isUserAuthenticationRequired(): Boolean
Gets whether user authentication is required to use this key. This method always returns false
on Android L (API 21 + 22).
toString
@NonNull fun toString(): String