MasterKey.Builder

public static final class MasterKey.Builder
extends Object

java.lang.Object
   ↳ androidx.security.crypto.MasterKey.Builder


Builder for generating a MasterKey.

Summary

Public constructors

Builder(Context context)

Creates a builder for a MasterKey using the default alias of MasterKey.DEFAULT_MASTER_KEY_ALIAS.

Builder(Context context, String keyAlias)

Creates a builder for a MasterKey.

Public methods

MasterKey build()

Builds a MasterKey from this builder.

MasterKey.Builder setKeyGenParameterSpec(KeyGenParameterSpec keyGenParameterSpec)

Sets a custom KeyGenParameterSpec to use as the basis of the master key.

MasterKey.Builder setKeyScheme(MasterKey.KeyScheme keyScheme)

Sets a MasterKey.KeyScheme to be used for the master key.

MasterKey.Builder setRequestStrongBoxBacked(boolean requestStrongBoxBacked)

Sets whether or not to request this key is strong box backed.

MasterKey.Builder setUserAuthenticationRequired(boolean authenticationRequired)

When used with setKeyScheme(KeyScheme), sets that the built master key should require the user to authenticate before it's unlocked, probably using the androidx.biometric library.

MasterKey.Builder setUserAuthenticationRequired(boolean authenticationRequired, int userAuthenticationValidityDurationSeconds)

When used with setKeyScheme(KeyScheme), sets that the built master key should require the user to authenticate before it's unlocked, probably using the androidx.biometric library, and that the key should remain unlocked for the provided duration.

Inherited methods