public static final class Armadillo.Builder
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
android.content.SharedPreferences |
build()
Build a
SharedPreferences instance |
Armadillo.Builder |
contentKeyDigest(byte[] salt) |
Armadillo.Builder |
contentKeyDigest(int contentKeyOutLength) |
Armadillo.Builder |
contentKeyDigest(StringMessageDigest stringMessageDigest) |
Armadillo.Builder |
dataObfuscatorFactory(DataObfuscator.Factory dataObfuscatorFactory)
Set your own data obfuscation implementation.
|
Armadillo.Builder |
encryptionFingerprint(byte[] fingerprint) |
Armadillo.Builder |
encryptionFingerprint(android.content.Context context) |
Armadillo.Builder |
encryptionFingerprint(android.content.Context context,
byte[] additionalData) |
Armadillo.Builder |
encryptionFingerprint(android.content.Context context,
java.lang.String... additionalData) |
Armadillo.Builder |
encryptionFingerprint(EncryptionFingerprint fingerprint) |
Armadillo.Builder |
encryptionKeyStrength(int keyStrength)
Set the key length for the symmetric encryption.
|
Armadillo.Builder |
keyStretchingFunction(KeyStretchingFunction keyStretchingFunction)
Set a different key derivation function for provided password.
|
Armadillo.Builder |
password(char[] password)
Provide a user password used for all of entries of the
SharedPreferences. |
Armadillo.Builder |
recoveryPolicy(boolean throwRuntimeException,
boolean removeBrokenContent) |
Armadillo.Builder |
recoveryPolicy(RecoveryPolicy recoveryPolicy) |
Armadillo.Builder |
secureRandom(java.security.SecureRandom secureRandom)
Provide your own
SecureRandom implementation. |
Armadillo.Builder |
securityProvider(java.security.Provider provider)
Set the security provider for most cryptographic primitives (symmetric encryption,
pbkdf2, ...).
|
Armadillo.Builder |
symmetricEncryption(AuthenticatedEncryption authenticatedEncryption)
Set your own implementation of
AuthenticatedEncryption. |
public Armadillo.Builder encryptionFingerprint(android.content.Context context)
public Armadillo.Builder encryptionFingerprint(android.content.Context context, byte[] additionalData)
public Armadillo.Builder encryptionFingerprint(android.content.Context context, java.lang.String... additionalData)
public Armadillo.Builder encryptionFingerprint(EncryptionFingerprint fingerprint)
public Armadillo.Builder encryptionFingerprint(byte[] fingerprint)
public Armadillo.Builder contentKeyDigest(byte[] salt)
public Armadillo.Builder contentKeyDigest(int contentKeyOutLength)
public Armadillo.Builder contentKeyDigest(StringMessageDigest stringMessageDigest)
public Armadillo.Builder encryptionKeyStrength(int keyStrength)
Currently there are 2 options:
Note: Usually there is no real advantage to set it to VERY HIGH as HIGH (128 bit key length) is fully secure for the foreseeable future. VERY HIGH only adds more security margin for possible quantum computer attacks (but if you are a user which is threatened by these kinds of attacks you wouldn't use this lib anyway)
keyStrength - HIGH (default) or VERY HIGHpublic Armadillo.Builder securityProvider(java.security.Provider provider)
Only set if you know what you are doing.
provider - JCA providerpublic Armadillo.Builder symmetricEncryption(AuthenticatedEncryption authenticatedEncryption)
AuthenticatedEncryption. Use this if setting
the security provider with securityProvider(Provider) is not enough
customization. With this a any symmetric encryption algorithm might be used.
Only set if you know what you are doing.
authenticatedEncryption - to be used by the shared preferencespublic Armadillo.Builder keyStretchingFunction(KeyStretchingFunction keyStretchingFunction)
BcryptKeyStretcher
is used. There is also a implementation PBKDF2 (see PBKDF2KeyStretcher. If you want
to use a different function (e.g. scrypt) set the implementation here.
If you want to disable the key stretching feature you might use FastKeyStretcher here.keyStretchingFunction - to be used by the shared preferencespublic Armadillo.Builder dataObfuscatorFactory(DataObfuscator.Factory dataObfuscatorFactory)
HkdfXorObfuscator for the default obfuscation technique.
Only set if you know what you are doing.
dataObfuscatorFactory - that creates a obfuscator with given keypublic Armadillo.Builder secureRandom(java.security.SecureRandom secureRandom)
SecureRandom implementation.
Per default a no-provider constructor is used for SecureRandom which
is the currently recommended way (https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/)
Only set if you know what you are doing.
secureRandom - implementationpublic Armadillo.Builder recoveryPolicy(boolean throwRuntimeException, boolean removeBrokenContent)
public Armadillo.Builder recoveryPolicy(RecoveryPolicy recoveryPolicy)
public Armadillo.Builder password(char[] password)
SharedPreferences.
The password is treated as weak and is therefore subject to be stretched by the provided key
derivation function with key stretching property (see keyStretchingFunction(KeyStretchingFunction).
A side-effect is that putting or reading content is expensive and should not be done on the main thread.
password - provided by userpublic android.content.SharedPreferences build()
SharedPreferences instance