Fix session handling

This commit is contained in:
Niels Andriesse
2019-07-23 10:35:03 +10:00
parent ecd60b8723
commit a925b17419
9 changed files with 37 additions and 33 deletions

View File

@@ -94,7 +94,7 @@ public class IdentityKeyUtil {
save(context, IDENTITY_PUBLIC_KEY_PREF, Base64.encodeBytes(publicKey.serialize()));
save(context, IDENTITY_PRIVATE_KEY_PREF, Base64.encodeBytes(keyPair.getPrivateKey().serialize()));
} catch (Exception e) {
Log.d("Loki", "Couldn't restore key pair from seed due to error: " + e.getMessage());
Log.d("Loki", "Couldn't restore key pair from seed due to error: " + e.getMessage() + ".");
}
}

View File

@@ -102,14 +102,12 @@ public class PreKeyUtil {
}
public synchronized static List<PreKeyRecord> generatePreKeys(Context context, int amount) {
PreKeyStore preKeyStore = new TextSecurePreKeyStore(context);
List<PreKeyRecord> records = new LinkedList<>();
int preKeyIDOffset = TextSecurePreferences.getNextPreKeyId(context);
for (int i = 0; i < amount; i++) {
int preKeyID = (preKeyIDOffset + i) % Medium.MAX_VALUE;
ECKeyPair keyPair = Curve.generateKeyPair();
PreKeyRecord record = new PreKeyRecord(preKeyID, keyPair);
preKeyStore.storePreKey(preKeyID, record);
records.add(record);
}
TextSecurePreferences.setNextPreKeyId(context, (preKeyIDOffset + BATCH_SIZE + 1) % Medium.MAX_VALUE);

View File

@@ -92,8 +92,8 @@ public class TextSecureSessionStore implements LokiSessionDatabaseProtocol {
}
}
public void archiveAllSessions(@NonNull String name) {
SignalProtocolAddress address = new SignalProtocolAddress(name, -1);
public void archiveAllSessions(@NonNull String hexEncodedPublicKey) {
SignalProtocolAddress address = new SignalProtocolAddress(hexEncodedPublicKey, -1);
archiveSiblingSessions(address);
}