Make sure to save the hash of the user selected PIN plus the salt used to generate it are both saved into the shared preferences, when creating or importing an account.

This commit is contained in:
Severiano Jaramillo 2019-02-18 14:13:02 -06:00
parent fac7bb031e
commit 97d9e8bcfb

View file

@ -32,13 +32,14 @@ abstract class BaseAccountFragment : ConnectedFragment() {
* @param accountProperties Account properties object
*/
protected fun onAccountSelected(accountProperties: AccountProperties, pin: String) {
val encryptedPIN = CryptoUtils.encrypt(context!!, pin).trim()
val salt = CryptoUtils.generateSalt()
val hashedPIN = CryptoUtils.createSHA256Hash(salt + pin)
// Stores the user selected PIN encrypted
PreferenceManager.getDefaultSharedPreferences(context!!)
.edit()
.putString(Constants.KEY_HASHED_PIN_PATTERN, encryptedPIN)
.apply()
// Stores the user selected PIN, hashed
PreferenceManager.getDefaultSharedPreferences(context!!).edit()
.putString(Constants.KEY_HASHED_PIN_PATTERN, hashedPIN)
.putString(Constants.KEY_PIN_PATTERN_SALT, salt)
.putInt(Constants.KEY_SECURITY_LOCK_SELECTED, 1).apply() // 1 -> PIN
// Stores the accounts this key refers to
val id = accountProperties.id