Search in sources :

Example 21 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendRetryReceipt.

/**
 * Send a retry receipt for a bad-encrypted envelope.
 */
public void sendRetryReceipt(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, Optional<byte[]> groupId, DecryptionErrorMessage errorMessage) throws IOException, UntrustedIdentityException {
    PlaintextContent content = new PlaintextContent(errorMessage);
    EnvelopeContent envelopeContent = EnvelopeContent.plaintext(content, groupId);
    sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), envelopeContent, false, null);
}
Also used : PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) EnvelopeContent(org.whispersystems.signalservice.api.crypto.EnvelopeContent)

Example 22 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendReceipt.

/**
 * Send a read receipt for a received message.
 *
 * @param recipient The sender of the received message you're acknowledging.
 * @param message The read receipt to deliver.
 */
public SendMessageResult sendReceipt(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceReceiptMessage message) throws IOException, UntrustedIdentityException {
    Content content = createReceiptContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    return sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), message.getWhen(), envelopeContent, false, null);
}
Also used : 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 23 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendTyping.

/**
 * Send a typing indicator.
 *
 * @param recipient The destination
 * @param message The typing indicator to deliver
 */
public void sendTyping(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceTypingMessage message) throws IOException, UntrustedIdentityException {
    Content content = createTypingContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), envelopeContent, true, null);
}
Also used : 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 24 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent in project Signal-Android by signalapp.

the class SignalServiceMessageSender method sendSenderKeyDistributionMessage.

/**
 * Sends the provided {@link SenderKeyDistributionMessage} to the specified recipients.
 */
public List<SendMessageResult> sendSenderKeyDistributionMessage(DistributionId distributionId, List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, SenderKeyDistributionMessage message, byte[] groupId) throws IOException {
    ByteString distributionBytes = ByteString.copyFrom(message.serialize());
    Content content = Content.newBuilder().setSenderKeyDistributionMessage(distributionBytes).build();
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.of(groupId));
    long timestamp = System.currentTimeMillis();
    Log.d(TAG, "[" + timestamp + "] Sending SKDM to " + recipients.size() + " recipients for DistributionId " + distributionId);
    return sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, envelopeContent, false, null, null);
}
Also used : ByteString(com.google.protobuf.ByteString) 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 25 with EnvelopeContent

use of org.whispersystems.signalservice.api.crypto.EnvelopeContent 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

EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)28 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)26 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)24 SendMessageResult (org.whispersystems.signalservice.api.messages.SendMessageResult)8 NullMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage)4 ByteString (com.google.protobuf.ByteString)2 IOException (java.io.IOException)2 UnidentifiedAccess (org.whispersystems.signalservice.api.crypto.UnidentifiedAccess)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2