Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
trinity/include/encryption.h

44 lines
1.4 KiB
C
Raw Normal View History

#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;
};