Commit 900261f2 authored by Ghislain MARY's avatar Ghislain MARY

Merge branch 'bctoolbox'

parents 897f0ba1 a1bc3110
......@@ -68,7 +68,6 @@ option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation dir
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
cmake_dependent_option(ENABLE_DTLS "Build with DTLS support." YES "ENABLE_SRTP" NO)
option(ENABLE_SRTP "Build with the SRTP transport support." YES)
cmake_dependent_option(ENABLE_ZRTP "Build with ZRTP support." YES "ENABLE_SRTP" NO)
......@@ -150,7 +149,8 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
else()
find_package(ORTP REQUIRED)
endif()
find_package(PolarSSL)
if(ENABLE_PCAP)
find_package(PCAP QUIET)
endif()
......@@ -175,7 +175,6 @@ if(ENABLE_SRTP)
if(NOT SRTP_FOUND)
message(WARNING "Could not find SRTP library, Mediastreamer2 will be compiled without SRTP support.")
set(ENABLE_SRTP OFF CACHE BOOL "Build with the SRTP transport support." FORCE)
set(ENABLE_DTLS OFF CACHE BOOL "Build mediastreamer2 with DTLS support." FORCE)
endif()
endif()
if(ENABLE_ZRTP)
......@@ -189,16 +188,6 @@ if(ENABLE_ZRTP)
set(ENABLE_ZRTP OFF CACHE BOOL "Build mediastreamer2 with ZRTP support." FORCE)
endif()
endif()
if(ENABLE_DTLS AND ENABLE_SRTP) # DTLS requires SRTP
if(NOT POLARSSL_FOUND OR NOT HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
if (NOT POLARSSL_FOUND)
message(WARNING "Could not find polarssl library required by DTLS, mediastreamer2 will be compiled without DTLS support.")
else()
message(WARNING "Polarssl library was found but misses HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE required by DTLS, mediastreamer2 will be compiled without DTLS support.")
endif()
set(ENABLE_DTLS OFF CACHE BOOL "Build mediastreamer2 with DTLS support." FORCE)
endif()
endif()
if(ENABLE_GSM)
find_package(GSM)
if(NOT GSM_FOUND)
......@@ -311,6 +300,11 @@ if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR
message(FATAL_ERROR "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolBox REQUIRED)
endif()
include_directories(
include
......@@ -320,6 +314,7 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
${ORTP_INCLUDE_DIRS}
${BCTOOLBOX_INCLUDE_DIRS}
)
if(BZRTP_FOUND)
......@@ -328,9 +323,6 @@ endif()
if(SRTP_FOUND)
include_directories(${SRTP_INCLUDE_DIRS})
endif()
if(POLARSSL_FOUND)
include_directories(${POLARSSL_INCLUDE_DIRS})
endif()
if(GSM_FOUND)
include_directories(${GSM_INCLUDE_DIRS})
endif()
......@@ -412,9 +404,6 @@ endif()
if(BZRTP_FOUND)
set(HAVE_ZRTP 1)
endif()
if(ENABLE_DTLS)
set(HAVE_DTLS 1)
endif()
if(ENABLE_ALSA)
set(__ALSA_ENABLED__ 1)
endif()
......
############################################################################
# FindPolarSSL.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
# FindiBcToolBox.cmake
# Copyright (C) 2016 Belledonne Communications, Grenoble France
#
############################################################################
#
......@@ -20,58 +20,37 @@
#
############################################################################
#
# - Find the polarssl include file and library
# - Find the bctoolbox include file and library
#
# POLARSSL_FOUND - system has polarssl
# POLARSSL_INCLUDE_DIRS - the polarssl include directory
# POLARSSL_LIBRARIES - The libraries needed to use polarssl
# BCTOOLBOX_FOUND - system has BC Toolbox
# BCTOOLBOX_INCLUDE_DIRS - the BC Toolbox include directory
# BCTOOLBOX_LIBRARIES - The libraries needed to use BC Toolbox
include(CMakePushCheckState)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
set(_POLARSSL_ROOT_PATHS
set(_BCTOOLBOX_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(POLARSSL_INCLUDE_DIRS
NAMES polarssl/ssl.h
HINTS _POLARSSL_ROOT_PATHS
find_path(BCTOOLBOX_INCLUDE_DIRS
NAMES bctoolbox/crypto.h
HINTS _BCTOOLBOX_ROOT_PATHS
PATH_SUFFIXES include
)
if(POLARSSL_INCLUDE_DIRS)
set(HAVE_POLARSSL_SSL_H 1)
endif()
find_library(POLARSSL_LIBRARIES
NAMES polarssl
HINTS _POLARSSL_ROOT_PATHS
find_library(BCTOOLBOX_LIBRARIES
NAMES bctoolbox
HINTS _BCTOOLBOX_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if(POLARSSL_LIBRARIES)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${POLARSSL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${POLARSSL_LIBRARIES})
check_c_source_compiles("#include <polarssl/version.h>
#include <polarssl/x509.h>
#if POLARSSL_VERSION_NUMBER >= 0x01030000
#include <polarssl/compat-1.2.h>
#endif
int main(int argc, char *argv[]) {
x509parse_crtpath(0,0);
return 0;
}"
X509PARSE_CRTPATH_OK)
check_symbol_exists(ssl_get_dtls_srtp_protection_profile "polarssl/ssl.h" HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
cmake_pop_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PolarSSL
find_package_handle_standard_args(BcToolBox
DEFAULT_MSG
POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H
BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES
)
mark_as_advanced(POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H X509PARSE_CRTPATH_OK HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
mark_as_advanced(BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES)
......@@ -1119,6 +1119,15 @@ else
fi
dnl check bctoolbox library
PKG_CHECK_MODULES(BCTOOLBOX, bctoolbox >= 0.0.0, found_bctoolbox=true, found_bctoolbox=false)
if test "$found_bctoolbox" = "true" ; then
LIBS="$LIBS $BCTOOLBOX_LIBS"
CFLAGS="$CFLAGS $BCTOOLBOX_CFLAGS"
else
AC_MSG_ERROR("Could not found Bctoolbox")
fi
dnl check for libzrtp support (RFC 6189: Media Path Key Agreement for Unicast Secure RTP)
AC_ARG_ENABLE(zrtp,
[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=detect)])],
......@@ -1130,6 +1139,7 @@ AC_ARG_ENABLE(zrtp,
[zrtp=detect]
)
if test "$zrtp" != "false" ; then
PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 1.0.0, found_zrtp=true, found_zrtp=false)
if test "$zrtp$found_zrtp" = "truefalse" ; then
......@@ -1156,79 +1166,6 @@ fi
AM_CONDITIONAL(LIBBZRTP,test x$zrtp != xfalse)
dnl Polarssl lib is requested for DTLS
AC_ARG_WITH( polarssl,
[ --with-polarssl Set prefix where polarssl can be found (ex:/usr, /usr/local)[[default=PREFIX or /usr if NONE]] ],
[ polarssl_prefix=${withval}],[ if test "$prefix" != "NONE"; then
polarssl_prefix=${prefix}
else
polarssl_prefix="/usr"
fi ])
found_polarssl=no
if test "$polarssl_prefix" != "none" ; then
if test "$polarssl_prefix" != "/usr" ; then
POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
POLARSSL_LIBS="-L${polarssl_prefix}/lib"
fi
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
LIBS="$LIBS $POLARSSL_LIBS"
AC_CHECK_LIB(mbedtls, sha1_update , [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lmbedtls"],
[AC_CHECK_LIB(polarssl, sha1_update, [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"],[AC_MSG_NOTICE([polarssl library not found !])])])
if test "x$found_polarssl" == "xyes" ; then
AC_CHECK_HEADERS(polarssl/ssl.h, [found_polarssl=yes],[found_polarssl=no POLARSSL_CFLAGS="" POLARSSL_LIBS=""])
fi
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
fi
dnl check for DTLS-SRTP support, need polarssl version >= 1.4
AC_ARG_ENABLE(dtls,
[AS_HELP_STRING([--enable-dtls], [Turn on or off compilation of dtls (default=no)])],
[case "${enableval}" in
yes) dtls=true ;;
no) dtls=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dtls) ;;
esac],
[dtls=false]
)
if test "$dtls" = "true" ; then
if test "$have_srtp" = "false" ; then
AC_MSG_ERROR("DTLS-SRTP requires SRTP")
fi
if test "x$found_polarssl" != "xyes" ; then
AC_MSG_ERROR("DTLS-SRTP requires POLARSSL")
fi
dnl check for polarssl presence and support for DTLS
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
LIBS="$LIBS $POLARSSL_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <polarssl/ssl.h>
]],
[[ssl_set_dtls_srtp_protection_profiles(0,0,0)]])],
[AC_DEFINE(HAVE_DTLS, 1, [Defined when dtls support is compiled])
AC_MSG_NOTICE([polarssl usable for DTLS-SRTP])],[AC_MSG_ERROR([polarssl not usable for DTLS-SRTP])])
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
else
echo "DTLS-SRTP compilation is disabled."
fi
AC_SUBST(POLARSSL_CFLAGS)
AC_SUBST(POLARSSL_LIBS)
dnl check for bcg729 annexB presence to use for VAD/DTX (RFC3389 : Real-time Transport Protocol (RTP) Payload for Comfort Noise (CN))
AC_ARG_ENABLE(g729bCN,
[AS_HELP_STRING([--enable-g729bCN], [Turn on or off usage of G729AnnexB in RFC3389 implementation of Comfort Noise Payload (default=no)])],
......@@ -1379,6 +1316,5 @@ echo "Summary of build options:"
printf "* %-30s %s\n" "Video support" $video
printf "* %-30s %s\n" "sRTP encryption" $have_srtp
printf "* %-30s %s\n" "zRTP encryption" $zrtp
printf "* %-30s %s\n" "SRTP-DTLS encryption" $dtls
printf "* %-30s %s\n" "Non-free codecs" $non_free_codecs
......@@ -372,6 +372,7 @@ endif()
set(VOIP_LIBS
${BCTOOLBOX_LIBRARIES}
${ORTP_LIBRARIES}
mediastreamer_base
)
......@@ -395,9 +396,6 @@ endif()
if(SRTP_FOUND)
list(APPEND VOIP_LIBS ${SRTP_LIBRARIES})
endif()
if(POLARSSL_FOUND)
list(APPEND VOIP_LIBS ${POLARSSL_LIBRARIES})
endif()
if(GSM_FOUND)
list(APPEND VOIP_LIBS ${GSM_LIBRARIES})
endif()
......
......@@ -57,7 +57,7 @@ libmediastreamer_voip_la_LIBADD= libmediastreamer_base.la \
$(PCAP_LIBS) \
$(OPUS_LIBS) \
$(SRTP_LIBS) \
$(POLARSSL_LIBS)
$(BCTOOLBOX_LIBS)
if LIBBZRTP
......@@ -398,7 +398,7 @@ AM_CFLAGS=\
$(PCAP_CFLAGS) \
$(OPUS_CFLAGS) \
$(SRTP_CFLAGS) \
$(POLARSSL_CFLAGS)
$(BCTOOLBOX_CFLAGS)
AM_CXXFLAGS=\
$(STRICT_OPTIONS) \
......
This diff is collapsed.
......@@ -118,6 +118,7 @@
#include "mediastreamer2/stun_udp.h"
#include "mediastreamer2/stun.h"
#include "ortp/ortp.h"
#include "bctoolbox/crypto.h"
static char *ipaddr(const StunAddress4 *addr)
{
......@@ -1328,25 +1329,6 @@ randomPort(void)
}
#ifndef HAVE_POLARSSL_SSL_H
void
stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
const char *username, const char *realm, const char *password)
{
strncpy(hmac,"hmac-not-implemented",20);
ms_error("hmac-not-implemented for stun, mediastreamer2 needs polarssl dependency");
}
void
stunCalculateIntegrity_shortterm(char* hmac, const char* input, int length, const char* key)
{
strncpy(hmac,"hmac-not-implemented",20);
ms_error("hmac-not-implemented for stun, mediastreamer2 needs polarssl dependency");
}
#else
#include "polarssl/sha1.h"
#include "polarssl/md5.h"
void
stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
const char *username, const char *realm, const char *password)
......@@ -1355,23 +1337,21 @@ stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
char HA1_text[1024];
snprintf(HA1_text, sizeof(HA1_text), "%s:%s:%s", username, realm, password);
md5((unsigned char *)HA1_text, strlen(HA1_text), HA1);
bctoolbox_md5((unsigned char *)HA1_text, strlen(HA1_text), HA1);
sha1_hmac(HA1, sizeof(HA1),
bctoolbox_hmacSha1(HA1, sizeof(HA1),
(const unsigned char*) input, length,
(unsigned char*)hmac);
20, (unsigned char*)hmac); /* SHA1 output length is 20 bytes, get them all */
}
void
stunCalculateIntegrity_shortterm(char* hmac, const char* input, int length, const char* key)
{
sha1_hmac((const unsigned char *)key, strlen(key),
bctoolbox_hmacSha1((const unsigned char *)key, strlen(key),
(const unsigned char*) input, length,
(unsigned char*)hmac);
20, (unsigned char*)hmac); /* SHA1 output length is 20 bytes, get them all */
}
#endif
uint32_t
stunCalculateFingerprint(const char* input, int length)
{
......
......@@ -43,7 +43,7 @@ TEST_DEPLIBS+=\
$(VP8_LIBS) \
$(VIDEO_LIBS) \
$(PCAP_LIBS) \
$(POLARSSL_LIBS)
$(BCTOOLBOX_LIBS)
if ORTP_ENABLED
if MS2_FILTERS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment