From 47bd4dfb2bc720d2b5919b93985f87d918af572a Mon Sep 17 00:00:00 2001
From: Tobias Fella <fella@posteo.de>
Date: Tue, 7 Dec 2021 00:25:05 +0100
Subject: Port E2EE to database instead of JSON files

---
 lib/crypto/e2ee.h                 | 6 ++++++
 lib/crypto/qolminboundsession.cpp | 2 +-
 lib/crypto/qolminboundsession.h   | 2 +-
 lib/crypto/qolmsession.h          | 3 ---
 4 files changed, 8 insertions(+), 5 deletions(-)

(limited to 'lib/crypto')

diff --git a/lib/crypto/e2ee.h b/lib/crypto/e2ee.h
index 2d280185..41cd2878 100644
--- a/lib/crypto/e2ee.h
+++ b/lib/crypto/e2ee.h
@@ -49,6 +49,12 @@ struct Encrypted {
 
 using PicklingMode = std::variant<Unencrypted, Encrypted>;
 
+class QOlmSession;
+using QOlmSessionPtr = std::unique_ptr<QOlmSession>;
+
+class QOlmInboundGroupSession;
+using QOlmInboundGroupSessionPtr = std::unique_ptr<QOlmInboundGroupSession>;
+
 template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
 template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
 
diff --git a/lib/crypto/qolminboundsession.cpp b/lib/crypto/qolminboundsession.cpp
index beaf3299..31d699f1 100644
--- a/lib/crypto/qolminboundsession.cpp
+++ b/lib/crypto/qolminboundsession.cpp
@@ -72,7 +72,7 @@ QByteArray QOlmInboundGroupSession::pickle(const PicklingMode &mode) const
     return pickledBuf;
 }
 
-std::variant<std::unique_ptr<QOlmInboundGroupSession>, QOlmError> QOlmInboundGroupSession::unpickle(QByteArray &pickled, const PicklingMode &mode)
+std::variant<std::unique_ptr<QOlmInboundGroupSession>, QOlmError> QOlmInboundGroupSession::unpickle(const QByteArray &pickled, const PicklingMode &mode)
 {
     QByteArray pickledBuf = pickled;
     const auto groupSession = olm_inbound_group_session(new uint8_t[olm_inbound_group_session_size()]);
diff --git a/lib/crypto/qolminboundsession.h b/lib/crypto/qolminboundsession.h
index 36ab4942..362e42ba 100644
--- a/lib/crypto/qolminboundsession.h
+++ b/lib/crypto/qolminboundsession.h
@@ -27,7 +27,7 @@ public:
     QByteArray pickle(const PicklingMode &mode) const;
     //! Deserialises from encrypted Base64 that was previously obtained by pickling
     //! an `OlmInboundGroupSession`.
-    static std::variant<std::unique_ptr<QOlmInboundGroupSession>, QOlmError> unpickle(QByteArray &picked, const PicklingMode &mode);
+    static std::variant<std::unique_ptr<QOlmInboundGroupSession>, QOlmError> unpickle(const QByteArray &picked, const PicklingMode &mode);
     //! Decrypts ciphertext received for this group session.
     std::variant<std::pair<QString, uint32_t>, QOlmError> decrypt(const QByteArray &message);
     //! Export the base64-encoded ratchet key for this session, at the given index,
diff --git a/lib/crypto/qolmsession.h b/lib/crypto/qolmsession.h
index 7a040b3d..711ca66b 100644
--- a/lib/crypto/qolmsession.h
+++ b/lib/crypto/qolmsession.h
@@ -73,7 +73,4 @@ private:
     static std::variant<std::unique_ptr<QOlmSession>, QOlmError> createInbound(QOlmAccount *account, const QOlmMessage& preKeyMessage, bool from = false, const QString& theirIdentityKey = "");
     OlmSession* m_session;
 };
-
-using QOlmSessionPtr = std::unique_ptr<QOlmSession>;
-
 } //namespace Quotient
-- 
cgit v1.2.3