summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-20 13:29:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-20 13:29:51 +0000
commit9845eae91ff808b703e430da0f74ea01b4c0a157 (patch)
tree1e459c957406003f575c1d28d148490c92428eca
parentca2a90cb613a130b878b9ac4db6708bbd140b66b (diff)
own password storage removed from MRA
git-svn-id: http://svn.miranda-ng.org/main/trunk@6946 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/MRA/src/Mra.h16
-rw-r--r--protocols/MRA/src/MraProto.h24
-rw-r--r--protocols/MRA/src/Mra_functions.cpp201
-rw-r--r--protocols/MRA/src/Mra_options.cpp14
4 files changed, 87 insertions, 168 deletions
diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h
index 770a0e18bb..583add72c5 100644
--- a/protocols/MRA/src/Mra.h
+++ b/protocols/MRA/src/Mra.h
@@ -6,7 +6,7 @@
#define _CRT_SECURE_NO_WARNINGS
-#pragma warning(disable:4267)
+#pragma warning(disable:4267 4312)
//#define CRTDLL
@@ -146,16 +146,16 @@ __forceinline BinBuffer& operator >>(BinBuffer& buf, CMStringW &sVar) { buf.get
/////////////////////////////////////////////////////////////////////////////
-BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
-BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
+bool DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
+bool DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
-BOOL DB_GetStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringA &Ret);
-BOOL DB_GetStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringW &Ret);
+bool DB_GetStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringA &Ret);
+bool DB_GetStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringW &Ret);
-BOOL DB_SetStringExA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringA &value);
-BOOL DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringW &value);
+bool DB_SetStringExA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringA &value);
+bool DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringW &value);
-BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
+bool DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
#include "MraConstans.h"
#include "MraProto.h"
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h
index 6adc51259a..791a15bc6d 100644
--- a/protocols/MRA/src/MraProto.h
+++ b/protocols/MRA/src/MraProto.h
@@ -89,29 +89,29 @@ struct CMraProto : public PROTO<CMraProto>
__forceinline void MraPopupShowFromAgentW(DWORD dwType, DWORD dwFlags, LPCWSTR lpszMessage) {
MraPopupShowFromContactW(NULL, dwType, dwFlags, lpszMessage); }
- __forceinline BOOL mraGetStaticStringA(HANDLE Contact, const char *ValueName, char *Ret, size_t RetBuffSize, size_t *pRetBuffSize) {
+ __forceinline bool mraGetStaticStringA(HANDLE Contact, const char *ValueName, char *Ret, size_t RetBuffSize, size_t *pRetBuffSize) {
return DB_GetStaticStringA(Contact, m_szModuleName, ValueName, Ret, RetBuffSize, pRetBuffSize); }
- __forceinline BOOL mraGetStaticStringW(HANDLE Contact, const char *ValueName, WCHAR *Ret, size_t RetBuffSize, size_t *pRetBuffSize) {
+ __forceinline bool mraGetStaticStringW(HANDLE Contact, const char *ValueName, WCHAR *Ret, size_t RetBuffSize, size_t *pRetBuffSize) {
return DB_GetStaticStringW(Contact, m_szModuleName, ValueName, Ret, RetBuffSize, pRetBuffSize); }
- __forceinline BOOL mraGetStringA(HANDLE Contact, const char *ValueName, CMStringA &Ret) {
+ __forceinline bool mraGetStringA(HANDLE Contact, const char *ValueName, CMStringA &Ret) {
return DB_GetStringA(Contact, m_szModuleName, ValueName, Ret); }
- __forceinline BOOL mraGetStringW(HANDLE Contact, const char *ValueName, CMStringW &Ret) {
+ __forceinline bool mraGetStringW(HANDLE Contact, const char *ValueName, CMStringW &Ret) {
return DB_GetStringW(Contact, m_szModuleName, ValueName, Ret); }
- __forceinline BOOL mraSetStringA(HANDLE Contact, const char *valueName, const CMStringA &parValue) {
+ __forceinline bool mraSetStringA(HANDLE Contact, const char *valueName, const CMStringA &parValue) {
return DB_SetStringExA(Contact, m_szModuleName, valueName, parValue); }
- __forceinline BOOL mraSetStringW(HANDLE Contact, const char *valueName, const CMStringW &parValue) {
+ __forceinline bool mraSetStringW(HANDLE Contact, const char *valueName, const CMStringW &parValue) {
return DB_SetStringExW(Contact, m_szModuleName, valueName, parValue); }
- __forceinline BOOL mraSetStringExA(HANDLE Contact, const char *valueName, const CMStringA &parValue) {
+ __forceinline bool mraSetStringExA(HANDLE Contact, const char *valueName, const CMStringA &parValue) {
return DB_SetStringExA(Contact, m_szModuleName, valueName, parValue); }
- __forceinline BOOL mraSetStringExW(HANDLE Contact, const char *valueName, const CMStringW &parValue) {
+ __forceinline bool mraSetStringExW(HANDLE Contact, const char *valueName, const CMStringW &parValue) {
return DB_SetStringExW(Contact, m_szModuleName, valueName, parValue); }
- __forceinline BOOL mraWriteContactSettingBlob(HANDLE hContact, const char *lpszValueName, LPVOID lpbValue, size_t dwValueSize) {
- return db_set_blob(hContact, m_szModuleName, lpszValueName, lpbValue, dwValueSize); }
- __forceinline BOOL mraGetContactSettingBlob(HANDLE hContact, const char *lpszValueName, LPVOID lpbRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize) {
+ __forceinline bool mraWriteContactSettingBlob(HANDLE hContact, const char *lpszValueName, LPVOID lpbValue, size_t dwValueSize) {
+ return db_set_blob(hContact, m_szModuleName, lpszValueName, lpbValue, dwValueSize) != 0; }
+ __forceinline bool mraGetContactSettingBlob(HANDLE hContact, const char *lpszValueName, LPVOID lpbRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize) {
return DB_GetContactSettingBlob(hContact, m_szModuleName, lpszValueName, lpbRet, dwRetBuffSize, pdwRetBuffSize); }
// ====| Services |====================================================================
@@ -289,9 +289,7 @@ struct CMraProto : public PROTO<CMraProto>
DWORD ProtoBroadcastAckAsync(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam);
CMStringA CreateBlobFromContact(HANDLE hContact, const CMStringW &wszRequestReason);
- bool SetPassDB(const CMStringA& pass);
bool GetPassDB(CMStringA& pass);
- bool GetPassDB_v1(CMStringA &res);
bool MraRequestXStatusDetails(DWORD dwXStatus);
bool MraSendReplyBlogStatus(HANDLE hContact);
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp
index 7bce3fba9b..83f0ccd79c 100644
--- a/protocols/MRA/src/Mra_functions.cpp
+++ b/protocols/MRA/src/Mra_functions.cpp
@@ -170,9 +170,9 @@ void MraAddrListFree(MRA_ADDR_LIST *pmalAddrList)
}
}
-BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
+bool DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
{
- BOOL bRet = FALSE;
+ bool bRet = false;
size_t dwReadedStringLen, dwRetBuffSizeLocal;
DBVARIANT dbv = {0};
if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv) == 0)
@@ -182,7 +182,7 @@ BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam
{
dwRetBuffSizeLocal = WideCharToMultiByte(MRA_CODE_PAGE, 0, dbv.pwszVal, dwReadedStringLen, lpszRetBuff, dwRetBuffSize, NULL, NULL);
(*((CHAR*)(lpszRetBuff+dwRetBuffSizeLocal))) = 0;
- bRet = TRUE;
+ bRet = true;
}else {
dwRetBuffSizeLocal = dwReadedStringLen;
if (lpszRetBuff && dwRetBuffSize >= sizeof(WORD)) (*((WORD*)lpszRetBuff)) = 0;
@@ -199,9 +199,9 @@ BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam
}
// sizes in wchars
-BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpwszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
+bool DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpwszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
{
- BOOL bRet = FALSE;
+ bool bRet = false;
size_t dwReadedStringLen;
DBVARIANT dbv = {0};
if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv) == 0)
@@ -211,7 +211,7 @@ BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam
{
memmove(lpwszRetBuff, dbv.pszVal, (dwReadedStringLen*sizeof(WCHAR)));//include null terminated
(*((WCHAR*)(lpwszRetBuff+dwReadedStringLen))) = 0;
- bRet = TRUE;
+ bRet = true;
}else {
if (lpwszRetBuff && dwRetBuffSize >= sizeof(WCHAR)) (*((WCHAR*)lpwszRetBuff)) = 0;
}
@@ -226,65 +226,62 @@ BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueNam
return bRet;
}
-BOOL DB_GetStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringA& res)
+bool DB_GetStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringA& res)
{
char *szRes = db_get_sa(hContact, lpszModule, lpszValueName);
if (szRes) {
res = szRes;
mir_free(szRes);
- return TRUE;
+ return true;
}
res.Empty();
- return FALSE;
+ return false;
}
-BOOL DB_GetStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringW& res)
+bool DB_GetStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, CMStringW& res)
{
WCHAR *szRes = db_get_wsa(hContact, lpszModule, lpszValueName);
if (szRes) {
res = szRes;
mir_free(szRes);
- return TRUE;
+ return true;
}
res.Empty();
- return FALSE;
+ return false;
}
-BOOL DB_SetStringExA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringA &szValue)
+bool DB_SetStringExA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringA &szValue)
{
if (szValue.IsEmpty()) {
db_unset(hContact, lpszModule, lpszValueName);
return true;
}
- return db_set_s(hContact, lpszModule, lpszValueName, szValue);
+ return db_set_s(hContact, lpszModule, lpszValueName, szValue) != 0;
}
-BOOL DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringW &szValue)
+bool DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, const CMStringW &szValue)
{
if (szValue.IsEmpty()) {
db_unset(hContact, lpszModule, lpszValueName);
return true;
}
- return db_set_ws(hContact, lpszModule, lpszValueName, szValue);
+ return db_set_ws(hContact, lpszModule, lpszValueName, szValue) != 0;
}
-BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
+bool DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
{
- BOOL bRet = FALSE;
+ bool bRet = false;
DBVARIANT dbv;
- if (db_get(hContact, lpszModule, lpszValueName, &dbv) == 0)
- {
- if (dbv.type == DBVT_BLOB)
- {
- if (dwRetBuffSize >= dbv.cpbVal)
- {
+ if (db_get(hContact, lpszModule, lpszValueName, &dbv) == 0) {
+ if (dbv.type == DBVT_BLOB) {
+ if (dwRetBuffSize >= dbv.cpbVal) {
memmove(lpRet, dbv.pbVal, dbv.cpbVal);
- bRet = TRUE;
+ bRet = true;
}
if (pdwRetBuffSize) (*pdwRetBuffSize) = dbv.cpbVal;
}
@@ -292,9 +289,9 @@ BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszVal
}
else {
if (pdwRetBuffSize) (*pdwRetBuffSize) = 0;
- bRet = FALSE;
+ bRet = false;
}
- return(bRet);
+ return bRet;
}
DWORD CMraProto::MraMoveContactToGroup(HANDLE hContact, DWORD dwGroupID, LPCTSTR ptszName)
@@ -1325,69 +1322,13 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD
/////////////////////////////////////////////////////////////////////////////////////////
-static DWORD MemFillRandom(LPVOID lpBuff, size_t dwBuffSize)
-{
- DWORD dwRetErrorCode;
-
- if (lpBuff && dwBuffSize) {
- HCRYPTPROV hCryptProv = NULL;
-
- if (CryptAcquireContext(&hCryptProv, NULL, MS_STRONG_PROV, PROV_RSA_FULL, 0) == FALSE && GetLastError() == NTE_BAD_KEYSET)
- CryptAcquireContext(&hCryptProv, NULL, MS_STRONG_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET);
-
- if (hCryptProv) {
- if (CryptGenRandom(hCryptProv, dwBuffSize, (BYTE*)lpBuff))
- dwRetErrorCode = NO_ERROR;
- else
- dwRetErrorCode = GetLastError();
- }
- else dwRetErrorCode = GetLastError();
-
- CryptReleaseContext(hCryptProv, 0);
- }
- else dwRetErrorCode = ERROR_INVALID_HANDLE;
-
- return dwRetErrorCode;
-}
-
-bool CMraProto::SetPassDB(const CMStringA& pass)
+bool CMraProto::GetPassDB(CMStringA &res)
{
- if (pass.GetLength() >= 128)
- return false;
+ int storageType = getDword("pCryptVer", 0);
+ if (storageType == 0)
+ return mraGetStringA(NULL, "Password", res) != 0;
- CMStringA szEmail;
- if ( !mraGetStringA(NULL, "e-mail", szEmail))
- return false;
-
- BYTE btRandomData[256], btCryptedPass[256] = {0}, bthmacSHA1[MIR_SHA1_HASH_SIZE] = {0};
- MemFillRandom(btRandomData, sizeof(btRandomData));
-
- SHA1GetDigest((void*)pass.c_str(), pass.GetLength(), &btCryptedPass[1]);
-
- //BASE64EncodeUnSafe(lpszBuff, dwBuffSize, &btCryptedPass[(1+MIR_SHA1_HASH_SIZE)], (sizeof(btCryptedPass)-1), &dwBuffSize);
- memmove(&btCryptedPass[(1+MIR_SHA1_HASH_SIZE)], pass.c_str(), pass.GetLength());
- btCryptedPass[0] = (BYTE)pass.GetLength();
- //memmove(&btCryptedPass[1], lpszBuff, dwBuffSize);
-
- mir_hmac_sha1(bthmacSHA1, (BYTE*)szEmail.c_str(), szEmail.GetLength(), btRandomData, sizeof(btRandomData));
-
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
- RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, sizeof(btRandomData));
- CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
-
- setDword("pCryptVer", MRA_PASS_CRYPT_VER);
- mraWriteContactSettingBlob(NULL, "pCryptData", btRandomData, sizeof(btRandomData));
- mraWriteContactSettingBlob(NULL, "pCryptPass", btCryptedPass, sizeof(btCryptedPass));
- return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-bool CMraProto::GetPassDB_v1(CMStringA &res)
-{
- BYTE btRandomData[256] = {0}, btCryptedPass[256] = {0}, bthmacSHA1[MIR_SHA1_HASH_SIZE] = {0};
+ BYTE btRandomData[256] = { 0 }, btCryptedPass[256] = { 0 }, bthmacSHA1[MIR_SHA1_HASH_SIZE] = { 0 };
size_t dwRandomDataSize, dwCryptedPass, dwPassSize;
CMStringA szEmail;
@@ -1398,61 +1339,43 @@ bool CMraProto::GetPassDB_v1(CMStringA &res)
if (mraGetStringA(NULL, "e-mail", szEmail)) {
mir_hmac_sha1(bthmacSHA1, (BYTE*)szEmail.c_str(), szEmail.GetLength(), btRandomData, sizeof(btRandomData));
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
- CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
- RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
-
- dwPassSize = (*btCryptedPass);
- btCryptedPass[dwPassSize+1+MIR_SHA1_HASH_SIZE] = 0;
-
- unsigned dwDecodedSize;
- mir_ptr<BYTE> pDecoded((PBYTE)mir_base64_decode((LPCSTR)&btCryptedPass[1+MIR_SHA1_HASH_SIZE], &dwDecodedSize));
- SHA1GetDigest(pDecoded, dwDecodedSize, btRandomData);
- if ( !memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE)) {
+ if (storageType == 2) {
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+ CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
+ RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+
+ dwPassSize = btCryptedPass[0];
+ SHA1GetDigest(&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], dwPassSize, btRandomData);
+ if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
+ return false;
+
+ res = CMStringA((char*)&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], dwPassSize);
+ }
+ else if (storageType == 1) {
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+ CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
+ RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+
+ dwPassSize = (*btCryptedPass);
+ btCryptedPass[dwPassSize + 1 + MIR_SHA1_HASH_SIZE] = 0;
+
+ unsigned dwDecodedSize;
+ mir_ptr<BYTE> pDecoded((PBYTE)mir_base64_decode((LPCSTR)&btCryptedPass[1 + MIR_SHA1_HASH_SIZE], &dwDecodedSize));
+ SHA1GetDigest(pDecoded, dwDecodedSize, btRandomData);
+ if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
+ return false;
res = CMStringA((LPSTR)(PBYTE)pDecoded, dwDecodedSize);
- return true;
}
+ else return false;
}
- return false;
-}
-
-bool CMraProto::GetPassDB(CMStringA &res)
-{
- switch (getDword("pCryptVer", 0)) {
- case 1:
- return GetPassDB_v1(res);
- case 2:
- break;
- default:
- return false;
- }
-
- CMStringA szEmail;
- BYTE btRandomData[256] = {0}, btCryptedPass[256] = {0}, bthmacSHA1[MIR_SHA1_HASH_SIZE] = {0};
- size_t dwRandomDataSize, dwCryptedPass;
-
- if (mraGetContactSettingBlob(NULL, "pCryptData", btRandomData, sizeof(btRandomData), &dwRandomDataSize))
- if (dwRandomDataSize == sizeof(btRandomData))
- if (mraGetContactSettingBlob(NULL, "pCryptPass", btCryptedPass, sizeof(btCryptedPass), &dwCryptedPass))
- if (dwCryptedPass == sizeof(btCryptedPass))
- if (mraGetStringA(NULL, "e-mail", szEmail)) {
- mir_hmac_sha1(bthmacSHA1, (BYTE*)szEmail.GetString(), szEmail.GetLength(), btRandomData, sizeof(btRandomData));
-
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
- CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
- RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
-
- DWORD dwPassSize = btCryptedPass[0];
- SHA1GetDigest(&btCryptedPass[(1+MIR_SHA1_HASH_SIZE)], dwPassSize, btRandomData);
- if ( !memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
- res = CMStringA((char*)&btCryptedPass[(1+MIR_SHA1_HASH_SIZE)], dwPassSize);
- return true;
- }
-
- return false;
+ delSetting("pCryptData");
+ delSetting("pCryptPass");
+ delSetting("pCryptVer");
+ setString("Password", res);
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/MRA/src/Mra_options.cpp b/protocols/MRA/src/Mra_options.cpp
index cfd9cca5b9..5fd6a27b67 100644
--- a/protocols/MRA/src/Mra_options.cpp
+++ b/protocols/MRA/src/Mra_options.cpp
@@ -40,10 +40,9 @@ INT_PTR CALLBACK DlgProcOptsAccount(HWND hWndDlg, UINT msg, WPARAM wParam, LPARA
GetDlgItemText(hWndDlg, IDC_LOGIN, szBuff, SIZEOF(szBuff));
ppro->setTString(NULL, "e-mail", szBuff);
- char szPass[MAX_EMAIL_LEN];
- if (GetDlgItemTextA(hWndDlg, IDC_PASSWORD, szPass, SIZEOF(szPass))) {
- ppro->SetPassDB(szPass);
- SecureZeroMemory(szPass, SIZEOF(szPass));
+ if (GetDlgItemText(hWndDlg, IDC_PASSWORD, szBuff, SIZEOF(szBuff))) {
+ ppro->setTString("Password", szBuff);
+ SecureZeroMemory(szBuff, SIZEOF(szBuff));
}
return TRUE;
}
@@ -93,10 +92,9 @@ INT_PTR CALLBACK DlgProcAccount(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lP
GetDlgItemText(hWndDlg, IDC_LOGIN, szBuff, SIZEOF(szBuff));
ppro->mraSetStringW(NULL, "e-mail", szBuff);
- char szPass[MAX_EMAIL_LEN];
- if (GetDlgItemTextA(hWndDlg, IDC_PASSWORD, szPass, SIZEOF(szPass))) {
- ppro->SetPassDB(szPass);
- SecureZeroMemory(szPass, SIZEOF(szPass));
+ if (GetDlgItemText(hWndDlg, IDC_PASSWORD, szBuff, SIZEOF(szBuff))) {
+ ppro->setTString("Password", szBuff);
+ SecureZeroMemory(szBuff, sizeof(szBuff));
}
return TRUE;
}