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  [[deprecated("Use deterministic variant instead. In the future, this will construct an invalid OutboundGroupSession.")]]
30  explicit OutboundGroupSession();
31 
39  OutboundGroupSession(RandomTag, RandomData random, Timestamp creationTime);
40 
46 
47  std::string encrypt(std::string plainText);
48 
49  bool valid() const;
50 
51  std::string sessionKey();
52  std::string initialSessionKey() const;
53  std::string sessionId();
54 
55  int messageIndex();
56 
57  Timestamp creationTimeMs() const;
58  private:
59  friend void to_json(nlohmann::json &j, const OutboundGroupSession &s);
60  friend void from_json(const nlohmann::json &j, OutboundGroupSession &s);
61  std::unique_ptr<OutboundGroupSessionPrivate> m_d;
62  };
63 }
maybe.hpp
Kazv::OutboundGroupSession::sessionKey
std::string sessionKey()
Definition: outbound-group-session.cpp:170
Kazv::RandomData
std::string RandomData
Definition: crypto-util.hpp:35
crypto-util.hpp
Kazv::OutboundGroupSession::constructRandomSize
static std::size_t constructRandomSize()
Definition: outbound-group-session.cpp:93
Kazv::OutboundGroupSession::sessionId
std::string sessionId()
Definition: outbound-group-session.cpp:180
Kazv::OutboundGroupSession::initialSessionKey
std::string initialSessionKey() const
Definition: outbound-group-session.cpp:175
event.hpp
Kazv::OutboundGroupSession::operator=
OutboundGroupSession & operator=(const OutboundGroupSession &that)
Definition: outbound-group-session.cpp:128
Kazv
Definition: location.hpp:10
Kazv::Timestamp
std::int_fast64_t Timestamp
Definition: event.hpp:18
Kazv::OutboundGroupSession::creationTimeMs
Timestamp creationTimeMs() const
Definition: outbound-group-session.cpp:195
Kazv::OutboundGroupSession::valid
bool valid() const
Definition: outbound-group-session.cpp:140
Kazv::OutboundGroupSession::~OutboundGroupSession
~OutboundGroupSession()
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::OutboundGroupSession
Definition: outbound-group-session.hpp:21
Kazv::OutboundGroupSession::encrypt
std::string encrypt(std::string plainText)
Definition: outbound-group-session.cpp:145
Kazv::OutboundGroupSession::to_json
friend void to_json(nlohmann::json &j, const OutboundGroupSession &s)
Definition: outbound-group-session.cpp:200
libkazv-config.hpp
Kazv::OutboundGroupSession::from_json
friend void from_json(const nlohmann::json &j, OutboundGroupSession &s)
Definition: outbound-group-session.cpp:211
Kazv::OutboundGroupSession::messageIndex
int messageIndex()
Definition: outbound-group-session.cpp:190
Kazv::RandomTag
The tag to indicate that a constructor should use user-provided random data.
Definition: crypto-util.hpp:33
Kazv::OutboundGroupSession::OutboundGroupSession
OutboundGroupSession()
Definition: outbound-group-session.cpp:105