aboutsummaryrefslogtreecommitdiff
path: root/lib/crypto/qolmsession.h
blob: 3be3c7fc23bda9647eb0a3503cbe0743553ed2e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
//}

}