summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/signal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/WhatsApp/src/signal.cpp')
-rw-r--r--protocols/WhatsApp/src/signal.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/protocols/WhatsApp/src/signal.cpp b/protocols/WhatsApp/src/signal.cpp
index 5710392e43..39b0347eae 100644
--- a/protocols/WhatsApp/src/signal.cpp
+++ b/protocols/WhatsApp/src/signal.cpp
@@ -517,6 +517,38 @@ signal_buffer* MSignalStore::decryptGroupSignalProto(const CMStringA &group, con
}
/////////////////////////////////////////////////////////////////////////////////////////
+// encryption
+
+signal_buffer* MSignalStore::encryptSignalProto(const WAJid &to, const MBinBuffer &buf, int &type)
+{
+ auto *pSession = createSession(to.user, to.device);
+
+ ciphertext_message *pEncrypted;
+ logError(
+ session_cipher_encrypt(pSession->getCipher(), buf.data(), buf.length(), &pEncrypted),
+ "unable to encrypt signal message");
+
+ type = ciphertext_message_get_type(pEncrypted);
+
+ auto *res = ciphertext_message_get_serialized(pEncrypted);
+ signal_message_destroy((signal_type_base *)pEncrypted);
+ return res;
+}
+
+MBinBuffer MSignalStore::encodeSignedIdentity(bool bIncludeSignatureKey)
+{
+ proto::ADVSignedDeviceIdentity identity;
+ identity << pProto->getBlob("WAAccount");
+
+ if (!bIncludeSignatureKey)
+ identity.clear_accountsignaturekey();
+
+ MBinBuffer res(identity.ByteSize());
+ identity.SerializeToArray(res.data(), (int)res.length());
+ return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// generate and save pre keys set
void MSignalStore::generatePrekeys(int count)