aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-05-16 20:46:34 +0200
committerTobias Fella <fella@posteo.de>2022-05-16 20:46:34 +0200
commit3eb7ad8b0a1ac0f6f9cda679108937a01268f184 (patch)
tree65ff603d112a01bc1057e3b7eaaf4e7530b948cc /lib/e2ee
parent20bd96ac67c06617e619460c4cd07b5e15cc74d7 (diff)
downloadlibquotient-3eb7ad8b0a1ac0f6f9cda679108937a01268f184.tar.gz
libquotient-3eb7ad8b0a1ac0f6f9cda679108937a01268f184.zip
Save and load outgoing megolm session
Diffstat (limited to 'lib/e2ee')
-rw-r--r--lib/e2ee/qolmoutboundsession.cpp22
-rw-r--r--lib/e2ee/qolmoutboundsession.h9
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/e2ee/qolmoutboundsession.cpp b/lib/e2ee/qolmoutboundsession.cpp
index 96bad344..10b0c4de 100644
--- a/lib/e2ee/qolmoutboundsession.cpp
+++ b/lib/e2ee/qolmoutboundsession.cpp
@@ -66,7 +66,7 @@ QOlmExpected<QOlmOutboundGroupSessionPtr> QOlmOutboundGroupSession::unpickle(QBy
auto *olmOutboundGroupSession = olm_outbound_group_session(new uint8_t[olm_outbound_group_session_size()]);
QByteArray key = toKey(mode);
const auto error = olm_unpickle_outbound_group_session(olmOutboundGroupSession, key.data(), key.length(),
- pickled.data(), pickled.length());
+ pickledBuf.data(), pickledBuf.length());
if (error == olm_error()) {
return lastError(olmOutboundGroupSession);
}
@@ -123,3 +123,23 @@ QOlmExpected<QByteArray> QOlmOutboundGroupSession::sessionKey() const
}
return keyBuffer;
}
+
+int QOlmOutboundGroupSession::messageCount() const
+{
+ return m_messageCount;
+}
+
+void QOlmOutboundGroupSession::setMessageCount(int messageCount)
+{
+ m_messageCount = messageCount;
+}
+
+QDateTime QOlmOutboundGroupSession::creationTime() const
+{
+ return m_creationTime;
+}
+
+void QOlmOutboundGroupSession::setCreationTime(const QDateTime& creationTime)
+{
+ m_creationTime = creationTime;
+}
diff --git a/lib/e2ee/qolmoutboundsession.h b/lib/e2ee/qolmoutboundsession.h
index 8058bbb1..56b25974 100644
--- a/lib/e2ee/qolmoutboundsession.h
+++ b/lib/e2ee/qolmoutboundsession.h
@@ -26,6 +26,7 @@ public:
//! pickling a `QOlmOutboundGroupSession`.
static QOlmExpected<QOlmOutboundGroupSessionPtr> unpickle(
QByteArray& pickled, const PicklingMode& mode);
+
//! Encrypts a plaintext message using the session.
QOlmExpected<QByteArray> encrypt(const QString& plaintext);
@@ -44,8 +45,16 @@ public:
//! ratchet key that will be used for the next message.
QOlmExpected<QByteArray> sessionKey() const;
QOlmOutboundGroupSession(OlmOutboundGroupSession *groupSession);
+
+ int messageCount() const;
+ void setMessageCount(int messageCount);
+
+ QDateTime creationTime() const;
+ void setCreationTime(const QDateTime& creationTime);
private:
OlmOutboundGroupSession *m_groupSession;
+ int m_messageCount = 0;
+ QDateTime m_creationTime = QDateTime::currentDateTime();
};
} // namespace Quotient