Drop unencrypted storage on Android versions below 4.3

This commit is contained in:
Jakob Nixdorf 2017-06-30 16:31:12 +02:00
parent 9ad8f95ba3
commit 6e68141638
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -23,7 +23,6 @@
package org.shadowice.flocke.andotp; package org.shadowice.flocke.andotp;
import android.content.Context; import android.content.Context;
import android.os.Build;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -53,11 +52,8 @@ public class SettingsHelper {
try { try {
byte[] data = a.toString().getBytes(); byte[] data = a.toString().getBytes();
int currentApiVersion = android.os.Build.VERSION.SDK_INT; SecretKey key = EncryptionHelper.loadOrGenerateKeys(context, new File(context.getFilesDir() + "/" + KEY_FILE));
if (currentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2) { data = EncryptionHelper.encrypt(key,data);
SecretKey key = EncryptionHelper.loadOrGenerateKeys(context, new File(context.getFilesDir() + "/" + KEY_FILE));
data = EncryptionHelper.encrypt(key,data);
}
writeFully(new File(context.getFilesDir() + "/" + SETTINGS_FILE), data); writeFully(new File(context.getFilesDir() + "/" + SETTINGS_FILE), data);
@ -72,11 +68,9 @@ public class SettingsHelper {
try { try {
byte[] data = readFully(new File(context.getFilesDir() + "/" + SETTINGS_FILE)); byte[] data = readFully(new File(context.getFilesDir() + "/" + SETTINGS_FILE));
int currentApiVersion = android.os.Build.VERSION.SDK_INT; SecretKey key = EncryptionHelper.loadOrGenerateKeys(context, new File(context.getFilesDir() + "/" + KEY_FILE));
if (currentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2) { data = EncryptionHelper.decrypt(key, data);
SecretKey key = EncryptionHelper.loadOrGenerateKeys(context, new File(context.getFilesDir() + "/" + KEY_FILE));
data = EncryptionHelper.decrypt(key, data);
}
JSONArray a = new JSONArray(new String(data)); JSONArray a = new JSONArray(new String(data));
for(int i=0;i< a.length(); i++){ for(int i=0;i< a.length(); i++){