diff --git a/submodules/build/builder-iphone-os.mk b/submodules/build/builder-iphone-os.mk index 47516d4e0..619e211d8 100644 --- a/submodules/build/builder-iphone-os.mk +++ b/submodules/build/builder-iphone-os.mk @@ -21,7 +21,7 @@ ############################################################################ host?=armv6-apple-darwin -enable_zrtp=no +enable_zrtp=yes config_site:=iphone-config.site library_mode:= --disable-shared --enable-static linphone_configure_controls= --disable-video \ @@ -38,6 +38,7 @@ linphone_configure_controls= --disable-video \ --with-gsm=$(prefix) \ LIBZRTPCPP_CFLAGS="-I$(prefix)/include" \ LIBZRTPCPP_LIBS="-L$(prefix)/lib -lzrtpcpp -lcrypto" \ + SRTP_LIBS="-L$(prefix)/lib -lsrtp -lcrypto" \ SPEEX_CFLAGS="-I$(prefix)/include" \ SPEEXDSP_CFLAGS="-I$(prefix)/include" \ SPEEXDSP_LIBS="-L$(prefix)/lib -lspeexdsp" \ @@ -108,7 +109,7 @@ clean-makefile-linphone: clean-makefile-osip2 clean-makefile-eXosip2 clean-makef cd $(LINPHONE_BUILD_DIR) && rm -f Makefile && rm -f oRTP/Makefile && rm -f mediastreamer2/Makefile -$(LINPHONE_SRC_DIR)/configure: build-srtp +$(LINPHONE_SRC_DIR)/configure: cd $(LINPHONE_SRC_DIR) && ./autogen.sh $(LINPHONE_BUILD_DIR)/Makefile: $(LINPHONE_SRC_DIR)/configure diff --git a/submodules/build/builders.d/openssl.mk b/submodules/build/builders.d/openssl.mk index 54a2b517e..0b2e5bf80 100644 --- a/submodules/build/builders.d/openssl.mk +++ b/submodules/build/builders.d/openssl.mk @@ -14,7 +14,7 @@ $(OPENSSL_BUILD_DIR)/Configure: && tar xvzf openssl-$(openssl_version).tar.gz \ && rm -f openssl-$(openssl_version).tar.gz \ && mv openssl-$(openssl_version) openssl \ - && cd openssl && patch -p0 < $(BUILDER_SRC_DIR)/build/openssl.patch + && cd openssl && patch -p0 < $(BUILDER_SRC_DIR)/build/builders.d/openssl.patch $(OPENSSL_BUILD_DIR)/Makefile: $(OPENSSL_BUILD_DIR)/Configure cd $(OPENSSL_BUILD_DIR) \ diff --git a/submodules/build/openssl.patch b/submodules/build/builders.d/openssl.patch similarity index 100% rename from submodules/build/openssl.patch rename to submodules/build/builders.d/openssl.patch diff --git a/submodules/build/builders.d/srtp.mk b/submodules/build/builders.d/srtp.mk index 05b1b545e..38cccdbd9 100644 --- a/submodules/build/builders.d/srtp.mk +++ b/submodules/build/builders.d/srtp.mk @@ -5,7 +5,8 @@ srtp_url?=http://srtp.sourceforge.net/srtp-$(srtp_version).tgz $(BUILDER_SRC_DIR)/$(srtp_dir)/configure: cd $(BUILDER_SRC_DIR)/externals \ && wget $(srtp_url) \ - && tar zxvf srtp-$(srtp_version).tgz + && tar zxvf srtp-$(srtp_version).tgz \ + && cd srtp && patch -p0 < $(BUILDER_SRC_DIR)/build/builders.d/srtp.patch $(BUILDER_BUILD_DIR)/$(srtp_dir)/Makefile: $(BUILDER_SRC_DIR)/$(srtp_dir)/configure mkdir -p $(BUILDER_BUILD_DIR)/$(srtp_dir) @@ -16,7 +17,7 @@ $(BUILDER_BUILD_DIR)/$(srtp_dir)/Makefile: $(BUILDER_SRC_DIR)/$(srtp_dir)/config build-srtp: $(BUILDER_BUILD_DIR)/$(srtp_dir)/Makefile cp -rf $(BUILDER_SRC_DIR)/$(srtp_dir)/include $(BUILDER_BUILD_DIR)/$(srtp_dir) cp -rf $(BUILDER_SRC_DIR)/$(srtp_dir)/crypto/include $(BUILDER_BUILD_DIR)/$(srtp_dir) - -cd $(BUILDER_BUILD_DIR)/$(srtp_dir) && make uninstall + -cd $(BUILDER_BUILD_DIR)/$(srtp_dir) && make uninstall && make clean cd $(BUILDER_BUILD_DIR)/$(srtp_dir) && make libsrtp.a && make install clean-srtp: diff --git a/submodules/build/builders.d/srtp.patch b/submodules/build/builders.d/srtp.patch new file mode 100644 index 000000000..7dfe02e97 --- /dev/null +++ b/submodules/build/builders.d/srtp.patch @@ -0,0 +1,77 @@ +diff -rupN ../srtp_old/crypto/cipher/aes_icm.c ./crypto/cipher/aes_icm.c +--- ../srtp_old/crypto/cipher/aes_icm.c 2011-09-06 10:09:18.000000000 +0200 ++++ ./crypto/cipher/aes_icm.c 2011-09-06 10:19:16.000000000 +0200 +@@ -281,7 +281,7 @@ aes_icm_set_iv(aes_icm_ctx_t *c, void *i + * this is an internal, hopefully inlined function + */ + +-inline void ++static void + aes_icm_advance_ismacryp(aes_icm_ctx_t *c, uint8_t forIsmacryp) { + /* fill buffer with new keystream */ + v128_copy(&c->keystream_buffer, &c->counter); +diff -rupN ../srtp_old/srtp.patch ./srtp.patch +--- ../srtp_old/srtp.patch 2011-09-06 10:14:26.000000000 +0200 ++++ ./srtp.patch 2011-09-06 10:21:47.000000000 +0200 +@@ -1,50 +1,12 @@ +-diff -rupN ../srtp_old/crypto/cipher/aes.c ./crypto/cipher/aes.c +---- ../srtp_old/crypto/cipher/aes.c 2011-09-06 10:09:18.000000000 +0200 +-+++ ./crypto/cipher/aes.c 2011-09-06 10:05:35.000000000 +0200 +-@@ -1358,7 +1358,7 @@ static uint32_t U4[256] = { +- +- extern debug_module_t mod_aes_icm; +- ++diff -rupN ../srtp_old/crypto/cipher/aes_icm.c ./crypto/cipher/aes_icm.c ++--- ../srtp_old/crypto/cipher/aes_icm.c 2011-09-06 10:09:18.000000000 +0200 +++++ ./crypto/cipher/aes_icm.c 2011-09-06 10:19:16.000000000 +0200 ++@@ -281,7 +281,7 @@ aes_icm_set_iv(aes_icm_ctx_t *c, void *i ++ * this is an internal, hopefully inlined function ++ */ ++ + -inline void +-+void +- aes_expand_encryption_key(const v128_t *key, +- aes_expanded_key_t expanded_key) { +- int i; +-@@ -1411,7 +1411,7 @@ aes_expand_encryption_key(const v128_t * +- } +- } +- +--inline void +-+void +- aes_expand_decryption_key(const v128_t *key, +- aes_expanded_key_t expanded_key) { +- int i; +-diff -rupN ../srtp_old/crypto/include/aes.h ./crypto/include/aes.h +---- ../srtp_old/crypto/include/aes.h 2011-09-06 10:09:18.000000000 +0200 +-+++ ./crypto/include/aes.h 2011-09-06 10:03:53.000000000 +0200 +-@@ -55,11 +55,11 @@ +- +- typedef v128_t aes_expanded_key_t[11]; +- +--inline void +-+void +- aes_expand_encryption_key(const v128_t *key, +- aes_expanded_key_t expanded_key); +- +--inline void +-+void +- aes_expand_decryption_key(const v128_t *key, +- aes_expanded_key_t expanded_key); +- +-diff -rupN ../srtp_old/crypto/math/datatypes.c ./crypto/math/datatypes.c +---- ../srtp_old/crypto/math/datatypes.c 2011-09-06 10:09:18.000000000 +0200 +-+++ ./crypto/math/datatypes.c 2011-09-06 10:02:55.000000000 +0200 +-@@ -124,7 +124,7 @@ octet_string_hex_string(const void *s, i +- return bit_string; +- } +- +--inline int +-+static int +- hex_char_to_nibble(uint8_t c) { +- switch(c) { +- case ('0'): return 0x0; +++static void ++ aes_icm_advance_ismacryp(aes_icm_ctx_t *c, uint8_t forIsmacryp) { ++ /* fill buffer with new keystream */ ++ v128_copy(&c->keystream_buffer, &c->counter); diff --git a/submodules/build/builders.d/zrtp.mk b/submodules/build/builders.d/zrtp.mk index 49088d1a4..2dcc70ccf 100644 --- a/submodules/build/builders.d/zrtp.mk +++ b/submodules/build/builders.d/zrtp.mk @@ -2,6 +2,7 @@ #Thus the use of a toolchain file. TC = -DCMAKE_TOOLCHAIN_FILE=$(BUILDER_SRC_DIR)build/iphone-toolchain.cmake$(tc_proc) $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir)/Makefile: + cp $(BUILDER_SRC_DIR)/build/builders.d/zrtpcpp.CMakeLists.txt $(BUILDER_SRC_DIR)/$(zrtpcpp_dir)/CMakeLists.txt mkdir -p $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir) cd $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir)/\ && host_alias=$(host) . $(BUILDER_SRC_DIR)/build/$(config_site) \ @@ -10,7 +11,7 @@ $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir)/Makefile: ifeq ($(enable_zrtp),yes) -build-zrtpcpp: $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir)/Makefile build-openssl +build-zrtpcpp: $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir)/Makefile echo "Build ZRTP - prefix $(prefix)" cd $(BUILDER_BUILD_DIR)/$(zrtpcpp_dir) && make && make install diff --git a/submodules/build/builders.d/zrtpcpp.CMakeLists.txt b/submodules/build/builders.d/zrtpcpp.CMakeLists.txt new file mode 100755 index 000000000..4f20891f6 --- /dev/null +++ b/submodules/build/builders.d/zrtpcpp.CMakeLists.txt @@ -0,0 +1,169 @@ +# Copyright (C) 2009 Werner Dittman +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +cmake_minimum_required(VERSION 2.6) + +PROJECT(libzrtpcpp) + +SET(CPACK_PACKAGE_VERSION_MAJOR 2) +SET(CPACK_PACKAGE_VERSION_MINOR 0) +SET(CPACK_PACKAGE_VERSION_PATCH 0) + +set (VERSION 2.0.0) +set (SOVERSION 2) +set (PACKAGE libzrtpcpp) + +if(MSVC60) + set(BUILD_STATIC ON CACHE BOOL "static linking only" FORCE) + MARK_AS_ADVANCED(BUILD_STATIC) +else() + option(BUILD_STATIC "Set to OFF to build shared libraries" ON) +endif() + +# set to true for debug and trace during CMakeLists development +set(CMAKE_VERBOSE_MAKEFILE FALSE) + +MESSAGE( STATUS "Configuring GNU ${PROJECT_NAME} ${VERSION}...") + +# include most of the fine stuff we need +include(cmake/Modules/FindGcryptConfig.cmake) +include(FindPkgConfig) +include(CheckLibraryExists) +include(CheckIncludeFiles) +include(cmake/Modules/AutoArgs.cmake) + +if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) + include(cmake/Modules/GeneratePackage.cmake) + + GENERATE_PACKAGING(${PACKAGE} ${VERSION}) +endif() + +# check the -Denable-ccrtp setting, defaults to true +enable_arg(ccrtp true "Enable GNU ccRTP support for GNU ZRTP") +args_help() + +# this caused problems in debian where it has to always be lib.... +set(LIBDIRNAME "lib") +if (NOT EXISTS /etc/debian_version) + if ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" ) + set(LIBDIRNAME "lib64") + endif() +endif() + +# setup the Thread include and lib +find_package(Threads) +if(CMAKE_HAVE_PTHREAD_H) + set(HAVE_PTHREAD_H TRUE) +endif() +set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) + +if(enable_ccrtp) + if (USES_CCRTP_INCLUDE_DIRS) + message(STATUS " Using local commoncpp dependency") + else() + find_package(PkgConfig) + pkg_check_modules(USES_CCRTP libccrtp>=2.0.0) + endif() + include_directories(${USES_CCRTP_INCLUDE_DIRS}) + link_directories(${USES_CRTP_LIBRARY_DIRS}) + add_definitions(${USES_CCRTP_CFLAGS}) + set (LIBS ${LIBS} ${USES_CCRTP_LDFLAGS} ${USES_CCRTP_LIBRARIES}) +endif() + +if (CMAKE_CROSSCOMPILING) + include_directories(${CMAKE_INSTALL_PREFIX}/include) + link_directories(${CMAKE_INSTALL_PREFIX}/lib) + set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${CMAKE_INSTALL_PREFIX}/include") +## set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_INSTALL_PREFIX}/lib/*") +endif() + + +# now get info about crypto libraries +gcr_check(GCRYPT gcrypt) +#if(GCRYPT_FOUND) +# check_include_files(gcrypt.h HAVE_GCRYPT_H) +# set(LIBS ${LIBS} ${GCRYPT_LIBRARIES}) +# set(BUILD_REQ "libgcrypt-devel") +# set(CRYPTOBACKEND="") +# set(PACKAGE_REQ "libgcrypt") +#else() + pkg_check_modules(OPENSSL libcrypto>=0.9.8) + if (OPENSSL_FOUND) + check_include_files(openssl/bn.h HAVE_OPENSSL_BN_H) + check_include_files(openssl/aes.h HAVE_OPENSSL_AES_H) + check_include_files(openssl/sha.h HAVE_OPENSSL_SHA_H) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -lcrypto") + check_library_exists(crypto EVP_CipherInit_ex "${CMAKE_INSTALL_PREFIX}/lib" HAVE_SSL_CRYPT) +# don't test HAVE_SSL_CRYPT_FOUND as it doesn't work + if (HAVE_OPENSSL_BN_H_FOUND) +# AND HAVE_OPENSSL_AES_H_FOUND AND HAVE_OPENSSL_SHA_H_FOUND)) + message(FATAL_ERROR "Openssl crypto library not found") + endif() + set(LIBS ${LIBS} -lcrypto) + set(CRYPTOBACKEND "libcrypto >= 0.9.8") + set(BUILD_REQ "libopenssl-devel >= 0.9.8") + set(PACKAGE_REQ "libopenssl >= 0.9.8") + else() + message(FATAL_ERROR "No crypto library found") + endif() +#endif() + +check_include_files(stdlib.h HAVE_STDLIB_H) +check_include_files(string.h HAVE_STRING_H) + +# necessary and required modules checked, ready to generate config.h +configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +# the following set(...) commands are only to have backward +# compatibility with autoconf stuff to generate the pc file +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${prefix}/bin) +set(libdir ${prefix}/lib) +set(includedir ${prefix}/include) +set(PACKAGE pkgconfig) +configure_file(libzrtpcpp.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libzrtpcpp.pc @ONLY) + +configure_file(libzrtpcpp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/libzrtpcpp.spec @ONLY) + +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src) + +add_definitions(-g -O2 -fno-strict-aliasing) +if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-Wno-long-long -Wno-char-subscripts) + add_definitions(-Wall -ansi -pedantic) + add_definitions(-DNEW_STDCPP) +# add_definitions(-D__EXPORT=) +endif() + +add_subdirectory(src) + +if (enable_ccrtp) + add_subdirectory(demo) +endif() + +if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/package/) + MESSAGE(STATUS "package dir not found") + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package/) +endif() + +########### install files ############### +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzrtpcpp.pc DESTINATION ${LIBDIRNAME}/pkgconfig) + +if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) + + ########### Add uninstall target ############### + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + add_custom_target(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + +endif()