diff options
Diffstat (limited to 'protocols/Skype/src/skype_runtime.cpp')
-rw-r--r-- | protocols/Skype/src/skype_runtime.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp index 1844d2109a..9824ef10bb 100644 --- a/protocols/Skype/src/skype_runtime.cpp +++ b/protocols/Skype/src/skype_runtime.cpp @@ -1,43 +1,50 @@ #include "skype_proto.h"
#include "aes\aes.h"
-#include "base64\base64.h"
#include "..\..\..\skypekit\key.h"
char *CSkypeProto::LoadKeyPair()
{
- HRSRC hRes = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
- if (hRes)
+ HRSRC hResource = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
+ if (hResource)
{
- HGLOBAL hResource = LoadResource(g_hInstance, hRes);
- if (hResource)
+ HGLOBAL hLoadedResource = LoadResource(g_hInstance, hResource);
+ if (hLoadedResource)
{
- aes_context ctx;
- unsigned char key[128];
+ LPVOID pLockedResource = LockResource(hLoadedResource);
- int basedecoded = Base64::Decode(MY_KEY, (char *)key, MAX_PATH);
- ::aes_set_key(&ctx, key, 128);
- memset(key, 0, sizeof(key));
+ if (pLockedResource)
+ {
+ aes_context ctx;
+ char *key = (char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)MY_KEY);
+
+ ::aes_set_key(&ctx, (unsigned char *)key, 128);
+ ::mir_free(key);
+
+ int length = ::SizeofResource(g_hInstance, hResource);
+ if (length != 0)
+ {
+ char *pData = (char *)pLockedResource;
+ if (!pData)
+ return NULL;
- basedecoded = ::SizeofResource(g_hInstance, hRes);
- char *pData = (char *)hResource;
- if (!pData)
- return NULL;
+ pData[length] = 0;
- unsigned char *bufD = (unsigned char *)::malloc(basedecoded + 1);
- unsigned char *tmpD = (unsigned char *)::malloc(basedecoded + 1);
- basedecoded = Base64::Decode(pData, (char *)tmpD, basedecoded);
+ unsigned char *bufD = (unsigned char *)::mir_alloc(length * 2);
+ unsigned char *tmpD = (unsigned char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)pData);
- for (int i = 0; i < basedecoded; i += 16)
- aes_decrypt(&ctx, tmpD+i, bufD+i);
+ for (int i = 0; i < length; i += 16)
+ aes_decrypt(&ctx, tmpD + i, bufD + i);
- ::free(tmpD);
- bufD[basedecoded] = 0; //cert should be null terminated
- return (char *)bufD;
+ ::mir_free(tmpD);
+ //bufD[length] = 0; //cert should be null terminated
+ return (char *)bufD;
+ }
+ }
}
- return NULL;
}
+
return NULL;
}
|