Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,60 @@ public static void deserializeFingerprints(
}
}

public static DtlsRawKeyFingerprintPacketExtension deserializeRawKeyFingerprint(
JSONObject fingerprint,
IceUdpTransportPacketExtension transportIQ)
{
DtlsRawKeyFingerprintPacketExtension fingerprintIQ;

if (fingerprint == null)
{
fingerprintIQ = null;
}
else
{
Object theFingerprint
= fingerprint.get(DtlsRawKeyFingerprintPacketExtension.ELEMENT);

fingerprintIQ = new DtlsRawKeyFingerprintPacketExtension();
// fingerprint
if (theFingerprint != null)
{
fingerprintIQ.setFingerprint(theFingerprint.toString());
}
// attributes
deserializeAbstractPacketExtensionAttributes(
fingerprint,
fingerprintIQ);
/*
* XXX The fingerprint is stored as the text of the
* DtlsFingerprintPacketExtension instance. But it is a Java String
* and, consequently, the
* deserializeAbstractPacketExtensionAttributes method will
* deserialize it into an attribute of the
* DtlsFingerprintPacketExtension instance.
*/
fingerprintIQ.removeAttribute(
DtlsRawKeyFingerprintPacketExtension.ELEMENT);

transportIQ.addChildExtension(fingerprintIQ);
}
return fingerprintIQ;
}

public static void deserializeRawKeyFingerprints(
JSONArray fingerprints,
IceUdpTransportPacketExtension transportIQ)
{
if ((fingerprints != null) && !fingerprints.isEmpty())
{
for (Object fingerprint : fingerprints)
{
deserializeRawKeyFingerprint((JSONObject) fingerprint, transportIQ);
}
}
}

public static void deserializeParameters(
JSONObject parameters,
PayloadTypePacketExtension payloadTypeIQ)
Expand Down Expand Up @@ -564,6 +618,7 @@ public static IceUdpTransportPacketExtension deserializeTransport(
{
Object xmlns = transport.get(JSONSerializer.XMLNS);
Object fingerprints = transport.get(JSONSerializer.FINGERPRINTS);
Object rawKeyFingerprints = transport.get(JSONSerializer.RAW_KEY_FINGERPRINTS);
Object candidateList = transport.get(JSONSerializer.CANDIDATE_LIST);
Object webSocketList = transport.get(JSONSerializer.WEBSOCKET_LIST);
Object remoteCandidate
Expand Down Expand Up @@ -597,6 +652,12 @@ public static IceUdpTransportPacketExtension deserializeTransport(
(JSONArray) fingerprints,
transportIQ);
}
if (rawKeyFingerprints != null)
{
deserializeRawKeyFingerprints(
(JSONArray) rawKeyFingerprints,
transportIQ);
}
// candidateList
if (candidateList != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public final class JSONSerializer
*/
static final String FINGERPRINTS = DtlsFingerprintPacketExtension.ELEMENT + "s";

/**
* The name of the JSON pair which specifies the array of
* <tt>DtlsRawKeyFingerprintPacketExtension</tt> child extensions of
* <tt>IceUdpTransportPacketExtension</tt>.
*/
static final String RAW_KEY_FINGERPRINTS = DtlsRawKeyFingerprintPacketExtension.ELEMENT + "s";

/**
* The name of the JSON pair which specifies the value of the
* <tt>parameters</tt> property of <tt>PayloadTypePacketExtension</tt>.
Expand Down Expand Up @@ -198,6 +205,53 @@ public static JSONArray serializeFingerprints(
return fingerprintsJSONArray;
}

public static JSONObject serializeRawKeyFingerprint(
DtlsRawKeyFingerprintPacketExtension fingerprint)
{
JSONObject fingerprintJSONObject;

if (fingerprint == null)
{
fingerprintJSONObject = null;
}
else
{
String theFingerprint = fingerprint.getFingerprint();

fingerprintJSONObject = new JSONObject();
// fingerprint
if (theFingerprint != null)
{
fingerprintJSONObject.put(
fingerprint.getElementName(),
theFingerprint);
}
// attributes
serializeAbstractPacketExtensionAttributes(
fingerprint,
fingerprintJSONObject);
}
return fingerprintJSONObject;
}

public static JSONArray serializeRawKeyFingerprints(
Collection<DtlsRawKeyFingerprintPacketExtension> fingerprints)
{
JSONArray fingerprintsJSONArray;

if (fingerprints == null)
{
fingerprintsJSONArray = null;
}
else
{
fingerprintsJSONArray = new JSONArray();
for (DtlsRawKeyFingerprintPacketExtension fingerprint : fingerprints)
fingerprintsJSONArray.add(serializeRawKeyFingerprint(fingerprint));
}
return fingerprintsJSONArray;
}

public static JSONObject serializeParameters(
Collection<ParameterPacketExtension> parameters)
{
Expand Down Expand Up @@ -508,6 +562,9 @@ public static JSONObject serializeTransport(
List<DtlsFingerprintPacketExtension> fingerprints
= transport.getChildExtensionsOfType(
DtlsFingerprintPacketExtension.class);
List<DtlsRawKeyFingerprintPacketExtension> rawKeyFingerprints
= transport.getChildExtensionsOfType(
DtlsRawKeyFingerprintPacketExtension.class);
List<CandidatePacketExtension> candidateList
= transport.getCandidateList();
List<WebSocketPacketExtension> webSocketList
Expand All @@ -530,6 +587,12 @@ public static JSONObject serializeTransport(
FINGERPRINTS,
serializeFingerprints(fingerprints));
}
if ((rawKeyFingerprints != null) && !rawKeyFingerprints.isEmpty())
{
jsonObject.put(
RAW_KEY_FINGERPRINTS,
serializeRawKeyFingerprints(rawKeyFingerprints));
}
// candidateList
if ((candidateList != null) && !candidateList.isEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright @ 2018 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.xmpp.extensions.jingle;

import org.jitsi.xmpp.extensions.AbstractPacketExtension;

/**
* Implements <tt>AbstractPacketExtension</tt> for the <tt>raw-key-fingerprint</tt>
* element equivalent to the SDP attribute defined in draft-lennox-sdp-raw-key-fingerprints.
*/
public class DtlsRawKeyFingerprintPacketExtension
extends AbstractPacketExtension
{
/**
* The XML name of the <tt>raw-key-fingerprint</tt> element.
*/
public static final String ELEMENT = "raw-key-fingerprint";

/**
* The XML name of the <tt>raw-key-fingerprint</tt> element's attribute which
* specifies the hash function utilized to calculate the fingerprint.
*/
private static final String HASH_ATTR_NAME = "hash";

/**
* The XML namespace of the <tt>fingerprint</tt> element defined by
* XEP-0320: Use of DTLS-SRTP in Jingle Sessions.
*/
public static final String NAMESPACE = "urn:xmpp:jingle:apps:dtls:0";

/** Initializes a new <tt>DtlsFingerprintPacketExtension</tt> instance. */
public DtlsRawKeyFingerprintPacketExtension()
{
super(NAMESPACE, ELEMENT);
}

/**
* Gets the fingerprint carried/represented by this instance.
*
* @return the fingerprint carried/represented by this instance
*/
public String getFingerprint()
{
return getText();
}

/**
* Gets the hash function utilized to calculate the fingerprint
* carried/represented by this instance.
*
* @return the hash function utilized to calculate the fingerprint
* carried/represented by this instance
*/
public String getHash()
{
return getAttributeAsString(HASH_ATTR_NAME);
}

/**
* Sets the fingerprint to be carried/represented by this instance.
*
* @param fingerprint the fingerprint to be carried/represented by this
* instance
*/
public void setFingerprint(String fingerprint)
{
setText(fingerprint);
}

/**
* Sets the hash function utilized to calculate the fingerprint
* carried/represented by this instance.
*
* @param hash the hash function utilized to calculate the fingerprint
* carried/represented by this instance
*/
public void setHash(String hash)
{
setAttribute(HASH_ATTR_NAME, hash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ public static IceUdpTransportPacketExtension cloneTransportAndCandidates(
copy.setRequired(dtlsFingerprint.getRequired());
copy.setSetup(dtlsFingerprint.getSetup());

dst.addChildExtension(copy);
}
for (DtlsRawKeyFingerprintPacketExtension rawKeyFingerprint
: src.getChildExtensionsOfType(
DtlsRawKeyFingerprintPacketExtension.class))
{
DtlsRawKeyFingerprintPacketExtension copy =
new DtlsRawKeyFingerprintPacketExtension();
copy.setFingerprint(rawKeyFingerprint.getFingerprint());
copy.setHash(rawKeyFingerprint.getHash());

dst.addChildExtension(copy);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ public JingleIQProvider()
new DefaultPacketExtensionProvider
<>(DtlsFingerprintPacketExtension.class));

ProviderManager.addExtensionProvider(
DtlsRawKeyFingerprintPacketExtension.ELEMENT,
DtlsRawKeyFingerprintPacketExtension.NAMESPACE,
new DefaultPacketExtensionProvider
<>(DtlsRawKeyFingerprintPacketExtension.class));

/*
* XEP-0251: Jingle Session Transfer <transfer/> and <transferred>
* providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ private val expectedMappings = listOf(
<transport>
<transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" pwd="1a5ejbent91k6io6a3fauikg22" ufrag="2ivqh1fvtf0l3h">
<fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" setup="actpass" hash="sha-256" cryptex="true">2E:CC:85:71:32:5B:B5:60:64:C8:F6:7B:6D:45:D4:34:2B:51:A0:06:B5:EA:2F:84:BC:7B:64:1F:A3:0A:69:23</fingerprint>
<raw-key-fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-256">31:D8:D0:A2:E8:2F:A6:43:5D:0C:69:BE:23:7A:0C:B1:4D:22:56:18:0B:5D:79:78:F6:E2:71:62:2E:46:45:E9</raw-key-fingerprint>
<web-socket xmlns="http://jitsi.org/protocol/colibri" url="wss://beta-us-ashburn-1-global-2808-jvb-83-102-26.jitsi.net:443/colibri-ws/default-id/3d937bbdf97a23e0/79f0273e?pwd=1a5ejbent91k6io6a3fauikg22"/>
<rtcp-mux/>
<candidate component="1" foundation="2" generation="0" id="653aa1ba295b62480ffffffffdc52c0d9" network="0" priority="1694498815" protocol="udp" type="srflx" ip="129.80.210.199" port="10000" rel-addr="0.0.0.0" rel-port="9"/>
Expand Down Expand Up @@ -351,6 +352,12 @@ private val expectedMappings = listOf(
"hash": "sha-256",
"cryptex": true
}
],
"raw-key-fingerprints": [
{
"raw-key-fingerprint": "31:D8:D0:A2:E8:2F:A6:43:5D:0C:69:BE:23:7A:0C:B1:4D:22:56:18:0B:5D:79:78:F6:E2:71:62:2E:46:45:E9",
"hash": "sha-256"
}
]
}
}
Expand Down
Loading