[svn-commits] mjordan: trunk r372712 - in /trunk: ./ channels/sip/sdp_crypto.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Sep 8 20:28:34 CDT 2012


Author: mjordan
Date: Sat Sep  8 20:28:31 2012
New Revision: 372712

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372712
Log:
Only re-create an SRTP session when needed

In r356604, SRTP handling was fixed to accomodate multiple crypto keys in an
SDP offer and the ability to re-create an SRTP session when the crypto keys
changed.  In certain circumstances - most notably when a phone is put on
hold after having been bridged for a significant amount of time - the act
of re-creating the SRTP session causes problems for certain models of phones.
The patch committed in r356604 always re-created the SRTP session regardless
of whether or not the cryptographic keys changed.  Since this is technically
not necessary, this patch modifies the behavior to only re-create the SRTP
session if Asterisk detects that the remote key has changed.  This allows
models of phones that do not handle the SRTP session changing to continue
to work, while also providing the behavior needed for those phones that do
re-negotiate cryptographic keys.

(issue ASTERISK-20194)
Reported by: Nicolo Mazzon
Tested by: Nicolo Mazzon

Review: https://reviewboard.asterisk.org/r/2099
........

Merged revisions 372709 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 372710 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 372711 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/channels/sip/sdp_crypto.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/channels/sip/sdp_crypto.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/sdp_crypto.c?view=diff&rev=372712&r1=372711&r2=372712
==============================================================================
--- trunk/channels/sip/sdp_crypto.c (original)
+++ trunk/channels/sip/sdp_crypto.c Sat Sep  8 20:28:31 2012
@@ -50,6 +50,7 @@
 	char *a_crypto;
 	unsigned char local_key[SRTP_MASTER_LEN];
 	char local_key64[SRTP_MASTER_LEN64];
+	unsigned char remote_key[SRTP_MASTER_LEN];
 };
 
 static int set_crypto_policy(struct ast_srtp_policy *policy, int suite_val, const unsigned char *master_key, unsigned long ssrc, int inbound);
@@ -260,11 +261,16 @@
 		return -1;
 	}
 
-
 	if ((key_len = ast_base64decode(remote_key, key_salt, sizeof(remote_key))) != SRTP_MASTER_LEN) {
-		ast_log(LOG_WARNING, "SRTP sdescriptions key %d != %d\n", key_len, SRTP_MASTER_LEN);
-		return -1;
-	}
+		ast_log(LOG_WARNING, "SRTP descriptions key %d != %d\n", key_len, SRTP_MASTER_LEN);
+		return -1;
+	}
+
+	if (!memcmp(p->remote_key, remote_key, sizeof(p->remote_key))) {
+		ast_debug(1, "SRTP remote key unchanged; maintaining current policy\n");
+		return 0;
+	}
+	memcpy(p->remote_key, remote_key, sizeof(p->remote_key));
 
 	if (sdp_crypto_activate(p, suite_val, remote_key, rtp) < 0) {
 		return -1;




More information about the svn-commits mailing list