Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/crypto.cpp
| Show First 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | std::size_t Crypto::importInboundGroupSessions(const nlohmann::json &keys) | ||||
| std::size_t count = 0; | std::size_t count = 0; | ||||
| for (const auto &data : keys) { | for (const auto &data : keys) { | ||||
| if (!data.is_object()) { | if (!data.is_object()) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| auto key = nlohmann::json::object(); | auto key = nlohmann::json::object(); | ||||
| if (!(cast(key, data, "algorithm", identValidate([](const auto &j) { | if (!(cast(key, data, "algorithm", identValidate([](const auto &j) { | ||||
| return j == "m.megolm.v1.aes-sha2"; | return j == megOlmAlgo; | ||||
| })) && cast(key, data, "room_id", validateStr) | })) && cast(key, data, "room_id", validateStr) | ||||
| && cast(key, data, "sender_key", validateStr) | |||||
| && cast(key, data, "session_id", validateStr) | |||||
| && cast(key, data, "session_key", validateStr) | && cast(key, data, "session_key", validateStr) | ||||
| && cast(key, data, "session_id", validateStr) | |||||
| && cast(key, data, "/sender_claimed_keys/ed25519"_json_pointer, validateStr) | |||||
| )) { | )) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| auto keyOfGroupSession = KeyOfGroupSession{ | auto keyOfGroupSession = KeyOfGroupSession{ | ||||
| key["room_id"].template get<std::string>(), | key["room_id"].template get<std::string>(), | ||||
| key["session_id"].template get<std::string>(), | key["session_id"].template get<std::string>(), | ||||
| }; | }; | ||||
| if (createInboundGroupSession( | if (createInboundGroupSession( | ||||
| keyOfGroupSession, | keyOfGroupSession, | ||||
| key["session_key"].template get<std::string>(), | key["session_key"].template get<std::string>(), | ||||
| key["sender_key"].template get<std::string>() | key["sender_claimed_keys"]["ed25519"].template get<std::string>() | ||||
| )) { | )) { | ||||
| ++count; | ++count; | ||||
| } | } | ||||
| } | } | ||||
| return count; | return count; | ||||
| } | } | ||||
| bool Crypto::hasInboundGroupSession(KeyOfGroupSession k) const | bool Crypto::hasInboundGroupSession(KeyOfGroupSession k) const | ||||
| ▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines | |||||