diff options
author | cyBerta <cyberta@riseup.net> | 2023-05-24 21:47:16 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2023-07-13 10:53:49 +0200 |
commit | af123f7a34eaa7839a238b32f2cb4ef473c9ed22 (patch) | |
tree | ad333a029411adbfaa66c1532783426935bb3b81 | |
parent | c3be00774aa344e263baba9a0055135891fbffa0 (diff) |
use updated encrypted shared preferences API
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java index eadd37bc..12196aee 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java @@ -43,6 +43,7 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; import androidx.security.crypto.EncryptedSharedPreferences; +import androidx.security.crypto.MasterKey; import org.json.JSONException; import org.json.JSONObject; @@ -70,13 +71,16 @@ public class PreferenceHelper { public static SharedPreferences getSharedPreferences(Context context) { try { + MasterKey masterKey = new MasterKey.Builder(context) + .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) + .build(); + return EncryptedSharedPreferences.create( - SHARED_ENCRYPTED_PREFERENCES, - "leap_secret_shared_prefs", context, + SHARED_ENCRYPTED_PREFERENCES, + masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM - ); + EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM); } catch (GeneralSecurityException | IOException e) { e.printStackTrace(); } |