summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-24 16:35:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-24 16:35:14 +0000
commitc47ca004ba979d23a86211393c9e35deadd66c46 (patch)
treece49a57e87bf5caac81d2d54a590e3aea3d61ea3 /protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp
parent126f606ea6a845d914e3ff074dc725443bb57bf0 (diff)
adaptation of WhatsApp for protocol version 1.5/2.0
git-svn-id: http://svn.miranda-ng.org/main/trunk@11898 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp')
-rw-r--r--protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp37
1 files changed, 6 insertions, 31 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp b/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp
index a27c3c42eb..d2ff14411a 100644
--- a/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp
+++ b/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp
@@ -13,41 +13,16 @@ using namespace Utilities;
/////////////////////////////////////////////////////////////////////////////////////////
// Token generation
-static char WaKey[] = "/UIGKU1FVQa+ATM2A0za7G2KI9S/CwPYjgAbc67v7ep42eO/WeTLx1lb1cHwxpsEgF4+PmYpLd2YpGUdX/A2JQitsHzDwgcdBpUf7psX1BU=";
-static char WaSignature[] = "MIIDMjCCAvCgAwIBAgIETCU2pDALBgcqhkjOOAQDBQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMRYwFAYDVQQKEw1XaGF0c0FwcCBJbmMuMRQwEgYDVQQLEwtFbmdpbmVlcmluZzEUMBIGA1UEAxMLQnJpYW4gQWN0b24wHhcNMTAwNjI1MjMwNzE2WhcNNDQwMjE1MjMwNzE2WjB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExFjAUBgNVBAoTDVdoYXRzQXBwIEluYy4xFDASBgNVBAsTC0VuZ2luZWVyaW5nMRQwEgYDVQQDEwtCcmlhbiBBY3RvbjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDRGYtLgWh7zyRtQainJfCpiaUbzjJuhMgo4fVWZIvXHaSHBU1t5w//S0lDK2hiqkj8KpMWGywVov9eZxZy37V26dEqr/c2m5qZ0E+ynSu7sqUD7kGx/zeIcGT0H+KAVgkGNQCo5Uc0koLRWYHNtYoIvt5R3X6YZylbPftF/8ayWTALBgcqhkjOOAQDBQADLwAwLAIUAKYCp0d6z4QQdyN74JDfQ2WCyi8CFDUM4CaNB+ceVXdKtOrNTQcc0e+t";
-static char WaClassesMd5[] = "xOyKd7AoN0uoos7Fkeup5w=="; // 2.11.407
+static char WaToken[] = "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1418865329241";
std::string WAToken::GenerateToken(const string &number)
{
- unsigned int keyLen, dataLen, classesLen;
- mir_ptr<BYTE> key((BYTE*)mir_base64_decode(WaKey, &keyLen));
- mir_ptr<BYTE> data((BYTE*)mir_base64_decode(WaSignature, &dataLen));
- mir_ptr<BYTE> classes((BYTE*)mir_base64_decode(WaClassesMd5, &classesLen));
-
- BYTE opad[64], ipad[64];
- memset(opad, 0x5C, sizeof(opad));
- memset(ipad, 0x36, sizeof(ipad));
- for (int i = 0; i < sizeof(opad); i++) {
- opad[i] = (BYTE)(opad[i] ^ key[i]);
- ipad[i] = (BYTE)(ipad[i] ^ key[i]);
- }
+ uint8_t digest[16];
+ md5_string(WaToken + number, digest);
- BYTE hash1[MIR_SHA1_HASH_SIZE], hash2[MIR_SHA1_HASH_SIZE];
- mir_sha1_ctx ctx;
- mir_sha1_init(&ctx);
- mir_sha1_append(&ctx, ipad, sizeof(ipad));
- mir_sha1_append(&ctx, data, dataLen);
- mir_sha1_append(&ctx, classes, classesLen);
- mir_sha1_append(&ctx, (PBYTE)number.c_str(), (int)number.size());
- mir_sha1_finish(&ctx, hash1);
-
- mir_sha1_init(&ctx);
- mir_sha1_append(&ctx, opad, sizeof(opad));
- mir_sha1_append(&ctx, hash1, sizeof(hash1));
- mir_sha1_finish(&ctx, hash2);
-
- ptrA result(mir_urlEncode(ptrA(mir_base64_encode(hash2, sizeof(hash2)))));
- return std::string(result);
+ char dest[33];
+ bin2hex(digest, sizeof(digest), dest);
+ return dest;
}
/////////////////////////////////////////////////////////////////////////////////////////