mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-18 15:56:24 +01:00
Collapse KeyExchangeMessage and KeyExchangeProcessor interfaces.
This commit is contained in:
@@ -32,7 +32,6 @@ import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.DecryptingQueue;
|
||||
import org.thoughtcrime.securesms.crypto.KeyExchangeProcessor;
|
||||
import org.thoughtcrime.securesms.crypto.KeyExchangeProcessorV2;
|
||||
import org.thoughtcrime.securesms.crypto.protocol.KeyExchangeMessage;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -148,19 +147,12 @@ public class ReceiveKeyActivity extends Activity {
|
||||
}
|
||||
|
||||
private boolean isTrusted(KeyExchangeMessage message, PreKeyWhisperMessage messageBundle, IdentityKey identityUpdateMessage) {
|
||||
RecipientDevice recipientDevice = new RecipientDevice(recipient.getRecipientId(), recipientDeviceId);
|
||||
RecipientDevice recipientDevice = new RecipientDevice(recipient.getRecipientId(), recipientDeviceId);
|
||||
KeyExchangeProcessor processor = new KeyExchangeProcessor(this, masterSecret, recipientDevice);
|
||||
|
||||
if (message != null) {
|
||||
KeyExchangeProcessor processor = KeyExchangeProcessor.createFor(this, masterSecret,
|
||||
recipientDevice, message);
|
||||
return processor.isTrusted(message);
|
||||
} else if (messageBundle != null) {
|
||||
KeyExchangeProcessorV2 processor = new KeyExchangeProcessorV2(this, masterSecret, recipientDevice);
|
||||
return processor.isTrusted(messageBundle);
|
||||
} else if (identityUpdateMessage != null) {
|
||||
KeyExchangeProcessorV2 processor = new KeyExchangeProcessorV2(this, masterSecret, recipientDevice);
|
||||
return processor.isTrusted(identityUpdateMessage);
|
||||
}
|
||||
if (message != null) return processor.isTrusted(message);
|
||||
else if (messageBundle != null) return processor.isTrusted(messageBundle);
|
||||
else if (identityUpdateMessage != null) return processor.isTrusted(identityUpdateMessage);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -186,7 +178,7 @@ public class ReceiveKeyActivity extends Activity {
|
||||
} else if (getIntent().getBooleanExtra("is_identity_update", false)) {
|
||||
this.identityUpdateMessage = new IdentityKey(Base64.decodeWithoutPadding(messageBody), 0);
|
||||
} else {
|
||||
this.keyExchangeMessage = KeyExchangeMessage.createFor(messageBody);
|
||||
this.keyExchangeMessage = new KeyExchangeMessage(messageBody);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
@@ -227,9 +219,13 @@ public class ReceiveKeyActivity extends Activity {
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (keyExchangeMessage != null) {
|
||||
try {
|
||||
RecipientDevice recipientDevice = new RecipientDevice(recipient.getRecipientId(), recipientDeviceId);
|
||||
KeyExchangeProcessor processor = KeyExchangeProcessor.createFor(ReceiveKeyActivity.this, masterSecret, recipientDevice, keyExchangeMessage);
|
||||
RecipientDevice recipientDevice = new RecipientDevice(recipient.getRecipientId(),
|
||||
recipientDeviceId);
|
||||
KeyExchangeProcessor processor = new KeyExchangeProcessor(ReceiveKeyActivity.this,
|
||||
masterSecret, recipientDevice);
|
||||
|
||||
processor.processKeyExchangeMessage(keyExchangeMessage, threadId);
|
||||
|
||||
DatabaseFactory.getEncryptingSmsDatabase(ReceiveKeyActivity.this)
|
||||
.markAsProcessedKeyExchange(messageId);
|
||||
} catch (InvalidMessageException e) {
|
||||
@@ -240,7 +236,7 @@ public class ReceiveKeyActivity extends Activity {
|
||||
} else if (keyExchangeMessageBundle != null) {
|
||||
try {
|
||||
RecipientDevice recipientDevice = new RecipientDevice(recipient.getRecipientId(), recipientDeviceId);
|
||||
KeyExchangeProcessorV2 processor = new KeyExchangeProcessorV2(ReceiveKeyActivity.this,
|
||||
KeyExchangeProcessor processor = new KeyExchangeProcessor(ReceiveKeyActivity.this,
|
||||
masterSecret, recipientDevice);
|
||||
processor.processKeyExchangeMessage(keyExchangeMessageBundle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user