[asterisk-commits] chan sip: Don't refuse calls with "optional crypto"; fall ba... (asterisk[11])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 6 22:47:52 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP.
......................................................................
chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP.
Certain SNOM phones send so-called "optional crypto" in their SDP body.
Regular SRTP setup looks like this:
m=audio 64620 RTP/SAVP 8 0 9 99 3 18 4 101
a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...
SNOM-style "optional crypto" looks like this:
m=audio 61438 RTP/AVP 8 0 9 99 3 18 4 101
a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...
A crypto line is supplied, but the m-line does not have SAVP.
When res_srtp.so is *not* loaded, then chan_sip.so treats the optional
crypto as regular RTP, but when res_srtp.so *is* loaded, it refuses the
incoming call with the following message:
WARNING: process_sdp: Failed to receive SDP offer/answer with
required SRTP crypto attributes for audio
For platforms that want to start providing SRTP this presents a
compatibility problem.
This changeset lets chan_sip handle the SDP as if no crypto-line was
supplied: i.e. accept the call as regular RTP, just like it did before
res_srtp was loaded.
Now you'll get this informative warning instead:
WARNING: Ignoring crypto attribute in SDP because RTP transport is
insecure
ASTERISK-23989 #close
Reported by: Olle Johansson
Change-Id: I91a15ae05a0296e398d6b65f53bb11afde1d80e2
---
M channels/chan_sip.c
1 file changed, 25 insertions(+), 5 deletions(-)
Approvals:
George Joseph: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
Objections:
Alexander Traud: I would prefer this is not merged as is
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 9eaed58..1e686c8 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1658,7 +1658,8 @@
/*------ SRTP Support -------- */
static int setup_srtp(struct sip_srtp **srtp);
-static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct sip_srtp **srtp, const char *a);
+static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct sip_srtp **srtp,
+ const char *a, int secure_transport);
/*------ T38 Support --------- */
static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
@@ -10339,7 +10340,7 @@
}
} else if (process_sdp_a_sendonly(value, &sendonly)) {
processed = TRUE;
- } else if (!processed_crypto && process_crypto(p, p->rtp, &p->srtp, value)) {
+ } else if (!processed_crypto && process_crypto(p, p->rtp, &p->srtp, value, secure_audio)) {
processed_crypto = TRUE;
processed = TRUE;
} else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec)) {
@@ -10356,7 +10357,7 @@
if (p->vsrtp) {
ast_set_flag(p->vsrtp, SRTP_CRYPTO_OFFER_OK);
}
- } else if (!processed_crypto && process_crypto(p, p->vrtp, &p->vsrtp, value)) {
+ } else if (!processed_crypto && process_crypto(p, p->vrtp, &p->vsrtp, value, secure_video)) {
processed_crypto = TRUE;
processed = TRUE;
} else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec)) {
@@ -10369,7 +10370,7 @@
processed = TRUE;
} else if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec)) {
processed = TRUE;
- } else if (!processed_crypto && process_crypto(p, p->trtp, &p->tsrtp, value)) {
+ } else if (!processed_crypto && process_crypto(p, p->trtp, &p->tsrtp, value, 1)) {
processed_crypto = TRUE;
processed = TRUE;
}
@@ -33549,7 +33550,8 @@
return 0;
}
-static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct sip_srtp **srtp, const char *a)
+static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct sip_srtp **srtp,
+ const char *a, int secure_transport)
{
struct ast_rtp_engine_dtls *dtls;
@@ -33562,6 +33564,24 @@
if (strncasecmp(a, "crypto:", 7)) {
return FALSE;
}
+
+ if (!secure_transport) {
+ /* > The Secure Real-time Transport Protocol (SRTP)
+ * > [RFC3711] provides security services for RTP media
+ * > and is signaled by use of secure RTP transport (e.g.,
+ * > "RTP/SAVP" or "RTP/SAVPF") in an SDP media (m=) line.
+ * > ...
+ * > The "crypto" attribute MUST only appear at the SDP
+ * > media level (not at the session level).
+ *
+ * Ergo, we can trust RTP/(S)AVP to be read from the m=
+ * line before we get here. If it was RTP/AVP, then this
+ * is SNOM-specific optional SRTP. Ignore it.
+ */
+ ast_log(LOG_WARNING, "Ignoring crypto attribute in SDP because RTP transport is insecure\n");
+ return FALSE;
+ }
+
if (!*srtp) {
if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
ast_log(LOG_WARNING, "Ignoring unexpected crypto attribute in SDP answer\n");
--
To view, visit https://gerrit.asterisk.org/3831
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I91a15ae05a0296e398d6b65f53bb11afde1d80e2
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Walter Doekes <walter+asterisk at wjd.nu>
Gerrit-Reviewer: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list