Commit 43eef42c authored by johan's avatar johan

Merge branch 'master' into zrtphash

Conflicts:
	include/cryptoWrapper.h
	src/bzrtp.c
	src/zidCache.c
parents 987effd8 d5d9ee8c
......@@ -7,24 +7,29 @@ LOCAL_MODULE := libbzrtp
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES = src/bzrtp.c \
src/cryptoPolarssl.c \
src/cryptoUtils.c \
src/packetParser.c \
src/stateMachine.c \
src/zidCache.c \
src/pgpwords.c
LOCAL_SRC_FILES = \
src/bzrtp.c \
src/cryptoUtils.c \
src/packetParser.c \
src/stateMachine.c \
src/zidCache.c \
src/pgpwords.c
LOCAL_STATIC_LIBRARIES += polarssl \
liblpxml2
LOCAL_STATIC_LIBRARIES += liblpxml2
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/../externals/polarssl/include \
$(LOCAL_PATH)/../externals/libxml2/include \
$(LOCAL_PATH)/../externals/build/libxml2
ifeq ($(BUILD_BCTOOLBOX_MBEDTLS),1)
LOCAL_SRC_FILES += src/cryptoMbedtls.c
LOCAL_STATIC_LIBRARIES += mbedtls
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../externals/mbedtls/include
else
LOCAL_SRC_FILES += src/cryptoPolarssl.c
LOCAL_STATIC_LIBRARIES += polarssl
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../externals/polarssl/include
endif
include $(BUILD_STATIC_LIBRARY)
......@@ -21,11 +21,11 @@
############################################################################
cmake_minimum_required(VERSION 3.0)
project(BZRTP C)
set(BZRTP_VERSION 1.0.3)
project(bzrtp VERSION 1.0.3 LANGUAGES C)
option(ENABLE_STATIC "Build static library (default is shared library)." NO)
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_TESTS "Enable compilation of unit tests." NO)
......@@ -46,6 +46,11 @@ macro(apply_compile_flags SOURCE_FILES)
endmacro()
if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
......@@ -53,31 +58,16 @@ if(MSVC)
list(APPEND CMAKE_REQUIRED_INCLUDES ${MSVC_INCLUDE_DIR})
endif()
include(GNUInstallDirs)
include(CheckLibraryExists)
check_library_exists("m" "sqrt" "" HAVE_SQRT)
if(ENABLE_TESTS)
find_package(CUnit)
if(CUNIT_FOUND)
check_library_exists(${CUNIT_LIBRARIES} "CU_add_suite" "" HAVE_CU_ADD_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_get_suite" "" HAVE_CU_GET_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_curses_run_tests" "" HAVE_CU_CURSES)
else()
message(WARNING "Could not find cunit framework, tests will not be compiled.")
set(ENABLE_TESTS OFF CACHE BOOL "Enable compilation of tests" FORCE)
endif()
endif()
find_package(MbedTLS)
if (MBEDTLS_FOUND)
message("Use mbedTLS")
else()
find_package(PolarSSL)
if (POLARSSL_FOUND)
message("Use polarSSL")
else()
message(FATAL_ERROR " No polarSSL or mbedTLS found")
endif()
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox REQUIRED OPTIONAL_COMPONENTS tester)
endif()
find_package(XML2)
......@@ -104,26 +94,14 @@ if(STRICT_OPTIONS_CPP)
string(REPLACE ";" " " STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP}")
endif()
if (MBEDTLS_FOUND)
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
${MBEDTLS_INCLUDE_DIRS}
)
set(LIBS ${MBEDTLS_LIBRARIES})
else ()
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
${POLARSSL_INCLUDE_DIRS}
)
set(LIBS ${POLARSSL_LIBRARIES})
endif()
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
${BCTOOLBOX_CORE_INCLUDE_DIRS}
)
set(LIBS ${BCTOOLBOX_CORE_LIBRARIES})
if(CUNIT_FOUND)
include_directories(${CUNIT_INCLUDE_DIRS})
list(APPEND LIBS ${CUNIT_LIBRARIES})
endif()
if(XML2_FOUND)
include_directories(${XML2_INCLUDE_DIRS})
list(APPEND LIBS ${XML2_LIBRARIES})
......@@ -142,7 +120,7 @@ endif()
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_TESTS)
if(ENABLE_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing()
add_subdirectory(test)
endif()
......@@ -151,25 +129,24 @@ endif()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfigVersion.cmake"
VERSION ${BZRTP_VERSION}
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BZRTPTargets.cmake"
)
configure_file(cmake/BZRTPConfig.cmake
configure_file(cmake/BZRTPConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfig.cmake"
COPYONLY
@ONLY
)
set(ConfigPackageLocation lib/cmake/BZRTP)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE BZRTPTargets.cmake
DESTINATION ${ConfigPackageLocation}
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/BZRTPConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src include test
EXTRA_DIST=CMakeLists.txt cmake/BZRTPConfig.cmake.in cmake/FindXML2.cmake config.h.cmake include/CMakeLists.txt src/CMakeLists.txt test/CMakeLists.txt
test:
cd test && $(MAKE) test
......
......@@ -4,7 +4,7 @@ The library written in C 89 is fully portable and can be executed on many platf
Licensing: The source code is licensed under GPLv2.
Dependencies:
- polarssl 1.3 OR mbedTLS 1.3
- bctoolbox
By default, the upstream package installs into /usr/local. Please use
'./configure --prefix' to change it
......
......@@ -31,11 +31,23 @@ if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${CMAKE_CURRENT_LIST_DIR}/BZRTPTargets.cmake")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox REQUIRED COMPONENTS core)
endif()
get_filename_component(BZRTP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BZRTP_INCLUDE_DIRS "${EP_bzrtp_INCLUDE_DIR}")
else()
set(BZRTP_INCLUDE_DIRS "${BZRTP_CMAKE_DIR}/../../../include")
endif()
set(BZRTP_LIBRARIES bzrtp)
list(APPEND BZRTP_INCLUDE_DIRS ${BCTOOLBOX_CORE_INCLUDE_DIRS})
list(APPEND BZRTP_LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES})
if(@ENABLE_SHARED@)
set(BZRTP_LIBRARIES bzrtp)
else()
set(BZRTP_LIBRARIES bzrtp-static)
endif()
set(BZRTP_FOUND 1)
############################################################################
# FindCUnit.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the CUnit include file and library
#
# CUNIT_FOUND - system has CUnit
# CUNIT_INCLUDE_DIRS - the CUnit include directory
# CUNIT_LIBRARIES - The libraries needed to use CUnit
include(CheckIncludeFile)
include(CheckLibraryExists)
set(_CUNIT_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(CUNIT_INCLUDE_DIRS
NAMES CUnit/CUnit.h
HINTS _CUNIT_ROOT_PATHS
PATH_SUFFIXES include
)
if(CUNIT_INCLUDE_DIRS)
set(HAVE_CUNIT_CUNIT_H 1)
endif()
find_library(CUNIT_LIBRARIES
NAMES cunit
HINTS ${_CUNIT_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUnit
DEFAULT_MSG
CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES
)
mark_as_advanced(CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES)
############################################################################
# FindMdebTLS.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the mbedTLS include file and library
#
# MBEDTLS_FOUND - system has mbedTLS
# MBEDTLS_INCLUDE_DIRS - the mbedTLS include directory
# MBEDTLS_LIBRARIES - The libraries needed to use mbedTLS
include(CMakePushCheckState)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
set(_MBEDTLS_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(MBEDTLS_INCLUDE_DIRS
NAMES mbedtls/ssl.h
HINTS _MBEDTLS_ROOT_PATHS
PATH_SUFFIXES include
)
# find the three mbedtls library
find_library(MBEDTLS_LIBRARY
NAMES mbedtls
HINTS _MBEDTLS_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if (MBEDTLS_LIBRARY)
find_library(MBEDX509_LIBRARY
NAMES mbedx509
HINTS _MBEDTLS_ROOT_PATHS
PATH_SUFFIXES bin lib
)
endif()
if (MBEDX509_LIBRARY)
find_library(MBEDCRYPTO_LIBRARY
NAMES mbedcrypto
HINTS _MBEDTLS_ROOT_PATHS
PATH_SUFFIXES bin lib
)
endif()
# check we have a mbedTLS version 2 or above(all functions are prefixed mbedtls_)
if (MBEDCRYPTO_LIBRARY)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${MBEDTLS_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
check_symbol_exists(mbedtls_ssl_init "mbedtls/ssl.h" MBEDTLS_V2)
cmake_pop_check_state()
endif()
if (MBEDTLS_V2)
set (MBEDTLS_LIBRARIES
${MBEDTLS_LIBRARY}
${MBEDX509_LIBRARY}
${MBEDCRYPTO_LIBRARY}
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS
DEFAULT_MSG
MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARIES
)
mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARIES)
############################################################################
# FindPolarSSL.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the polarssl include file and library
#
# POLARSSL_FOUND - system has polarssl
# POLARSSL_INCLUDE_DIRS - the polarssl include directory
# POLARSSL_LIBRARIES - The libraries needed to use polarssl
include(CMakePushCheckState)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
set(_POLARSSL_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(POLARSSL_INCLUDE_DIRS
NAMES polarssl/ssl.h
HINTS _POLARSSL_ROOT_PATHS
PATH_SUFFIXES include
)
if(POLARSSL_INCLUDE_DIRS)
set(HAVE_POLARSSL_SSL_H 1)
endif()
find_library(POLARSSL_LIBRARIES
NAMES polarssl mbedtls
HINTS _POLARSSL_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
DEFAULT_MSG
POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H
)
mark_as_advanced(POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H X509PARSE_CRTPATH_OK HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
......@@ -26,13 +26,16 @@
# XML2_INCLUDE_DIRS - the libxml2 include directory
# XML2_LIBRARIES - The libraries needed to use libxml2
set(_XML2_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
if(APPLE AND NOT IOS)
set(XML2_HINTS "/usr")
endif()
if(XML2_HINTS)
set(XML2_LIBRARIES_HINTS "${XML2_HINTS}/lib")
endif()
find_path(XML2_INCLUDE_DIRS
NAMES libxml/xmlreader.h
HINTS _XML2_ROOT_PATHS
HINTS "${XML2_HINTS}"
PATH_SUFFIXES include/libxml2
)
......@@ -42,8 +45,7 @@ endif()
find_library(XML2_LIBRARIES
NAMES xml2
HINTS ${_XML2_ROOT_PATHS}
PATH_SUFFIXES bin lib
HINTS "${XML2_LIBRARIES_HINTS}"
)
include(FindPackageHandleStandardArgs)
......
......@@ -31,72 +31,13 @@ if test "$found_cunit" = "no" ; then
])
fi
dnl check mbedtls unless we specified a with-polarssl
crypto_lib=mbedtls
AC_ARG_WITH( polarssl,
[ --with-polarssl Set prefix where polarssl can be found (ex:/usr, /usr/local)[default=PREFIX], if set, force usage of polarssl instead of mbedtls when both are present ],
[
polarssl_prefix=${withval}
crypto_lib=polarssl
],[ polarssl_prefix=${prefix} ])
if test "$crypto_lib" == "mbedtls" ; then
AC_ARG_WITH( mbedtls,
[ --with-mbedtls Set prefix where mbedTLS can be found (ex:/usr, /usr/local)[default=PREFIX] ],
[ mbedtls_prefix=${withval} ],[ mbedtls_prefix=${prefix} ])
if test "mbedtls_prefix" != "NONE" ; then
MBEDTLS_CFLAGS="-I${mbedtls_prefix}/include"
MBEDTLS_LIBS="-L${mbedtls_prefix}/lib"
fi
LIBS_save=$LIBS
LIBS="$LIBS $MBEDTLS_LIBS"
AC_CHECK_LIB(mbedtls, mbedtls_ssl_init, [
mbedtls_found=yes
MBEDTLS_LIBS="$MBEDTLS_LIBS -lmbedtls -lmbedx509 -lmbedcrypto"
AC_MSG_NOTICE("Use mbed TLS as crypto library")
],
[mbdetls_found=no],
[-lmbedx509 -lmbedcrypto]
)
LIBS=$LIBS_save
AC_SUBST(MBEDTLS_LIBS)
AC_SUBST(MBEDTLS_CFLAGS)
fi
AM_CONDITIONAL(LIBMBEDTLS, test x$mbedtls_found == xyes)
dnl check polarssl if no mbedtls was found
polarssl_found=no
if test "$mbedtls_found" != "yes" ; then
if test "$polarssl_prefix" != "NONE" ; then
POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
POLARSSL_LIBS="-L${polarssl_prefix}/lib"
fi
LIBS_save=$LIBS
LIBS="$LIBS $POLARSSL_LIBS"
AC_CHECK_LIB(polarssl, ssl_init , [
POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"
polarssl_found=yes
AC_MSG_NOTICE("Use polar SSL as crypto library")
],
[AC_MSG_ERROR([MbedTLS nor PolarSSL library not found])])
LIBS=$LIBS_save
AC_SUBST(POLARSSL_LIBS)
AC_SUBST(POLARSSL_CFLAGS)
dnl check bctoolbox
PKG_CHECK_MODULES(BCTOOLBOX, [bctoolbox] ,[bctoolbox_found=yes] ,foo=bar)
if test "$bctoolbox_found" != "yes" ; then
AC_MSG_ERROR([bctoolbox not found, aborting. ])
fi
AM_CONDITIONAL(LIBPOLARSSL, test x$polarssl_found == xyes)
dnl check libxml2
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0] ,[libxml2_found=yes] ,foo=bar)
if test "$libxml2_found" != "yes" ; then
......
file(GLOB HEADER_FILES "bzrtp/*.h")
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
install(FILES ${HEADER_FILES}
DESTINATION include/bzrtp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
install(FILES bzrtp/bzrtp.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bzrtp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
SUBDIRS = bzrtp
EXTRA_DIST=cryptoUtils.h cryptoWrapper.h packetParser.h stateMachine.h typedef.h zidCache.h
EXTRA_DIST=cryptoUtils.h packetParser.h stateMachine.h typedef.h zidCache.h
......@@ -31,6 +31,16 @@
#include "typedef.h"
#include "packetParser.h"
/** Return available crypto functions. For now we have
*
* - Hash: HMAC-SHA256(Mandatory)
* - CipherBlock: AES128(Mandatory)
* - Auth Tag: HMAC-SHA132 and HMAC-SHA180 (These are mandatory for SRTP and depends on the SRTP implementation thus we can just suppose they are both available)
* - Key Agreement: DHM3k(Mandatory), DHM2k(optional and shall not be used except on low power devices)
* - Sas: base32(Mandatory), b256(pgp words)
*/
uint8_t bzrtpUtils_getAvailableCryptoTypes(uint8_t algoType, uint8_t availableTypes[7]);
/**
*
* @brief ZRTP Key Derivation Function as in rfc 4.5.1
......
This diff is collapsed.
......@@ -4,17 +4,17 @@
@author Johan Pascal
@copyright Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
......@@ -48,11 +48,11 @@
typedef struct bzrtpChannelContext_struct bzrtpChannelContext_t;
#include "cryptoWrapper.h"
#include <bctoolbox/crypto.h>
#include "packetParser.h"
#include "stateMachine.h"
#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#endif
......@@ -117,7 +117,7 @@ typedef struct cachedSecretsHash_struct {
*
*/
struct bzrtpChannelContext_struct {
void *clientData; /**< this is a pointer provided by the client which is then resent as a parameter of the callbacks functions. Usefull to store RTP session context for example */
uint8_t role;/**< can be INITIATOR or RESPONDER, is set to INITIATOR at creation, may switch to responder later */
......@@ -182,13 +182,13 @@ struct bzrtpChannelContext_struct {
};
/**
* @brief structure of the ZRTP engine context
* @brief structure of the ZRTP engine context
* Store current state, timers, HMAC and encryption keys
*/
struct bzrtpContext_struct {
/* contexts */
bzrtpRNGContext_t *RNGContext; /**< context for random number generation */
bzrtpDHMContext_t *DHMContext; /**< context for the Diffie-Hellman-Merkle operations. Only one DHM computation may be done during a call, so this belongs to the general context and not the channel one */
bctoolbox_rng_context_t *RNGContext; /**< context for random number generation */
bctoolbox_DHMContext_t *DHMContext; /**< context for the Diffie-Hellman-Merkle operations. Only one DHM computation may be done during a call, so this belongs to the general context and not the channel one */
/* flags */
uint8_t isSecure; /**< this flag is set to 1 after the first channel have completed the ZRTP protocol exchange(i.e. when the responder have sent the conf2ACK message) */
......@@ -213,7 +213,7 @@ struct bzrtpContext_struct {
uint8_t supportedKeyAgreement[7]; /**< list of supported key agreement algorithms mapped to uint8_t */
uint8_t sc; /**< sas count - set to 0 means we support only base32 (4 bits) */
uint8_t supportedSas[7]; /**< list of supported Sas representations mapped to uint8_t */
/* ZIDs and cache */
#ifdef HAVE_LIBXML2
xmlDocPtr cacheBuffer; /**< cache file is load in this buffer to be parsed/written */
......
......@@ -28,40 +28,39 @@ set(SOURCE_FILES
stateMachine.c
zidCache.c
)
if (POLARSSL_FOUND)
set(SOURCE_FILES
${SOURCE_FILES}
cryptoPolarssl.c
)
elseif (MBEDTLS_FOUND)
set(SOURCE_FILES
${SOURCE_FILES}
cryptoMbedtls.c
)
if(POLARSSL_FOUND)
list(APPEND SOURCE_FILES cryptoPolarssl.c)
elseif(MBEDTLS_FOUND)
list(APPEND SOURCE_FILES cryptoMbedtls.c)
endif()
apply_compile_flags(SOURCE_FILES "CPP")
if(ENABLE_STATIC)
add_library(bzrtp STATIC ${SOURCE_FILES})
target_link_libraries(bzrtp ${LIBS})
else()
add_library(bzrtp-static STATIC ${SOURCE_FILES})
set_target_properties(bzrtp-static PROPERTIES OUTPUT_NAME bzrtp)
target_link_libraries(bzrtp-static ${LIBS})
install(TARGETS bzrtp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
add_library(bzrtp SHARED ${SOURCE_FILES})
set_target_properties(bzrtp PROPERTIES VERSION 0)
target_link_libraries(bzrtp ${LIBS})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bzrtp.pdb
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
install(TARGETS bzrtp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(TARGETS bzrtp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
lib_LTLIBRARIES = libbzrtp.la
libbzrtp_la_LIBADD= $(LIBXML2_LIBS)
libbzrtp_la_SOURCES= bzrtp.c cryptoUtils.c packetParser.c zidCache.c stateMachine.c pgpwords.c
libbzrtp_la_LIBADD= $(LIBXML2_LIBS) $(BCTOOLBOX_LIBS)
libbzrtp_la_SOURCES= bzrtp.c cryptoUtils.c packetParser.c zidCache.c stateMachine.c pgpwords.c
AM_CPPFLAGS= -I$(top_srcdir)/include
AM_CPPFLAGS= -I$(top_srcdir)/include
AM_CFLAGS= $(LIBXML2_CFLAGS)
if LIBPOLARSSL
libbzrtp_la_LIBADD += $(POLARSSL_LIBS)
libbzrtp_la_SOURCES += cryptoPolarssl.c
AM_CFLAGS += $(POLARSSL_CFLAGS)
endif
if LIBMBEDTLS