mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-11 21:31:46 +00:00
Add padding for push messages.
1) Use 'bit padding.' 1) By default, pad at 160 byte increments.
This commit is contained in:
@@ -52,8 +52,11 @@ import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.whispersystems.textsecure.crypto.SessionCipherFactory;
|
||||
import org.whispersystems.textsecure.crypto.TransportDetails;
|
||||
import org.whispersystems.textsecure.push.IncomingPushMessage;
|
||||
import org.whispersystems.textsecure.push.PushTransportDetails;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.storage.SessionUtil;
|
||||
import org.whispersystems.textsecure.storage.TextSecureSessionStore;
|
||||
import org.whispersystems.textsecure.util.Base64;
|
||||
import org.whispersystems.textsecure.util.Hex;
|
||||
@@ -210,10 +213,12 @@ public class DecryptingQueue {
|
||||
return;
|
||||
}
|
||||
|
||||
SessionCipher sessionCipher = SessionCipherFactory.getInstance(context, masterSecret, recipientDevice);
|
||||
byte[] plaintextBody = sessionCipher.decrypt(message.getBody());
|
||||
int sessionVersion = SessionUtil.getSessionVersion(context, masterSecret, recipientDevice);
|
||||
SessionCipher sessionCipher = SessionCipherFactory.getInstance(context, masterSecret, recipientDevice);
|
||||
byte[] plaintextBody = sessionCipher.decrypt(message.getBody());
|
||||
TransportDetails transport = new PushTransportDetails(sessionVersion);
|
||||
|
||||
message = message.withBody(plaintextBody);
|
||||
message = message.withBody(transport.getStrippedPaddingMessageBody(plaintextBody));
|
||||
sendResult(PushReceiver.RESULT_OK);
|
||||
} catch (InvalidMessageException | LegacyMessageException | RecipientFormattingException e) {
|
||||
Log.w("DecryptionQueue", e);
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.whispersystems.textsecure.push.PushAttachmentPointer;
|
||||
import org.whispersystems.textsecure.push.PushBody;
|
||||
import org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent;
|
||||
import org.whispersystems.textsecure.push.PushServiceSocket;
|
||||
import org.whispersystems.textsecure.push.PushTransportDetails;
|
||||
import org.whispersystems.textsecure.push.StaleDevices;
|
||||
import org.whispersystems.textsecure.push.StaleDevicesException;
|
||||
import org.whispersystems.textsecure.push.UnregisteredUserException;
|
||||
@@ -344,8 +345,10 @@ public class PushTransport extends BaseTransport {
|
||||
}
|
||||
}
|
||||
|
||||
int sessionVersion = SessionUtil.getSessionVersion(context, masterSecret, pushAddress);
|
||||
SessionCipher cipher = SessionCipherFactory.getInstance(context, masterSecret, pushAddress);
|
||||
CiphertextMessage message = cipher.encrypt(plaintext);
|
||||
byte[] paddedPlaintext = new PushTransportDetails(sessionVersion).getPaddedMessageBody(plaintext);
|
||||
CiphertextMessage message = cipher.encrypt(paddedPlaintext);
|
||||
int remoteRegistrationId = cipher.getRemoteRegistrationId();
|
||||
|
||||
if (message.getType() == CiphertextMessage.PREKEY_TYPE) {
|
||||
|
||||
Reference in New Issue
Block a user