diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/util/KeystoreHelper.java b/android/java/org/chromium/chrome/browser/crypto_wallet/util/KeystoreHelper.java index 2ad6bde1f907..3348bba08059 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/util/KeystoreHelper.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/util/KeystoreHelper.java @@ -69,9 +69,13 @@ public static Cipher getCipherForDecryption() { } GCMParameterSpec spec = new GCMParameterSpec(128, Base64.decode(ivBase64, Base64.DEFAULT)); - SecretKey secretKey = - ((KeyStore.SecretKeyEntry) keyStore.getEntry(BRAVE_WALLET_ALIAS, null)) - .getSecretKey(); + + KeyStore.SecretKeyEntry secretKeyEntry = + (KeyStore.SecretKeyEntry) keyStore.getEntry(BRAVE_WALLET_ALIAS, null); + if (secretKeyEntry == null) { + return null; + } + SecretKey secretKey = secretKeyEntry.getSecretKey(); final Cipher cipher = Cipher.getInstance(TRANSFORMATION); cipher.init(Cipher.DECRYPT_MODE, secretKey, spec); return cipher;