From 7950e45697c90174aab71fb16eff322c9e13df1a Mon Sep 17 00:00:00 2001 From: Simone Arpe Date: Mon, 16 Dec 2024 13:19:07 +0100 Subject: [PATCH] Fix crash KeystoreHelper class --- .../browser/crypto_wallet/util/KeystoreHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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;