summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdb/src')
-rw-r--r--plugins/Dbx_mdb/src/dbcrypt.cpp103
-rw-r--r--plugins/Dbx_mdb/src/ui.cpp24
2 files changed, 12 insertions, 115 deletions
diff --git a/plugins/Dbx_mdb/src/dbcrypt.cpp b/plugins/Dbx_mdb/src/dbcrypt.cpp
index f13e74aa81..0ff3be3817 100644
--- a/plugins/Dbx_mdb/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdb/src/dbcrypt.cpp
@@ -25,106 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
-//VERY VERY VERY BASIC ENCRYPTION FUNCTION
-
-static void Encrypt(char *msg, BOOL up)
-{
- int jump = (up) ? 5 : -5;
- for (int i = 0; msg[i]; i++)
- msg[i] = msg[i] + jump;
-}
-
-__forceinline void DecodeString(LPSTR buf)
-{
- Encrypt(buf, FALSE);
-}
-
-struct VarDescr
-{
- VarDescr(LPCSTR var, LPCSTR value) :
- szVar(mir_strdup(var)),
- szValue(mir_strdup(value))
- {}
-
- VarDescr(LPCSTR var, LPSTR value) :
- szVar(mir_strdup(var)),
- szValue(value)
- {}
-
- VarDescr(LPCSTR var, PBYTE value, int len) :
- szVar(mir_strdup(var)),
- szValue((char*)memcpy(mir_alloc(len), value, len)),
- iLen(len)
- {}
-
- ptrA szVar, szValue;
- int iLen;
-};
-
-struct SettingUgraderParam
-{
- CDbxMdb *db;
- LPCSTR szModule;
- MCONTACT contactID;
- OBJLIST<VarDescr>* pList;
-};
-
-int sttSettingUgrader(const char *szSetting, LPARAM lParam)
-{
- SettingUgraderParam *param = (SettingUgraderParam*)lParam;
- if (param->db->IsSettingEncrypted(param->szModule, szSetting)) {
- DBVARIANT dbv = { DBVT_UTF8 };
- if (!param->db->GetContactSettingStr(param->contactID, param->szModule, szSetting, &dbv)) {
- if (dbv.type == DBVT_UTF8) {
- DecodeString(dbv.pszVal);
- param->pList->insert(new VarDescr(szSetting, (LPCSTR)dbv.pszVal));
- }
- param->db->FreeVariant(&dbv);
- }
- }
- return 0;
-}
-
-void sttContactEnum(MCONTACT contactID, const char *szModule, CDbxMdb *db)
-{
- OBJLIST<VarDescr> arSettings(1);
- SettingUgraderParam param = { db, szModule, contactID, &arSettings };
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttSettingUgrader;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)&param;
- db->EnumContactSettings(NULL, &dbces);
-
- for (int i = 0; i < arSettings.getCount(); i++) {
- VarDescr &p = arSettings[i];
-
- size_t len;
- BYTE *pResult = db->m_crypto->encodeString(p.szValue, &len);
- if (pResult != NULL) {
- DBCONTACTWRITESETTING dbcws = { szModule, p.szVar };
- dbcws.value.type = DBVT_ENCRYPTED;
- dbcws.value.pbVal = pResult;
- dbcws.value.cpbVal = (WORD)len;
- db->WriteContactSetting(contactID, &dbcws);
-
- mir_free(pResult);
- }
- }
-}
-
-int sttModuleEnum(const char *szModule, DWORD, LPARAM lParam)
-{
- CDbxMdb *db = (CDbxMdb*)lParam;
- sttContactEnum(NULL, szModule, db);
-
- for (MCONTACT contactID = db->FindFirstContact(); contactID; contactID = db->FindNextContact(contactID))
- sttContactEnum(contactID, szModule, db);
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
int CDbxMdb::InitCrypt()
{
@@ -191,9 +91,6 @@ int CDbxMdb::InitCrypt()
FreeVariant(&dbv);
}
- if (bMissingKey)
- EnumModuleNames(sttModuleEnum, this);
-
dbv.type = DBVT_BYTE;
if (!GetContactSetting(NULL, "CryptoEngine", "DatabaseEncryption", &dbv))
m_bEncrypted = dbv.bVal != 0;
diff --git a/plugins/Dbx_mdb/src/ui.cpp b/plugins/Dbx_mdb/src/ui.cpp
index aa7a2ecd11..353a2d01a9 100644
--- a/plugins/Dbx_mdb/src/ui.cpp
+++ b/plugins/Dbx_mdb/src/ui.cpp
@@ -27,7 +27,7 @@ struct DlgChangePassParam
{
CDbxMdb *db;
TCHAR newPass[100];
- int wrongPass;
+ unsigned short wrongPass;
};
#define MS_DB_CHANGEPASSWORD "DB/UI/ChangePassword"
@@ -120,13 +120,15 @@ static INT_PTR CALLBACK sttEnterPassword(HWND hwndDlg, UINT uMsg, WPARAM wParam,
bool CDbxMdb::EnterPassword(const BYTE *pKey, const size_t keyLen)
{
DlgChangePassParam param = { this };
- while (true) {
+ while (true)
+ {
// Esc pressed
if (IDOK != DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LOGIN), 0, sttEnterPassword, (LPARAM)&param))
return false;
- m_crypto->setPassword(ptrA(mir_utf8encodeT(param.newPass)));
- if (m_crypto->setKey(pKey, keyLen)) {
+ m_crypto->setPassword(pass_ptrA(mir_utf8encodeT(param.newPass)));
+ if (m_crypto->setKey(pKey, keyLen))
+ {
m_bUsesPassword = true;
SecureZeroMemory(&param, sizeof(param));
return true;
@@ -140,11 +142,13 @@ bool CDbxMdb::EnterPassword(const BYTE *pKey, const size_t keyLen)
static bool CheckOldPassword(HWND hwndDlg, CDbxMdb *db)
{
- if (db->usesPassword()) {
+ if (db->usesPassword())
+ {
TCHAR buf[100];
GetDlgItemText(hwndDlg, IDC_OLDPASS, buf, _countof(buf));
- ptrA oldPass(mir_utf8encodeT(buf));
- if (!db->m_crypto->checkPassword(oldPass)) {
+ pass_ptrA oldPass(mir_utf8encodeT(buf));
+ if (!db->m_crypto->checkPassword(oldPass))
+ {
SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Wrong old password entered!"));
return false;
}
@@ -311,8 +315,6 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, db);
- // main menu item
- // main menu item
CMenuItem mi;
// main menu item
@@ -320,10 +322,8 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
Menu_ConfigureItem(mi.root, MCI_OPT_UID, "F7C5567C-D1EE-484B-B4F6-24677A5AAAEF");
SET_UID(mi, 0x50321866, 0xba1, 0x46dd, 0xb3, 0xa6, 0xc3, 0xcc, 0x55, 0xf2, 0x42, 0x9e);
- mi.flags = CMIF_TCHAR;
mi.hIcolibItem = iconList[1].hIcolib;
- _A2T tszTitle(db->GetMenuTitle());
- mi.name.t = tszTitle;
+ mi.name.a = db->GetMenuTitle();
mi.pszService = MS_DB_CHANGEPASSWORD;
hSetPwdMenu = Menu_AddMainMenuItem(&mi);
return 0;