Skip to content

Commit

Permalink
Merge pull request #2865 from dimagi/removeCipherPool
Browse files Browse the repository at this point in the history
Remove unused cipher pool
  • Loading branch information
avazirna authored Dec 9, 2024
2 parents d7bd8f1 + 828e3fa commit a1947c9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 200 deletions.
59 changes: 0 additions & 59 deletions app/src/org/commcare/models/encryption/CipherPool.java

This file was deleted.

113 changes: 0 additions & 113 deletions app/src/org/commcare/models/legacy/DecryptingCursor.java

This file was deleted.

27 changes: 0 additions & 27 deletions app/src/org/commcare/services/CommCareSessionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.commcare.interfaces.FormSaveCallback;
import org.commcare.models.database.user.DatabaseUserOpenHelper;
import org.commcare.models.database.user.UserSandboxUtils;
import org.commcare.models.encryption.CipherPool;
import org.commcare.preferences.HiddenPreferences;
import org.commcare.sync.ExternalDataUpdateHelper;
import org.commcare.sync.FormSubmissionHelper;
Expand Down Expand Up @@ -91,7 +90,6 @@ public class CommCareSessionService extends Service {
private static final long SESSION_EXTENSION_TIME = 2 * 60 * 60 * 1000;

private Timer maintenanceTimer;
private CipherPool pool;

private byte[] key = null;

Expand Down Expand Up @@ -149,7 +147,6 @@ public CommCareSessionService getService() {
public void onCreate() {
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
setSessionLength();
createCipherPool();
}

@Override
Expand All @@ -162,27 +159,6 @@ public void onTaskRemoved(Intent rootIntent) {
}
}

public void createCipherPool() {
pool = new CipherPool() {
@Override
public Cipher generateNewCipher() {
synchronized (lock) {
try {
SecretKeySpec spec = new SecretKeySpec(key, "AES");
Cipher decrypter = Cipher.getInstance("AES");
decrypter.init(Cipher.DECRYPT_MODE, spec);

return decrypter;
} catch (NoSuchPaddingException | NoSuchAlgorithmException |
InvalidKeyException e) {
e.printStackTrace();
}
}
return null;
}
};
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// We want this service to continue running until it is explicitly
Expand Down Expand Up @@ -259,7 +235,6 @@ public void prepareStorage(byte[] symetricKey, UserKeyRecord record) {
synchronized (lock) {
this.userKeyRecordUUID = record.getUuid();
this.key = symetricKey;
pool.init();
if (userDatabase != null && userDatabase.isOpen()) {
userDatabase.close();
}
Expand Down Expand Up @@ -463,8 +438,6 @@ public void closeServiceResources() {
maintenanceTimer.cancel();
}
logoutStartedAt = -1;

pool.expire();
endHeartbeatLifecycle();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ public void startUserSession(byte[] symetricKey, UserKeyRecord record, boolean r
// manually create/setup session service because robolectric doesn't
// really support services
CommCareSessionService ccService = startRoboCommCareService();
ccService.createCipherPool();
ccService.prepareStorage(symetricKey, record);
User user = getUserFromDb(ccService, record);
if (user == null && cachedUserPassword != null) {
Expand Down

0 comments on commit a1947c9

Please sign in to comment.