Changeset View
Changeset View
Standalone View
Standalone View
native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | void CryptoModule::initializeInboundForReceivingSession( | ||||
std::unique_ptr<Session> newSession = Session::createSessionAsResponder( | std::unique_ptr<Session> newSession = Session::createSessionAsResponder( | ||||
this->account, this->keys.identityKeys.data(), encryptedMessage, idKeys); | this->account, this->keys.identityKeys.data(), encryptedMessage, idKeys); | ||||
this->sessions.insert(make_pair(targetUserId, std::move(newSession))); | this->sessions.insert(make_pair(targetUserId, std::move(newSession))); | ||||
} | } | ||||
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 &oneTimeKeys, | const OlmBuffer &oneTimeKeys, | ||||
size_t keyIndex) { | size_t keyIndex) { | ||||
if (this->hasSessionFor(targetUserId)) { | if (this->hasSessionFor(targetUserId)) { | ||||
throw std::runtime_error{ | throw std::runtime_error{ | ||||
"error initializeOutboundForSendingSession => session already " | "error initializeOutboundForSendingSession => session already " | ||||
"initialized"}; | "initialized"}; | ||||
} | } | ||||
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, | |||||
oneTimeKeys, | oneTimeKeys, | ||||
keyIndex); | keyIndex); | ||||
this->sessions.insert(make_pair(targetUserId, std::move(newSession))); | this->sessions.insert(make_pair(targetUserId, std::move(newSession))); | ||||
} | } | ||||
bool CryptoModule::hasSessionFor(const std::string &targetUserId) { | bool CryptoModule::hasSessionFor(const std::string &targetUserId) { | ||||
return (this->sessions.find(targetUserId) != this->sessions.end()); | return (this->sessions.find(targetUserId) != this->sessions.end()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |