summaryrefslogtreecommitdiff
path: root/protocols/MSN/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/MSN/src')
-rw-r--r--protocols/MSN/src/msn_auth.cpp37
-rw-r--r--protocols/MSN/src/msn_commands.cpp8
-rw-r--r--protocols/MSN/src/msn_global.h1
-rw-r--r--protocols/MSN/src/msn_mime.cpp4
-rw-r--r--protocols/MSN/src/msn_misc.cpp50
-rw-r--r--protocols/MSN/src/msn_p2p.cpp8
-rw-r--r--protocols/MSN/src/msn_soapab.cpp11
-rw-r--r--protocols/MSN/src/msn_srv.cpp21
8 files changed, 29 insertions, 111 deletions
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index 9c258922be..5abe9160f2 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -433,13 +433,8 @@ static unsigned char* PKCS5_Padding(char* in, size_t &len)
char* CMsnProto::GenerateLoginBlob(char* challenge)
{
- const size_t keylen = strlen(authSecretToken);
- size_t key1len = Netlib_GetBase64DecodedBufferSize(keylen);
- unsigned char* key1 = (unsigned char*)alloca(key1len);
-
- NETLIBBASE64 nlb = { authSecretToken, (int)keylen, key1, (int)key1len };
- CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM(&nlb));
- key1len = nlb.cbDecoded;
+ unsigned key1len;
+ BYTE *key1 = (BYTE*)mir_base64_decode(authSecretToken, &key1len);
mir_sha1_byte_t key2[MIR_SHA1_HASH_SIZE+4];
mir_sha1_byte_t key3[MIR_SHA1_HASH_SIZE+4];
@@ -481,13 +476,7 @@ char* CMsnProto::GenerateLoginBlob(char* challenge)
mir_free(newchl);
- const size_t rlen = Netlib_GetBase64EncodedBufferSize(pktsz);
- char* buf = (char*)mir_alloc(rlen);
-
- NETLIBBASE64 nlb1 = { buf, (int)rlen, userKey, (int)pktsz };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb1));
-
- return buf;
+ return mir_base64_encode(userKey, (unsigned)pktsz);
}
@@ -497,12 +486,8 @@ char* CMsnProto::HotmailLogin(const char* url)
CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
const size_t hotSecretlen = strlen(hotSecretToken);
- size_t key1len = Netlib_GetBase64DecodedBufferSize(hotSecretlen);
- unsigned char* key1 = (unsigned char*)alloca(key1len);
-
- NETLIBBASE64 nlb = { hotSecretToken, (int)hotSecretlen, key1, (int)key1len };
- CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM(&nlb));
- key1len = nlb.cbDecoded;
+ unsigned key1len;
+ BYTE *key1 = (BYTE*)mir_base64_decode(hotSecretToken, &key1len);
static const unsigned char encdata[] = "WS-SecureConversation";
const size_t data1len = sizeof(nonce) + sizeof(encdata) - 1;
@@ -518,11 +503,8 @@ char* CMsnProto::HotmailLogin(const char* url)
char* xmlenc = (char*)alloca(xmlenclen);
UrlEncode(hotAuthToken, xmlenc, xmlenclen);
- size_t noncenclen = Netlib_GetBase64EncodedBufferSize(sizeof(nonce));
- char* noncenc = (char*)alloca(noncenclen);
- NETLIBBASE64 nlb1 = { noncenc, (int)noncenclen, nonce, sizeof(nonce) };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb1));
- noncenclen = nlb1.cchEncoded - 1;
+ ptrA noncenc( mir_base64_encode(nonce, sizeof(nonce)));
+ size_t noncenclen = lstrlenA(noncenc);
const size_t fnpstlen = strlen(xmlenc) + strlen(url) + 3*noncenclen + 100;
char* fnpst = (char*)mir_alloc(fnpstlen);
@@ -535,13 +517,10 @@ char* CMsnProto::HotmailLogin(const char* url)
mir_sha1_byte_t hash[MIR_SHA1_HASH_SIZE];
hmac_sha1(hash, key2, sizeof(key2), (mir_sha1_byte_t*)fnpst, sz);
- NETLIBBASE64 nlb2 = { noncenc, (int)noncenclen, hash, sizeof(hash) };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb2));
+ noncenc = mir_base64_encode(hash, sizeof(hash));
sz += mir_snprintf(fnpst + sz, fnpstlen - sz, "&hash=");
-
UrlEncode(noncenc, fnpst + sz, fnpstlen - sz);
-
return fnpst;
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index b4b7ed8478..057f2f3111 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -302,15 +302,11 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in
ft->p2p_object[sz] = 0;
size_t slen = strlen(lastsml);
- size_t rlen = Netlib_GetBase64EncodedBufferSize(slen);
- char* buf = (char*)mir_alloc(rlen);
-
- NETLIBBASE64 nlb = { buf, (int)rlen, (PBYTE)lastsml, (int)slen };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+ ptrA buf( mir_base64_encode((PBYTE)lastsml, (unsigned)slen));
+ int rlen = lstrlenA(buf);
char* smileyName = (char*)mir_alloc(rlen*3);
UrlEncode(buf, smileyName, rlen*3);
- mir_free(buf);
TCHAR path[MAX_PATH];
MSN_GetCustomSmileyFileName(hContact, path, SIZEOF(path), smileyName, iSmileyType);
diff --git a/protocols/MSN/src/msn_global.h b/protocols/MSN/src/msn_global.h
index 2fe7bce1ed..aa7ed0f001 100644
--- a/protocols/MSN/src/msn_global.h
+++ b/protocols/MSN/src/msn_global.h
@@ -164,7 +164,6 @@ void stripBBCode(char* src);
void stripColorCode(char* src);
void parseWLID(char* wlid, char** net, char** email, char** inst);
-char* MSN_Base64Decode(const char* str);
char* GetGlobalIp(void);
template <class chartype> void UrlDecode(chartype* str);
diff --git a/protocols/MSN/src/msn_mime.cpp b/protocols/MSN/src/msn_mime.cpp
index 6ce94286da..e511d2017b 100644
--- a/protocols/MSN/src/msn_mime.cpp
+++ b/protocols/MSN/src/msn_mime.cpp
@@ -455,7 +455,7 @@ wchar_t* MimeHeaders::decode(const char* val)
case 'b':
case 'B':
{
- char* dec = MSN_Base64Decode(fld);
+ char* dec = (char*)mir_base64_decode(fld, 0);
strcpy(fld, dec);
mir_free(dec);
break;
@@ -501,7 +501,7 @@ char* MimeHeaders::decodeMailBody(char* msgBody)
else *(dst++) = *(src++);
}
*dst = 0;
- res = MSN_Base64Decode(msgBody);
+ res = (char*)mir_base64_decode(msgBody, 0);
}
else
{
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index bf31569fd8..dad0f8d79a 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -165,13 +165,10 @@ char* MSN_GetAvatarHash(char* szContext, char** pszUrl)
ezxml_t xmli = ezxml_parse_str(NEWSTR_ALLOCA(szContext), strlen(szContext));
const char *szAvatarHash = ezxml_attr(xmli, "SHA1D");
if (szAvatarHash != NULL) {
- BYTE szActHash[MIR_SHA1_HASH_SIZE+2] = {0};
- const size_t len = strlen(szAvatarHash);
-
- NETLIBBASE64 nlb = { (char*)szAvatarHash, (int)len, szActHash, sizeof(szActHash) };
- int decod = CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM(&nlb));
- if (decod != 0 && nlb.cbDecoded > 0)
- res = arrayToHex(szActHash, nlb.cbDecoded);
+ unsigned hashLen;
+ mir_ptr<BYTE> hash((BYTE*)mir_base64_decode(szAvatarHash, &hashLen));
+ if (hash)
+ res = arrayToHex(hash, hashLen);
if (pszUrl) {
const char *pszUrlAttr;
@@ -313,7 +310,6 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen
{
mir_sha1_ctx sha1ctx;
BYTE sha1c[MIR_SHA1_HASH_SIZE], sha1d[MIR_SHA1_HASH_SIZE];
- char szSha1c[41], szSha1d[41];
char *szFname = mir_utf8encodeT(sztFname);
@@ -321,10 +317,7 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen
mir_sha1_append(&sha1ctx, (mir_sha1_byte_t*)pData, (int)cbLen);
mir_sha1_finish(&sha1ctx, sha1d);
- {
- NETLIBBASE64 nlb = { szSha1d, sizeof(szSha1d), (PBYTE)sha1d, sizeof(sha1d) };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
- }
+ ptrA szSha1d( mir_base64_encode((PBYTE)sha1d, sizeof(sha1d)));
mir_sha1_init(&sha1ctx);
ezxml_t xmlp = ezxml_new("msnobj");
@@ -352,15 +345,12 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen
ezxml_set_attr(xmlp, "Friendly", "AAA=");
mir_sha1_append(&sha1ctx, (PBYTE)"SHA1D", 5);
- mir_sha1_append(&sha1ctx, (PBYTE)szSha1d, (int)strlen(szSha1d));
+ mir_sha1_append(&sha1ctx, (PBYTE)(char*)szSha1d, (int)strlen(szSha1d));
ezxml_set_attr(xmlp, "SHA1D", szSha1d);
mir_sha1_finish(&sha1ctx, sha1c);
- {
- NETLIBBASE64 nlb = { szSha1c, sizeof(szSha1c), (PBYTE)sha1c, sizeof(sha1c) };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
- }
+ ptrA szSha1c( mir_base64_encode((PBYTE)sha1c, sizeof(sha1c)));
// ezxml_set_attr(xmlp, "SHA1C", szSha1c);
@@ -1293,32 +1283,6 @@ char* TWinErrorCode::getText()
return mErrorText;
}
-char* MSN_Base64Decode(const char* str)
-{
- if (str == NULL) return NULL;
-
- size_t len = strlen(str);
- size_t reslen = Netlib_GetBase64DecodedBufferSize(len) + 4;
- char* res = (char*)mir_alloc(reslen);
-
- char* p = const_cast< char* >(str);
- if (len & 3) { // fix for stupid Kopete's base64 encoder
- char* p1 = (char*)alloca(len+5);
- memcpy(p1, p, len);
- p = p1;
- p1 += len;
- for (int i = 4 - (len & 3); i > 0; i--, p1++, len++)
- *p1 = '=';
- *p1 = 0;
- }
-
- NETLIBBASE64 nlb = { p, (int)len, (PBYTE)res, (int)reslen };
- if (!CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM(&nlb))) nlb.cbDecoded = 0;
- res[nlb.cbDecoded] = 0;
-
- return res;
-}
-
bool CMsnProto::MSN_IsMyContact(HANDLE hContact)
{
const char* szProto = GetContactProto(hContact);
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp
index 46a24488a7..09c32ac1d9 100644
--- a/protocols/MSN/src/msn_p2p.cpp
+++ b/protocols/MSN/src/msn_p2p.cpp
@@ -1215,7 +1215,7 @@ void CMsnProto::p2p_InitFileTransfer(
if (p2p_getSessionByID(dwSessionId))
return;
- szContext = MSN_Base64Decode(szContext);
+ szContext = (char*)mir_base64_decode(szContext, 0);
filetransfer* ft = new filetransfer(this);
ft->p2p_acksessid = MSN_GenRandom();
@@ -2311,10 +2311,8 @@ void CMsnProto::p2p_invite(unsigned iAppID, filetransfer* ft, const char *wlid)
if (!ft->bAccepted)
ft->p2p_sessionid = MSN_GenRandom();
- int cbContextEnc = Netlib_GetBase64EncodedBufferSize((int)cbContext);
- char* szContextEnc = (char*)alloca(cbContextEnc);
- NETLIBBASE64 nlb = { szContextEnc, cbContextEnc, (PBYTE)pContext, (int)cbContext };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+ ptrA szContextEnc( mir_base64_encode((PBYTE)pContext, (unsigned)cbContext));
+ int cbContextEnc = lstrlenA(szContextEnc);
MimeHeaders chdrs(10);
chdrs.addString("EUF-GUID", szAppID);
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp
index d0e1e6b32c..2010a9b6dd 100644
--- a/protocols/MSN/src/msn_soapab.cpp
+++ b/protocols/MSN/src/msn_soapab.cpp
@@ -972,15 +972,8 @@ bool CMsnProto::MSN_ABFind(const char* szMethod, const char* szGuid, bool deltas
if (!msnLoggedIn && msnNsThread)
{
char *szCircleTicket = ezxml_txt(ezxml_get(body, "CircleResult", 0, "CircleTicket", -1));
- int cbCircleTicket = (int)strlen(szCircleTicket);
-
- int cbCircleTicketEnc = Netlib_GetBase64EncodedBufferSize(cbCircleTicket);
- char* szCircleTicketEnc = (char*)alloca(cbCircleTicketEnc);
-
- NETLIBBASE64 nlb = { szCircleTicketEnc, cbCircleTicketEnc, (PBYTE)szCircleTicket, cbCircleTicket };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
-
- if (szCircleTicketEnc[0])
+ ptrA szCircleTicketEnc( mir_base64_encode((PBYTE)szCircleTicket, (unsigned)strlen(szCircleTicket)));
+ if (szCircleTicketEnc)
msnNsThread->sendPacket("USR", "SHA A %s", szCircleTicketEnc);
}
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp
index cbff0068a8..55d46c4c80 100644
--- a/protocols/MSN/src/msn_srv.cpp
+++ b/protocols/MSN/src/msn_srv.cpp
@@ -341,33 +341,23 @@ void CMsnProto::MSN_SetNicknameUtf(const char* nickname)
void CMsnProto::msn_storeAvatarThread(void* arg)
{
StoreAvatarData* dat = (StoreAvatarData*)arg;
- char *szEncBuf = NULL;
+ ptrA szEncBuf;
if (dat)
- {
- size_t szEncPngSize = Netlib_GetBase64EncodedBufferSize(dat->dataSize);
- szEncBuf = (char*)mir_alloc(szEncPngSize);
- NETLIBBASE64 nlb = { szEncBuf, (int)szEncPngSize, dat->data, (int)dat->dataSize };
- CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
- }
+ szEncBuf = mir_base64_encode(dat->data, (unsigned)dat->dataSize);
if (photoid[0] && dat)
- {
MSN_StoreUpdateDocument(dat->szName, dat->szMimeType, szEncBuf);
- }
- else
- {
+ else {
MSN_StoreUpdateProfile(NULL, NULL, 1);
- if (photoid[0])
- {
+ if (photoid[0]) {
MSN_StoreDeleteRelationships(true);
MSN_StoreDeleteRelationships(false);
photoid[0] = 0;
}
- if (dat)
- {
+ if (dat) {
MSN_StoreCreateDocument(dat->szName, dat->szMimeType, szEncBuf);
MSN_StoreCreateRelationships();
}
@@ -379,7 +369,6 @@ void CMsnProto::msn_storeAvatarThread(void* arg)
if (dat)
{
- mir_free(szEncBuf);
mir_free(dat->szName);
mir_free(dat->data);
mir_free(dat);