res_srtp: Add support for libsrtp2

ASTERISK-25294 #close
Reported by: Tzafrir Cohen

ASTERISK-26976 #close
Reported by: Alex

Change-Id: I789b1c3d1ed31365bbd9339fa58ef36f48833c40
This commit is contained in:
Sean Bright
2017-05-26 12:15:42 -04:00
parent 56b6a71548
commit 1f136fe885
6 changed files with 704 additions and 75 deletions

View File

@@ -2476,54 +2476,65 @@ then
AST_C_DEFINE_CHECK([SSL_OP_NO_TLSV1_2], [SSL_OP_NO_TLSv1_2], [openssl/ssl.h])
fi
AST_EXT_LIB_CHECK([SRTP], [srtp], [srtp_init], [srtp/srtp.h])
AST_EXT_LIB_CHECK([SRTP], [srtp2], [srtp_init], [srtp2/srtp.h], [], [], [2])
AST_EXT_LIB_CHECK_SHARED([SRTP], [srtp2], [srtp_init], [srtp2/srtp.h], [], [], [], [
AC_MSG_WARN([***])
AC_MSG_WARN([*** libsrtp2 could not be linked as a shared object.])
AC_MSG_WARN([*** Try compiling libsrtp2 manually. Configure libsrtp2])
AC_MSG_WARN([*** with ./configure --prefix=/usr replacing /usr with])
AC_MSG_WARN([*** the prefix of your choice, and then make with])
AC_MSG_WARN([*** 'make libsrtp2.so'])
AC_MSG_WARN([***])
AC_MSG_WARN([*** After re-installing libsrtp2, re-run the Asterisk])
AC_MSG_WARN([*** configure script.])
AC_MSG_WARN([***])
AC_MSG_WARN([*** If you do not need SRTP support re-run configure])
AC_MSG_WARN([*** with the --without-srtp option.])
exit 1
])
if test "$PBX_SRTP" = "1";
if test "x$PBX_SRTP" = x1;
then
saved_libs="${LIBS}"
saved_ldflags="${LDFLAGS}"
saved_cflags="${CFLAGS}"
LIBS="${LIBS} ${SRTP_LIB}"
LDFLAGS="${LDFLAGS} -shared -fPIC"
CFLAGS="${CFLAGS} ${SRTP_INCLUDE}"
AC_MSG_CHECKING(for the ability of -lsrtp to be linked in a shared object)
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[#include <srtp/srtp.h>],
[srtp_init();]
)
],
[ AC_MSG_RESULT(yes) ],
[
AC_MSG_RESULT(no)
AC_MSG_WARN(***)
AC_MSG_WARN(*** libsrtp could not be linked as a shared object.)
AC_MSG_WARN(*** Try compiling libsrtp manually. Configure libsrtp)
AC_MSG_WARN(*** with ./configure CFLAGS=-fPIC --prefix=/usr)
AC_MSG_WARN(*** replacing /usr with the prefix of your choice.)
AC_MSG_WARN(*** After re-installing libsrtp, re-run the Asterisk)
AC_MSG_WARN(*** configure script.)
AC_MSG_WARN(***)
AC_MSG_WARN(*** If you do not need SRTP support re-run configure)
AC_MSG_WARN(*** with the --without-srtp option.)
AST_EXT_LIB_CHECK([SRTP_256], [srtp2], [srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80])
AST_EXT_LIB_CHECK([SRTP_GCM], [srtp2], [srtp_crypto_policy_set_aes_gcm_128_8_auth])
AST_EXT_LIB_CHECK([SRTP_SHUTDOWN], [srtp2], [srtp_shutdown], [srtp2/srtp.h])
# libsrtp2 removed support for PRNG, so we require OpenSSL
if test "x$PBX_OPENSSL" != x1;
then
AC_MSG_WARN([***])
AC_MSG_WARN([*** OpenSSL required when using libsrtp2, checking for libsrtp instead.])
AC_MSG_WARN([***])
PBX_SRTP=0
fi
fi
if test "x$PBX_SRTP" != x1;
then
AST_EXT_LIB_CHECK([SRTP], [srtp], [srtp_init], [srtp/srtp.h], [], [], [1])
AST_EXT_LIB_CHECK_SHARED([SRTP], [srtp], [srtp_init], [srtp/srtp.h], [], [], [], [
AC_MSG_WARN([***])
AC_MSG_WARN([*** libsrtp could not be linked as a shared object.])
AC_MSG_WARN([*** Try compiling libsrtp manually. Configure libsrtp])
AC_MSG_WARN([*** with ./configure CFLAGS=-fPIC --prefix=/usr])
AC_MSG_WARN([*** replacing /usr with the prefix of your choice.])
AC_MSG_WARN([*** After re-installing libsrtp, re-run the Asterisk])
AC_MSG_WARN([*** configure script.])
AC_MSG_WARN([***])
AC_MSG_WARN([*** If you do not need SRTP support re-run configure])
AC_MSG_WARN([*** with the --without-srtp option.])
exit 1
]
)
LIBS="${saved_libs}"
LDFLAGS="${saved_ldflags}"
CFLAGS="${saved_cflags}"
fi
])
if test "$PBX_SRTP" = "1";
then
AST_EXT_LIB_CHECK([SRTP_256], [srtp], [crypto_policy_set_aes_cm_256_hmac_sha1_80])
AST_EXT_LIB_CHECK([SRTP_192], [srtp], [crypto_policy_set_aes_cm_192_hmac_sha1_80])
AST_EXT_LIB_CHECK([SRTP_GCM], [srtp], [aes_gcm_128_openssl])
if test "x$PBX_SRTP" = x1;
then
AST_EXT_LIB_CHECK([SRTP_256], [srtp], [crypto_policy_set_aes_cm_256_hmac_sha1_80])
AST_EXT_LIB_CHECK([SRTP_192], [srtp], [crypto_policy_set_aes_cm_192_hmac_sha1_80])
AST_EXT_LIB_CHECK([SRTP_GCM], [srtp], [crypto_policy_set_aes_gcm_128_8_auth])
AST_EXT_LIB_CHECK([SRTP_SHUTDOWN], [srtp], [srtp_shutdown], [srtp/srtp.h])
fi
fi
AST_EXT_LIB_CHECK([SRTP_SHUTDOWN], [srtp], [srtp_shutdown], [srtp/srtp.h])
for ver in 2.0 2.2 2.4 2.6; do
AST_PKG_CONFIG_CHECK([GMIME], gmime-$ver)
if test "$PBX_GMIME" = 1; then