libkazv
outbound-group-session.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2021 Tusooa Zhu <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 <memory>
11 
12 #include <maybe.hpp>
13 #include <event.hpp>
14 
15 #include "crypto-util.hpp"
16 
17 namespace Kazv
18 {
19  struct OutboundGroupSessionPrivate;
20 
22  {
23  public:
27  static std::size_t constructRandomSize();
28 
29  explicit OutboundGroupSession();
30 
38  OutboundGroupSession(RandomTag, RandomData random, Timestamp creationTime);
39 
45 
46  std::string encrypt(std::string plainText);
47 
48  bool valid() const;
49 
50  std::string sessionKey();
51  std::string initialSessionKey() const;
52  std::string sessionId();
53 
54  int messageIndex();
55 
56  Timestamp creationTimeMs() const;
57  private:
58  friend void to_json(nlohmann::json &j, const OutboundGroupSession &s);
59  friend void from_json(const nlohmann::json &j, OutboundGroupSession &s);
60  std::unique_ptr<OutboundGroupSessionPrivate> m_d;
61  };
62 }
Definition: outbound-group-session.hpp:22
OutboundGroupSession & operator=(const OutboundGroupSession &that)
Definition: outbound-group-session.cpp:99
std::string sessionKey()
Definition: outbound-group-session.cpp:136
std::string sessionId()
Definition: outbound-group-session.cpp:146
bool valid() const
Definition: outbound-group-session.cpp:111
OutboundGroupSession()
Definition: outbound-group-session.cpp:76
int messageIndex()
Definition: outbound-group-session.cpp:152
friend void from_json(const nlohmann::json &j, OutboundGroupSession &s)
Definition: outbound-group-session.cpp:174
friend void to_json(nlohmann::json &j, const OutboundGroupSession &s)
Definition: outbound-group-session.cpp:162
static std::size_t constructRandomSize()
Definition: outbound-group-session.cpp:71
std::string initialSessionKey() const
Definition: outbound-group-session.cpp:141
Timestamp creationTimeMs() const
Definition: outbound-group-session.cpp:157
std::string encrypt(std::string plainText)
Definition: outbound-group-session.cpp:116
Definition: location.hpp:10
std::string RandomData
Definition: crypto-util.hpp:34
nlohmann::json json
Definition: jsonwrap.hpp:20
std::int_fast64_t Timestamp
Definition: event.hpp:18
The tag to indicate that a constructor should use user-provided random data.
Definition: crypto-util.hpp:32