44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
|
#pragma once
|
||
|
|
||
|
#include <QString>
|
||
|
#include <QJsonObject>
|
||
|
|
||
|
#include <olm/olm.h>
|
||
|
|
||
|
class Encryption {
|
||
|
public:
|
||
|
void createNewDeviceKeys();
|
||
|
QJsonObject generateOneTimeKeys(int number);
|
||
|
int getRecommendedNumberOfOneTimeKeys();
|
||
|
|
||
|
QString saveDeviceKeys();
|
||
|
void loadDeviceKeys(QString bytes);
|
||
|
|
||
|
OlmOutboundGroupSession* beginOutboundSession();
|
||
|
std::string getGroupSessionId(OlmOutboundGroupSession* session);
|
||
|
std::string getGroupSessionKey(OlmOutboundGroupSession* session);
|
||
|
OlmSession* beginOutboundOlmSession(std::string identityKey, std::string oneTimeKey);
|
||
|
std::string getSessionId(OlmSession* session);
|
||
|
std::string encrypt(OlmSession* session, std::string message);
|
||
|
std::string encryptGroup(OlmOutboundGroupSession* session, std::string message);
|
||
|
|
||
|
QString saveSession(OlmOutboundGroupSession* session);
|
||
|
OlmOutboundGroupSession* loadSession(QString bytes);
|
||
|
|
||
|
// inbound messaging
|
||
|
OlmSession* createInboundSession(std::string senderKey, std::string body);
|
||
|
std::vector<std::uint8_t> decrypt(OlmSession* session, int msgType, std::string cipherText);
|
||
|
|
||
|
OlmInboundGroupSession* beginInboundSession(std::string sessionKey);
|
||
|
std::vector<std::uint8_t> decrypt(OlmInboundGroupSession* session, std::string cipherText);
|
||
|
|
||
|
QString signMessage(QString message);
|
||
|
|
||
|
QJsonObject identityKey;
|
||
|
|
||
|
private:
|
||
|
void initAccount();
|
||
|
|
||
|
OlmAccount* account = nullptr;
|
||
|
};
|