diff options
author | George Hazan <ghazan@miranda.im> | 2021-04-25 15:35:39 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-04-25 15:35:39 +0300 |
commit | 68f68d7633596d9f39a0bd48f26732b24a2b5ee9 (patch) | |
tree | bd52f64f99547c84c98a413b7e2b6c2f07407ebd /protocols/WhatsAppWeb/src/utils.cpp | |
parent | 9449b0587fa74976ff55828f5d850bc061e331b8 (diff) |
code cleaning
Diffstat (limited to 'protocols/WhatsAppWeb/src/utils.cpp')
-rw-r--r-- | protocols/WhatsAppWeb/src/utils.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/protocols/WhatsAppWeb/src/utils.cpp b/protocols/WhatsAppWeb/src/utils.cpp index 853c5ae383..4300256cf7 100644 --- a/protocols/WhatsAppWeb/src/utils.cpp +++ b/protocols/WhatsAppWeb/src/utils.cpp @@ -67,16 +67,17 @@ bool WhatsAppProto::decryptBinaryMessage(size_t cbSize, const void *buf, MBinBuf } // okay, let's decrypt this thing + auto *pBuf = (const unsigned char *)buf; { BYTE iv[16]; - memcpy(iv, (char*)buf + 32, sizeof(iv)); - res.assign((char*)buf + 48, cbSize - 48); - res.append((char*)mac_key.data(), 32); // reserve 32 more bytes for temp data + memcpy(iv, pBuf + 32, sizeof(iv)); + res.assign(pBuf + 48, cbSize - 48); + res.append(mac_key.data(), 32); // reserve 32 more bytes for temp data int dec_len = 0, final_len = 0; EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, (BYTE*)enc_key.data(), iv); - EVP_DecryptUpdate(ctx, (BYTE*)res.data(), &dec_len, (BYTE*)buf + 48, (int)cbSize - 48); + EVP_DecryptUpdate(ctx, (BYTE*)res.data(), &dec_len, pBuf + 48, (int)cbSize - 48); EVP_DecryptFinal_ex(ctx, (BYTE*)res.data() + dec_len, &final_len); EVP_CIPHER_CTX_free(ctx); } @@ -517,7 +518,7 @@ void WAWriter::writeString(const char *str, bool bRaw) else { int len = (int)strlen(str); writeLength(len); - body.append((void *)str, len); + body.append(str, len); } } |