diff options
author | George Hazan <george.hazan@gmail.com> | 2013-06-04 07:55:00 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-06-04 07:55:00 +0000 |
commit | 8751885ea79df4b666b65bb2b6900617785e0da7 (patch) | |
tree | 676db28129ece760d7ad354b2d39ba371453db8c /protocols/Skype | |
parent | 09476981eccbcae37ef4526f3fbcb18fca686ffa (diff) |
end of base64* zoo
git-svn-id: http://svn.miranda-ng.org/main/trunk@4879 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_account.cpp | 14 | ||||
-rw-r--r-- | protocols/Skype/src/skype_runtime.cpp | 57 |
2 files changed, 30 insertions, 41 deletions
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index 2f1379048f..1121628193 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -180,12 +180,10 @@ void CSkypeProto::InitProxy() this->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
- char *encodedPass = (char *)::CallService(MS_UTILS_ENCODEBASE64, 0, (LPARAM)nlus.szProxyAuthPassword);
+ ptrA encodedPass( mir_base64_encode((BYTE*)nlus.szProxyAuthPassword, lstrlenA(nlus.szProxyAuthPassword)));
- this->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
- this->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass);
-
- ::mir_free(encodedPass);
+ this->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
+ this->SetStr(SETUPKEY_HTTPS_PROXY_PWD, (char*)encodedPass);
}
break;
@@ -197,12 +195,8 @@ void CSkypeProto::InitProxy() this->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
- char *encodedPass = (char *)::CallService(MS_UTILS_ENCODEBASE64, 0, (LPARAM)nlus.szProxyAuthPassword);
-
- this->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
+ this->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
this->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword);
-
- ::mir_free(encodedPass);
}
break;
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)
|