forked from CODeRUS/libaxolotl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sessioncipher.h
43 lines (37 loc) · 2.05 KB
/
sessioncipher.h
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
#ifndef SESSIONCIPHER_H
#define SESSIONCIPHER_H
#include <QSharedPointer>
#include "state/sessionstore.h"
#include "sessionbuilder.h"
#include "ratchet/messagekeys.h"
class SessionCipher
{
public:
SessionCipher(QSharedPointer<SessionStore> sessionStore, QSharedPointer<PreKeyStore> preKeyStore,
QSharedPointer<SignedPreKeyStore> signedPreKeyStore, QSharedPointer<IdentityKeyStore> identityKeyStore,
qulonglong recipientId, int deviceId);
SessionCipher(QSharedPointer<AxolotlStore> store, qulonglong recipientId, int deviceId);
QSharedPointer<CiphertextMessage> encrypt(const QByteArray &paddedMessage);
QByteArray decrypt(QSharedPointer<PreKeyWhisperMessage> ciphertext);
QByteArray decrypt(QSharedPointer<WhisperMessage> ciphertext);
QByteArray decrypt(SessionRecord *sessionRecord, QSharedPointer<WhisperMessage> ciphertext);
QByteArray decrypt(SessionState *sessionState, QSharedPointer<WhisperMessage> ciphertextMessage);
int getRemoteRegistrationId();
int getSessionVersion() ;
private:
void init(QSharedPointer<SessionStore> sessionStore, QSharedPointer<PreKeyStore> preKeyStore,
QSharedPointer<SignedPreKeyStore> signedPreKeyStore, QSharedPointer<IdentityKeyStore> identityKeyStore,
qulonglong recipientId, int deviceId);
ChainKey getOrCreateChainKey(SessionState *sessionState, const DjbECPublicKey &theirEphemeral);
MessageKeys getOrCreateMessageKeys(SessionState *sessionState,
const DjbECPublicKey &theirEphemeral,
const ChainKey &chainKey, uint counter);
QByteArray getCiphertext(int version, const MessageKeys &messageKeys, const QByteArray &plaintext);
QByteArray getPlaintext(int version, const MessageKeys &messageKeys, const QByteArray &cipherText);
QSharedPointer<SessionStore> sessionStore;
SessionBuilder sessionBuilder;
QSharedPointer<PreKeyStore> preKeyStore;
qulonglong recipientId;
int deviceId;
};
#endif // SESSIONCIPHER_H