Commit 937c2920 authored by T Dev. D's avatar T Dev. D 😎
Browse files

secure wipe modifs

parent 64c823a5
......@@ -916,10 +916,10 @@ public class PayloadUtil {
private synchronized void secureDelete(File file) throws IOException {
if (file.exists()) {
long length = file.length();
SecureRandom random = new SecureRandom();
RandomAccessFile raf = new RandomAccessFile(file, "rws");
for(int i = 0; i < 5; i++) {
for(int i = 0; i < 3; i++) {
long length = file.length();
SecureRandom random = new SecureRandom();
RandomAccessFile raf = new RandomAccessFile(file, "rws");
raf.seek(0);
raf.getFilePointer();
byte[] data = new byte[64];
......@@ -929,8 +929,8 @@ public class PayloadUtil {
raf.write(data);
pos += data.length;
}
raf.close();
}
raf.close();
file.delete();
}
}
......
......@@ -14,7 +14,6 @@ import com.samourai.wallet.access.AccessFactory;
import com.samourai.wallet.api.APIFactory;
import com.samourai.wallet.bip47.BIP47Util;
import com.samourai.wallet.hd.HD_Wallet;
import com.samourai.wallet.hd.HD_WalletFactory;
import com.samourai.wallet.payload.PayloadUtil;
import com.samourai.wallet.prng.PRNGFixes;
import com.samourai.wallet.R;
......@@ -22,16 +21,17 @@ import com.samourai.wallet.ricochet.RicochetMeta;
import com.samourai.wallet.segwit.BIP49Util;
import com.samourai.wallet.segwit.BIP84Util;
import com.samourai.wallet.send.BlockedUTXO;
import com.samourai.wallet.whirlpool.WhirlpoolMeta;
import com.samourai.wallet.whirlpool.service.WhirlpoolNotificationService;
import com.samourai.whirlpool.client.wallet.WhirlpoolUtils;
import java.io.File;
import java.io.IOException;
import java.security.Security;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static android.content.Context.ACTIVITY_SERVICE;
public class AppUtil {
public static final int MIN_BACKUP_PW_LENGTH = 6;
......@@ -103,7 +103,7 @@ public class AppUtil {
e.printStackTrace();
;
}
/*
try {
HD_Wallet hdw = HD_WalletFactory.getInstance(context).get();
String[] s = hdw.getXPUBs();
......@@ -112,11 +112,18 @@ public class AppUtil {
}
String _s = BIP49Util.getInstance(context).getWallet().getAccount(0).ypubstr();
// APIFactory.getInstance(context).deleteXPUB(_s, true);
PayloadUtil.getInstance(context).wipe();
}
catch(Exception e) {
e.printStackTrace();
}
*/
try {
PayloadUtil.getInstance(context).wipe();
}
catch(IOException ioe) {
ioe.printStackTrace();
}
BIP49Util.getInstance(context).reset();
BIP84Util.getInstance(context).reset();
......@@ -144,6 +151,13 @@ public class AppUtil {
SentToFromBIP47Util.getInstance().reset();
BatchSendUtil.getInstance().clear();
AccessFactory.getInstance(context).setIsLoggedIn(false);
try {
clearApplicationData();
}
catch(IOException ioe) {
ioe.printStackTrace();
}
}
public void restartApp() {
......@@ -202,7 +216,7 @@ public class AppUtil {
public boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager manager = (ActivityManager)context.getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
Log.d("AppUtil", "service class name:" + serviceClass.getName() + " is running");
......@@ -297,4 +311,32 @@ public class AppUtil {
CLIPBOARD_SEEN = seen;
}
private void clearApplicationData() throws IOException {
File cacheDirectory = context.getCacheDir();
File applicationDirectory = new File(cacheDirectory.getParent());
if (applicationDirectory.exists()) {
String[] fileNames = applicationDirectory.list();
for (String fileName : fileNames) {
deleteFiles(new File(applicationDirectory, fileName));
}
}
}
private synchronized boolean deleteFiles(File file) throws IOException {
boolean deletedAll = true;
if (file != null) {
if (file.isDirectory()) {
String[] children = file.list();
for (int i = 0; i < children.length; i++) {
deletedAll = deleteFiles(new File(file, children[i])) && deletedAll;
}
}
else {
deletedAll = file.delete();
}
}
return deletedAll;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment