mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
Message sender cleanup.
This commit is contained in:
parent
ea0c3c8a36
commit
99f9e60a50
@ -1374,7 +1374,8 @@ public class SignalServiceMessageSender {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
OutgoingPushMessage message = getFallbackCipherEncryptedMessage(recipient.getNumber(), plaintext, unidentifiedAccess);
|
//AC: Use unencrypted messages for private chats.
|
||||||
|
OutgoingPushMessage message = getUnencryptedMessage(plaintext);
|
||||||
messages.add(message);
|
messages.add(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1382,24 +1383,30 @@ public class SignalServiceMessageSender {
|
|||||||
return new OutgoingPushMessageList(recipient.getNumber(), timestamp, messages, online);
|
return new OutgoingPushMessageList(recipient.getNumber(), timestamp, messages, online);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OutgoingPushMessage getUnencryptedMessage(byte[] plaintext) {
|
||||||
|
Log.d("Loki", "Bypassing cipher and preparing a plaintext message.");
|
||||||
|
int deviceID = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||||
|
PushTransportDetails transportDetails = new PushTransportDetails(FallbackSessionCipher.getSessionVersion());
|
||||||
|
byte[] bytes = transportDetails.getPaddedMessageBody(plaintext);
|
||||||
|
return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.UNIDENTIFIED_SENDER_VALUE, deviceID, 0, Base64.encodeBytes(bytes));
|
||||||
|
}
|
||||||
|
|
||||||
private OutgoingPushMessage getFallbackCipherEncryptedMessage(String publicKey, byte[] plaintext, Optional<UnidentifiedAccess> unidentifiedAccess)
|
private OutgoingPushMessage getFallbackCipherEncryptedMessage(String publicKey, byte[] plaintext, Optional<UnidentifiedAccess> unidentifiedAccess)
|
||||||
throws InvalidKeyException
|
throws InvalidKeyException
|
||||||
{
|
{
|
||||||
Log.d("Loki", "Using fallback cipher.");
|
Log.d("Loki", "Using fallback cipher.");
|
||||||
int deviceID = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
int deviceID = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||||
// SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(publicKey, deviceID);
|
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(publicKey, deviceID);
|
||||||
// byte[] userPrivateKey = store.getIdentityKeyPair().getPrivateKey().serialize();
|
byte[] userPrivateKey = store.getIdentityKeyPair().getPrivateKey().serialize();
|
||||||
// FallbackSessionCipher cipher = new FallbackSessionCipher(userPrivateKey, publicKey);
|
FallbackSessionCipher cipher = new FallbackSessionCipher(userPrivateKey, publicKey);
|
||||||
PushTransportDetails transportDetails = new PushTransportDetails(FallbackSessionCipher.getSessionVersion());
|
PushTransportDetails transportDetails = new PushTransportDetails(FallbackSessionCipher.getSessionVersion());
|
||||||
// byte[] bytes = cipher.encrypt(transportDetails.getPaddedMessageBody(plaintext));
|
byte[] bytes = cipher.encrypt(transportDetails.getPaddedMessageBody(plaintext));
|
||||||
byte[] bytes = transportDetails.getPaddedMessageBody(plaintext);
|
if (bytes == null) { bytes = new byte[0]; }
|
||||||
// if (bytes == null) { bytes = new byte[0]; }
|
|
||||||
if (unidentifiedAccess.isPresent()) {
|
if (unidentifiedAccess.isPresent()) {
|
||||||
// SealedSessionCipher sealedSessionCipher = new SealedSessionCipher(store, null, signalProtocolAddress);
|
SealedSessionCipher sealedSessionCipher = new SealedSessionCipher(store, null, signalProtocolAddress);
|
||||||
// FallbackMessage message = new FallbackMessage(bytes);
|
FallbackMessage message = new FallbackMessage(bytes);
|
||||||
// byte[] ciphertext = sealedSessionCipher.encrypt(signalProtocolAddress, unidentifiedAccess.get().getUnidentifiedCertificate(), message);
|
byte[] ciphertext = sealedSessionCipher.encrypt(signalProtocolAddress, unidentifiedAccess.get().getUnidentifiedCertificate(), message);
|
||||||
// return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.UNIDENTIFIED_SENDER_VALUE, deviceID, 0, Base64.encodeBytes(ciphertext));
|
return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.UNIDENTIFIED_SENDER_VALUE, deviceID, 0, Base64.encodeBytes(ciphertext));
|
||||||
return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.UNIDENTIFIED_SENDER_VALUE, deviceID, 0, Base64.encodeBytes(bytes));
|
|
||||||
} else {
|
} else {
|
||||||
return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.FALLBACK_MESSAGE_VALUE, deviceID, 0, Base64.encodeBytes(bytes));
|
return new OutgoingPushMessage(SignalServiceProtos.Envelope.Type.FALLBACK_MESSAGE_VALUE, deviceID, 0, Base64.encodeBytes(bytes));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user