diff options
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/WhatsAppWeb/src/noise.cpp | 5 | ||||
| -rw-r--r-- | protocols/WhatsAppWeb/src/wareader.cpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/protocols/WhatsAppWeb/src/noise.cpp b/protocols/WhatsAppWeb/src/noise.cpp index 5c4037b61f..3c2927edd6 100644 --- a/protocols/WhatsAppWeb/src/noise.cpp +++ b/protocols/WhatsAppWeb/src/noise.cpp @@ -253,7 +253,10 @@ MBinBuffer WANoise::encrypt(const void *pData, size_t cbLen) int enc_len = 0, final_len = 0; EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, (BYTE *)encKey.data(), iv); - EVP_EncryptUpdate(ctx, NULL, &enc_len, hash, sizeof(hash)); + + if (!bInitFinished) + EVP_EncryptUpdate(ctx, NULL, &enc_len, hash, sizeof(hash)); + for (size_t len = 0; len < cbLen; len += 1024) { size_t portionSize = cbLen - len; EVP_EncryptUpdate(ctx, outbuf, &enc_len, (BYTE *)pData + len, (int)min(portionSize, 1024)); diff --git a/protocols/WhatsAppWeb/src/wareader.cpp b/protocols/WhatsAppWeb/src/wareader.cpp index 30d9aab7c0..1c164d7148 100644 --- a/protocols/WhatsAppWeb/src/wareader.cpp +++ b/protocols/WhatsAppWeb/src/wareader.cpp @@ -409,8 +409,10 @@ void WAWriter::writePacked(const CMStringA &str, int tag) if (str.GetLength() > 254) return; + writeByte(tag); + int len = str.GetLength() / 2; - BYTE firstByte = (len % 2) == 0 ? 0 : 0x80; + BYTE firstByte = (str.GetLength() % 2) == 0 ? 0 : 0x80; writeByte(firstByte | len); const char *p = str; @@ -434,6 +436,11 @@ void WAWriter::writeString(const char *str) writeByte(LIST_EMPTY); else writeString(CMStringA(str, int(pszDelimiter - str))); + + if (pszDelimiter[1] == 0) // empty jid + writeByte(LIST_EMPTY); + else + writeString(pszDelimiter + 1); } else { CMStringA buf(str); |
