Changeset View
Changeset View
Standalone View
Standalone View
native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
#include "CryptoModule.h" | #include "CryptoModule.h" | ||||
#include "Logger.h" | |||||
#include "PlatformSpecificTools.h" | #include "PlatformSpecificTools.h" | ||||
#include "olm/account.hh" | #include "olm/account.hh" | ||||
#include "olm/session.hh" | #include "olm/session.hh" | ||||
#include <stdexcept> | #include <stdexcept> | ||||
namespace comm { | namespace comm { | ||||
namespace crypto { | namespace crypto { | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
void CryptoModule::initializeOutboundForSendingSession( | void CryptoModule::initializeOutboundForSendingSession( | ||||
const std::string &targetUserId, | const std::string &targetUserId, | ||||
const OlmBuffer &idKeys, | const OlmBuffer &idKeys, | ||||
const OlmBuffer &preKeys, | const OlmBuffer &preKeys, | ||||
const OlmBuffer &preKeySignature, | const OlmBuffer &preKeySignature, | ||||
const OlmBuffer &oneTimeKeys, | const OlmBuffer &oneTimeKeys, | ||||
size_t keyIndex) { | size_t keyIndex) { | ||||
if (this->hasSessionFor(targetUserId)) { | if (this->hasSessionFor(targetUserId)) { | ||||
throw std::runtime_error{ | Logger::log( | ||||
"error initializeOutboundForSendingSession => session already " | "olm session overwritten for the user with id: " + targetUserId); | ||||
"initialized"}; | this->sessions.erase(this->sessions.find(targetUserId)); | ||||
} | } | ||||
std::unique_ptr<Session> newSession = Session::createSessionAsInitializer( | std::unique_ptr<Session> newSession = Session::createSessionAsInitializer( | ||||
this->account, | this->account, | ||||
this->keys.identityKeys.data(), | this->keys.identityKeys.data(), | ||||
idKeys, | idKeys, | ||||
preKeys, | preKeys, | ||||
preKeySignature, | preKeySignature, | ||||
oneTimeKeys, | oneTimeKeys, | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |