MasterKey.Builder
class MasterKey.Builder
Builder for generating a MasterKey.
Summary
Public constructors |
|---|
|
Creates a builder for a |
|
Creates a builder for a |
Public functions |
|
|---|---|
MasterKey |
Builds a |
MasterKey.Builder |
@RequiresApi(value = Build.VERSION_CODES.M)Sets a custom |
MasterKey.Builder |
Sets a |
MasterKey.Builder |
Sets whether or not to request this key is strong box backed. |
MasterKey.Builder |
When used with |
MasterKey.Builder |
When used with |
Public constructors
Builder(context: Context)
Creates a builder for a MasterKey using the default alias of DEFAULT_MASTER_KEY_ALIAS.
| Parameters | |
|---|---|
context: Context |
The context to use with this master key. |
Public functions
@RequiresApi(value = Build.VERSION_CODES.M)
funsetKeyGenParameterSpec(keyGenParameterSpec: KeyGenParameterSpec): MasterKey.Builder
Sets a custom KeyGenParameterSpec to use as the basis of the master key. NOTE: Either this method OR setKeyScheme should be used to set the parameters to use for building the master key. Calling either function after the other will throw an IllegalArgumentException.
| Parameters | |
|---|---|
keyGenParameterSpec: KeyGenParameterSpec |
The key spec to use. |
| Returns | |
|---|---|
MasterKey.Builder |
This builder. |
funsetKeyScheme(keyScheme: MasterKey.KeyScheme): MasterKey.Builder
Sets a KeyScheme to be used for the master key.
This uses a default KeyGenParameterSpec associated with the provided KeyScheme.
NOTE: Either this method OR setKeyGenParameterSpec should be used to set the parameters to use for building the master key. Calling either function after the other will throw an IllegalArgumentException.
| Parameters | |
|---|---|
keyScheme: MasterKey.KeyScheme |
The KeyScheme to use. |
| Returns | |
|---|---|
MasterKey.Builder |
This builder. |
funsetRequestStrongBoxBacked(requestStrongBoxBacked: Boolean): MasterKey.Builder
Sets whether or not to request this key is strong box backed. This setting is only applicable on P and above, and only on devices that support Strongbox.
| Parameters | |
|---|---|
requestStrongBoxBacked: Boolean |
Whether to request to use strongbox |
| Returns | |
|---|---|
MasterKey.Builder |
This builder. |
funsetUserAuthenticationRequired(authenticationRequired: Boolean): MasterKey.Builder
When used with setKeyScheme, sets that the built master key should require the user to authenticate before it's unlocked, probably using the androidx.biometric library.
This method sets the validity duration of the key to getDefaultAuthenticationValidityDurationSeconds.
| Parameters | |
|---|---|
authenticationRequired: Boolean |
Whether user authentication should be required to use the key. |
| Returns | |
|---|---|
MasterKey.Builder |
This builder. |
funsetUserAuthenticationRequired(
authenticationRequired: Boolean,
userAuthenticationValidityDurationSeconds: @IntRange(from = 1) Int
): MasterKey.Builder
When used with setKeyScheme, 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.
| Parameters | |
|---|---|
authenticationRequired: Boolean |
Whether user authentication should be required to use the key. |
userAuthenticationValidityDurationSeconds: @IntRange(from = 1) Int |
Duration in seconds that the key should remain unlocked following user authentication. |
| Returns | |
|---|---|
MasterKey.Builder |
This builder. |