summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_runtime.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2013-06-03 20:54:43 +0000
committerAlexander Lantsev <aunsane@gmail.com>2013-06-03 20:54:43 +0000
commit0ad4fffb15944d82febdcec80ef920cd400d8169 (patch)
treef663a50d2c7311cf9a2eaa52ffd2c3fde30d3f21 /protocols/Skype/src/skype_runtime.cpp
parent5e3b2449340245febd68b79c148a5ca3fd95336a (diff)
- use core base64 funcs
- few changes in group chat git-svn-id: http://svn.miranda-ng.org/main/trunk@4876 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/skype_runtime.cpp')
-rw-r--r--protocols/Skype/src/skype_runtime.cpp53
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;
}