Add some checks to prevent crashes when the encryption key is not set

This commit is contained in:
Jakob Nixdorf 2018-01-02 14:07:40 +01:00
parent 2b74b9d6f7
commit bd12b5a17f
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -422,15 +422,18 @@ public class MainActivity extends BaseActivity
encryptionKey = KeyStoreHelper.loadEncryptionKeyFromKeyStore(this);
} else if (encryptionType == Constants.EncryptionType.PASSWORD) {
byte[] credentialSeed = intent.getByteArrayExtra(EXTRA_NAME_PASSWORD_KEY);
encryptionKey = EncryptionHelper.generateSymmetricKey(credentialSeed);
if (credentialSeed != null && credentialSeed.length > 0)
encryptionKey = EncryptionHelper.generateSymmetricKey(credentialSeed);
}
boolean saveDatabase = intent.getBooleanExtra(EXTRA_NAME_SAVE_DATABASE, false);
adapter.setEncryptionKey(encryptionKey);
if (encryptionKey != null) {
adapter.setEncryptionKey(encryptionKey);
if (saveDatabase)
adapter.saveEntries();
if (saveDatabase)
adapter.saveEntries();
}
populateAdapter();
}