Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/session.cpp
| Show All 14 Lines | |||||
| namespace Kazv | namespace Kazv | ||||
| { | { | ||||
| SessionPrivate::SessionPrivate() | SessionPrivate::SessionPrivate() | ||||
| : session(std::nullopt) | : session(std::nullopt) | ||||
| { | { | ||||
| } | } | ||||
| SessionPrivate::SessionPrivate(OutboundSessionTag, | SessionPrivate::SessionPrivate(OutboundSessionTag, | ||||
| RandomTag, | RandomTag, | ||||
| RandomData random, | [[maybe_unused]] RandomData random, | ||||
| CryptoPrivate &cryptoD, | CryptoPrivate &cryptoD, | ||||
| std::string theirIdentityKey, | std::string theirIdentityKey, | ||||
| std::string theirOneTimeKey) | std::string theirOneTimeKey) | ||||
| : SessionPrivate() | : SessionPrivate() | ||||
| { | { | ||||
| assert(random.size() >= Session::constructOutboundRandomSize()); | assert(random.size() >= Session::constructOutboundRandomSize()); | ||||
| session = checkVodozemacError([&]() { | session = checkVodozemacError([&]() { | ||||
| auto identityKey = vodozemac::types::curve_key_from_base64(rust::Str(theirIdentityKey)); | auto identityKey = vodozemac::types::curve_key_from_base64(rust::Str(theirIdentityKey)); | ||||
| auto oneTimeKey = vodozemac::types::curve_key_from_base64(rust::Str(theirOneTimeKey)); | auto oneTimeKey = vodozemac::types::curve_key_from_base64(rust::Str(theirOneTimeKey)); | ||||
| return cryptoD.account.value()->create_outbound_session( | return cryptoD.account.value()->create_outbound_session( | ||||
| ▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | MaybeString Session::decrypt(int type, std::string message) | ||||
| return std::string(res.value().begin(), res.value().end()); | return std::string(res.value().begin(), res.value().end()); | ||||
| } | } | ||||
| std::size_t Session::encryptRandomSize() const | std::size_t Session::encryptRandomSize() const | ||||
| { | { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| std::pair<int, std::string> Session::encryptWithRandom(RandomData random, std::string plainText) | std::pair<int, std::string> Session::encryptWithRandom([[maybe_unused]] RandomData random, std::string plainText) | ||||
| { | { | ||||
| assert(random.size() >= encryptRandomSize()); | assert(random.size() >= encryptRandomSize()); | ||||
| auto res = checkVodozemacError([&]() { | auto res = checkVodozemacError([&]() { | ||||
| return m_d->session.value()->encrypt(plainText); | return m_d->session.value()->encrypt(plainText); | ||||
| }); | }); | ||||
| if (!res.has_value()) { | if (!res.has_value()) { | ||||
| Show All 29 Lines | |||||