From 1d2173c7aed0587cdd434e69e89a3972a2642cd8 Mon Sep 17 00:00:00 2001 From: Alexander Traud Date: Wed, 13 Jul 2016 12:24:46 +0200 Subject: res_srtp: Enable AES-256 and AES-GCM. ASTERISK-26190 #close Change-Id: I11326d80edd656524a51a19450e586c583aa0a0b --- res/res_pjsip_sdp_rtp.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'res/res_pjsip_sdp_rtp.c') diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 048209ce1..6610ef126 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -51,6 +51,7 @@ ASTERISK_REGISTER_FILE() #include "asterisk/acl.h" #include "asterisk/sdp_srtp.h" #include "asterisk/dsp.h" +#include "asterisk/linkedlists.h" /* for AST_LIST_NEXT */ #include "asterisk/res_pjsip.h" #include "asterisk/res_pjsip_session.h" @@ -938,6 +939,7 @@ static int add_crypto_to_stream(struct ast_sip_session *session, enum ast_rtp_dtls_hash hash; const char *crypto_attribute; struct ast_rtp_engine_dtls *dtls; + struct ast_sdp_srtp *tmp; static const pj_str_t STR_NEW = { "new", 3 }; static const pj_str_t STR_EXISTING = { "existing", 8 }; static const pj_str_t STR_ACTIVE = { "active", 6 }; @@ -957,16 +959,22 @@ static int add_crypto_to_stream(struct ast_sip_session *session, } } - crypto_attribute = ast_sdp_srtp_get_attrib(session_media->srtp, - 0 /* DTLS running? No */, - session->endpoint->media.rtp.srtp_tag_32 /* 32 byte tag length? */); - if (!crypto_attribute) { - /* No crypto attribute to add, bad news */ - return -1; - } + tmp = session_media->srtp; + + do { + crypto_attribute = ast_sdp_srtp_get_attrib(tmp, + 0 /* DTLS running? No */, + session->endpoint->media.rtp.srtp_tag_32 /* 32 byte tag length? */); + if (!crypto_attribute) { + /* No crypto attribute to add, bad news */ + return -1; + } + + attr = pjmedia_sdp_attr_create(pool, "crypto", + pj_cstr(&stmp, crypto_attribute)); + media->attr[media->attr_count++] = attr; + } while ((tmp = AST_LIST_NEXT(tmp, sdp_srtp_list))); - attr = pjmedia_sdp_attr_create(pool, "crypto", pj_cstr(&stmp, crypto_attribute)); - media->attr[media->attr_count++] = attr; break; case AST_SIP_MEDIA_ENCRYPT_DTLS: if (setup_dtls_srtp(session, session_media)) { -- cgit v1.2.3