From 8fa947aa19a9c6e202ab644975be39b966f6201c Mon Sep 17 00:00:00 2001 From: Carlos Perez Alcaraz Date: Tue, 8 Mar 2016 12:10:43 +0100 Subject: [PATCH] FS-8910: Properly negotiate SDES when receiving SDP with a=crypto:0 When receiving an SDP with a=crypto:0 with the wanted crypto suite, we should maintain that crypto tag in the local SDP in order for SDES setup to succeed. --- src/include/switch_core_media.h | 1 + src/switch_core_media.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 65c400ea33..721e90b3ac 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -39,6 +39,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_MAX_CAND_ACL 25 +#define SWITCH_NO_CRYPTO_TAG -1 typedef enum { DTMF_2833, diff --git a/src/switch_core_media.c b/src/switch_core_media.c index a3dba3cfd1..2e9eefece6 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -1065,7 +1065,7 @@ static switch_status_t switch_core_media_build_crypto(switch_media_handle_t *smh *p-- = '\0'; } - if (!index) index = ctype + 1; + if (index == SWITCH_NO_CRYPTO_TAG) index = ctype + 1; engine->ssec[ctype].local_crypto_key = switch_core_session_sprintf(smh->session, "%d %s inline:%s", index, SUITES[ctype].name, b64_key); switch_channel_set_variable_name_printf(smh->session->channel, engine->ssec[ctype].local_crypto_key, "rtp_last_%s_local_crypto_key", type2str(type)); @@ -1461,10 +1461,10 @@ SWITCH_DECLARE(void) switch_core_session_check_outgoing_crypto(switch_core_sessi for (i = 0; smh->crypto_suite_order[i] != CRYPTO_INVALID; i++) { switch_core_media_build_crypto(session->media_handle, - SWITCH_MEDIA_TYPE_AUDIO, 0, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0); + SWITCH_MEDIA_TYPE_AUDIO, SWITCH_NO_CRYPTO_TAG, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0); switch_core_media_build_crypto(session->media_handle, - SWITCH_MEDIA_TYPE_VIDEO, 0, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0); + SWITCH_MEDIA_TYPE_VIDEO, SWITCH_NO_CRYPTO_TAG, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0); } }