From b504646e58eb47a295ac58bce2870327dca00468 Mon Sep 17 00:00:00 2001 From: Johan Pascal Date: Thu, 4 Feb 2016 23:32:38 +0100 Subject: [PATCH] Move crypto API to bctoolbox - LIME is yet to be ported, compilation fail with LIME enabled --- CMakeLists.txt | 2 ++ cmake/FindBcToolBox.cmake | 56 +++++++++++++++++++++++++++++++++++++++ coreapi/CMakeLists.txt | 1 + coreapi/friendlist.c | 4 +-- 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100755 cmake/FindBcToolBox.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ab84b60cb..fc7aacf61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) else() find_package(BelleSIP REQUIRED) find_package(Mediastreamer2 REQUIRED) + find_package(BcToolBox REQUIRED) endif() find_package(XML2 REQUIRED) find_package(Zlib) @@ -181,6 +182,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/coreapi/ ${BELLESIP_INCLUDE_DIRS} ${MEDIASTREAMER2_INCLUDE_DIRS} + ${BCTOOLBOX_INCLUDE_DIRS} ) if(ENABLE_TUNNEL) include_directories(${TUNNEL_INCLUDE_DIRS}) diff --git a/cmake/FindBcToolBox.cmake b/cmake/FindBcToolBox.cmake new file mode 100755 index 000000000..5bfa2eb17 --- /dev/null +++ b/cmake/FindBcToolBox.cmake @@ -0,0 +1,56 @@ +############################################################################ +# FindiBcToolBox.cmake +# Copyright (C) 2016 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 bctoolbox include file and library +# +# 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(_BCTOOLBOX_ROOT_PATHS + ${CMAKE_INSTALL_PREFIX} +) + +find_path(BCTOOLBOX_INCLUDE_DIRS + NAMES bctoolbox/crypto.h + HINTS _BCTOOLBOX_ROOT_PATHS + PATH_SUFFIXES include +) + +find_library(BCTOOLBOX_LIBRARIES + NAMES bctoolbox + HINTS _BCTOOLBOX_ROOT_PATHS + PATH_SUFFIXES bin lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(BcToolBox + DEFAULT_MSG + BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES +) + +mark_as_advanced(BCTOOLBOX_INCLUDE_DIRS BCTOOLBOX_LIBRARIES) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index bd855d7e2..defbd1849 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -149,6 +149,7 @@ apply_compile_flags(LINPHONE_SOURCE_FILES_CXX "CPP" "CXX") apply_compile_flags(LINPHONE_SOURCE_FILES_OBJC "CPP" "OBJC") set(LIBS + ${BCTOOLBOX_LIBRARIES} ${BELLESIP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XML2_LIBRARIES} diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index fd0841782..4d3203e93 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphonecore.h" #include "private.h" -#include +#include static char * create_resource_list_xml(const LinphoneFriendList *list) { @@ -392,7 +392,7 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon char *xml_content = create_resource_list_xml(list); if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) { unsigned char digest[16]; - md5((unsigned char *)xml_content, strlen(xml_content), digest); + bctoolbox_md5((unsigned char *)xml_content, strlen(xml_content), digest); if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) { /* The content has not changed, only refresh the event. */ linphone_event_refresh_subscribe(list->event);