Search in sources :

Example 1 with RtpContentMap

use of eu.siacs.conversations.xmpp.jingle.RtpContentMap in project Conversations by siacs.

the class AxolotlService method encrypt.

private ListenableFuture<OmemoVerifiedPayload<OmemoVerifiedRtpContentMap>> encrypt(final RtpContentMap rtpContentMap, final XmppAxolotlSession session) {
    if (Config.REQUIRE_RTP_VERIFICATION) {
        requireVerification(session);
    }
    final ImmutableMap.Builder<String, RtpContentMap.DescriptionTransport> descriptionTransportBuilder = new ImmutableMap.Builder<>();
    final OmemoVerification omemoVerification = new OmemoVerification();
    omemoVerification.setDeviceId(session.getRemoteAddress().getDeviceId());
    omemoVerification.setSessionFingerprint(session.getFingerprint());
    for (final Map.Entry<String, RtpContentMap.DescriptionTransport> content : rtpContentMap.contents.entrySet()) {
        final RtpContentMap.DescriptionTransport descriptionTransport = content.getValue();
        final OmemoVerifiedIceUdpTransportInfo encryptedTransportInfo;
        try {
            encryptedTransportInfo = encrypt(descriptionTransport.transport, session);
        } catch (final CryptoFailedException e) {
            return Futures.immediateFailedFuture(e);
        }
        descriptionTransportBuilder.put(content.getKey(), new RtpContentMap.DescriptionTransport(descriptionTransport.description, encryptedTransportInfo));
    }
    return Futures.immediateFuture(new OmemoVerifiedPayload<>(omemoVerification, new OmemoVerifiedRtpContentMap(rtpContentMap.group, descriptionTransportBuilder.build())));
}
Also used : OmemoVerification(eu.siacs.conversations.xmpp.jingle.OmemoVerification) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) OmemoVerifiedIceUdpTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.OmemoVerifiedIceUdpTransportInfo) OmemoVerifiedRtpContentMap(eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap) RtpContentMap(eu.siacs.conversations.xmpp.jingle.RtpContentMap) ImmutableMap(com.google.common.collect.ImmutableMap) OmemoVerifiedRtpContentMap(eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap) OmemoVerifiedRtpContentMap(eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) RtpContentMap(eu.siacs.conversations.xmpp.jingle.RtpContentMap)

Example 2 with RtpContentMap

use of eu.siacs.conversations.xmpp.jingle.RtpContentMap in project Conversations by siacs.

the class AxolotlService method decrypt.

public ListenableFuture<OmemoVerifiedPayload<RtpContentMap>> decrypt(OmemoVerifiedRtpContentMap omemoVerifiedRtpContentMap, final Jid from) {
    final ImmutableMap.Builder<String, RtpContentMap.DescriptionTransport> descriptionTransportBuilder = new ImmutableMap.Builder<>();
    final OmemoVerification omemoVerification = new OmemoVerification();
    final ImmutableList.Builder<ListenableFuture<XmppAxolotlSession>> pepVerificationFutures = new ImmutableList.Builder<>();
    for (final Map.Entry<String, RtpContentMap.DescriptionTransport> content : omemoVerifiedRtpContentMap.contents.entrySet()) {
        final RtpContentMap.DescriptionTransport descriptionTransport = content.getValue();
        final OmemoVerifiedPayload<IceUdpTransportInfo> decryptedTransport;
        try {
            decryptedTransport = decrypt((OmemoVerifiedIceUdpTransportInfo) descriptionTransport.transport, from, pepVerificationFutures);
        } catch (CryptoFailedException e) {
            return Futures.immediateFailedFuture(e);
        }
        omemoVerification.setOrEnsureEqual(decryptedTransport);
        descriptionTransportBuilder.put(content.getKey(), new RtpContentMap.DescriptionTransport(descriptionTransport.description, decryptedTransport.payload));
    }
    processPostponed();
    final ImmutableList<ListenableFuture<XmppAxolotlSession>> sessionFutures = pepVerificationFutures.build();
    return Futures.transform(Futures.allAsList(sessionFutures), sessions -> {
        if (Config.REQUIRE_RTP_VERIFICATION) {
            for (XmppAxolotlSession session : sessions) {
                requireVerification(session);
            }
        }
        return new OmemoVerifiedPayload<>(omemoVerification, new RtpContentMap(omemoVerifiedRtpContentMap.group, descriptionTransportBuilder.build()));
    }, MoreExecutors.directExecutor());
}
Also used : OmemoVerification(eu.siacs.conversations.xmpp.jingle.OmemoVerification) IceUdpTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.IceUdpTransportInfo) OmemoVerifiedIceUdpTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.OmemoVerifiedIceUdpTransportInfo) ImmutableList(com.google.common.collect.ImmutableList) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) OmemoVerifiedIceUdpTransportInfo(eu.siacs.conversations.xmpp.jingle.stanzas.OmemoVerifiedIceUdpTransportInfo) OmemoVerifiedRtpContentMap(eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap) RtpContentMap(eu.siacs.conversations.xmpp.jingle.RtpContentMap) ImmutableMap(com.google.common.collect.ImmutableMap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OmemoVerifiedRtpContentMap(eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) RtpContentMap(eu.siacs.conversations.xmpp.jingle.RtpContentMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)2 OmemoVerification (eu.siacs.conversations.xmpp.jingle.OmemoVerification)2 OmemoVerifiedRtpContentMap (eu.siacs.conversations.xmpp.jingle.OmemoVerifiedRtpContentMap)2 RtpContentMap (eu.siacs.conversations.xmpp.jingle.RtpContentMap)2 OmemoVerifiedIceUdpTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.OmemoVerifiedIceUdpTransportInfo)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SessionBuilder (org.whispersystems.libsignal.SessionBuilder)2 ImmutableList (com.google.common.collect.ImmutableList)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 IceUdpTransportInfo (eu.siacs.conversations.xmpp.jingle.stanzas.IceUdpTransportInfo)1