Refactor out old classes.

This commit is contained in:
Moxie Marlinspike
2014-11-12 09:09:55 -08:00
parent f9934bd8e5
commit f09abff407
16 changed files with 53 additions and 102 deletions

View File

@@ -31,12 +31,12 @@ import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage;
import org.thoughtcrime.securesms.util.Dialogs;
import org.whispersystems.libaxolotl.SessionBuilder;
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
import org.whispersystems.libaxolotl.state.PreKeyStore;
import org.whispersystems.libaxolotl.state.SessionRecord;
import org.whispersystems.libaxolotl.state.SessionStore;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
import org.whispersystems.textsecure.push.PushAddress;
import org.whispersystems.textsecure.util.Base64;
public class KeyExchangeInitiator {
@@ -68,7 +68,7 @@ public class KeyExchangeInitiator {
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityKeyStore, recipient.getRecipientId(),
RecipientDevice.DEFAULT_DEVICE_ID);
PushAddress.DEFAULT_DEVICE_ID);
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
@@ -81,7 +81,7 @@ public class KeyExchangeInitiator {
Recipient recipient)
{
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
return sessionRecord.getSessionState().hasPendingKeyExchange();
}

View File

@@ -17,7 +17,7 @@ import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
import org.whispersystems.libaxolotl.state.AxolotlStore;
import org.whispersystems.libaxolotl.util.guava.Optional;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.push.PushAddress;
import org.whispersystems.textsecure.util.Util;
import java.io.IOException;
@@ -92,11 +92,11 @@ public class MmsCipher {
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
byte[] pduBytes = new PduComposer(context, message).make();
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
throw new NoSessionException("No session for: " + recipientId);
}
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());

View File

@@ -3,25 +3,7 @@ package org.thoughtcrime.securesms.crypto;
import android.content.Context;
import android.content.Intent;
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore;
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage;
import org.whispersystems.libaxolotl.InvalidKeyException;
import org.whispersystems.libaxolotl.SessionBuilder;
import org.whispersystems.libaxolotl.StaleKeyExchangeException;
import org.whispersystems.libaxolotl.UntrustedIdentityException;
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
import org.whispersystems.libaxolotl.state.IdentityKeyStore;
import org.whispersystems.libaxolotl.state.PreKeyBundle;
import org.whispersystems.libaxolotl.state.PreKeyStore;
import org.whispersystems.libaxolotl.state.SessionStore;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.util.Base64;
/**
* This class processes key exchange interactions.

View File

@@ -30,7 +30,7 @@ import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
import org.whispersystems.libaxolotl.state.AxolotlStore;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.push.PushAddress;
import java.io.IOException;
@@ -89,11 +89,11 @@ public class SmsCipher {
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
long recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();
if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) {
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
throw new NoSessionException("No session for: " + recipientId);
}
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));

View File

@@ -9,7 +9,7 @@ import org.whispersystems.libaxolotl.InvalidMessageException;
import org.whispersystems.libaxolotl.state.SessionRecord;
import org.whispersystems.libaxolotl.state.SessionState;
import org.whispersystems.libaxolotl.state.SessionStore;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.push.PushAddress;
import org.whispersystems.textsecure.util.Conversions;
import java.io.File;
@@ -108,7 +108,7 @@ public class TextSecureSessionStore implements SessionStore {
public void deleteAllSessions(long recipientId) {
List<Integer> devices = getSubDeviceSessions(recipientId);
deleteSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID);
deleteSession(recipientId, PushAddress.DEFAULT_DEVICE_ID);
for (int device : devices) {
deleteSession(recipientId, device);
@@ -156,7 +156,7 @@ public class TextSecureSessionStore implements SessionStore {
}
private String getSessionName(long recipientId, int deviceId) {
return recipientId + (deviceId == RecipientDevice.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
return recipientId + (deviceId == PushAddress.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
}
private byte[] readBlob(FileInputStream in) throws IOException {