diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-01-28 21:54:37 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:34:52 +0100 |
commit | dd0316ce57bd9256a093d66845e1d40cd9426ba4 (patch) | |
tree | 900996974e3bdec3a3ceda2ebdae0377dacc80e4 /lib/crypto/qolmsession.h | |
parent | 5910689306149cacf3ac644d3ea42e10f889e3fe (diff) | |
download | libquotient-dd0316ce57bd9256a093d66845e1d40cd9426ba4.tar.gz libquotient-dd0316ce57bd9256a093d66845e1d40cd9426ba4.zip |
Move files
Diffstat (limited to 'lib/crypto/qolmsession.h')
-rw-r--r-- | lib/crypto/qolmsession.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/crypto/qolmsession.h b/lib/crypto/qolmsession.h new file mode 100644 index 00000000..3be3c7fc --- /dev/null +++ b/lib/crypto/qolmsession.h @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#pragma once + +#include <variant> +#include <olm/olm.h> +#include "crypto/e2ee.h" +#include "crypto/errors.h" + +namespace Quotient { + +//! An encrypted Olm message. +struct Message { + QByteArray message; +}; + +//! A encrypted Olm pre-key message. +//! +//! This message, unlike a normal Message, can be used to create new Olm sessions. +struct PreKeyMessage +{ + QByteArray message; +}; + +enum OlmMessageType +{ + PreKeyType, + MessageType, +}; + +using OlmMessage = std::variant<Message, PreKeyMessage>; + +std::optional<OlmMessage> fromTypeAndCipthertext(size_t messageType, const QByteArray &ciphertext); + +std::pair<OlmMessageType, QByteArray> toPair(const OlmMessage &message); + +//class QOlmSession +//{ +// /// Creates an inbound session for sending/receiving messages from a received 'prekey' message. +// static std::variant<std::unique_ptr<QOlmSession>, OlmError> createInboundSession(const QOlmAccount &account, +// PreKeyMessage &message); +// +////private: +// //static std::variant<std::unique_ptr<QOlmSession>, OlmError> createSessionWith(std::function<std::variant<size_t(OlmSession *)>> func); +//} + +} |