From 36d6169386e04b6ebdb75489fce3b4d216292148 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 28 Feb 2019 13:35:09 +0100 Subject: [PATCH] jingle_ice_udp: Add DTLS-SRTP support. --- src/jingle_ice_udp.rs | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/jingle_ice_udp.rs b/src/jingle_ice_udp.rs index 40a07a6..3b38670 100644 --- a/src/jingle_ice_udp.rs +++ b/src/jingle_ice_udp.rs @@ -4,6 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use crate::jingle_dtls_srtp::Fingerprint; use std::net::IpAddr; generate_element!( @@ -17,8 +18,11 @@ generate_element!( ufrag: Option = "ufrag", ], children: [ - /// List of candidates for this ICE-UDP session. - candidates: Vec = ("candidate", JINGLE_ICE_UDP) => Candidate + /// List of candidates for this ICE-UDP session. + candidates: Vec = ("candidate", JINGLE_ICE_UDP) => Candidate, + + /// Fingerprint of the key used for the DTLS handshake. + fingerprint: Option = ("fingerprint", JINGLE_DTLS) => Fingerprint ] ); @@ -89,25 +93,27 @@ mod tests { use super::*; use minidom::Element; use try_from::TryFrom; + use crate::hashes::Algo; + use crate::jingle_dtls_srtp::Setup; #[cfg(target_pointer_width = "32")] #[test] fn test_size() { - assert_size!(Transport, 36); + assert_size!(Transport, 68); assert_size!(Type, 1); - assert_size!(Candidate, 72); + assert_size!(Candidate, 80); } #[cfg(target_pointer_width = "64")] #[test] fn test_size() { - assert_size!(Transport, 72); + assert_size!(Transport, 136); assert_size!(Type, 1); assert_size!(Candidate, 104); } #[test] - fn test_simple() { + fn test_gajim() { let elem: Element = " @@ -135,4 +141,25 @@ mod tests { assert_eq!(transport.pwd.unwrap(), "wakMJ8Ydd5rqnPaFerws5o"); assert_eq!(transport.ufrag.unwrap(), "aeXX"); } + + #[test] + fn test_jitsi_meet() { + let elem: Element = " + + 97:F2:B5:BE:DB:A6:00:B1:3E:40:B2:41:3C:0D:FC:E0:BD:B2:A0:E8 + + + +" + .parse() + .unwrap(); + let transport = Transport::try_from(elem).unwrap(); + assert_eq!(transport.pwd.unwrap(), "7lk9uul39gckit6t02oavv2r9j"); + assert_eq!(transport.ufrag.unwrap(), "2acq51d4p07v2m"); + + let fingerprint = transport.fingerprint.unwrap(); + assert_eq!(fingerprint.hash, Algo::Sha_1); + assert_eq!(fingerprint.setup, Setup::Actpass); + assert_eq!(fingerprint.value, [151, 242, 181, 190, 219, 166, 0, 177, 62, 64, 178, 65, 60, 13, 252, 224, 189, 178, 160, 232]); + } }