MasterKeys

@RequiresApi(value = Build.VERSION_CODES.M)
public final class MasterKeys


Convenient methods to create and obtain master keys in Android Keystore.

The master keys are used to encrypt data encryption keys for encrypting files and preferences.

Summary

Constants

static final @NonNull KeyGenParameterSpec

Public methods

static @NonNull String
getOrCreate(@NonNull KeyGenParameterSpec keyGenParameterSpec)

Creates or gets the master key provided

Constants

AES256_GCM_SPEC

Added in 1.0.0
Deprecated in 1.1.0-alpha07
public static final @NonNull KeyGenParameterSpec AES256_GCM_SPEC

Public methods

getOrCreate

Added in 1.0.0
Deprecated in 1.1.0-alpha07
public static @NonNull String getOrCreate(@NonNull KeyGenParameterSpec keyGenParameterSpec)

Creates or gets the master key provided

The encryption scheme is required fields to ensure that the type of encryption used is clear to developers.

Parameters
@NonNull KeyGenParameterSpec keyGenParameterSpec

The key encryption scheme

Returns
@NonNull String

The key alias for the master key