freeswitch/src
Piotr Gregor 1fdd58f533 FS-10778: Add support for MKI to SRTP
MKI support for SRTP has been tested on calls to/from
Telnyx's Skype for Business from/to local extension registered to FS
and between Skype for Business clients connected to FreeSWITCH.

SfB -> FreeSWITCH -> User 1004
   SRTP           RTP
   with
   MKI

SfB <- FreeSWITCH <- User 1004
   SRTP           RTP

SfB <-> FreeSWITCH <-> SfB
 SRTP/MKI      SRTP/MKI

Channel variable "rtp_secure_media_mki" was added to drive offering
of MKI on outbound SRTP from FS.

How to use rtp_secure_media_mki

Set rtp_secure_media_mki=true to offer MKI for outgoing SRTP (if SRTP is used) in inbound call.
Export rtp_secure_media=true to offer MKI for outgoing SRTP (if SRTP is used) on outbound call.
... or set it in the codec string for bridged calls

<action application="set" data="rtp_secure_media_mki=true"/>

<action application="export" data="rtp_secure_media_mki=true"/>

<action application="bridge" data="[absolute_codec_string=^^:PCMU:PCMA:G729,rtp_secure_media=true,rtp_secure_media_mki=true]sofia/external/+12404373253@169.55.36.24:5060;transport=tls"/>

EXAMPLES

1. Set example

 57     <extension name="telnyx_test_1_2">
 58         <condition field="destination_number" expression="^(0012404373253)$">
 59             <action application="set" data="rtp_secure_media=true"/>
 60             <action application="set" data="rtp_secure_media_mki=true"/>
 61             <action application="answer"/>
 62             <action application="bridge" data="user/1004@${domain_name}"/>
 63       </condition>
 64   </extension>

Description: SRTP will be used on outbound leg in incoming call due to rtp_secure_media=true
set and MKI will be offered in SDP. SRTP will not be used on a bridged call to extension 1004.

2. Export example

 75   <extension name="to_skype_for_business">
 76       <condition field="destination_number" expression="^(840531022)$">
 77           <action application="set" data="rtp_secure_media=optional"/>
 78           <action application="export" data="rtp_secure_media_mki=true"/>
 79           <action application="bridge" data="[absolute_codec_string=^^:PCMU:PCMA:G729,rtp_secure_media=true]sofia/external/+12404373728@169.55.36.24:5060;transport=tls"/>
 80       </condition>
 81   </extension>

Description: SRTP on inbound call has been set to optional therefore MKI will be used
on outbound SRTP in this call if SRTP is used at all. SRTP will be used on a bridged call
due to rtp_secure_media=true set in codec string and MKI will be used in offering SDP.

3. Bridging between Skype for Business clients: set

 97     <extension name="S4B_fs_S4B">
 98         <condition field="destination_number" expression="^(0012404373254)$">
 99             <action application="set" data="rtp_secure_media=true"/>
100             <action application="set" data="rtp_secure_media_mki=true"/>
101             <action application="bridge" data="[absolute_codec_string=^^:PCMU:PCMA:G729,rtp_secure_media=true]sofia/external/+12404373253@169.55.36.$
102       </condition>
103   </extension>

Result:
2017-11-27 19:00:26.977704 [NOTICE] switch_ivr_originate.c:527 Ring Ready sofia/external/+12404373728@telnyxlab.com!
2017-11-27 19:00:32.657687 [NOTICE] switch_core_media.c:1534 Skipping MKI due to empty index
2017-11-27 19:00:32.657687 [INFO] switch_rtp.c:4079 Activating audio Secure RTP SEND
2017-11-27 19:00:32.657687 [INFO] switch_rtp.c:4057 Activating audio Secure RTP RECV
2017-11-27 19:00:32.657687 [NOTICE] sofia.c:8419 Channel [sofia/external/%2B12404373253@169.55.36.24:5060] has been answered
2017-11-27 19:00:35.317702 [INFO] switch_rtp.c:4079 Activating audio Secure RTP SEND (with MKI)
2017-11-27 19:00:35.317702 [INFO] switch_rtp.c:4057 Activating audio Secure RTP RECV (with MKI)
2017-11-27 19:00:35.317702 [NOTICE] sofia_media.c:92 Pre-Answer sofia/external/+12404373728@telnyxlab.com!

Description: SRTP with MKI is used on outbound leg of inbound call (due to use on inbound leg of this call and "set").
Standard SRTP is used in both legs of outbound call, because rtp_secure_media_mki wasn't exported
or set in codec string for the outbound call.

4. Bridging between Skype for Business clients: Set and export

 97     <extension name="S4B_fs_S4B">
 98         <condition field="destination_number" expression="^(0012404373254)$">
 99             <action application="set" data="rtp_secure_media=true"/>
100             <action application="set" data="rtp_secure_media_mki=true"/>
101             <action application="export" data="rtp_secure_media_mki=true"/>
102             <action application="bridge" data="[absolute_codec_string=^^:PCMU:PCMA:G729,rtp_secure_media=true]sofia/external/+12404373253@169.55.36.24:5060;transport=tls"/>
103       </condition>
104   </extension>

Result:
2017-11-27 18:51:29.017689 [NOTICE] switch_ivr_originate.c:527 Ring Ready sofia/external/+12404373728@telnyxlab.com!
2017-11-27 18:51:35.097729 [INFO] switch_rtp.c:4079 Activating audio Secure RTP SEND (with MKI)
2017-11-27 18:51:35.097729 [INFO] switch_rtp.c:4057 Activating audio Secure RTP RECV (with MKI)
2017-11-27 18:51:35.097729 [NOTICE] sofia.c:8419 Channel [sofia/external/%2B12404373253@169.55.36.24:5060] has been answered
2017-11-27 18:51:37.797706 [INFO] switch_rtp.c:4079 Activating audio Secure RTP SEND (with MKI)
2017-11-27 18:51:37.797706 [INFO] switch_rtp.c:4057 Activating audio Secure RTP RECV (with MKI)

Description: Connecting Skype For Business client to Skype for Business client.
Send SRTP with MKI in both outbound streams:
	- for inbound call: MKI was offered in incoming call and enabled for outbound leg with "set"
	- for outbound call: MKI was enabled with "export"

5. Other examples

Setup to use SRTP with MKI only on the inbound SRTP on incoming call from Telnyx SfB
Tested dialing 0012404373253 from SfB to FS, leg SfB <-> FS uses SRTP with MKI
on inbound SRTP only

57     <extension name="telnyx_test_1_2">
58         <condition field="destination_number" expression="^(0012404373253)$">
59              <action application="set" data="rtp_secure_media=true"/>
61              <action application="answer"/>
62              <action application="bridge" data="user/1004@${domain_name}"/>
63       </condition>
64   </extension>

Result:
2017-11-23 20:44:35.406026 [INFO] mod_dialplan_xml.c:637 Processing Test02 <+12404373728>->0012404373253 in context public
2017-11-23 20:44:38.566022 [INFO] switch_rtp.c:4107 Activating audio Secure RTP SEND
2017-11-23 20:44:38.566022 [INFO] switch_rtp.c:4085 Activating audio Secure RTP RECV (with MKI)

Setup to send and receive SRTP with MKI on incoming call from Telnyx SfB
Tested dialing 0012404373253 from SfB to FS, leg SfB <-> FS uses SRTP with MKI
in both directions

57     <extension name="telnyx_test_1_2">
58         <condition field="destination_number" expression="^(0012404373253)$">
59     		<action application="set" data="rtp_secure_media=true"/>
60     		<action application="set" data="rtp_secure_media_mki"/>
61     		<action application="answer"/>
62     		<action application="bridge" data="user/1004@${domain_name}"/>
63       </condition>
64   </extension>

Result:
2017-11-23 20:42:06.026034 [INFO] mod_dialplan_xml.c:637 Processing Test02 <+12404373728>->0012404373253 in context public
2017-11-23 20:42:09.526034 [INFO] switch_rtp.c:4107 Activating audio Secure RTP SEND (with MKI)
2017-11-23 20:42:09.526034 [INFO] switch_rtp.c:4085 Activating audio Secure RTP RECV (with MKI)

Setup to offer MKI on outbound call to extension 1001 (X-Lite -> FS -> linphone)
Tested dialing 0012404373253 from user 1004, leg FS <-> 1001 uses SRTP with MKI

782     <extension name="telnyx_test_1_2">
783         <condition field="destination_number" expression="^(0012404373253)$">
784             <action application="export" data="rtp_secure_media_outbound=true"/>
785             <action application="export" data="rtp_secure_media_mki"/>
786             <action application="answer"/>
797             <action application="bridge" data="user/1001@${domain_name}"/>
798       </condition>
799   </extension>

Result:
2017-11-23 20:23:26.266034 [INFO] mod_dialplan_xml.c:637 Processing 1000 windows <1000>->0012404373253 in context default
2017-11-23 20:23:26.366035 [INFO] switch_rtp.c:4107 Activating audio Secure RTP SEND (with MKI)
2017-11-23 20:23:26.366035 [INFO] switch_rtp.c:4085 Activating audio Secure RTP RECV

SfB sometimes offers crypto with LIFETIME but no MKI index, e.g.:
a=crypto:5 AES_CM_128_HMAC_SHA1_80 inline:9OtFWi17H9E8ywlm0iazemjAqXu2RhJ3DZyo+VLJ|2^31

Defaulting to no-mki SRTP in case key material doesn't contain MKI index.
2018-07-24 07:21:34 +00:00
..
include FS-10778: Add support for MKI to SRTP 2018-07-24 07:21:34 +00:00
mod FS-10762: [freeswitch-core] Websocket logic error #resolve 2018-07-24 07:21:33 +00:00
.gitignore
CMakeLists.txt
Makefile.am
cJSON.c FS-10036: fix windows build issues. These patches need to go upstream 2017-03-15 16:13:40 -05:00
cJSON_Utils.c FS-10036: update cJSON code to pre 1.4.0 release of cJSON. this includes backports of all our fixes, and our build macros for windows and visibility. It also makes it easy to drop in a new version, and to in the future be able to switch to a system version of cJSON easily (after all these updates are in, probably around v2.0 timeframe. Note this new version adds a lot of extra error checking, fixes some buffer overruns, and improves parser and printer performance 2017-02-27 18:53:23 -06:00
fs_encode.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
g711.c
inet_pton.c
switch.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_apr.c FS-10876: [Build-System] Fix build in Visual Studio 2017 and Windows SDK 10. 2018-01-10 23:30:24 +03:00
switch_buffer.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_caller.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_channel.c FS-10387: [core] High memory usage with mod_sofia, osmo-nitb and DTX setting active #resolve 2017-06-22 15:48:20 -05:00
switch_config.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_console.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core.c FS-10189: [core] switch_core_add_state_handler runtime.state_handler_index may exceed SWITCH_MAX_STATE_HANDLERS #resolve 2017-06-05 18:31:56 -05:00
switch_core_asr.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_cert.c FS-9785: changes to support newer openssl 2017-06-26 14:53:39 -05:00
switch_core_codec.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_db.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_directory.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_event_hook.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_file.c FS-10503: [mod_av] mod_av split audio to two channels #resolve 2017-08-11 13:23:15 -05:00
switch_core_hash.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_io.c FS-11230: [core] Fix bad rtp timestamps triggered by cng/missed packet detection 2018-07-13 15:18:35 -04:00
switch_core_media.c FS-10778: Add support for MKI to SRTP 2018-07-24 07:21:34 +00:00
switch_core_media_bug.c FS-10388: [core] fix crash on shutdown when using multiple meida bugs 2017-07-05 15:54:56 -05:00
switch_core_memory.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_port_allocator.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_rwlock.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_session.c Revert "FS-10416: [mod_commands] add new outbound channels to an in-progress originate" 2017-07-11 17:25:48 -05:00
switch_core_speech.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_sqldb.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_state_machine.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_timer.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_core_video.c FS-11168: [core] fix compile error on gentoo from typo in assert statement 2018-05-16 17:12:08 -04:00
switch_cpp.cpp FS-10118: [freeswitch-core] Race conditions from lack of error checking in switch_core_session_read_lock #resolve 2017-03-09 13:22:25 -06:00
switch_curl.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_dso.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_estimators.c FS-10876: [Build-System] Fix build in Visual Studio 2017 and Windows SDK 10. 2018-01-10 23:30:24 +03:00
switch_event.c FS-10672 [core] Fix event url-encoding buffer size 2017-09-14 18:05:59 +03:00
switch_hashtable.c FS-10601: [freeswitch-core] accomodate should be accommodate #resolve 2017-08-21 17:09:24 -05:00
switch_ivr.c FS-10001: [core] Fix Buffer overflow collecting digits 2017-03-06 12:51:29 -06:00
switch_ivr_async.c FS-10503: [mod_av] mod_av split audio to two channels #resolve 2017-08-11 13:23:15 -05:00
switch_ivr_bridge.c FS-10328: [freeswitch-core] Add method to allow orphaned B legs during originate to transfer to another extension #resolve 2017-05-18 11:57:37 -05:00
switch_ivr_menu.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_ivr_originate.c Merge pull request #1374 in FS/freeswitch from ~MOCHOUINARD/freeswitch:bugfix/FS-10608-patch-change-hard-coded-60-value to master 2017-09-08 17:29:14 +00:00
switch_ivr_play_say.c FS-10859 #resolve 2017-12-24 10:23:13 +08:00
switch_ivr_say.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_jitterbuffer.c FS-10417: [freeswitch-core] Reduce flicker in screen sharing -- minor tweak 2017-06-26 12:56:42 -05:00
switch_json.c FS-10036: update cJSON code to pre 1.4.0 release of cJSON. this includes backports of all our fixes, and our build macros for windows and visibility. It also makes it easy to drop in a new version, and to in the future be able to switch to a system version of cJSON easily (after all these updates are in, probably around v2.0 timeframe. Note this new version adds a lot of extra error checking, fixes some buffer overruns, and improves parser and printer performance 2017-02-27 18:53:23 -06:00
switch_limit.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_loadable_module.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_log.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_mprintf.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_msrp.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_nat.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_odbc.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_pcm.c FS-10529: [mod_native_file] mod_native_file: remove "opus" extension -- fix regression 2017-08-17 16:08:40 -05:00
switch_pgsql.c FS-10774 - [switch_pgsql] Fix build for PostgreSQL/libpq 10 2017-11-06 10:35:36 -03:00
switch_profile.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_regex.c FS-11061: [core] fix build with newer pcre 2018-03-29 11:18:20 -04:00
switch_resample.c FS-9922: [mod_conference] Auto Energy Level 2017-05-03 15:25:04 -05:00
switch_rtp.c FS-10778: Add support for MKI to SRTP 2018-07-24 07:21:34 +00:00
switch_scheduler.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_sdp.c
switch_speex.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_stun.c FS-10394: [freeswitch-core] FS Crash while linphone sends ICE packets 2017-06-28 11:32:24 -05:00
switch_swig.c FS-10608: Change 60 second timeout value to a global #define SWITCH_DEFAULT_TIMEOUT 2017-08-29 13:54:34 -04:00
switch_swig.i
switch_time.c FS-10126: [freeswitch-core] General Video Improvements #resolve 2017-03-15 15:24:01 -05:00
switch_utf8.c
switch_utils.c FS-10778: Add support for MKI to SRTP 2018-07-24 07:21:34 +00:00
switch_version.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
switch_vpx.c FS-10647: [mod_av] Video quality degragation from 1.6.17 to 1.6.19 #resolve 2017-09-06 12:59:18 -05:00
switch_xml.c FS-10784: [freeswitch-core] Make Users lists compatible with all forms of xml #resolve 2018-07-24 07:21:33 +00:00
switch_xml_config.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00
tone2wav.c FS-9924: Removed extra space in source files 2017-02-09 23:59:49 -05:00