Commit 111f3c92 authored by Johan Pascal's avatar Johan Pascal

Transport layer to X3DH server out of lib lime

-get rid of direct dependency on belle-sip
parent 1bee1805
......@@ -46,19 +46,15 @@ include(CheckSymbolExists)
include(CMakePushCheckState)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bellesip_CONFIG_DIR}/BelleSIPConfig.cmake")
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox 0.5.1 REQUIRED OPTIONAL_COMPONENTS tester)
find_package(BelleSIP REQUIRED)
endif()
find_package(Soci REQUIRED)
find_package(Sqlite3 REQUIRED)
set(LIME_LDFLAGS "${BELLESIP_LDFLAGS}")
include_directories(
include/
src/
......@@ -69,7 +65,6 @@ if(MSVC)
endif()
set(LIME_INCLUDE_DIRS
${BELLESIP_INCLUDE_DIRS}
${BCTOOLBOX_CORE_INCLUDE_DIRS}
)
......@@ -77,7 +72,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
add_definitions("-DHAVE_CONFIG_H")
set(LIME_CPPFLAGS ${BELLESIP_CPPFLAGS} ${BCTOOLBOX_CPPFLAGS})
set(LIME_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(LIME_CPPFLAGS)
list(REMOVE_DUPLICATES LIME_CPPFLAGS)
add_definitions(${LIME_CPPFLAGS})
......
......@@ -22,7 +22,6 @@
#include <memory> //smart ptrs
#include <unordered_map>
#include <vector>
#include "belle-sip/belle-sip.h"
namespace lime {
......@@ -43,9 +42,26 @@ namespace lime {
// a callback function must return a code and may return a string(could actually be empty) to detail what's happening
// callback is used on every operation possibly involving a connection to X3DH server: create_user, delete_user, encrypt
using limeCallback = std::function<void(lime::callbackReturn, std::string)>;
// the user authenticate callback will pass a sip_auth_event to be completed with user's password
using userAuthenticateCallback = std::function<void(belle_sip_auth_event_t *)>;
/* X3DH server communication : these functions prototypes are used to post data and get response from/to the X3DH server */
/**
* @brief Get the response from server. The external service providing secure communication to the X3DH server shall forward to lime library the server's response
*
* @param[in] responseCode Lime expects communication with server to be over HTTPS, this shall be the response code. Lime expects 200 for successfull response from server.
* Any other response code is treated as an error and response ignored(but it is still usefull to forward it in order to perform internal cleaning)
* @param[in] responseBody The actual response from X3DH server
*/
using limeX3DHServerResponseProcess = std::function<void(int responseCode, const std::vector<uint8_t> &responseBody)>;
/**
* @brief Post a message to the X3DH server
*
* @param[in] url X3DH server's URL
* @param[in] from User identification on X3DH server(which shall challenge for password digest, this is not however part of lime)
* @param[in] message The message to post to the X3DH server
* @param[in] responseProcess Function to be called with server's response
*/
using limeX3DHServerPostData = std::function<void(const std::string &url, const std::string &from, const std::vector<uint8_t> &message, const limeX3DHServerResponseProcess &reponseProcess)>;
/* Forward declare the class managing one lime user*/
class LimeGeneric;
......@@ -55,8 +71,7 @@ namespace lime {
private :
std::unordered_map<std::string, std::shared_ptr<LimeGeneric>> m_users_cache; // cache of already opened Lime Session, identified by user Id (GRUU)
std::string m_db_access; // DB access information forwarded to SOCI to correctly access database
belle_http_provider_t *m_http_provider; // used to access the X3DH key server
userAuthenticateCallback m_user_auth; // called to complete user authentication on server
limeX3DHServerPostData m_X3DH_post_data; // send data to the X3DH key server
void load_user(std::shared_ptr<LimeGeneric> &user, const std::string &localDeviceId); // helper function, get from m_users_cache of local Storage the requested Lime object
public :
......@@ -116,7 +131,7 @@ namespace lime {
* @param[in/out] recipients a list of recipientData holding: the recipient device Id(GRUU) and an empty buffer to store the cipherHeader which must then be routed to that recipient
* @param[in] plainMessage a buffer holding the message to encrypt, can be text or data.
* @param[out] cipherMessage points to the buffer to store the encrypted message which must be routed to all recipients
* @param[in] callback This operation contact the X3DH server and is thus asynchronous, when server responds,
* @param[in] callback Performing encryption may involve the X3DH server and is thus asynchronous, when the operation is completed,
* this callback will be called giving the exit status and an error message in case of failure.
* It is advised to capture a copy of cipherMessage and recipients shared_ptr in this callback so they can access
* the output of encryption as it won't be part of the callback parameters.
......@@ -195,12 +210,11 @@ namespace lime {
/**
* @brief Lime Manager constructor
*
* @param[in] db_access string used to access DB: can be filename for sqlite3 or access params for mysql, directly forwarded to SOCI session opening
* @param[in] http_provider An http provider used to access X3DH server, no scheduling is done on it internally
* @param[in] user_authentication_callback To complete user authentication on server: must provide user credentials
* @param[in] db_access string used to access DB: can be filename for sqlite3 or access params for mysql, directly forwarded to SOCI session opening
* @param[in] X3DH_post_data A function to send data to the X3DH server, parameters includes a callback to transfer back the server response
*/
LimeManager(const std::string &db_access, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback)
: m_users_cache{}, m_db_access{db_access}, m_http_provider{http_provider}, m_user_auth{user_authentication_callback} {};
LimeManager(const std::string &db_access, const limeX3DHServerPostData &X3DH_post_data)
: m_users_cache{}, m_db_access{db_access}, m_X3DH_post_data{X3DH_post_data} {};
~LimeManager() = default;
};
......
......@@ -50,7 +50,7 @@ if(ENABLE_STATIC)
add_library(lime-static STATIC ${LIME_HEADER_FILES} ${LIME_SOURCE_FILES_C} ${LIME_SOURCE_FILES_CXX})
set_target_properties(lime-static PROPERTIES OUTPUT_NAME lime)
target_include_directories(lime-static PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
target_link_libraries(lime-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES} ${BELLESIP_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${SQLITE3_LIBRARIES})
target_link_libraries(lime-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${SQLITE3_LIBRARIES})
endif()
if(ENABLE_SHARED)
add_library(lime SHARED ${LIME_HEADER_FILES} ${LIME_SOURCE_FILES_C} ${LIME_SOURCE_FILES_CXX})
......@@ -59,7 +59,7 @@ if(ENABLE_SHARED)
endif()
set_target_properties(lime PROPERTIES VERSION ${LIME_SO_VERSION})
target_include_directories(lime PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
target_link_libraries(lime PRIVATE ${BCTOOLBOX_CORE_LIBRARIES} ${BELLESIP_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${SQLITE3_LIBRARIES})
target_link_libraries(lime PRIVATE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${SQLITE3_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lime.pdb
......
......@@ -54,16 +54,15 @@ namespace lime {
* @param[in/out] localStorage pointer to DB accessor
* @param[in] deviceId device Id(shall be GRUU), stored in the structure
* @param[in] url URL of the X3DH key server used to publish our keys(retrieved from DB)
* @param[in] http_provider An HTTP stack
* @param[in] user_authentication_callback called to get users credentials to log on X3DH key server
* @param[in] X3DH_post_data A function used to communicate with the X3DH server
* @param[in] Uid the DB internal Id for this user, speed up DB operations by holding it in DB
*/
template <typename Curve>
Lime<Curve>::Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback, const long int Uid)
Lime<Curve>::Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data, const long int Uid)
: m_RNG{bctbx_rng_context_new()}, m_selfDeviceId{deviceId},
m_Ik{}, m_Ik_loaded(false),
m_localStorage(std::move(localStorage)), m_db_Uid{Uid},
m_http_provider{http_provider}, m_user_auth{user_authentication_callback}, m_X3DH_Server_URL{url},
m_X3DH_post_data{X3DH_post_data}, m_X3DH_Server_URL{url},
m_DR_sessions_cache{}, m_ongoing_encryption{nullptr}, m_encryption_queue{}
{ }
......@@ -75,15 +74,14 @@ namespace lime {
* @param[in/out] localStorage pointer to DB accessor
* @param[in] deviceId device Id(shall be GRUU), stored in the structure
* @param[in] url URL of the X3DH key server used to publish our keys
* @param[in] http_provider An HTTP stack
* @param[in] user_authentication_callback called to get users credentials to log on X3DH key server
* @param[in] X3DH_post_data A function used to communicate with the X3DH server
*/
template <typename Curve>
Lime<Curve>::Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback)
Lime<Curve>::Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data)
: m_RNG{bctbx_rng_context_new()}, m_selfDeviceId{deviceId},
m_Ik{}, m_Ik_loaded(false),
m_localStorage(std::move(localStorage)), m_db_Uid{0},
m_http_provider{http_provider}, m_user_auth{user_authentication_callback}, m_X3DH_Server_URL{url},
m_X3DH_post_data{X3DH_post_data}, m_X3DH_Server_URL{url},
m_DR_sessions_cache{}, m_ongoing_encryption{nullptr}, m_encryption_queue{}
{
try {
......@@ -113,7 +111,7 @@ namespace lime {
*/
template <typename Curve>
void Lime<Curve>::publish_user(const limeCallback &callback, const uint16_t OPkInitialBatchSize) {
callbackUserData<Curve> *userData = new callbackUserData<Curve>{this->shared_from_this(), callback, OPkInitialBatchSize, true};
auto userData = make_shared<callbackUserData<Curve>>(this->shared_from_this(), callback, OPkInitialBatchSize, true);
get_SelfIdentityKey(); // make sure our Ik is loaded in object
std::vector<uint8_t> X3DHmessage{};
x3dh_protocol::buildMessage_registerUser<Curve>(X3DHmessage, m_Ik.publicKey());
......@@ -126,7 +124,7 @@ namespace lime {
m_localStorage->delete_LimeUser(m_selfDeviceId);
// delete user from server
callbackUserData<Curve> *userData = new callbackUserData<Curve>{this->shared_from_this(), callback};
auto userData = make_shared<callbackUserData<Curve>>(this->shared_from_this(), callback);
std::vector<uint8_t> X3DHmessage{};
x3dh_protocol::buildMessage_deleteUser<Curve>(X3DHmessage);
postToX3DHServer(userData, X3DHmessage);
......@@ -137,7 +135,7 @@ namespace lime {
// Do we need to update the SPk
if (!is_currentSPk_valid()) {
BCTBX_SLOGI<<"User "<<m_selfDeviceId<<" updates its SPk";
callbackUserData<Curve> *userData = new callbackUserData<Curve>{this->shared_from_this(), callback};
auto userData = make_shared<callbackUserData<Curve>>(this->shared_from_this(), callback);
// generate and publish the SPk
X<Curve> SPk{};
Signature<Curve> SPk_sig{};
......@@ -154,7 +152,7 @@ namespace lime {
template <typename Curve>
void Lime<Curve>::update_OPk(const limeCallback &callback, uint16_t OPkServerLowLimit, uint16_t OPkBatchSize) {
// Request Server for the count of our OPk it still holds
callbackUserData<Curve> *userData = new callbackUserData<Curve>{this->shared_from_this(), callback, OPkServerLowLimit, OPkBatchSize};
auto userData = make_shared<callbackUserData<Curve>>(this->shared_from_this(), callback, OPkServerLowLimit, OPkBatchSize);
std::vector<uint8_t> X3DHmessage{};
x3dh_protocol::buildMessage_getSelfOPks<Curve>(X3DHmessage);
postToX3DHServer(userData, X3DHmessage); // in the response from server, if more OPks are needed, it will generate and post them before calling the callback
......@@ -206,8 +204,7 @@ namespace lime {
// retrieve bundles from X3DH server, when they arrive, it will run the X3DH initiation and create the DR sessions
std::vector<uint8_t> X3DHmessage{};
x3dh_protocol::buildMessage_getPeerBundles<Curve>(X3DHmessage, missing_devices);
// use the raw pointer to userData as it is passed to belle-sip C callbacks but store it in current object so it is not destroyed
postToX3DHServer(userData.get(), X3DHmessage);
postToX3DHServer(userData, X3DHmessage);
} else { // got everyone, encrypt
encryptMessage(internal_recipients, *plainMessage, *recipientUserId, m_selfDeviceId, *cipherMessage);
// move cipher headers to the input/output structure
......@@ -299,14 +296,13 @@ namespace lime {
* @param[in] url URL of X3DH key server to be used to publish our keys
* @param[in] curve Which curve shall we use for this account, select the implemenation to instanciate when using this user
* @param[in] initialOPkBatchSize Number of OPks in the first batch uploaded to X3DH server
* @param[in] http_provider An http provider used to communicate with x3dh key server
* @param[in] user_authentication_callback To complete user authentication on server: must provide user credentials
* @param[in] X3DH_post_data A function used to communicate with the X3DH server
* @param[in] callback To provide caller the operation result
*
* @return a pointer to the LimeGeneric class allowing access to API declared in lime.hpp
*/
std::shared_ptr<LimeGeneric> insert_LimeUser(const std::string &dbFilename, const std::string &deviceId, const std::string &url, const lime::CurveId curve, const uint16_t OPkInitialBatchSize,
belle_http_provider *http_provider, const userAuthenticateCallback &user_authentication_callback, const limeCallback &callback) {
const limeX3DHServerPostData &X3DH_post_data, const limeCallback &callback) {
BCTBX_SLOGI<<"Create Lime user "<<deviceId;
/* first check the requested curve is instanciable and return an exception if not */
#ifndef EC25519_ENABLED
......@@ -330,7 +326,7 @@ namespace lime {
#ifdef EC25519_ENABLED
{
/* constructor will insert user in Db, if already present, raise an exception*/
auto lime_ptr = std::make_shared<Lime<C255>>(std::move(localStorage), deviceId, url, http_provider, user_authentication_callback);
auto lime_ptr = std::make_shared<Lime<C255>>(std::move(localStorage), deviceId, url, X3DH_post_data);
lime_ptr->publish_user(callback, OPkInitialBatchSize);
return lime_ptr;
}
......@@ -340,7 +336,7 @@ namespace lime {
case lime::CurveId::c448 :
#ifdef EC448_ENABLED
{
auto lime_ptr = std::make_shared<Lime<C448>>(std::move(localStorage), deviceId, url, http_provider, user_authentication_callback);
auto lime_ptr = std::make_shared<Lime<C448>>(std::move(localStorage), deviceId, url, X3DH_post_data);
lime_ptr->publish_user(callback, OPkInitialBatchSize);
return lime_ptr;
}
......@@ -364,12 +360,11 @@ namespace lime {
*
* @param[in] dbFilename Path to filename to use
* @param[in] deviceId User to lookup in DB, deviceId shall be the GRUU
* @param[in] http_provider An http provider used to communicate with x3dh key server
* @param[in] user_authentication_callback To complete user authentication on server: must provide user credentials
* @param[in] X3DH_post_data A function used to communicate with the X3DH server
*
* @return a pointer to the LimeGeneric class allowing access to API declared in lime.hpp
*/
std::shared_ptr<LimeGeneric> load_LimeUser(const std::string &dbFilename, const std::string &deviceId, belle_http_provider *http_provider, const userAuthenticateCallback &user_authentication_callback) {
std::shared_ptr<LimeGeneric> load_LimeUser(const std::string &dbFilename, const std::string &deviceId, const limeX3DHServerPostData &X3DH_post_data) {
/* open DB and load user */
auto localStorage = std::unique_ptr<lime::Db>(new lime::Db(dbFilename)); // create as unique ptr, ownership is then passed to the Lime structure when instanciated
......@@ -397,14 +392,14 @@ namespace lime {
switch (curve) {
case lime::CurveId::c25519 :
#ifdef EC25519_ENABLED
return std::make_shared<Lime<C255>>(std::move(localStorage), deviceId, x3dh_server_url, http_provider, user_authentication_callback, Uid);
return std::make_shared<Lime<C255>>(std::move(localStorage), deviceId, x3dh_server_url, X3DH_post_data, Uid);
#endif
break;
case lime::CurveId::c448 :
#ifdef EC448_ENABLED
return std::make_shared<Lime<C448>>(std::move(localStorage), deviceId, x3dh_server_url, http_provider, user_authentication_callback, Uid);
return std::make_shared<Lime<C448>>(std::move(localStorage), deviceId, x3dh_server_url, X3DH_post_data, Uid);
#endif
break;
......
......@@ -56,8 +56,7 @@ namespace lime {
long int m_db_Uid; // the Uid in database, retrieved at creation/load, used for faster access
/* network related */
belle_http_provider_t *m_http_provider; // externally provided http stack used to communicate with x3dh server
userAuthenticateCallback m_user_auth; // called to complete user authentication on server
limeX3DHServerPostData m_X3DH_post_data; // externally provided function to communicate with x3dh server
std::string m_X3DH_Server_URL; // url of x3dh key server
/* Double ratchet related */
......@@ -89,11 +88,9 @@ namespace lime {
std::shared_ptr<DR<Curve>> X3DH_init_receiver_session(const std::vector<uint8_t> X3DH_initMessage, const std::string &senderDeviceId); // from received X3DH init packet, try to compute the shared secrets, then create the DR_Session
/* network related */
void postToX3DHServer(callbackUserData<Curve> *userData, const std::vector<uint8_t> &message); // send a request to X3DH server
static void process_response(void *data, const belle_http_response_event_t *event) noexcept; // callback on server response (must be static)
static void process_io_error(void *data, const belle_sip_io_error_event_t *event) noexcept; // callback on server i/o error (must be static)
static void process_auth_requested(void *data, belle_sip_auth_event_t *event) noexcept; // callback on server requesting user credentials (must be static)
void cleanUserData(callbackUserData<Curve> *userData); // clean user data
void postToX3DHServer(std::shared_ptr<callbackUserData<Curve>> userData, const std::vector<uint8_t> &message); // send a request to X3DH server
void process_response(std::shared_ptr<callbackUserData<Curve>> userData, int responseCode, const std::vector<uint8_t> &responseBody) noexcept; // callback on server response
void cleanUserData(std::shared_ptr<callbackUserData<Curve>> userData); // clean user data
public: /* Implement API defined in lime.hpp in factory abstract class */
/**
......@@ -102,8 +99,8 @@ namespace lime {
* - one to load the user from db based on provided user Id(which shall be GRUU)
* Note: ownership of localStorage pointer is transfered to a shared pointer, private menber of Lime class
*/
Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback);
Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback, const long Uid);
Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data);
Lime(std::unique_ptr<lime::Db> &&localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data, const long Uid);
~Lime();
Lime(Lime<Curve> &a) = delete; // can't copy a session, force usage of shared pointers
Lime<Curve> &operator=(Lime<Curve> &a) = delete; // can't copy a session
......
......@@ -100,7 +100,9 @@ namespace lime {
public :
constexpr static size_t signatureLength(void) {return Curve::EDSigSize();}; // provide a static size function to be able to call the function not on an object
Signature(const uint8_t *buffer) {std::copy_n(buffer, Curve::EDSigSize(), this->data());}
Signature(std::vector<uint8_t>::const_iterator buffer) {std::copy_n(buffer, Curve::EDSigSize(), this->begin());}
Signature() {};
void assign(std::vector<uint8_t>::const_iterator buffer) {std::copy_n(buffer, Curve::EDSigSize(), this->begin());} // copy from a std::vector<uint8_t>
};
......
......@@ -23,7 +23,6 @@
#include <memory> // unique_ptr
#include <unordered_map>
#include <vector>
#include "belle-sip/belle-sip.h"
namespace lime {
......@@ -138,26 +137,24 @@ namespace lime {
* @param[in] url URL of X3DH key server to be used to publish our keys
* @param[in] curve Which curve shall we use for this account, select the implemenation to instanciate when using this user
* @param[in] initialOPkBatchSize Number of OPks in the first batch uploaded to X3DH server
* @param[in] http_provider An http provider used to communicate with x3dh key server
* @param[in] user_authentication_callback To complete user authentication on server: must provide user credentials
* @param[in] X3DH_post_data A function to communicate with x3dh key server
* @param[in] callback To provide caller the operation result
*
* @return a pointer to the LimeGeneric class allowing access to API declared in lime.hpp
*/
std::shared_ptr<LimeGeneric> insert_LimeUser(const std::string &dbFilename, const std::string &deviceId, const std::string &url, const lime::CurveId curve, const uint16_t OPkInitialBatchSize,
belle_http_provider *http_provider, const userAuthenticateCallback &user_authentication_callback, const limeCallback &callback);
const limeX3DHServerPostData &X3DH_post_data, const limeCallback &callback);
/**
* @brief Load a local user from database
*
* @param[in] dbFilename path to the database to be used
* @param[in] deviceId a unique identifier to a local user, if not already present in base it will be inserted. Recommended value: device's GRUU
* @param[in] http_provider An http provider used to access X3DH server, no scheduling is done on it internally
* @param[in] user_authentication_callback To complete user authentication on server: must provide user credentials
* @param[in] X3DH_post_data A function to communicate with x3dh key server
*
* @return a unique pointer to the object to be used by this user for any Lime operations
*/
std::shared_ptr<LimeGeneric> load_LimeUser(const std::string &dbFilename, const std::string &deviceId, belle_http_provider_t *http_provider, const userAuthenticateCallback &user_authentication_callback);
std::shared_ptr<LimeGeneric> load_LimeUser(const std::string &dbFilename, const std::string &deviceId, const limeX3DHServerPostData &X3DH_post_data);
}
#endif // lime_lime_hpp
......@@ -35,7 +35,7 @@ namespace lime {
// Load user object
auto userElem = m_users_cache.find(localDeviceId);
if (userElem == m_users_cache.end()) { // not in cache, load it from DB
user = load_LimeUser(m_db_access, localDeviceId, m_http_provider, m_user_auth);
user = load_LimeUser(m_db_access, localDeviceId, m_X3DH_post_data);
m_users_cache[localDeviceId]=user;
} else {
user = userElem->second;
......@@ -65,7 +65,7 @@ namespace lime {
}
});
m_users_cache.insert({localDeviceId, insert_LimeUser(m_db_access, localDeviceId, x3dhServerUrl, curve, OPkInitialBatchSize, m_http_provider, m_user_auth, managerCreateCallback)});
m_users_cache.insert({localDeviceId, insert_LimeUser(m_db_access, localDeviceId, x3dhServerUrl, curve, OPkInitialBatchSize, m_X3DH_post_data, managerCreateCallback)});
}
void LimeManager::delete_user(const std::string &localDeviceId, const limeCallback &callback) {
......
This diff is collapsed.
......@@ -41,6 +41,13 @@ namespace lime {
X3DH_peerBundle(std::string &&deviceId, const uint8_t *Ik, const uint8_t *SPk, uint32_t SPk_id, const uint8_t *SPk_sig, const uint8_t *OPk, uint32_t OPk_id) :
deviceId{deviceId}, Ik{Ik}, SPk{SPk}, SPk_id{SPk_id}, SPk_sig{SPk_sig}, haveOPk{true}, OPk{OPk}, OPk_id{OPk_id} {};
// use uint8_t * constructor for all keys/signatures
X3DH_peerBundle(std::string &&deviceId, std::vector<uint8_t>::const_iterator Ik, std::vector<uint8_t>::const_iterator SPk, uint32_t SPk_id, std::vector<uint8_t>::const_iterator SPk_sig) :
deviceId{deviceId}, Ik{Ik}, SPk{SPk}, SPk_id{SPk_id}, SPk_sig{SPk_sig}, haveOPk{false}, OPk{}, OPk_id{0} {};
X3DH_peerBundle(std::string &&deviceId, std::vector<uint8_t>::const_iterator Ik, std::vector<uint8_t>::const_iterator SPk, uint32_t SPk_id, std::vector<uint8_t>::const_iterator SPk_sig, std::vector<uint8_t>::const_iterator OPk, uint32_t OPk_id) :
deviceId{deviceId}, Ik{Ik}, SPk{SPk}, SPk_id{SPk_id}, SPk_sig{SPk_sig}, haveOPk{true}, OPk{OPk}, OPk_id{OPk_id} {};
};
namespace x3dh_protocol {
......
......@@ -20,6 +20,12 @@
#
############################################################################
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bellesip_CONFIG_DIR}/BelleSIPConfig.cmake")
else()
find_package(BelleSIP REQUIRED)
endif()
if(ENABLE_SHARED)
set(LIME_LIBRARIES_FOR_TESTER lime)
else()
......@@ -36,6 +42,7 @@ set(SOURCE_FILES_CXX
bc_apply_compile_flags(SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
include_directories(${BELLESIP_INCLUDE_DIRS})
add_executable(lime_tester ${SOURCE_FILES_CXX} ${HEADER_FILES_CXX})
set_target_properties(lime_tester PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(lime_tester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
......
......@@ -23,6 +23,7 @@
#include "bctoolbox/crypto.h"
#include "lime_double_ratchet.hpp"
#include "lime_localStorage.hpp"
#include "belle-sip/belle-sip.h"
#include "soci/sqlite3/soci-sqlite3.h"
......@@ -147,6 +148,7 @@ int wait_for(belle_sip_stack_t*s1,int* counter,int value,int timeout);
// not based on the From field of HTPP packets
const std::string test_server_user_name{"alice"};
const std::string test_server_user_password{"you see the problem is this"};
} // namespace lime_tester
#endif
This diff is collapsed.
This diff is collapsed.
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