Skip to content

Commit

Permalink
Add cryptex attribute to fingerprint packet extension. (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox authored Feb 16, 2023
1 parent 6c4c83a commit 379c87b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ public static JSONObject serializeFingerprint(
serializeAbstractPacketExtensionAttributes(
fingerprint,
fingerprintJSONObject);
Object cryptex = fingerprintJSONObject.get(DtlsFingerprintPacketExtension.CRYPTEX_ATTR_NAME);
if (cryptex instanceof String)
{
/* Represent cryptex as a boolean. */
fingerprintJSONObject.put(DtlsFingerprintPacketExtension.CRYPTEX_ATTR_NAME,
Boolean.parseBoolean((String)cryptex));
}
}
return fingerprintJSONObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public class DtlsFingerprintPacketExtension
*/
private static final String SETUP_ATTR_NAME = "setup";

/**
* The XML name of the <tt>fingerprint</tt> element's attribute which
* signals whether it supports the cryptex extension. Note: This is non-standard.
*/
public static final String CRYPTEX_ATTR_NAME = "cryptex";

/** Initializes a new <tt>DtlsFingerprintPacketExtension</tt> instance. */
public DtlsFingerprintPacketExtension()
{
Expand Down Expand Up @@ -117,6 +123,17 @@ public String getSetup()
return getAttributeAsString(SETUP_ATTR_NAME);
}

/**
* Returns value of 'cryptex' attribute. See {@link #CRYPTEX_ATTR_NAME} for more
* info.
*/
public boolean getCryptex()
{
String attr = getAttributeAsString(CRYPTEX_ATTR_NAME);

return (attr == null) ? false : Boolean.parseBoolean(attr);
}

/**
* Sets the fingerprint to be carried/represented by this instance.
*
Expand Down Expand Up @@ -157,4 +174,13 @@ public void setSetup(String setup)
{
setAttribute(SETUP_ATTR_NAME, setup);
}

/**
* Sets new value for 'cryptex' attribute.
* @param cryptex see {@link #CRYPTEX_ATTR_NAME} for details.
*/
public void setCryptex(Boolean cryptex)
{
setAttribute(CRYPTEX_ATTR_NAME, cryptex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private val expectedMappings = listOf(
<endpoint xmlns="jitsi:colibri2" id="79f0273e">
<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">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>
<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>
<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 @@ -346,7 +346,8 @@ private val expectedMappings = listOf(
{
"fingerprint": "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",
"setup": "actpass",
"hash": "sha-256"
"hash": "sha-256",
"cryptex": true
}
]
}
Expand Down

0 comments on commit 379c87b

Please sign in to comment.