Go to the documentation of this file.
12 #include <nlohmann/json.hpp>
14 #include <immer/map.hpp>
15 #include <immer/flex_vector.hpp>
165 bool verify(
nlohmann::json object, std::string userId, std::string deviceId, std::string ed25519Key);
216 immer::map<std::string, immer::map<std::string ,
217 std::string >> keyMap)
const;
234 std::string theirIdentityKey,
235 std::string theirOneTimeKey);
237 template<
class Archive>
238 void save(Archive & ar,
const unsigned int )
const {
242 template<
class Archive>
243 void load(Archive &ar,
const unsigned int ) {
246 loadJson(nlohmann::json::parse(std::move(j)));
249 BOOST_SERIALIZATION_SPLIT_MEMBER()
std::string outboundGroupSessionCurrentKey(std::string roomId)
Definition: crypto.cpp:532
UserIdToDeviceIdMap devicesMissingOutboundSessionKey(immer::map< std::string, immer::map< std::string, std::string >> keyMap) const
Definition: crypto.cpp:538
std::optional< std::string > rotateMegOlmSessionWithRandomIfNeeded(RandomData random, Timestamp timeMs, std::string roomId, MegOlmSessionRotateDesc desc)
Rotate the megolm session using user-provided random data, if we need to rotate it.
Definition: crypto.cpp:518
Definition: session.hpp:26
std::string RandomData
Definition: crypto-util.hpp:34
int uploadedOneTimeKeysCount(std::string algorithm) const
Definition: crypto.cpp:349
bool valid() const
Definition: crypto.cpp:253
static std::size_t createOutboundSessionRandomSize()
Definition: crypto.cpp:563
MaybeString getInboundGroupSessionEd25519KeyFromEvent(const nlohmann::json &eventJson) const
Definition: crypto.cpp:413
Definition: location.hpp:26
std::string curve25519IdentityKey() const
Definition: crypto.cpp:275
bool hasInboundGroupSession(KeyOfGroupSession k) const
Definition: crypto.cpp:371
static std::size_t genOneTimeKeysRandomSize(int num)
Get the size of random data needed to generate num one-time keys.
Definition: crypto.cpp:308
Timestamp ms
The time limit of the megolm session, in milliseconds.
Definition: crypto.hpp:29
Definition: location.hpp:10
static std::size_t encryptOlmMaxRandomSize()
Definition: crypto.cpp:452
std::int_fast64_t Timestamp
Definition: event.hpp:18
Definition: crypto.hpp:26
void genOneTimeKeysWithRandom(RandomData random, int num)
Generate num one-time keys with user-provided random data.
Definition: crypto.cpp:313
static std::size_t rotateMegOlmSessionRandomSize()
Definition: crypto.cpp:505
Definition: session-p.hpp:15
Definition: crypto-util.hpp:23
Crypto & operator=(const Crypto &that)
Definition: crypto.cpp:236
std::string outboundGroupSessionInitialKey(std::string roomId)
Definition: crypto.cpp:526
bool verify(nlohmann::json object, std::string userId, std::string deviceId, std::string ed25519Key)
Check whether the signature of userId/deviceId is valid in object.
Definition: crypto.cpp:386
void markOneTimeKeysAsPublished()
Definition: crypto.cpp:338
std::string ed25519IdentityKey() const
Definition: crypto.cpp:270
Crypto()
Construct an invalid Crypto.
Definition: crypto.cpp:214
std::size_t encryptOlmRandomSize(std::string theirCurve25519IdentityKey) const
Definition: crypto.cpp:430
static std::size_t constructRandomSize()
Definition: crypto.cpp:209
nlohmann::json json
Definition: jsonwrap.hpp:20
std::size_t maxNumberOfOneTimeKeys() const
Definition: crypto.cpp:303
Definition: crypto-p.hpp:25
std::string sign(nlohmann::json j)
Definition: crypto.cpp:280
bool createInboundGroupSession(KeyOfGroupSession k, std::string sessionKey, std::string ed25519Key)
Definition: crypto.cpp:366
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: crypto.hpp:214
void save(Archive &ar, const unsigned int) const
Definition: crypto.hpp:238
Definition: crypto.hpp:35
int messages
The message limit of the megolm session.
Definition: crypto.hpp:31
nlohmann::json encryptOlmWithRandom(RandomData random, nlohmann::json eventJson, std::string theirCurve25519IdentityKey)
Encrypt eventJson with olm, for the recipient identified with theirCurve25519IdentityKey.
Definition: crypto.cpp:457
bool operator==(const Crypto &that) const
Definition: crypto.cpp:248
Definition: clientutil.hpp:216
void loadJson(const nlohmann::json &j)
Definition: crypto.cpp:604
nlohmann::json encryptMegOlm(nlohmann::json eventJson)
returns the content template with everything but deviceId eventJson should contain type,...
Definition: crypto.cpp:477
void setUploadedOneTimeKeysCount(immer::map< std::string, int > uploadedOneTimeKeysCount)
Definition: crypto.cpp:298
std::string rotateMegOlmSessionWithRandom(RandomData random, Timestamp timeMs, std::string roomId)
Rotate the megolm session using user-provided random data.
Definition: crypto.cpp:510
void load(Archive &ar, const unsigned int)
Definition: crypto.hpp:243
nlohmann::json unpublishedOneTimeKeys() const
According to olm.h, this returns an object like.
Definition: crypto.cpp:322
void createOutboundSessionWithRandom(RandomData random, std::string theirIdentityKey, std::string theirOneTimeKey)
Create an outbound session using user-provided random data.
Definition: crypto.cpp:568
nlohmann::json toJson() const
Definition: crypto.cpp:587
int numUnpublishedOneTimeKeys() const
Definition: crypto.cpp:344
The tag to indicate that a constructor should use user-provided random data.
Definition: crypto-util.hpp:32
MaybeString decrypt(nlohmann::json eventJson)
Returns decrypted message if we can decrypt it otherwise returns the error.
Definition: crypto.cpp:354