A shared preference implementation for confidential data in Android. Per default uses AES-GCM, BCrypt and HKDF as cryptographic primitives. Uses the concept of device fingerprinting combined with optional user provided passwords and strong password hashes.
SharedPreferences preferences = Armadillo.create(context, prefName)
.password(Keys.UserProvidedPassword.toCharArray()) //use user provided password
.securityProvider(Security.getProvider("BC")) //use bouncy-castle security provider
.keyStretchingFunction(new PBKDF2KeyStretcher()) //use PBKDF2 as user password kdf
.contentKeyDigest(Bytes.from(getUniqueDeviceId(context)).array()) //use custom content key digest salt
.secureRandom(new SecureRandom()) //provide your own secure random for salt/iv generation
.encryptionFingerprint(context, (Keys.EncryptionFingerprint).getBytes(StandardCharsets.UTF_8)) //add the user id to fingerprint
.supportVerifyPassword(true) //enables optional password validation support .isValidPassword()
.enableDerivedPasswordCache(true) //enable caching for derived password making consecutive getters faster
.build();
SharedPreferences preferences = Armadillo.create(context, prefName) .password(Keys.UserProvidedPassword.toCharArray()) //use user provided password .securityProvider(Security.getProvider("BC")) //use bouncy-castle security provider .keyStretchingFunction(new PBKDF2KeyStretcher()) //use PBKDF2 as user password kdf .contentKeyDigest(Bytes.from(getUniqueDeviceId(context)).array()) //use custom content key digest salt .secureRandom(new SecureRandom()) //provide your own secure random for salt/iv generation .encryptionFingerprint(context, (Keys.EncryptionFingerprint).getBytes(StandardCharsets.UTF_8)) //add the user id to fingerprint .supportVerifyPassword(true) //enables optional password validation support
.isValidPassword()
.enableDerivedPasswordCache(true) //enable caching for derived password making consecutive getters faster .build();