Commit 3300be5c authored by Ghislain MARY's avatar Ghislain MARY

Merge branch 'fix/windows_build' into 'master'

Fix windows build

See merge request !7
parents 09e63cf6 f2aaecc3
......@@ -86,6 +86,8 @@ if(MSVC)
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "/WX")
endif()
# avoid conflicts with std::min and std::max
add_definitions("-DNOMINMAX")
else()
if (ENABLE_PROFILING)
list(APPEND STRICT_OPTIONS_CXX "-g -pg")
......
......@@ -64,6 +64,9 @@ if(ENABLE_SHARED)
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} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN})
if(WIN32)
set_target_properties(lime PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
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
......
......@@ -278,10 +278,48 @@ namespace lime {
/* instantiate Lime for C255 and C448 */
#ifdef EC25519_ENABLED
/* These extern templates are defines in lime_localStorage.cpp */
extern template bool Lime<C255>::create_user();
extern template void Lime<C255>::get_SelfIdentityKey();
extern template void Lime<C255>::X3DH_generate_SPk(X<C255, lime::Xtype::publicKey> &publicSPk, DSA<C255, DSAtype::signature> &SPk_sig, uint32_t &SPk_id);
extern template void Lime<C255>::X3DH_generate_OPks(std::vector<X<C255, lime::Xtype::publicKey>> &publicOPks, std::vector<uint32_t> &OPk_ids, const uint16_t OPk_number);
extern template void Lime<C255>::cache_DR_sessions(std::vector<RecipientInfos<C255>> &internal_recipients, std::vector<std::string> &missing_devices);
extern template void Lime<C255>::get_DRSessions(const std::string &senderDeviceId, const long int ignoreThisDBSessionId, std::vector<std::shared_ptr<DR<C255>>> &DRSessions);
extern template void Lime<C255>::X3DH_get_SPk(uint32_t SPk_id, Xpair<C255> &SPk);
extern template bool Lime<C255>::is_currentSPk_valid(void);
extern template void Lime<C255>::X3DH_get_OPk(uint32_t OPk_id, Xpair<C255> &SPk);
extern template void Lime<C255>::X3DH_updateOPkStatus(const std::vector<uint32_t> &OPkIds);
/* These extern templates are defined in lime_x3dh.cpp*/
extern template void Lime<C255>::X3DH_init_sender_session(const std::vector<X3DH_peerBundle<C255>> &peerBundle);
extern template std::shared_ptr<DR<C255>> Lime<C255>::X3DH_init_receiver_session(const std::vector<uint8_t> X3DH_initMessage, const std::string &peerDeviceId);
/* These extern templates are defined in lime_x3dh_protocol.cpp*/
extern template void Lime<C255>::postToX3DHServer(std::shared_ptr<callbackUserData<C255>> userData, const std::vector<uint8_t> &message);
extern template void Lime<C255>::process_response(std::shared_ptr<callbackUserData<C255>> userData, int responseCode, const std::vector<uint8_t> &responseBody) noexcept;
extern template void Lime<C255>::cleanUserData(std::shared_ptr<callbackUserData<C255>> userData);
template class Lime<C255>;
#endif
#ifdef EC448_ENABLED
/* These extern templates are defines in lime_localStorage.cpp */
extern template bool Lime<C448>::create_user();
extern template void Lime<C448>::get_SelfIdentityKey();
extern template void Lime<C448>::X3DH_generate_SPk(X<C448, lime::Xtype::publicKey> &publicSPk, DSA<C448, DSAtype::signature> &SPk_sig, uint32_t &SPk_id);
extern template void Lime<C448>::X3DH_generate_OPks(std::vector<X<C448, lime::Xtype::publicKey>> &publicOPks, std::vector<uint32_t> &OPk_ids, const uint16_t OPk_number);
extern template void Lime<C448>::cache_DR_sessions(std::vector<RecipientInfos<C448>> &internal_recipients, std::vector<std::string> &missing_devices);
extern template void Lime<C448>::get_DRSessions(const std::string &senderDeviceId, const long int ignoreThisDBSessionId, std::vector<std::shared_ptr<DR<C448>>> &DRSessions);
extern template void Lime<C448>::X3DH_get_SPk(uint32_t SPk_id, Xpair<C448> &SPk);
extern template bool Lime<C448>::is_currentSPk_valid(void);
extern template void Lime<C448>::X3DH_get_OPk(uint32_t OPk_id, Xpair<C448> &SPk);
extern template void Lime<C448>::X3DH_updateOPkStatus(const std::vector<uint32_t> &OPkIds);
/* These extern templates are defined in lime_x3dh.cpp*/
extern template void Lime<C448>::X3DH_init_sender_session(const std::vector<X3DH_peerBundle<C448>> &peerBundle);
extern template std::shared_ptr<DR<C448>> Lime<C448>::X3DH_init_receiver_session(const std::vector<uint8_t> X3DH_initMessage, const std::string &peerDeviceId);
/* These extern templates are defined in lime_x3dh_protocol.cpp*/
extern template void Lime<C448>::postToX3DHServer(std::shared_ptr<callbackUserData<C448>> userData, const std::vector<uint8_t> &message);
extern template void Lime<C448>::process_response(std::shared_ptr<callbackUserData<C448>> userData, int responseCode, const std::vector<uint8_t> &responseBody) noexcept;
extern template void Lime<C448>::cleanUserData(std::shared_ptr<callbackUserData<C448>> userData);
template class Lime<C448>;
#endif
......@@ -352,7 +390,7 @@ namespace lime {
throw BCTBX_EXCEPTION << "Cannot create lime user "<<deviceId;//<<". Unsupported curve (id <<"static_cast<uint8_t>(curve)") requested";
break;
}
} catch (BctbxException &e) {
} catch (BctbxException &) {
throw; // just forward the exceptions raised by constructor
}
return nullptr;
......@@ -413,7 +451,7 @@ namespace lime {
throw BCTBX_EXCEPTION << "Cannot create load user "<<deviceId;//<<". Unsupported curve (id <<"static_cast<uint8_t>(curve)") requested";
break;
}
} catch (BctbxException &e) {
} catch (BctbxException &) {
throw;
}
return nullptr;
......
......@@ -375,7 +375,7 @@ void HMAC(const uint8_t *const key, const size_t keySize, const uint8_t *const i
/* HMAC specialized template for SHA512 */
template <> void HMAC<SHA512>(const uint8_t *const key, const size_t keySize, const uint8_t *const input, const size_t inputSize, uint8_t *hash, size_t hashSize) {
bctbx_hmacSha512(key, keySize, input, inputSize, std::min(SHA512::ssize(),hashSize), hash);
bctbx_hmacSha512(key, keySize, input, inputSize, static_cast<uint8_t>(std::min(SHA512::ssize(),hashSize)), hash);
}
/* generic implementation, of HKDF RFC-5869 */
......
......@@ -437,10 +437,16 @@ namespace lime {
/* template instanciations for DHKeyX25519 and DHKeyX448 */
#ifdef EC25519_ENABLED
extern template bool DR<C255>::session_load();
extern template bool DR<C255>::session_save();
extern template bool DR<C255>::trySkippedMessageKeys(const uint16_t Nr, const X<C255, lime::Xtype::publicKey> &DHr, DRMKey &MK);
template class DR<C255>;
#endif
#ifdef EC448_ENABLED
extern template bool DR<C448>::session_load();
extern template bool DR<C448>::session_save();
extern template bool DR<C448>::trySkippedMessageKeys(const uint16_t Nr, const X<C448, lime::Xtype::publicKey> &DHr, DRMKey &MK);
template class DR<C448>;
#endif
/**
......
......@@ -88,7 +88,7 @@ namespace lime {
void X3DH_init_sender_session(const std::vector<X3DH_peerBundle<Curve>> &peersBundle); // compute a sender X3DH using the data from peer bundle, then create and load the DR_Session
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 */
/* network related, implemented in lime_x3dh_protocol.cpp */
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
......
......@@ -17,14 +17,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bctoolbox/exception.hh>
#include <soci/soci.h>
#include "lime_log.hpp"
#include "lime/lime.hpp"
#include "lime_localStorage.hpp"
#include "lime_double_ratchet.hpp"
#include "lime_impl.hpp"
#include "bctoolbox/exception.hh"
#include "soci/sqlite3/soci-sqlite3.h"
using namespace::std;
using namespace::soci;
using namespace::lime;
......@@ -41,7 +42,7 @@ namespace lime {
*
* @param[in] filename The path to DB file
*/
Db::Db(std::string filename) : sql{sqlite3, filename}{
Db::Db(std::string filename) : sql{"sqlite3", filename}{
constexpr int db_module_table_not_holding_lime_row = -1;
int userVersion=db_module_table_not_holding_lime_row;
......
......@@ -25,11 +25,11 @@
#include "lime_keys.hpp"
#include "lime_crypto_primitives.hpp"
#include "lime_double_ratchet_protocol.hpp"
#include "bctoolbox/exception.hh"
#include "lime-tester-utils.hpp"
#include "soci/soci.h"
#include "soci/sqlite3/soci-sqlite3.h"
#include <bctoolbox/exception.hh>
#include <soci/soci.h>
using namespace::std;
using namespace::soci;
......@@ -42,7 +42,7 @@ std::string test_x3dh_c448_server_port{"25520"};
/* for testing purpose RNG, no need to be good one */
std::random_device rd;
std::uniform_int_distribution<uint8_t> uniform_dist(0,255);
std::uniform_int_distribution<int> uniform_dist(0,255);
// default value for the timeout
int wait_for_timeout=4000;
......@@ -169,7 +169,7 @@ std::vector<std::string> messages_pattern = {
*/
void randomize(uint8_t *buffer, const size_t size) {
for (size_t i=0; i<size; i++) {
buffer[i] = lime_tester::uniform_dist(rd);
buffer[i] = (uint8_t)lime_tester::uniform_dist(rd);
}
}
/**
......@@ -281,7 +281,7 @@ bool DR_message_payloadDirectEncrypt(std::vector<uint8_t> &message) {
// check protocol version
if (message[0] != static_cast<uint8_t>(lime::double_ratchet_protocol::DR_v01)) return false;
return (message[1]&static_cast<uint8_t>(lime::double_ratchet_protocol::DR_message_type::payload_direct_encryption_flag));
return !!(message[1]&static_cast<uint8_t>(lime::double_ratchet_protocol::DR_message_type::payload_direct_encryption_flag));
}
bool DR_message_holdsX3DHInit(std::vector<uint8_t> &message) {
......@@ -297,7 +297,7 @@ bool DR_message_holdsX3DHInit(std::vector<uint8_t> &message, bool &haveOPk) {
if (message[0] != static_cast<uint8_t>(lime::double_ratchet_protocol::DR_v01)) return false;
// check message type: we must have a X3DH init message
if (!(message[1]&static_cast<uint8_t>(lime::double_ratchet_protocol::DR_message_type::X3DH_init_flag))) return false;
bool payload_direct_encryption = (message[1]&static_cast<uint8_t>(lime::double_ratchet_protocol::DR_message_type::payload_direct_encryption_flag));
bool payload_direct_encryption = !!(message[1]&static_cast<uint8_t>(lime::double_ratchet_protocol::DR_message_type::payload_direct_encryption_flag));
/* check message length :
* message with payload not included (DR payload is a fixed 32 byte random seed)
......@@ -398,7 +398,7 @@ long int get_DRsessionsId(const std::string &dbFilename, const std::string &self
sessionsId.resize(25); // no more than 25 sessions id fetched
std::vector<int> status(25);
try {
soci::session sql(sqlite3, dbFilename); // open the DB
soci::session sql("sqlite3", dbFilename); // open the DB
soci::statement st = (sql.prepare << "SELECT s.sessionId, s.Status FROM DR_sessions as s INNER JOIN lime_PeerDevices as d on s.Did = d.Did INNER JOIN lime_LocalUsers as u on u.Uid = s.Uid WHERE u.UserId = :selfId AND d.DeviceId = :peerId ORDER BY s.Status DESC, s.Did;", into(sessionsId), into(status), use(selfDeviceId), use(peerDeviceId));
st.execute();
if (st.fetch()) { // all retrieved session shall fit in the arrays no need to go on several fetch
......@@ -427,7 +427,7 @@ long int get_DRsessionsId(const std::string &dbFilename, const std::string &self
*/
unsigned int get_StoredMessageKeyCount(const std::string &dbFilename, const std::string &selfDeviceId, const std::string &peerDeviceId) noexcept{
try {
soci::session sql(sqlite3, dbFilename); // open the DB
soci::session sql("sqlite3", dbFilename); // open the DB
unsigned int mkCount=0;
sql<< "SELECT count(m.MK) FROM DR_sessions as s INNER JOIN lime_PeerDevices as d on s.Did = d.Did INNER JOIN lime_LocalUsers as u on u.Uid = s.Uid INNER JOIN DR_MSk_DHr as c on c.sessionId = s.sessionId INNER JOIN DR_MSk_Mk as m ON m.DHid=c.DHid WHERE u.UserId = :selfId AND d.DeviceId = :peerId ORDER BY s.Status DESC, s.Did;", into(mkCount), use(selfDeviceId), use(peerDeviceId);
if (sql.got_data()) {
......@@ -447,7 +447,7 @@ unsigned int get_StoredMessageKeyCount(const std::string &dbFilename, const std:
*/
bool get_SPks(const std::string &dbFilename, const std::string &selfDeviceId, size_t &count, uint32_t &activeId) noexcept{
try {
soci::session sql(sqlite3, dbFilename); // open the DB
soci::session sql("sqlite3", dbFilename); // open the DB
count=0;
sql<< "SELECT count(SPKid) FROM X3DH_SPK as s INNER JOIN lime_LocalUsers as u on u.Uid = s.Uid WHERE u.UserId = :selfId;", into(count), use(selfDeviceId);
if (sql.got_data()) {
......@@ -471,7 +471,7 @@ bool get_SPks(const std::string &dbFilename, const std::string &selfDeviceId, si
*/
size_t get_OPks(const std::string &dbFilename, const std::string &selfDeviceId) noexcept {
try {
soci::session sql(sqlite3, dbFilename); // open the DB
soci::session sql("sqlite3", dbFilename); // open the DB
auto count=0;
sql<< "SELECT count(OPKid) FROM X3DH_OPK as o INNER JOIN lime_LocalUsers as u on u.Uid = o.Uid WHERE u.UserId = :selfId;", into(count), use(selfDeviceId);
if (sql.got_data()) {
......@@ -491,7 +491,7 @@ size_t get_OPks(const std::string &dbFilename, const std::string &selfDeviceId)
*/
void forwardTime(const std::string &dbFilename, int days) noexcept {
try {
soci::session sql(sqlite3, dbFilename); // open the DB
soci::session sql("sqlite3", dbFilename); // open the DB
/* move back by days all timeStamp, we have some in DR_sessions and X3DH_SPk tables */
sql<<"UPDATE DR_sessions SET timeStamp = date (timeStamp, '-"<<days<<" day');";
sql<<"UPDATE X3DH_SPK SET timeStamp = date (timeStamp, '-"<<days<<" day');";
......
......@@ -166,6 +166,8 @@ int wait_for(belle_sip_stack_t*s1,int* counter,int value,int timeout);
#endif
} // namespace lime_tester
extern "C" {
/* some shared variable defined in lime_ff-tester, used only when FFI is enabled
* and they are duplicate of command line arguments variable already existing in C++ from lime_tester-utils.cpp
* but it's easier to read and implement this way */
......@@ -177,4 +179,6 @@ extern char ffi_test_x3dh_c448_server_port[16];
// ffi default value for the timeout
extern int ffi_wait_for_timeout;
}
#endif //lime_tester_utils_hpp
......@@ -133,15 +133,15 @@ int main(int argc, char *argv[]) {
} else if (strcmp(argv[i],"--x3dh-server-name")==0){
CHECK_ARG("--x3dh-server-name", ++i, argc);
lime_tester::test_x3dh_server_url=std::string(argv[i]);
strncpy(ffi_test_x3dh_server_url, argv[i], sizeof(ffi_test_x3dh_server_url));
strncpy(ffi_test_x3dh_server_url, argv[i], sizeof(ffi_test_x3dh_server_url)-1);
} else if (strcmp(argv[i],"--c255-x3dh-server-port")==0){
CHECK_ARG("--c255-x3dh-server-port", ++i, argc);
lime_tester::test_x3dh_c25519_server_port=std::string(argv[i]);
strncpy(ffi_test_x3dh_c25519_server_port, argv[i], sizeof(ffi_test_x3dh_c25519_server_port));
strncpy(ffi_test_x3dh_c25519_server_port, argv[i], sizeof(ffi_test_x3dh_c25519_server_port)-1);
} else if (strcmp(argv[i],"--c448-x3dh-server-port")==0){
CHECK_ARG("--c448-x3dh-server-port", ++i, argc);
lime_tester::test_x3dh_c448_server_port=std::string(argv[i]);
strncpy(ffi_test_x3dh_c448_server_port, argv[i], sizeof(ffi_test_x3dh_c448_server_port));
strncpy(ffi_test_x3dh_c448_server_port, argv[i], sizeof(ffi_test_x3dh_c448_server_port)-1);
} else if (strcmp(argv[i],"--operation-timeout")==0){
CHECK_ARG("--operation-timeout", ++i, argc);
lime_tester::wait_for_timeout=std::atoi(argv[i]);
......
......@@ -40,8 +40,8 @@ constexpr uint64_t BENCH_TIMING_MS=200;
/* Function */
static void snprintSI(std::string &output, double x, const char *unit, const char *spacer = " ") {
const char *small[] = {" ","m","µ","n","p"};
const char *big[] = {" ","k","M","G","T"};
const char *_small[] = {" ","m","µ","n","p"};
const char *_big[] = {" ","k","M","G","T"};
constexpr size_t tempBufferSize = 100;
char tempBuffer[tempBufferSize]; // hoping no one will use this function to print more than 100 chars...
......@@ -52,16 +52,16 @@ static void snprintSI(std::string &output, double x, const char *unit, const cha
if (x < 1) {
unsigned di=0;
for (di=0; di<sizeof(small)/sizeof(*small)-1 && x && x < 1; di++) {
for (di=0; di<sizeof(_small)/sizeof(*_small)-1 && x && x < 1; di++) {
x *= 1000.0;
}
snprintf(tempBuffer, sizeof(tempBuffer), "%6.2f%s%s%s", x, spacer, small[di], unit);
snprintf(tempBuffer, sizeof(tempBuffer), "%6.2f%s%s%s", x, spacer, _small[di], unit);
} else {
unsigned di=0;
for (di=0; di<sizeof(big)/sizeof(*big)-1 && x && x >= 1000; di++) {
for (di=0; di<sizeof(_big)/sizeof(*_big)-1 && x && x >= 1000; di++) {
x /= 1000.0;
}
snprintf(tempBuffer, sizeof(tempBuffer), "%6.2f%s%s%s", x, spacer, big[di], unit);
snprintf(tempBuffer, sizeof(tempBuffer), "%6.2f%s%s%s", x, spacer, _big[di], unit);
}
output = tempBuffer;
......
......@@ -63,7 +63,7 @@ static void sendMessageTo(std::string recipient, std::vector<uint8_t> &DRmessage
}
LIME_LOGE<<"sending a message to unknown user "<<recipient;
BC_FAIL();
BC_FAIL("");
}
static void getMessageFor(std::string recipient, std::vector<uint8_t> &DRmessage, std::vector<uint8_t> &cipherMessage) {
......@@ -74,7 +74,7 @@ static void getMessageFor(std::string recipient, std::vector<uint8_t> &DRmessage
}
LIME_LOGE<<"getting a message to unknown user "<<recipient;
BC_FAIL();
BC_FAIL("");
}
struct C_Callback_userData {
......@@ -356,8 +356,8 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -595,8 +595,8 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......
......@@ -208,7 +208,7 @@ static void lime_exchange_messages(std::shared_ptr<std::string> &aliceDeviceId,
messageCount++;
}
}
} catch (BctbxException &e) {
} catch (BctbxException &) {
BC_FAIL("Message Exchange failed");
throw;
}
......@@ -257,7 +257,7 @@ static void lime_session_establishment(const lime::CurveId curve, const std::str
lime_exchange_messages(aliceDeviceId, aliceManager, bobDeviceId, bobManager, 1, 1);
} catch (BctbxException &e) {
} catch (BctbxException &) {
BC_FAIL("Session establishment failed");
throw;
}
......@@ -335,7 +335,7 @@ static void lime_encryptionPolicyError_test(const lime::CurveId curve, const std
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
} catch (BctbxException &) {
BC_FAIL("Session establishment failed");
throw;
}
......@@ -397,7 +397,7 @@ static void lime_session_establishment(const lime::CurveId curve, const std::str
bobManager->create_user(*bobDeviceId, x3dh_server_url, curve, lime_tester::OPkInitialBatchSize, callback);
BC_ASSERT_TRUE(lime_tester::wait_for(stack,&counters.operation_success, ++expected_success,lime_tester::wait_for_timeout));
} catch (BctbxException &e) {
} catch (BctbxException &) {
BC_FAIL("Session establishment failed");
throw;
}
......@@ -480,7 +480,7 @@ static void lime_encryptionPolicy_test(std::shared_ptr<LimeManager> aliceManager
}
} catch (BctbxException &e) {
} catch (BctbxException &) {
BC_FAIL("Session establishment failed");
throw;
}
......@@ -788,8 +788,8 @@ static void lime_identityVerifiedStatus_test(const lime::CurveId curve, const st
BC_ASSERT_TRUE(bobManager->get_peerDeviceStatus(*aliceDeviceId) == lime::PeerDeviceStatus::trusted);
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
auto gotException = false;
......@@ -797,8 +797,8 @@ static void lime_identityVerifiedStatus_test(const lime::CurveId curve, const st
try {
// try to set another key for alice in bob's context, it shall generate an exception
bobManager->set_peerDeviceStatus(*aliceDeviceId, fakeIk, lime::PeerDeviceStatus::trusted);
} catch (BctbxException &e) {
BC_PASS();
} catch (BctbxException &) {
BC_PASS("");
gotException = true;
// Now delete the alice device from Bob's cache and check its status is now back to unknown
......@@ -820,8 +820,8 @@ static void lime_identityVerifiedStatus_test(const lime::CurveId curve, const st
try {
// try to set it to trusted, still using the fake Ik, it shall generate an exception as the Ik is invalid in storage
bobManager->set_peerDeviceStatus(*aliceDeviceId, fakeIk, lime::PeerDeviceStatus::trusted);
} catch (BctbxException &e) {
BC_PASS();
} catch (BctbxException &) {
BC_PASS("");
gotException = true;
}
......@@ -831,8 +831,8 @@ static void lime_identityVerifiedStatus_test(const lime::CurveId curve, const st
try {
// same than above but using the actual key : try to set it to trusted, still using the fake Ik, it shall generate an exception as the Ik is invalid in storage
bobManager->set_peerDeviceStatus(*aliceDeviceId, aliceIk, lime::PeerDeviceStatus::trusted);
} catch (BctbxException &e) {
BC_PASS();
} catch (BctbxException &) {
BC_PASS("");
gotException = true;
// Now delete the alice device from Bob's cache and check its status is now back to unknown
......@@ -956,8 +956,8 @@ static void lime_identityVerifiedStatus_test(const lime::CurveId curve, const st
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -1154,8 +1154,8 @@ static void lime_peerDeviceStatus_test(const lime::CurveId curve, const std::str
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -1185,17 +1185,17 @@ static void lime_getSelfIk_test(const lime::CurveId curve, const std::string &db
BC_ASSERT_TRUE((Ik==pattern));
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
return;
}
// try to get the Ik of a user not in there, we shall get an exception
try {
aliceManager->get_selfIdentityKey("bob", Ik);
} catch (BctbxException &e) {
} catch (BctbxException &) {
// just swallow it
BC_PASS();
BC_PASS("");
return;
}
BC_FAIL("Get the Ik of a user not in local Storage didn't throw an exception");
......@@ -1336,8 +1336,8 @@ static void lime_update_OPk_test(const lime::CurveId curve, const std::string &d
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -1504,8 +1504,8 @@ static void lime_update_SPk_test(const lime::CurveId curve, const std::string &d
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -1606,8 +1606,8 @@ static void lime_update_clean_MK_test(const lime::CurveId curve, const std::stri
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -1703,8 +1703,8 @@ static void x3dh_without_OPk_test(const lime::CurveId curve, const std::string &
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
static void x3dh_without_OPk() {
......@@ -1855,8 +1855,8 @@ static void x3dh_sending_chain_limit_test(const lime::CurveId curve, const std::
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
static void x3dh_sending_chain_limit() {
......@@ -2069,8 +2069,8 @@ static void x3dh_multiple_DRsessions_test(const lime::CurveId curve, const std::
remove(dbFilenameBob.data()); // delete the database file if already exists
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -2278,8 +2278,8 @@ static void x3dh_multidev_operation_queue_test(const lime::CurveId curve, const
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -2397,7 +2397,7 @@ static void x3dh_operation_queue_test(const lime::CurveId curve, const std::stri
}
} catch (BctbxException &e) {
LIME_LOGE << e;
BC_FAIL();
BC_FAIL("");
}
}
......@@ -2604,8 +2604,8 @@ static void x3dh_basic_test(const lime::CurveId curve, const std::string &dbBase
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -2890,8 +2890,8 @@ static void x3dh_user_not_found_test(const lime::CurveId curve, const std::strin
remove(dbFilenameBob.data());
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -2954,8 +2954,8 @@ static void user_management_test(const lime::CurveId curve, const std::string &d
auto alice = load_LimeUser(dbFilenameAlice, *aliceDeviceName, X3DHServerPost);
/* no need to wait here, it shall load alice immediately */
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
bool gotExpectedException = false;
......@@ -2963,7 +2963,7 @@ static void user_management_test(const lime::CurveId curve, const std::string &d
try {
auto alice = insert_LimeUser(dbFilenameAlice, *aliceDeviceName, x3dh_server_url, curve, lime_tester::OPkInitialBatchSize, X3DHServerPost, callback);
/* no need to wait here, it must fail immediately */
} catch (BctbxException &e) {
} catch (BctbxException &) {
gotExpectedException = true;
}
if (!gotExpectedException) {
......@@ -2977,7 +2977,7 @@ static void user_management_test(const lime::CurveId curve, const std::string &d
try {
auto alice = load_LimeUser(dbFilenameAlice, "bob", X3DHServerPost);
/* no need to wait here, it must fail immediately */
} catch (BctbxException &e) {
} catch (BctbxException &) {
gotExpectedException = true;
}
if (!gotExpectedException) {
......@@ -3001,7 +3001,7 @@ static void user_management_test(const lime::CurveId curve, const std::string &d
try {
// delete bob which is not there, it shall raise an exception and never get to the callback
Manager->delete_user("bob", callback);
} catch (BctbxException &e) {
} catch (BctbxException &) {
gotExpectedException = true;
}
if (!gotExpectedException) {
......@@ -3038,8 +3038,8 @@ static void user_management_test(const lime::CurveId curve, const std::string &d
remove(dbFilenameAliceTmp.data()); // delete the database file
}
} catch (BctbxException &e) {
LIME_LOGE <<e;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......
......@@ -292,8 +292,8 @@ static void group_basic_test(const lime::CurveId curve, const std::string &dbBas
}
} catch (BctbxException &e) {
LIME_LOGE <<e;;
BC_FAIL();
LIME_LOGE << e;
BC_FAIL("");
}
}
......@@ -319,7 +319,7 @@ static void group_one_talking_bench() {
// time spent in test is more or less linear to the device number, try to reach the one wich lead to a maximunBenchTime execution
span = bctbx_get_cur_time_ms() - start;
LIME_LOGE<<"Curve 25519 group chat test with "<<to_string(deviceNumber)<<" devices ran in "<<to_string(span)<<" ms"<<std::endl;
deviceNumber *= std::max(float(maximumBenchTime)/float(span), 1.0f) * 1.2;
deviceNumber *= int(std::max(float(maximumBenchTime)/float(span), 1.0f) * 1.2);
}
#endif
#ifdef EC448_ENABLED
......@@ -332,7 +332,7 @@ static void group_one_talking_bench() {
// time spent in test is more or less linear to the device number, try to reach the one wich lead to a maximunBenchTime execution
span = bctbx_get_cur_time_ms() - start;
LIME_LOGE<<"Curve 448 group chat test with "<<to_string(deviceNumber)<<" devices ran in "<<to_string(span)<<" ms"<<std::endl;
deviceNumber *= std::max(float(maximumBenchTime)/float(span), 1.0f) * 1.2;
deviceNumber *= int(std::max(float(maximumBenchTime)/float(span), 1.0f) * 1.2);
}
#endif
}
......@@ -357,7 +357,7 @@ static void group_all_talking_bench() {
// time spent in test is more or less linear to the square of device number, try to reach the one wich lead to a maximunBenchTime execution
span = bctbx_get_cur_time_ms() - start;
LIME_LOGE<<"Curve 25519 group chat test with "<<to_string(deviceNumber)<<" devices ran in "<<to_string(span)<<" ms"<<std::endl;
deviceNumber *= std::sqrt(std::max(float(maximumBenchTime)/float(span), 1.0f)) * 1.2;
deviceNumber *= int(std::sqrt(std::max(float(maximumBenchTime)/float(span), 1.0f)) * 1.2);
}
#endif
#ifdef EC448_ENABLED
......@@ -370,7 +370,7 @@ static void group_all_talking_bench() {
// time spent in test is more or less linear to the square of device number, try to reach the one wich lead to a maximunBenchTime execution
span = bctbx_get_cur_time_ms() - start;
LIME_LOGE<<"Curve 448 group chat test with "<<to_string(deviceNumber)<<" devices ran in "<<to_string(span)<<" ms"<<std::endl;
deviceNumber *= std::sqrt(std::max(float(maximumBenchTime)/float(span), 1.0f)) * 1.2;
deviceNumber *= int(std::sqrt(std::max(float(maximumBenchTime)/float(span), 1.0f)) * 1.2);
}
#endif
}
......
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