diff options
author | George Hazan <ghazan@miranda.im> | 2022-09-28 15:10:08 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-09-28 15:10:08 +0300 |
commit | 771e0f81583ee61646a9c5a71aa1e1e25c737827 (patch) | |
tree | 70db7cda0ec85115f0123b87a40822f5bf7e49c1 /protocols/WhatsAppWeb/src | |
parent | 3e1bb4ac88fe352f955cd639aeb1e3f57163b180 (diff) |
WhatsApp: another fix for packet decryption
Diffstat (limited to 'protocols/WhatsAppWeb/src')
-rw-r--r-- | protocols/WhatsAppWeb/src/noise.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/protocols/WhatsAppWeb/src/noise.cpp b/protocols/WhatsAppWeb/src/noise.cpp index b85bc8eb7b..207d53d56a 100644 --- a/protocols/WhatsAppWeb/src/noise.cpp +++ b/protocols/WhatsAppWeb/src/noise.cpp @@ -137,8 +137,7 @@ void WANoise::init() void WANoise::finish() { - deriveKey("", 0, salt, encKey); - decKey.assign(encKey.data(), encKey.length()); + deriveKey("", 0, encKey, decKey); readCounter = writeCounter = 0; memset(hash, 0, sizeof(hash)); bInitFinished = true; @@ -184,7 +183,9 @@ MBinBuffer WANoise::decrypt(const void *pData, size_t cbLen) EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, (BYTE *)decKey.data(), iv); - EVP_DecryptUpdate(ctx, nullptr, &tag_len, hash, sizeof(hash)); + if (!bInitFinished) + EVP_DecryptUpdate(ctx, nullptr, &tag_len, hash, sizeof(hash)); + cbLen -= 16; EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, (BYTE *)pData + cbLen); |