diff options
Diffstat (limited to 'protocols/Skype/src/skype_runtime.cpp')
-rw-r--r-- | protocols/Skype/src/skype_runtime.cpp | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp index 9824ef10bb..9d319ac7cd 100644 --- a/protocols/Skype/src/skype_runtime.cpp +++ b/protocols/Skype/src/skype_runtime.cpp @@ -7,45 +7,40 @@ char *CSkypeProto::LoadKeyPair()
{
HRSRC hResource = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
- if (hResource)
- {
- HGLOBAL hLoadedResource = LoadResource(g_hInstance, hResource);
- if (hLoadedResource)
- {
- LPVOID pLockedResource = LockResource(hLoadedResource);
+ if (hResource == NULL)
+ return NULL;
- if (pLockedResource)
- {
- aes_context ctx;
- char *key = (char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)MY_KEY);
+ HGLOBAL hLoadedResource = LoadResource(g_hInstance, hResource);
+ if (hLoadedResource == NULL)
+ return NULL;
- ::aes_set_key(&ctx, (unsigned char *)key, 128);
- ::mir_free(key);
+ LPVOID pLockedResource = LockResource(hLoadedResource);
+ if (pLockedResource == NULL)
+ return NULL;
- int length = ::SizeofResource(g_hInstance, hResource);
- if (length != 0)
- {
- char *pData = (char *)pLockedResource;
- if (!pData)
- return NULL;
+ aes_context ctx;
+ char *key = (char*)mir_base64_decode(MY_KEY, NULL);
- pData[length] = 0;
+ ::aes_set_key(&ctx, (unsigned char *)key, 128);
+ ::mir_free(key);
- unsigned char *bufD = (unsigned char *)::mir_alloc(length * 2);
- unsigned char *tmpD = (unsigned char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)pData);
+ int length = ::SizeofResource(g_hInstance, hResource);
+ if (length == 0)
+ return NULL;
- for (int i = 0; i < length; i += 16)
- aes_decrypt(&ctx, tmpD + i, bufD + i);
+ char *pData = (char *)alloca(length+1);
+ memcpy(pData, pLockedResource, length);
+ pData[length] = 0;
- ::mir_free(tmpD);
- //bufD[length] = 0; //cert should be null terminated
- return (char *)bufD;
- }
- }
- }
- }
+ unsigned char *bufD = (unsigned char *)::mir_alloc(length * 2);
+ unsigned char *tmpD = (unsigned char *)mir_base64_decode(pData, NULL);
+
+ for (int i = 0; i < length; i += 16)
+ aes_decrypt(&ctx, tmpD + i, bufD + i);
- return NULL;
+ ::mir_free(tmpD);
+ //bufD[length] = 0; //cert should be null terminated
+ return (char *)bufD;
}
int CSkypeProto::StartSkypeRuntime(const wchar_t *profileName)
|