Google berkomitmen untuk mendorong terwujudnya keadilan ras bagi komunitas Kulit Hitam. Lihat caranya.

MasterKey

public final class MasterKey
extends Object

java.lang.Object
   ↳ 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

class MasterKey.Builder

Builder for generating a MasterKey

enum MasterKey.KeyScheme

Algorithm/Cipher choices used for the master key. 

Constants

int DEFAULT_AES_GCM_MASTER_KEY_SIZE

The default and recommended size for the master key.

String DEFAULT_MASTER_KEY_ALIAS

The default master key alias.

Public methods

static int getDefaultAuthenticationValidityDurationSeconds()

The default validity period for authentication in seconds.

int getUserAuthenticationValidityDurationSeconds()

Gets the duration in seconds that the key is unlocked for following user authentication.

boolean isKeyStoreBacked()

Checks if this key is backed by the Android Keystore.

boolean isStrongBoxBacked()

Gets whether the key is backed by strong box.

boolean isUserAuthenticationRequired()

Gets whether user authentication is required to use this key.

String toString()

Inherited methods

Constants

DEFAULT_AES_GCM_MASTER_KEY_SIZE

public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE

The default and recommended size for the master key.

Constant Value: 256 (0x00000100)

DEFAULT_MASTER_KEY_ALIAS

public static final String DEFAULT_MASTER_KEY_ALIAS

The default master key alias.

Constant Value: "_androidx_security_master_key_"

Public methods

getDefaultAuthenticationValidityDurationSeconds

public static int getDefaultAuthenticationValidityDurationSeconds ()

The default validity period for authentication in seconds.

Returns
int

getUserAuthenticationValidityDurationSeconds

public int getUserAuthenticationValidityDurationSeconds ()

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

public boolean isKeyStoreBacked ()

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

public boolean isStrongBoxBacked ()

Gets whether the key is backed by strong box.

Returns
boolean

isUserAuthenticationRequired

public boolean isUserAuthenticationRequired ()

Gets whether user authentication is required to use this key. This method always returns false on Android L (API 21 + 22).

Returns
boolean

toString

public String toString ()

Returns
String