From bd12b5a17f45c944f8eefbaf4c91a6802ec788c3 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Tue, 2 Jan 2018 14:07:40 +0100 Subject: [PATCH] Add some checks to prevent crashes when the encryption key is not set --- .../flocke/andotp/Activities/MainActivity.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java index e955a5cf..3fa4cb9e 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java @@ -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(); }