Search in sources :

Example 16 with EnvelopeContent

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

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 17 with EnvelopeContent

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

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

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 19 with EnvelopeContent

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

the class SignalServiceMessageSender method sendTyping.

public void sendTyping(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, SignalServiceTypingMessage message, CancelationSignal cancelationSignal) throws IOException {
    Content content = createTypingContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.absent());
    sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), envelopeContent, true, null, cancelationSignal);
}
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 20 with EnvelopeContent

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

the class SignalServiceMessageSender method sendCallMessage.

/**
 * Send a call setup message to a single recipient.
 *
 * @param recipient The message's destination.
 * @param message The call message.
 * @throws IOException
 */
public void sendCallMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceCallMessage message) throws IOException, UntrustedIdentityException {
    Content content = createCallContent(message);
    EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.DEFAULT, Optional.absent());
    sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), 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)

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