summary refs log tree commit diff
path: root/src/CacheCryptoStructs.h
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-02-28 19:10:39 -0500
committerGitHub <noreply@github.com>2020-02-28 19:10:39 -0500
commit30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606 (patch)
treeddadd16c86600ce937b47798a9b3d5ff2fdec998 /src/CacheCryptoStructs.h
parentMerge pull request #129 from nico202/master (diff)
parentMerge branch 'master' into 0.7.0-dev (diff)
downloadnheko-30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606.tar.xz
Merge pull request #130 from Nheko-Reborn/0.7.0-dev
0.7.0 dev merge to master
Diffstat (limited to 'src/CacheCryptoStructs.h')
-rw-r--r--src/CacheCryptoStructs.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/CacheCryptoStructs.h b/src/CacheCryptoStructs.h
new file mode 100644

index 00000000..14c9c86b --- /dev/null +++ b/src/CacheCryptoStructs.h
@@ -0,0 +1,67 @@ +#pragma once + +#include <map> +#include <mutex> + +//#include <nlohmann/json.hpp> + +#include <mtx/responses.hpp> +#include <mtxclient/crypto/client.hpp> + +// Extra information associated with an outbound megolm session. +struct OutboundGroupSessionData +{ + std::string session_id; + std::string session_key; + uint64_t message_index = 0; +}; + +void +to_json(nlohmann::json &obj, const OutboundGroupSessionData &msg); +void +from_json(const nlohmann::json &obj, OutboundGroupSessionData &msg); + +struct OutboundGroupSessionDataRef +{ + OlmOutboundGroupSession *session; + OutboundGroupSessionData data; +}; + +struct DevicePublicKeys +{ + std::string ed25519; + std::string curve25519; +}; + +void +to_json(nlohmann::json &obj, const DevicePublicKeys &msg); +void +from_json(const nlohmann::json &obj, DevicePublicKeys &msg); + +//! Represents a unique megolm session identifier. +struct MegolmSessionIndex +{ + //! The room in which this session exists. + std::string room_id; + //! The session_id of the megolm session. + std::string session_id; + //! The curve25519 public key of the sender. + std::string sender_key; +}; + +void +to_json(nlohmann::json &obj, const MegolmSessionIndex &msg); +void +from_json(const nlohmann::json &obj, MegolmSessionIndex &msg); + +struct OlmSessionStorage +{ + // Megolm sessions + std::map<std::string, mtx::crypto::InboundGroupSessionPtr> group_inbound_sessions; + std::map<std::string, mtx::crypto::OutboundGroupSessionPtr> group_outbound_sessions; + std::map<std::string, OutboundGroupSessionData> group_outbound_session_data; + + // Guards for accessing megolm sessions. + std::mutex group_outbound_mtx; + std::mutex group_inbound_mtx; +};