aboutsummaryrefslogtreecommitdiff
path: root/lib/olm/e2ee.h
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-01-23 21:46:26 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:34:52 +0100
commitc8d67f737e84bbec98a54fc19a8aa56dbc39d542 (patch)
tree094704820b91f7f31bbb0562e2e01f3f1fd2a311 /lib/olm/e2ee.h
parente2075a1f33f7987385fc61338ce1756715fdaf6a (diff)
downloadlibquotient-c8d67f737e84bbec98a54fc19a8aa56dbc39d542.tar.gz
libquotient-c8d67f737e84bbec98a54fc19a8aa56dbc39d542.zip
Implement Inboundsession
Diffstat (limited to 'lib/olm/e2ee.h')
-rw-r--r--lib/olm/e2ee.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/olm/e2ee.h b/lib/olm/e2ee.h
new file mode 100644
index 00000000..40ab56c7
--- /dev/null
+++ b/lib/olm/e2ee.h
@@ -0,0 +1,71 @@
+// SPDX-FileCopyrightText: 2019 Alexey Andreyev <aa13q@ya.ru>
+// SPDX-FileCopyrightText: 2019 Kitsune Ral <Kitsune-Ral@users.sf.net>
+// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#pragma once
+
+#include "util.h"
+#include <optional>
+#include <string>
+#include <variant>
+#include <QMap>
+
+#include <QStringList>
+
+namespace Quotient {
+inline const auto CiphertextKeyL = "ciphertext"_ls;
+inline const auto SenderKeyKeyL = "sender_key"_ls;
+inline const auto DeviceIdKeyL = "device_id"_ls;
+inline const auto SessionIdKeyL = "session_id"_ls;
+
+inline const auto AlgorithmKeyL = "algorithm"_ls;
+inline const auto RotationPeriodMsKeyL = "rotation_period_ms"_ls;
+inline const auto RotationPeriodMsgsKeyL = "rotation_period_msgs"_ls;
+
+inline const auto AlgorithmKey = QStringLiteral("algorithm");
+inline const auto RotationPeriodMsKey = QStringLiteral("rotation_period_ms");
+inline const auto RotationPeriodMsgsKey =
+ QStringLiteral("rotation_period_msgs");
+
+inline const auto Ed25519Key = QStringLiteral("ed25519");
+inline const auto Curve25519Key = QStringLiteral("curve25519");
+inline const auto SignedCurve25519Key = QStringLiteral("signed_curve25519");
+inline const auto OlmV1Curve25519AesSha2AlgoKey =
+ QStringLiteral("m.olm.v1.curve25519-aes-sha2");
+inline const auto MegolmV1AesSha2AlgoKey =
+ QStringLiteral("m.megolm.v1.aes-sha2");
+inline const QStringList SupportedAlgorithms = { OlmV1Curve25519AesSha2AlgoKey,
+ MegolmV1AesSha2AlgoKey };
+
+struct Unencrypted {};
+struct Encrypted {
+ QByteArray key;
+};
+
+using PicklingMode = std::variant<Unencrypted, Encrypted>;
+
+template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
+template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
+
+struct IdentityKeys
+{
+ QByteArray curve25519;
+ QByteArray ed25519;
+};
+
+//! Struct representing the the one-time keys.
+struct OneTimeKeys
+{
+ QMap<QString, QMap<QString, QString>> keys;
+
+ //! Get the HashMap containing the curve25519 one-time keys.
+ QMap<QString, QString> curve25519() const;
+
+ //! Get a reference to the hashmap corresponding to given key type.
+ std::optional<QMap<QString, QString>> get(QString keyType) const;
+};
+
+bool operator==(const IdentityKeys& lhs, const IdentityKeys& rhs);
+
+} // namespace Quotient