libkazv
Loading...
Searching...
No Matches
crypto-p.hpp
Go to the documentation of this file.
1/*
2 * This file is part of libkazv.
3 * SPDX-FileCopyrightText: 2021-2024 tusooa <tusooa@kazv.moe>
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 */
6
7#pragma once
8#include <libkazv-config.hpp>
9
10#include <vodozemac.h>
11
12#include "crypto.hpp"
13#include "crypto-util.hpp"
14#include "crypto-util-p.hpp"
15#include "session.hpp"
18#include <immer/map.hpp>
19#include <immer/box.hpp>
20
21namespace Kazv
22{
23 using SessionList = std::vector<Session>;
24
26 {
29 CryptoPrivate(const CryptoPrivate &that);
31
32 std::optional<rust::Box<vodozemac::olm::Account>> account;
33 immer::map<std::string /* algorithm */, int> uploadedOneTimeKeysCount;
35 immer::map<std::string /* theirCurve25519IdentityKey */, immer::box<Session>> knownSessions;
36 immer::map<KeyOfGroupSession, immer::box<InboundGroupSession>> inboundGroupSessions;
37
38 immer::map<std::string /* roomId */, immer::box<OutboundGroupSession>> outboundGroupSessions;
39
40 bool valid{true};
41
42 std::string pickle() const;
43 bool unpickle(std::string data);
44 bool unpickleFromLibolm(std::string data);
45
46 std::string ed25519IdentityKey() const;
47 std::string curve25519IdentityKey() const;
48
50 // Here we need the full event for eventId and originServerTs
52
54 bool createInboundSession(std::string theirCurve25519IdentityKey,
55 std::string message);
56
57 bool createInboundGroupSession(KeyOfGroupSession k, std::string sessionKey, std::string ed25519Key);
58
60 std::string roomId, std::optional<MegOlmSessionRotateDesc> desc);
61 };
62
63}
Definition maybe.hpp:25
Definition location.hpp:10
std::string RandomData
Definition crypto-util.hpp:35
nlohmann::json json
Definition jsonwrap.hpp:20
std::int_fast64_t Timestamp
Definition event.hpp:18
std::vector< Session > SessionList
Definition crypto-p.hpp:23
Definition crypto-p.hpp:26
~CryptoPrivate()
Definition crypto.cpp:48
MaybeString decryptOlm(nlohmann::json content)
Definition crypto.cpp:93
immer::map< std::string, immer::box< OutboundGroupSession > > outboundGroupSessions
Definition crypto-p.hpp:38
immer::map< KeyOfGroupSession, immer::box< InboundGroupSession > > inboundGroupSessions
Definition crypto-p.hpp:36
bool reuseOrCreateOutboundGroupSession(RandomData random, Timestamp timeMs, std::string roomId, std::optional< MegOlmSessionRotateDesc > desc)
Definition crypto.cpp:180
immer::map< std::string, int > uploadedOneTimeKeysCount
Definition crypto-p.hpp:33
std::string curve25519IdentityKey() const
Definition crypto.cpp:272
bool unpickle(std::string data)
Definition crypto.cpp:71
MaybeString decryptMegOlm(nlohmann::json eventJson)
Definition crypto.cpp:144
std::string ed25519IdentityKey() const
Definition crypto.cpp:266
bool unpickleFromLibolm(std::string data)
Definition crypto.cpp:82
bool createInboundGroupSession(KeyOfGroupSession k, std::string sessionKey, std::string ed25519Key)
Definition crypto.cpp:426
immer::map< std::string, immer::box< Session > > knownSessions
Definition crypto-p.hpp:35
int numUnpublishedKeys
Definition crypto-p.hpp:34
bool valid
Definition crypto-p.hpp:40
std::optional< rust::Box< vodozemac::olm::Account > > account
Definition crypto-p.hpp:32
bool createInboundSession(std::string theirCurve25519IdentityKey, std::string message)
returns whether the session is successfully established
Definition crypto.cpp:166
CryptoPrivate()
Definition crypto.cpp:34
std::string pickle() const
Definition crypto.cpp:65
Definition crypto-util.hpp:24
The tag to indicate that a constructor should use user-provided random data.
Definition crypto-util.hpp:33