Commit 0e6a06ab authored by Johan Pascal's avatar Johan Pascal

Merge branch 'master' into ecc

parents a23c7340 63156af8
......@@ -31,3 +31,4 @@ stamp-h1
.libs
INSTALL
m4
bzrtp.spec
......@@ -22,7 +22,7 @@
cmake_minimum_required(VERSION 3.0)
project(bzrtp VERSION 1.0.5 LANGUAGES C CXX)
project(bzrtp VERSION 1.0.6 LANGUAGES C CXX)
option(ENABLE_SHARED "Build shared library." YES)
......@@ -68,7 +68,7 @@ add_definitions("-DHAVE_CONFIG_H")
set(STRICT_OPTIONS_CPP )
if(NOT MSVC)
list(APPEND STRICT_OPTIONS_CPP "-Wall")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments")
endif()
if(ENABLE_STRICT)
......@@ -147,14 +147,4 @@ install(FILES
)
# CPack settings
set(CPACK_PACKAGE_NAME "bzrtp")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
"^${CMAKE_BINARY_DIR}"
"/\\\\..+"
)
include(CPack)
add_subdirectory(build)
bzrtp-1.0.6 - July 20th, 2017
* bug fixes
bzrtp-1.0.5 - February 23th, 2017
* bug fixes
......
......@@ -74,6 +74,15 @@ Our CMake scripts may automatically add some paths into research paths of genera
To ensure that the installed binaries are striped of any rpath, use `-DCMAKE_SKIP_INSTALL_RPATH=ON`
while you invoke cmake.
Rpm packaging
bzrtp can be generated with cmake3 using the following command:
mkdir WORK
cd WORK
cmake3 ../
make package_source
rpmbuild -ta --clean --rmsource --rmspec bzrtp-<version>-<release>.tar.gz
----------------------------------
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
if (NOT CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_NAME "bzrtp")
ENDIF()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION})
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
"${CMAKE_BINARY_DIR}"
"^${PROJECT_SOURCE_DIR}/.git*"
)
bc_project_build_version(${PROJECT_VERSION} PROJECT_VERSION_BUILD)
if(PROJECT_VERSION_BUILD)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_BUILD}")
endif()
message("-- Package file name is ${CPACK_PACKAGE_FILE_NAME}" )
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rpm/bzrtp.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/../bzrtp.spec)
include(CPack)
# -*- rpm-spec -*-
## rpmbuild options
# These 2 lines are here because we can build the RPM for flexisip, in which
# case we prefix the entire installation so that we don't break compatibility
# with the user's libs.
# To compile with bc prefix, use rpmbuild -ba --with bc [SPEC]
%define pkg_name bzrtp
# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir
# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros
%define _datarootdir %{_prefix}/share
%define _datadir %{_datarootdir}
%define _docdir %{_datadir}/doc
%define build_number @PROJECT_VERSION_BUILD@
Name: %{pkg_name}
Version: @PROJECT_VERSION@
Release: %{build_number}%{?dist}
Summary: BZRTP is an opensource implementation of ZRTP keys exchange protocol.
Group: Applications/Communications
License: GPL
URL: http://www.linphone.org
Source0: %{name}-%{version}-%{build_number}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
%description
BZRTP is an opensource implementation of ZRTP keys exchange protocol.
The library written in C 89 is fully portable and can be executed on many platforms including both ARM processor and x86.
Licensing: The source code is licensed under GPLv2.
%package devel
Summary: Development libraries for bzrtp
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
Libraries and headers required to develop software with bzrtp
%if 0%{?rhel} && 0%{?rhel} <= 7
%global cmake_name cmake3
%define ctest_name ctest3
%else
%global cmake_name cmake
%define ctest_name ctest
%endif
%prep
%setup -n %{name}-%{version}-%build_number
%build
%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix}
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%check
%{ctest_name} -V %{?_smp_mflags}
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README.md
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root)
%{_includedir}/bzrtp
%{_libdir}/libbzrtp.a
%{_libdir}/libbzrtp.so
%{_datadir}/bzrtp/cmake/BZRTPConfig.cmake
%{_datadir}/bzrtp/cmake/BZRTPTargets-noconfig.cmake
%{_datadir}/bzrtp/cmake/BZRTPTargets.cmake
%{_datadir}/bzrtp/cmake/BZRTPConfigVersion.cmake
%changelog
* Wed Jul 19 2017 jehan.monnier <jehan.monnier@linphone.org>
- Initial RPM release.
......@@ -191,6 +191,11 @@ typedef struct bzrtpCallbacks_struct {
*/
typedef struct bzrtpContext_struct bzrtpContext_t;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Create context structure and initialise it
*
......@@ -443,7 +448,7 @@ BZRTP_EXPORT int bzrtp_cache_getZuid(void *dbPointer, const char *selfURI, const
*
* @return 0 on succes, error code otherwise
*/
BZRTP_EXPORT int bzrtp_cache_write(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount);
BZRTP_EXPORT int bzrtp_cache_write(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount);
/**
* @brief Read data from specified table/columns from cache adressing it by zuid (ZID/URI binding id used in cache)
......@@ -461,7 +466,7 @@ BZRTP_EXPORT int bzrtp_cache_write(void *dbPointer, int zuid, char *tableName, c
*
* @return 0 on succes, error code otherwise
*/
BZRTP_EXPORT int bzrtp_cache_read(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount);
BZRTP_EXPORT int bzrtp_cache_read(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount);
/**
* @brief Perform migration from xml version to sqlite3 version of cache
......@@ -490,4 +495,8 @@ BZRTP_EXPORT int bzrtp_cache_migration(void *cacheXmlPtr, void *cacheSqlite, con
*/
BZRTP_EXPORT int bzrtp_exportKey(bzrtpContext_t *zrtpContext, char *label, size_t labelLength, uint8_t *derivedKey, size_t *derivedKeyLength);
#ifdef __cplusplus
}
#endif
#endif /* ifndef BZRTP_H */
......@@ -52,7 +52,6 @@ typedef struct bzrtpChannelContext_struct bzrtpChannelContext_t;
#include "stateMachine.h"
/* logging */
#define BCTBX_LOG_DOMAIN "bzrtp"
#include "bctoolbox/logging.h"
#ifdef _WIN32
......
......@@ -28,6 +28,11 @@ set(SOURCE_FILES
stateMachine.c
zidCache.c
)
add_definitions(
-DBCTBX_LOG_DOMAIN="bzrtp"
)
if(POLARSSL_FOUND)
list(APPEND SOURCE_FILES cryptoPolarssl.c)
elseif(MBEDTLS_FOUND)
......
......@@ -520,7 +520,7 @@ int bzrtp_processMessage(bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8_t
void bzrtp_SASVerified(bzrtpContext_t *zrtpContext) {
if (zrtpContext != NULL) {
uint8_t pvsFlag = 1;
char *colNames[] = {"pvs"};
const char *colNames[] = {"pvs"};
uint8_t *colValues[] = {&pvsFlag};
size_t colLength[] = {1};
......@@ -542,7 +542,7 @@ void bzrtp_SASVerified(bzrtpContext_t *zrtpContext) {
void bzrtp_resetSASVerified(bzrtpContext_t *zrtpContext) {
if (zrtpContext != NULL) {
uint8_t pvsFlag = 0;
char *colNames[] = {"pvs"};
const char *colNames[] = {"pvs"};
uint8_t *colValues[] = {&pvsFlag};
size_t colLength[] = {1};
bzrtp_cache_write(zrtpContext->zidCache, zrtpContext->zuid, "zrtp", colNames, colValues, colLength, 1);
......
......@@ -548,7 +548,7 @@ int state_keyAgreement_sendingCommit(bzrtpEvent_t event) {
/* in case of cache mismatch, be sure the Previously Verified Sas flag is reset in cache and in the context */
if (zrtpContext->cacheMismatchFlag == 1) {
uint8_t pvsFlag = 0;
char *colNames[] = {"pvs"};
const char *colNames[] = {"pvs"};
uint8_t *colValues[] = {&pvsFlag};
size_t colLength[] = {1};
......@@ -852,7 +852,7 @@ int state_keyAgreement_responderSendingDHPart1(bzrtpEvent_t event) {
/* in case of cache mismatch, be sure the Previously Verified Sas flag is reset in cache and in the context */
if (zrtpContext->cacheMismatchFlag == 1) {
uint8_t pvsFlag = 0;
char *colNames[] = {"pvs"};
const char *colNames[] = {"pvs"};
uint8_t *colValues[] = {&pvsFlag};
size_t colLength[] = {1};
......@@ -2204,7 +2204,7 @@ int bzrtp_deriveSrtpKeysFromS0(bzrtpContext_t *zrtpContext, bzrtpChannelContext_
* return 0 on success, error code otherwise
*/
int bzrtp_updateCachedSecrets(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext) {
char *colNames[] = {"rs1", "rs2"};
const char *colNames[] = {"rs1", "rs2"};
uint8_t *colValues[2] = {NULL, NULL};
size_t colLength[2] = {RETAINED_SECRET_LENGTH,0};
......
......@@ -95,6 +95,7 @@ int bzrtp_initCache(void *dbPointer) {
/* get current db schema version (user_version pragma in sqlite )*/
sql = sqlite3_mprintf("PRAGMA user_version;");
ret = sqlite3_exec(db, sql, callback_getUserVersion, &userVersion, &errmsg);
sqlite3_free(sql);
if (ret!=SQLITE_OK) {
sqlite3_free(errmsg);
return BZRTP_ZIDCACHE_UNABLETOREAD;
......@@ -108,6 +109,7 @@ int bzrtp_initCache(void *dbPointer) {
/* update the schema version in DB metadata */
sql = sqlite3_mprintf("PRAGMA user_version = %d;",ZIDCACHE_DBSCHEMA_VERSION_NUMBER);
ret = sqlite3_prepare(db, sql, -1, &stmt, NULL);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
return BZRTP_ZIDCACHE_UNABLETOUPDATE;
}
......@@ -464,7 +466,7 @@ int bzrtp_cache_getZuid(void *dbPointer, const char *selfURI, const char *peerUR
*
* @return 0 on succes, error code otherwise
*/
int bzrtp_cache_write(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
int bzrtp_cache_write(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
char *stmt=NULL;
int ret,i,j;
sqlite3_stmt *sqlStmt = NULL;
......@@ -568,7 +570,7 @@ int bzrtp_cache_write(void *dbPointer, int zuid, char *tableName, char **columns
*
* @return 0 on succes, error code otherwise
*/
int bzrtp_cache_read(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
int bzrtp_cache_read(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
char *stmt=NULL;
int ret,i,j;
sqlite3_stmt *sqlStmt = NULL;
......@@ -707,12 +709,12 @@ int bzrtp_cache_migration(void *cacheXmlPtr, void *cacheSqlite, const char *self
xmlChar *peerUri[128]; /* array to contain all the peer uris found in one node */
/* hopefully they won't be more than 128(it would mean some peer has more than 128 accounts and we called all of them...) */
int peerUriIndex=0; /* index of previous array */
char *zrtpColNames[] = {"rs1", "rs2", "pvs"};
const char *zrtpColNames[] = {"rs1", "rs2", "pvs"};
uint8_t *zrtpColValues[] = {NULL, NULL, NULL};
size_t zrtpColExpectedLengths[] = {32,32,1};
size_t zrtpColLengths[] = {0,0,0};
char *limeColNames[] = {"sndKey", "rcvKey", "sndSId", "rcvSId", "sndIndex", "rcvIndex", "valid"};
const char *limeColNames[] = {"sndKey", "rcvKey", "sndSId", "rcvSId", "sndIndex", "rcvIndex", "valid"};
uint8_t *limeColValues[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
size_t limeColExpectedLengths[] = {32,32,32,32,4,4,8};
size_t limeColLengths[] = {0,0,0,0,0,0,0};
......@@ -851,11 +853,11 @@ int bzrtp_getPeerAssociatedSecrets(bzrtpContext_t *context, uint8_t peerZID[12])
return 0;
}
int bzrtp_cache_write(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
int bzrtp_cache_write(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
return BZRTP_ERROR_CACHEDISABLED;
}
int bzrtp_cache_read(void *dbPointer, int zuid, char *tableName, char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
int bzrtp_cache_read(void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) {
return BZRTP_ERROR_CACHEDISABLED;
}
......
......@@ -29,6 +29,10 @@ set(TEST_SOURCES
testUtils.c
)
add_definitions(
-DBCTBX_LOG_DOMAIN="bzrtp"
)
bc_apply_compile_flags(TEST_SOURCES STRICT_OPTIONS_CPP)
add_executable(bzrtpTest ${TEST_SOURCES})
......@@ -53,5 +57,11 @@ if(HAVE_SQRT)
endif()
unset(PATTERN_FILES_IN_TEST_DIR CACHE)
find_file(PATTERN_FILES_IN_TEST_DIR
patternZIDAlice.sqlite ${CMAKE_CURRENT_BINARY_DIR}
)
if (NOT PATTERN_FILES_IN_TEST_DIR)
file(COPY patternZIDAlice.sqlite DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
add_test(NAME bzrtpTest COMMAND bzrtpTest)
add_test(NAME bzrtpTest COMMAND bzrtpTest --resource-dir .)
......@@ -9,7 +9,7 @@ bzrtpTest_SOURCES=bzrtpTest.c \
bzrtpZidCacheTest.c
bzrtpTest_CFLAGS=$(BCTOOLBOXTESTER_CFLAGS) $(LIBXML2_CFLAGS)
bzrtpTest_LDADD=$(top_builddir)/src/libbzrtp.la $(BCTOOLBOX_LIBS) $(BCTOOLBOXTESTER_LIBS) $(SQLITE3_LIBS) -lm
bzrtpTest_LDADD=$(top_builddir)/src/libbzrtp.la $(BCTOOLBOX_LIBS) $(BCTOOLBOXTESTER_LIBS) $(SQLITE3_LIBS) $(LIBXML2_LIBS) -lm
AM_CPPFLAGS=-I$(top_srcdir)/include
......
......@@ -637,7 +637,7 @@ void test_cache_enabled_exchange(void) {
uint8_t selfZIDalice[12];
uint8_t selfZIDbob[12];
int zuidAlice=0,zuidBob=0;
char *colNames[] = {"rs1", "rs2", "pvs"};
const char *colNames[] = {"rs1", "rs2", "pvs"};
uint8_t *colValuesAlice[3];
size_t colLengthAlice[3];
uint8_t *colValuesBob[3];
......@@ -721,7 +721,7 @@ void test_cache_mismatch_exchange(void) {
uint8_t selfZIDalice[12];
uint8_t selfZIDbob[12];
int zuidAlice=0,zuidBob=0;
char *colNames[] = {"rs1", "rs2", "pvs"};
const char *colNames[] = {"rs1", "rs2", "pvs"};
uint8_t *colValuesAlice[3];
size_t colLengthAlice[3];
uint8_t *colValuesBob[3];
......@@ -833,7 +833,7 @@ void test_cache_sas_not_confirmed(void) {
uint8_t selfZIDalice[12];
uint8_t selfZIDbob[12];
int zuidAlice=0,zuidBob=0;
char *colNames[] = {"rs1", "rs2", "pvs"};
const char *colNames[] = {"rs1", "rs2", "pvs"};
uint8_t *colValuesAlice[3];
size_t colLengthAlice[3];
uint8_t *colValuesBob[3];
......
......@@ -33,11 +33,12 @@
#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#include <libxml/parser.h>
static const char *xmlCacheMigration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cache><selfZID>00112233445566778899aabb</selfZID><peer><ZID>99887766554433221100ffee</ZID><rs1>c4274f13a2b6fa05c15ec93158f930e7264b0a893393376dbc80c6eb1cccdc5a</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>219d9e445d10d4ed64083c7ccbb83a23bc17a97df0af5de4261f3fe026b05b0b</sndKey><rcvKey>747e72a5cc996413cb9fa6e3d18d8b370436e274cd6ba4efc1a4580340af57ca</rcvKey><sndSId>df2bf38e719fa89e17332cf8d5e774ee70d347baa74d16dee01f306c54789869</sndSId><rcvSId>928ce78b0bfc30427a02b1b668b2b3b0496d5664d7e89b75ed292ee97e3fc850</rcvSId><sndIndex>496bcc89</sndIndex><rcvIndex>59337abe</rcvIndex><rs2>5dda11f388384b349d210612f30824268a3753a7afa52ef6df5866dca76315c4</rs2><uri>sip:bob2@sip.linphone.org</uri></peer><peer><ZID>ffeeddccbbaa987654321012</ZID><rs1>858b495dfad483af3c088f26d68c4beebc638bd44feae45aea726a771727235e</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>b6aac945057bc4466bfe9a23771c6a1b3b8d72ec3e7d8f30ed63cbc5a9479a25</sndKey><rcvKey>bea5ac3225edd0545b816f061a8190370e3ee5160e75404846a34d1580e0c263</rcvKey><sndSId>17ce70fdf12e500294bcb5f2ffef53096761bb1c912b21e972ae03a5a9f05c47</sndSId><rcvSId>7e13a20e15a517700f0be0921f74b96d4b4a0c539d5e14d5cdd8706441874ac0</rcvSId><sndIndex>75e18caa</sndIndex><rcvIndex>2cfbbf06</rcvIndex><rs2>1533dee20c8116dc2c282cae9adfea689b87bc4c6a4e18a846f12e3e7fea3959</rs2></peer><peer><ZID>0987654321fedcba5a5a5a5a</ZID><rs1>cb6ecc87d1dd87b23f225eec53a26fc541384917623e0c46abab8c0350c6929e</rs1><sndKey>92bb03988e8f0ccfefa37a55fd7c5893bea3bfbb27312f49dd9b10d0e3c15fc7</sndKey><rcvKey>2315705a5830b98f68458fcd49623144cb34a667512c4d44686aee125bb8b622</rcvKey><sndSId>94c56eea0dd829379263b6da3f6ac0a95388090f168a3568736ca0bd9f8d595f</sndSId><rcvSId>c319ae0d41183fec90afc412d42253c5b456580f7a463c111c7293623b8631f4</rcvSId><uri>sip:bob@sip.linphone.org</uri><sndIndex>2c46ddcc</sndIndex><rcvIndex>15f5779e</rcvIndex><valid>0000000058f095bf</valid><pvs>01</pvs></peer></cache>";
#endif /* HAVE_LIBXML2 */
#endif /* ZIDCACHE_ENABLED */
static const char *xmlCacheMigration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cache><selfZID>00112233445566778899aabb</selfZID><peer><ZID>99887766554433221100ffee</ZID><rs1>c4274f13a2b6fa05c15ec93158f930e7264b0a893393376dbc80c6eb1cccdc5a</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>219d9e445d10d4ed64083c7ccbb83a23bc17a97df0af5de4261f3fe026b05b0b</sndKey><rcvKey>747e72a5cc996413cb9fa6e3d18d8b370436e274cd6ba4efc1a4580340af57ca</rcvKey><sndSId>df2bf38e719fa89e17332cf8d5e774ee70d347baa74d16dee01f306c54789869</sndSId><rcvSId>928ce78b0bfc30427a02b1b668b2b3b0496d5664d7e89b75ed292ee97e3fc850</rcvSId><sndIndex>496bcc89</sndIndex><rcvIndex>59337abe</rcvIndex><rs2>5dda11f388384b349d210612f30824268a3753a7afa52ef6df5866dca76315c4</rs2><uri>sip:bob2@sip.linphone.org</uri></peer><peer><ZID>ffeeddccbbaa987654321012</ZID><rs1>858b495dfad483af3c088f26d68c4beebc638bd44feae45aea726a771727235e</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>b6aac945057bc4466bfe9a23771c6a1b3b8d72ec3e7d8f30ed63cbc5a9479a25</sndKey><rcvKey>bea5ac3225edd0545b816f061a8190370e3ee5160e75404846a34d1580e0c263</rcvKey><sndSId>17ce70fdf12e500294bcb5f2ffef53096761bb1c912b21e972ae03a5a9f05c47</sndSId><rcvSId>7e13a20e15a517700f0be0921f74b96d4b4a0c539d5e14d5cdd8706441874ac0</rcvSId><sndIndex>75e18caa</sndIndex><rcvIndex>2cfbbf06</rcvIndex><rs2>1533dee20c8116dc2c282cae9adfea689b87bc4c6a4e18a846f12e3e7fea3959</rs2></peer><peer><ZID>0987654321fedcba5a5a5a5a</ZID><rs1>cb6ecc87d1dd87b23f225eec53a26fc541384917623e0c46abab8c0350c6929e</rs1><sndKey>92bb03988e8f0ccfefa37a55fd7c5893bea3bfbb27312f49dd9b10d0e3c15fc7</sndKey><rcvKey>2315705a5830b98f68458fcd49623144cb34a667512c4d44686aee125bb8b622</rcvKey><sndSId>94c56eea0dd829379263b6da3f6ac0a95388090f168a3568736ca0bd9f8d595f</sndSId><rcvSId>c319ae0d41183fec90afc412d42253c5b456580f7a463c111c7293623b8631f4</rcvSId><uri>sip:bob@sip.linphone.org</uri><sndIndex>2c46ddcc</sndIndex><rcvIndex>15f5779e</rcvIndex><valid>0000000058f095bf</valid><pvs>01</pvs></peer></cache>";
void test_cache_getSelfZID(void) {
#ifdef ZIDCACHE_ENABLED
......@@ -56,7 +57,7 @@ void test_cache_getSelfZID(void) {
uint8_t rs1Value[] = {0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00};
uint8_t rs2Value[] = {0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, 0xff, 0xee};
uint8_t pvsValue[] = {0x1};
char *patternColNames[]={"rs1", "rs2", "pvs", "aux"};
const char *patternColNames[]={"rs1", "rs2", "pvs", "aux"};
uint8_t *patternColValues[] = {rs1Value, rs2Value, pvsValue};
size_t patternColValuesLength[] = {16, 16, 1};
uint8_t *readValues[] = {NULL, NULL, NULL,NULL};
......@@ -100,11 +101,11 @@ void test_cache_getSelfZID(void) {
BC_ASSERT_EQUAL(zuidalicebob, zuidCheck, int, "%d");
/* Then write in cache zrtp table */
BC_ASSERT_EQUAL(bzrtp_cache_write((void *)aliceDB, zuidalicebob, "zrtp", (char **)patternColNames, (uint8_t **)patternColValues, patternColValuesLength, patternLength), 0, int, "%x");
BC_ASSERT_EQUAL(bzrtp_cache_write((void *)aliceDB, zuidalicebob, "zrtp", patternColNames, (uint8_t **)patternColValues, patternColValuesLength, patternLength), 0, int, "%x");
/* Try to write a zuid row in zrtp table while zuid is not present in ziduri table: it shall fail */
BC_ASSERT_EQUAL(bzrtp_cache_write((void *)aliceDB, zuidalicebob+10, "zrtp", (char **)patternColNames, (uint8_t **)patternColValues, patternColValuesLength, patternLength), BZRTP_ZIDCACHE_UNABLETOUPDATE, int, "%x");
BC_ASSERT_EQUAL(bzrtp_cache_write((void *)aliceDB, zuidalicebob+10, "zrtp", patternColNames, (uint8_t **)patternColValues, patternColValuesLength, patternLength), BZRTP_ZIDCACHE_UNABLETOUPDATE, int, "%x");
/* Now read the data and check they're the same */
BC_ASSERT_EQUAL(bzrtp_cache_read((void *)aliceDB, zuidalicebob, "zrtp", (char **)patternColNames, readValues, readLength, patternLength+1), 0, int, "%x");
BC_ASSERT_EQUAL(bzrtp_cache_read((void *)aliceDB, zuidalicebob, "zrtp", patternColNames, readValues, readLength, patternLength+1), 0, int, "%x");
for (i=0; i<patternLength; i++) {
BC_ASSERT_EQUAL(readLength[i], patternColValuesLength[i], int, "%d");
BC_ASSERT_EQUAL(memcmp(readValues[i], patternColValues[i], patternColValuesLength[i]), 0, int, "%d");
......@@ -199,6 +200,7 @@ void test_cache_zrtpSecrets(void) {
void test_cache_migration(void) {
#ifdef ZIDCACHE_ENABLED
#ifdef HAVE_LIBXML2
uint8_t pattern_selfZIDalice[12] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb};
uint8_t selfZIDalice[12];
......@@ -222,7 +224,9 @@ void test_cache_migration(void) {
/* cleaning */
sqlite3_close(aliceDB);
xmlFree(cacheXml);
#else /* HAVE_LIBXML2 */
bzrtp_message("Test skipped as LibXML2 not present\n");
#endif /* HAVE_LIBXML2 */
#else /* ZIDCACHE_ENABLED */
bzrtp_message("Test skipped as ZID cache is disabled\n");
#endif /* ZIDCACHE_ENABLED */
......
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