libQuotient
A Qt library for building matrix clients
e2ee_common.h File Reference
#include <Quotient/converters.h>
#include <Quotient/expected.h>
#include <QtCore/QMetaType>
#include <QtCore/QStringBuilder>
#include <array>
#include <span>
#include <variant>
#include <olm/error.h>
Include dependency graph for e2ee_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Quotient::FixedBufferBase
 Non-template base for owning byte span classes. More...
 
class  Quotient::FixedBuffer< ExtentN, DataIsWriteable >
 
class  Quotient::PicklingKey
 
struct  Quotient::IdentityKeys
 
struct  Quotient::UnsignedOneTimeKeys
 Struct representing the one-time keys. More...
 
class  Quotient::SignedOneTimeKey
 

Namespaces

 Quotient
 

Macros

#define QOLM_INTERNAL_ERROR_X(Message_, LastError_)    qFatal("%s, internal error: %s", QUO_CSTR(Message_), LastError_)
 
#define QOLM_INTERNAL_ERROR(Message_)    QOLM_INTERNAL_ERROR_X((Message_), lastError())
 
#define QOLM_FAIL_OR_LOG_X(InternalCondition_, Message_, LastErrorText_)
 
#define QOLM_FAIL_OR_LOG(InternalFailureValue_, Message_)    QOLM_FAIL_OR_LOG_X(lastErrorCode() == (InternalFailureValue_), (Message_), lastError())
 

Typedefs

template<typename T >
using Quotient::QOlmExpected = Expected< T, OlmErrorCode >
 
using Quotient::byte_t = uint8_t
 
template<size_t N = std::dynamic_extent>
using Quotient::byte_view_t = std::span< const byte_t, N >
 
template<size_t N = std::dynamic_extent>
using Quotient::byte_span_t = std::span< byte_t, N >
 
using Quotient::OneTimeKeys = QHash< QString, std::variant< QString, SignedOneTimeKey > >
 

Functions

bool Quotient::isSupportedAlgorithm (const QString &algorithm)
 
QUOTIENT_API QByteArray Quotient::byteArrayForOlm (size_t bufferSize)
 Initialise a buffer object for use with Olm calls. More...
 
size_t Quotient::unsignedSize (const auto &buffer) requires(sizeof(std
 Get a size of a container coerced to size_t. More...
 
template<size_t N = std::dynamic_extent>
auto Quotient::asCBytes (const auto &buf)
 Obtain a std::span<const byte_t, N> looking into the passed buffer. More...
 
template<size_t N = std::dynamic_extent>
auto Quotient::asWritableCBytes (auto &buf)
 Obtain a std::span<byte_t, N> looking into the passed buffer. More...
 
auto Quotient::viewAsByteArray (const auto &aRange) -> auto requires(sizeof(*aRange.data())==sizeof(char))
 
auto Quotient::getRandom (size_t bytes)
 
template<size_t SizeN>
auto Quotient::getRandom ()
 
QUOTIENT_API void Quotient::fillFromSecureRng (std::span< byte_t > bytes)
 Fill the buffer with the securely generated random bytes. More...
 

Variables

constexpr auto Quotient::AlgorithmKeyL = "algorithm"_L1
 
constexpr auto Quotient::RotationPeriodMsKeyL = "rotation_period_ms"_L1
 
constexpr auto Quotient::RotationPeriodMsgsKeyL = "rotation_period_msgs"_L1
 
constexpr auto Quotient::AlgorithmKey = "algorithm"_L1
 
constexpr auto Quotient::RotationPeriodMsKey = "rotation_period_ms"_L1
 
constexpr auto Quotient::RotationPeriodMsgsKey = "rotation_period_msgs"_L1
 
constexpr auto Quotient::Ed25519Key = "ed25519"_L1
 
constexpr auto Quotient::Curve25519Key = "curve25519"_L1
 
constexpr auto Quotient::SignedCurve25519Key = "signed_curve25519"_L1
 
constexpr auto Quotient::OlmV1Curve25519AesSha2AlgoKey = "m.olm.v1.curve25519-aes-sha2"_L1
 
constexpr auto Quotient::MegolmV1AesSha2AlgoKey = "m.megolm.v1.aes-sha2"_L1
 
constexpr std::array Quotient::SupportedAlgorithms
 

Macro Definition Documentation

◆ QOLM_FAIL_OR_LOG

#define QOLM_FAIL_OR_LOG (   InternalFailureValue_,
  Message_ 
)     QOLM_FAIL_OR_LOG_X(lastErrorCode() == (InternalFailureValue_), (Message_), lastError())

Definition at line 60 of file e2ee_common.h.

◆ QOLM_FAIL_OR_LOG_X

#define QOLM_FAIL_OR_LOG_X (   InternalCondition_,
  Message_,
  LastErrorText_ 
)
Value:
do { \
if (InternalCondition_) \
QOLM_INTERNAL_ERROR_X((Message_), (LastErrorText_)); \
qWarning(E2EE).nospace() << (Message_) << ": " << (LastErrorText_); \
} while (false) /* End of macro */

Definition at line 53 of file e2ee_common.h.

◆ QOLM_INTERNAL_ERROR

#define QOLM_INTERNAL_ERROR (   Message_)     QOLM_INTERNAL_ERROR_X((Message_), lastError())

Definition at line 50 of file e2ee_common.h.

◆ QOLM_INTERNAL_ERROR_X

#define QOLM_INTERNAL_ERROR_X (   Message_,
  LastError_ 
)     qFatal("%s, internal error: %s", QUO_CSTR(Message_), LastError_)

Definition at line 47 of file e2ee_common.h.