1 diff -u -r mediastreamer2-2.16.1/configure.ac mediastreamer2-2.16.1-libsrtp2/configure.ac
2 --- mediastreamer2-2.16.1/configure.ac 2017-07-21 15:00:47.000000000 +0200
3 +++ mediastreamer2-2.16.1-libsrtp2/configure.ac 2018-01-13 00:06:22.194089121 +0100
6 dnl check for libsrtp support (secure rtp)
8 - AC_HELP_STRING([--with-srtp], [Set prefix where libsrtp can be found or "none" to disable (ex:/usr or /usr/local) [[default=/usr]]]),
9 + AC_HELP_STRING([--with-srtp], [Set prefix where libsrtp2 can be found or "none" to disable (ex:/usr or /usr/local) [[default=/usr]]]),
10 [srtp_prefix=$withval],
11 [if test "$prefix" != "NONE"; then
13 @@ -1051,22 +1051,22 @@
15 if test "${srtp_prefix}" != "none" ; then
16 if test "${srtp_prefix}" != "/usr" ; then
17 - SRTP_CFLAGS="-I${srtp_prefix}/include -I${srtp_prefix}/include/srtp"
18 + SRTP_CFLAGS="-I${srtp_prefix}/include -I${srtp_prefix}/include/srtp2"
19 SRTP_LIBS="-L${srtp_prefix}/lib"
21 - SRTP_LIBS="$SRTP_LIBS -lsrtp"
22 + SRTP_LIBS="$SRTP_LIBS -lsrtp2"
24 dnl check srtp headers
25 CPPFLAGS_save=$CPPFLAGS
26 CPPFLAGS="$CPPFLAGS $SRTP_CFLAGS"
27 - AC_CHECK_HEADER([srtp/srtp.h],have_srtp_headers=yes)
28 + AC_CHECK_HEADER([srtp2/srtp.h],have_srtp_headers=yes)
29 CPPFLAGS=$CPPFLAGS_save
31 dnl check for srtp lib
33 LDFLAGS="$LDFLAGS $SRTP_LIBS"
35 - AC_CHECK_LIB(srtp,[srtp_init, crypto_policy_set_aes_cm_256_hmac_sha1_80, crypto_policy_set_aes_cm_256_hmac_sha1_32], have_srtp_lib=yes)
36 + AC_CHECK_LIB(srtp2,[srtp_init, srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80, srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32], have_srtp_lib=yes)
42 LDFLAGS="$LDFLAGS $SRTP_LIBS"
47 - AC_MSG_WARN([This libsrtp version exports symbols conflicting with polarssl, resulting in a bad execution path. libsrtp will be statically linked])
48 + AC_MSG_WARN([This libsrtp2 version exports symbols conflicting with polarssl, resulting in a bad execution path. libsrtp2 will be statically linked])
49 srtp_polarssl_conflict=yes
51 srtp_polarssl_conflict=no
52 @@ -1086,13 +1086,13 @@
55 if test "$srtp_polarssl_conflict" = "yes"; then
56 - srtp_static_lib="${srtp_prefix}/lib/libsrtp.a"
57 + srtp_static_lib="${srtp_prefix}/lib/libsrtp2.a"
58 if test -f $srtp_static_lib -a -r $srtp_static_lib; then
59 - SRTP_LIBS="${srtp_prefix}/lib/libsrtp.a -Bsymbolic -Wl,--version-script=\$(top_srcdir)/src/libsrtp.map"
60 + SRTP_LIBS="${srtp_prefix}/lib/libsrtp2.a -Bsymbolic -Wl,--version-script=\$(top_srcdir)/src/libsrtp2.map"
61 AC_DEFINE(HAVE_SRTP, 1, [Defined when srtp support is compiled])
64 - AC_MSG_WARN([Could not access to $srtp_static_lib. Please use --with-srtp=PREFIX to specify the prefix where libsrtp.a has been installed])
65 + AC_MSG_WARN([Could not access to $srtp_static_lib. Please use --with-srtp=PREFIX to specify the prefix where libsrtp2.a has been installed])
69 diff -u -r mediastreamer2-2.16.1/src/crypto/ms_srtp.c mediastreamer2-2.16.1-libsrtp2/src/crypto/ms_srtp.c
70 --- mediastreamer2-2.16.1/src/crypto/ms_srtp.c 2017-07-21 15:00:47.000000000 +0200
71 +++ mediastreamer2-2.16.1-libsrtp2/src/crypto/ms_srtp.c 2018-01-13 00:14:48.575306030 +0100
73 // Windows phone doesn't use make install
76 -#include <srtp/srtp.h>
77 +#include <srtp2/srtp.h>
82 /**** Sender functions ****/
83 static int _process_on_send(RtpSession* session,MSSrtpStreamContext *ctx, mblk_t *m){
86 + srtp_err_status_t err;
87 bool_t is_rtp=ctx->is_rtp;
88 rtp_header_t *rtp_header=is_rtp?(rtp_header_t*)m->b_rptr:NULL;
89 rtcp_common_header_t *rtcp_header=!is_rtp?(rtcp_common_header_t*)m->b_rptr:NULL;
91 ms_mutex_lock(&ctx->mutex);
93 /*does not make sense to protect, because we don't have any key*/
95 + err=srtp_err_status_ok;
96 slen = 0; /*droping packets*/
98 /* defragment incoming message and enlarge the buffer for srtp to write its data */
100 } else if (rtcp_header && (slen>RTP_FIXED_HEADER_SIZE && rtcp_header->version==2)) {
101 ms_mutex_lock(&ctx->mutex);
104 + err=srtp_err_status_ok;
105 /*does not make sense to protect, because we don't have any key*/
106 slen = 0; /*droping packets*/
111 /* check return code from srtp_protect */
112 - if (err==err_status_ok){
113 + if (err==srtp_err_status_ok){
116 ortp_error("srtp_protect%s() failed (%d) for stream ctx [%p]", is_rtp?"":"_rtcp", err,ctx);
119 static int _process_on_receive(RtpSession* session,MSSrtpStreamContext *ctx, mblk_t *m, int err){
121 - err_status_t srtp_err;
122 + srtp_err_status_t srtp_err;
123 bool_t is_rtp=ctx->is_rtp;
125 /* keep NON-RTP data unencrypted */
129 srtp_err = is_rtp?srtp_unprotect(ctx->srtp,m->b_rptr,&slen):srtp_unprotect_rtcp(ctx->srtp,m->b_rptr,&slen);
130 - if (srtp_err==err_status_ok) {
131 + if (srtp_err==srtp_err_status_ok) {
134 ms_error("srtp_unprotect%s() failed (%d) on stream ctx [%p]", is_rtp?"":"_rtcp", srtp_err,ctx);
138 static int ms_media_stream_session_fill_srtp_context(MSMediaStreamSessions *sessions, bool_t is_send, bool_t is_rtp) {
139 - err_status_t err=0;
140 + srtp_err_status_t err=0;
141 RtpTransport *transport=NULL;
142 MSSrtpStreamContext* stream_ctx = get_stream_context(sessions,is_send,is_rtp);
144 @@ -258,28 +258,28 @@
148 -static int ms_set_srtp_crypto_policy(MSCryptoSuite suite, crypto_policy_t *policy) {
149 +static int ms_set_srtp_srtp_crypto_policy(MSCryptoSuite suite, srtp_crypto_policy_t *policy) {
151 case MS_AES_128_SHA1_32:
152 // srtp doc says: not adapted to rtcp...
153 - crypto_policy_set_aes_cm_128_hmac_sha1_32(policy);
154 + srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(policy);
156 case MS_AES_128_NO_AUTH:
157 // srtp doc says: not adapted to rtcp...
158 - crypto_policy_set_aes_cm_128_null_auth(policy);
159 + srtp_crypto_policy_set_aes_cm_128_null_auth(policy);
161 case MS_NO_CIPHER_SHA1_80:
162 - crypto_policy_set_null_cipher_hmac_sha1_80(policy);
163 + srtp_crypto_policy_set_null_cipher_hmac_sha1_80(policy);
165 case MS_AES_128_SHA1_80: /*default mode*/
166 - crypto_policy_set_aes_cm_128_hmac_sha1_80(policy);
167 + srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(policy);
169 case MS_AES_256_SHA1_80: // For backward compatibility
170 case MS_AES_CM_256_SHA1_80:
171 - crypto_policy_set_aes_cm_256_hmac_sha1_80(policy);
173 + srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80(policy);
175 case MS_AES_256_SHA1_32:
176 - crypto_policy_set_aes_cm_256_hmac_sha1_32(policy);
177 + srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32(policy);
179 case MS_CRYPTO_SUITE_INVALID:
181 @@ -291,13 +291,13 @@
182 static int ms_add_srtp_stream(srtp_t srtp, MSCryptoSuite suite, uint32_t ssrc, const char* key, size_t key_length, bool_t is_send, bool_t is_rtp)
184 srtp_policy_t policy;
187 + srtp_err_status_t err;
188 + srtp_ssrc_t ssrc_conf;
190 memset(&policy,0,sizeof(policy));
193 - if (ms_set_srtp_crypto_policy(suite, &policy.rtp) != 0) {
194 + if (ms_set_srtp_srtp_crypto_policy(suite, &policy.rtp) != 0) {
197 /* check if key length match given policy */
202 - if (ms_set_srtp_crypto_policy(suite, &policy.rtcp) != 0) {
203 + if (ms_set_srtp_srtp_crypto_policy(suite, &policy.rtcp) != 0) {
206 if ((int)key_length != policy.rtcp.cipher_key_len) {
210 err = srtp_add_stream(srtp, &policy);
211 - if (err != err_status_ok) {
212 + if (err != srtp_err_status_ok) {
213 ms_error("Failed to add stream to srtp session (%d)", err);
217 int ms_srtp_init(void)
221 + srtp_err_status_t st=0;
222 ms_message("srtp init");
223 if (!srtp_init_done) {
228 ms_fatal("Couldn't initialize SRTP library: %d.", st);
229 - err_reporting_init("mediastreamer2");
231 }else srtp_init_done++;
234 #else /* HAVE_SRTP */
236 typedef void* srtp_t;
237 -typedef int err_status_t;
238 +typedef int srtp_err_status_t;
240 bool_t ms_srtp_supported(void){