class 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 types

Builder for generating a MasterKey.

Algorithm/Cipher choices used for the master key.

Constants

const Int

The default and recommended size for the master key.

const String!
DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_"

The default master key alias.

Public functions

java-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

Constants

DEFAULT_AES_GCM_MASTER_KEY_SIZE

Added in 1.1.0-alpha07
const val DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256: Int

The default and recommended size for the master key.

DEFAULT_MASTER_KEY_ALIAS

Added in 1.1.0-alpha07
const val DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_": String!

The default master key alias.

Public functions

getDefaultAuthenticationValidityDurationSeconds

Added in 1.1.0-alpha07
java-static fun getDefaultAuthenticationValidityDurationSeconds(): Int

The default validity period for authentication in seconds.

getUserAuthenticationValidityDurationSeconds

Added in 1.1.0-alpha07
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.

Returns
Int

The duration the key is unlocked for in seconds.

isKeyStoreBacked

Added in 1.1.0-alpha07
fun isKeyStoreBacked(): Boolean

Checks if this key is backed by the Android Keystore.

Returns
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).

isStrongBoxBacked

Added in 1.1.0-alpha07
fun isStrongBoxBacked(): Boolean

Gets whether the key is backed by strong box.

isUserAuthenticationRequired

Added in 1.1.0-alpha07
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

fun toString(): String