summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin15/mir_full.sln2
-rw-r--r--protocols/WhatsApp/src/db.h2
-rw-r--r--protocols/WhatsApp/src/iq.cpp1
-rw-r--r--protocols/WhatsApp/src/proto.h2
-rw-r--r--protocols/WhatsApp/src/signal.cpp43
5 files changed, 33 insertions, 17 deletions
diff --git a/bin15/mir_full.sln b/bin15/mir_full.sln
index de637c8f7d..5cc7d6ad83 100644
--- a/bin15/mir_full.sln
+++ b/bin15/mir_full.sln
@@ -2087,7 +2087,7 @@ Global
{290C5ED4-71A7-4040-AD26-4820CF7A9E60} = {30218E20-9E62-4027-BB87-2627B17F6CA3}
{1C856B14-54CD-4D07-B18B-5F7DB073AB51} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
{A5B558C6-C767-11E1-A335-F6EB6188709B} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
- {6022990D-3FD5-46A9-8AB5-E444C51646F3} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
+ {6022990D-3FD5-46A9-8AB5-E444C51646F3} = {F9C41695-3353-4564-A154-58106829B19C}
{A8F23706-E590-4A87-96CC-5F8E5082503F} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
{DADAC956-3A54-440A-8B56-A07234DEE861} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
{D22C1BBB-E06A-4A28-8F33-17D1EA3E8563} = {E7FB43FB-3563-4568-8846-A88FC37449BF}
diff --git a/protocols/WhatsApp/src/db.h b/protocols/WhatsApp/src/db.h
index c8cb6e249c..164f2f5fe1 100644
--- a/protocols/WhatsApp/src/db.h
+++ b/protocols/WhatsApp/src/db.h
@@ -19,7 +19,7 @@ Copyright © 2019-22 George Hazan
#define DBKEY_SIGNED_IDENTITY_PUB "SignedIdentityPublicKey"
#define DBKEY_SIGNED_IDENTITY_PRIV "SignedIdentityPrivateKey"
-#define DBKEY_PREKEY "SignedPreKey0"
+#define DBKEY_PREKEY "SignedPreKey1"
#define DBKEY_PREKEY_NEXT_ID "PrekeyNextId"
#define DBKEY_PREKEY_UPLOAD_ID "PrekeyUploadId"
diff --git a/protocols/WhatsApp/src/iq.cpp b/protocols/WhatsApp/src/iq.cpp
index 61c54e4cd8..255682ad81 100644
--- a/protocols/WhatsApp/src/iq.cpp
+++ b/protocols/WhatsApp/src/iq.cpp
@@ -252,7 +252,6 @@ void WhatsAppProto::OnReceiveMessage(const WANode &node)
SendReceipt(szChatId, pszReceiptTo, msgId, pszReceiptType);
}
catch (const char *pszError) {
- debugLogA("Message cannot be parsed: %s", pszError);
}
if (!iDecryptable) {
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h
index d5fb32e80d..475f564027 100644
--- a/protocols/WhatsApp/src/proto.h
+++ b/protocols/WhatsApp/src/proto.h
@@ -211,6 +211,8 @@ public:
void generatePrekeys(int count);
+ void logError(int code, const char *szMessage);
+
void processSenderKeyMessage(const proto::Message_SenderKeyDistributionMessage &msg);
};
diff --git a/protocols/WhatsApp/src/signal.cpp b/protocols/WhatsApp/src/signal.cpp
index e80eeac4ee..c43b8eb8a3 100644
--- a/protocols/WhatsApp/src/signal.cpp
+++ b/protocols/WhatsApp/src/signal.cpp
@@ -32,6 +32,14 @@ MSignalStore::~MSignalStore()
signal_context_destroy(m_pContext);
}
+void MSignalStore::logError(int err, const char *pszMessage)
+{
+ if (err < 0) {
+ pProto->debugLogA("libsignal error %d: %s", err, pszMessage);
+ throw pszMessage;
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
static void log_func(int level, const char *pmsg, size_t /*msgLen*/, void *pUserData)
@@ -439,8 +447,9 @@ MSignalSession* MSignalStore::createSession(const CMStringA &szName, int deviceI
}
if (pSession->cipher == nullptr)
- if (session_cipher_create(&pSession->cipher, m_pStore, &pSession->address, m_pContext) < 0)
- throw "session_cipher_create failure";
+ logError(
+ session_cipher_create(&pSession->cipher, m_pStore, &pSession->address, m_pContext),
+ "session_cipher_create failure");
return pSession;
}
@@ -455,21 +464,25 @@ signal_buffer* MSignalStore::decryptSignalProto(const CMStringA &from, const cha
signal_buffer *result = nullptr;
if (!mir_strcmp(pszType, "pkmsg")) {
pre_key_signal_message *pMsg;
- if (pre_key_signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext) < 0)
- throw "unable to deserialize prekey message";
+ logError(
+ pre_key_signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext),
+ "unable to deserialize prekey message");
- if (session_cipher_decrypt_pre_key_signal_message(pSession->getCipher(), pMsg, this, &result) < 0)
- throw "unable to decrypt prekey message";
+ logError(
+ session_cipher_decrypt_pre_key_signal_message(pSession->getCipher(), pMsg, this, &result),
+ "unable to decrypt prekey message");
pre_key_signal_message_destroy((signal_type_base*)pMsg);
}
else {
signal_message *pMsg;
- if (signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext) < 0)
- throw "unable to deserialize signal message";
+ logError(
+ signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext),
+ "unable to deserialize signal message");
- if (session_cipher_decrypt_signal_message(pSession->getCipher(), pMsg, this, &result) < 0)
- throw "unable to decrypt signal message";
+ logError(
+ session_cipher_decrypt_signal_message(pSession->getCipher(), pMsg, this, &result),
+ "unable to decrypt signal message");
signal_message_destroy((signal_type_base *)pMsg);
}
@@ -483,12 +496,14 @@ signal_buffer* MSignalStore::decryptGroupSignalProto(const CMStringA &group, con
auto *pSession = createSession(group + CMStringA(FORMAT, "::%s::%d", jid.user.c_str(), jid.device), 0);
signal_message *pMsg;
- if (signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext) < 0)
- throw "unable to deserialize signal message";
+ logError(
+ signal_message_deserialize(&pMsg, (BYTE *)encrypted.data(), encrypted.length(), m_pContext),
+ "unable to deserialize signal message");
signal_buffer *result = nullptr;
- if (session_cipher_decrypt_signal_message(pSession->getCipher(), pMsg, this, &result) < 0)
- throw "unable to decrypt signal message";
+ logError(
+ session_cipher_decrypt_signal_message(pSession->getCipher(), pMsg, this, &result),
+ "unable to decrypt signal message");
signal_message_destroy((signal_type_base *)pMsg);
return result;