Search in sources :

Example 1 with NullMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage in project libsignal-service-java by signalapp.

the class SignalServiceMessageSender method sendMessage.

private void sendMessage(VerifiedMessage message) throws IOException, UntrustedIdentityException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    byte[] content = Content.newBuilder().setNullMessage(nullMessage).build().toByteArray();
    SendMessageResponse response = sendMessage(new SignalServiceAddress(message.getDestination()), message.getTimestamp(), content, false);
    if (response != null && response.getNeedsSync()) {
        byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray());
        sendMessage(localAddress, message.getTimestamp(), syncMessage, false);
    }
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) SendMessageResponse(org.whispersystems.signalservice.internal.push.SendMessageResponse) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress)

Example 2 with NullMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendVerifiedSyncMessage.

private SendMessageResult sendVerifiedSyncMessage(VerifiedMessage message) throws IOException, UntrustedIdentityException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    Content content = Content.newBuilder().setNullMessage(nullMessage).build();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    SendMessageResult result = sendMessage(message.getDestination(), Optional.absent(), message.getTimestamp(), envelopeContent, false, null);
    if (result.getSuccess().isNeedsSync()) {
        Content syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray());
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), message.getTimestamp(), syncMessageContent, false, null);
    }
    return result;
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 3 with NullMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method sendVerifiedSyncMessage.

private SendMessageResult sendVerifiedSyncMessage(VerifiedMessage message) throws IOException, UntrustedIdentityException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    Content content = Content.newBuilder().setNullMessage(nullMessage).build();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    SendMessageResult result = sendMessage(message.getDestination(), Optional.absent(), message.getTimestamp(), envelopeContent, false, null);
    if (result.getSuccess().isNeedsSync()) {
        Content syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray());
        EnvelopeContent syncMessageContent = EnvelopeContent.encrypted(syncMessage, ContentHint.IMPLICIT, Optional.absent());
        sendMessage(localAddress, Optional.absent(), message.getTimestamp(), syncMessageContent, false, null);
    }
    return result;
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 4 with NullMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method sendNullMessage.

public SendMessageResult sendNullMessage(SignalServiceAddress address, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws UntrustedIdentityException, IOException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    Content content = Content.newBuilder().setNullMessage(nullMessage).build();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    return sendMessage(address, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), envelopeContent, false, null);
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 5 with NullMessage

use of org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendNullMessage.

public SendMessageResult sendNullMessage(SignalServiceAddress address, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws UntrustedIdentityException, IOException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    Content content = Content.newBuilder().setNullMessage(nullMessage).build();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    return sendMessage(address, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), envelopeContent, false, null);
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) Content(org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Aggregations

NullMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage)6 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)4 EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)4 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)4 SendMessageResult (org.whispersystems.signalservice.api.messages.SendMessageResult)3 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)1 SendMessageResponse (org.whispersystems.signalservice.internal.push.SendMessageResponse)1