Search in sources :

Example 1 with UnidentifiedSenderMessageContent

use of org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent in project Signal-Android by WhisperSystems.

the class SignalServiceCipher method encryptForGroup.

public byte[] encryptForGroup(DistributionId distributionId, List<SignalProtocolAddress> destinations, SenderCertificate senderCertificate, byte[] unpaddedMessage, ContentHint contentHint, byte[] groupId) throws NoSessionException, UntrustedIdentityException, InvalidKeyException, InvalidRegistrationIdException {
    PushTransportDetails transport = new PushTransportDetails();
    SignalProtocolAddress localProtocolAddress = new SignalProtocolAddress(localAddress.getIdentifier(), localDeviceId);
    SignalGroupCipher groupCipher = new SignalGroupCipher(sessionLock, new GroupCipher(signalProtocolStore, localProtocolAddress));
    SignalSealedSessionCipher sessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getServiceId().uuid(), localAddress.getNumber().orNull(), localDeviceId));
    CiphertextMessage message = groupCipher.encrypt(distributionId.asUuid(), transport.getPaddedMessageBody(unpaddedMessage));
    UnidentifiedSenderMessageContent messageContent = new UnidentifiedSenderMessageContent(message, senderCertificate, contentHint.getType(), Optional.of(groupId));
    return sessionCipher.multiRecipientEncrypt(destinations, messageContent);
}
Also used : SealedSessionCipher(org.signal.libsignal.metadata.SealedSessionCipher) CiphertextMessage(org.whispersystems.libsignal.protocol.CiphertextMessage) PushTransportDetails(org.whispersystems.signalservice.internal.push.PushTransportDetails) GroupCipher(org.whispersystems.libsignal.groups.GroupCipher) UnidentifiedSenderMessageContent(org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress)

Example 2 with UnidentifiedSenderMessageContent

use of org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent in project Signal-Android by signalapp.

the class SignalServiceCipher method encryptForGroup.

public byte[] encryptForGroup(DistributionId distributionId, List<SignalProtocolAddress> destinations, SenderCertificate senderCertificate, byte[] unpaddedMessage, ContentHint contentHint, byte[] groupId) throws NoSessionException, UntrustedIdentityException, InvalidKeyException, InvalidRegistrationIdException {
    PushTransportDetails transport = new PushTransportDetails();
    SignalProtocolAddress localProtocolAddress = new SignalProtocolAddress(localAddress.getIdentifier(), localDeviceId);
    SignalGroupCipher groupCipher = new SignalGroupCipher(sessionLock, new GroupCipher(signalProtocolStore, localProtocolAddress));
    SignalSealedSessionCipher sessionCipher = new SignalSealedSessionCipher(sessionLock, new SealedSessionCipher(signalProtocolStore, localAddress.getServiceId().uuid(), localAddress.getNumber().orNull(), localDeviceId));
    CiphertextMessage message = groupCipher.encrypt(distributionId.asUuid(), transport.getPaddedMessageBody(unpaddedMessage));
    UnidentifiedSenderMessageContent messageContent = new UnidentifiedSenderMessageContent(message, senderCertificate, contentHint.getType(), Optional.of(groupId));
    return sessionCipher.multiRecipientEncrypt(destinations, messageContent);
}
Also used : SealedSessionCipher(org.signal.libsignal.metadata.SealedSessionCipher) CiphertextMessage(org.whispersystems.libsignal.protocol.CiphertextMessage) PushTransportDetails(org.whispersystems.signalservice.internal.push.PushTransportDetails) GroupCipher(org.whispersystems.libsignal.groups.GroupCipher) UnidentifiedSenderMessageContent(org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress)

Aggregations

SealedSessionCipher (org.signal.libsignal.metadata.SealedSessionCipher)2 UnidentifiedSenderMessageContent (org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent)2 SignalProtocolAddress (org.whispersystems.libsignal.SignalProtocolAddress)2 GroupCipher (org.whispersystems.libsignal.groups.GroupCipher)2 CiphertextMessage (org.whispersystems.libsignal.protocol.CiphertextMessage)2 PushTransportDetails (org.whispersystems.signalservice.internal.push.PushTransportDetails)2