diff options
Diffstat (limited to 'plugins/Db3x_mmap/src')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 16 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 1 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/ui.cpp | 6 |
3 files changed, 16 insertions, 7 deletions
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index e6bb7e704b..4193316d17 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -161,11 +161,9 @@ LBL_SetNewKey: if (dbv.cpbVal != (WORD)iKeyLength)
goto LBL_SetNewKey;
- if (!m_crypto->setKey(dbv.pbVal, iKeyLength)) {
+ if (!m_crypto->setKey(dbv.pbVal, iKeyLength))
if (!EnterPassword(dbv.pbVal, iKeyLength)) // password protected?
return 4;
- m_bUsesPassword = true;
- }
FreeVariant(&dbv);
}
@@ -198,3 +196,15 @@ void CDb3Mmap::StoreKey() SecureZeroMemory(pKey, iKeyLength);
}
+
+void CDb3Mmap::SetPassword(LPCTSTR ptszPassword)
+{
+ if (ptszPassword == NULL || *ptszPassword == 0) {
+ m_bUsesPassword = false;
+ m_crypto->setPassword(NULL);
+ }
+ else {
+ m_bUsesPassword = true;
+ m_crypto->setPassword(ptrA(mir_utf8encodeT(ptszPassword)));
+ }
+}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 9415524871..1d5fae78a6 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -300,6 +300,7 @@ struct CDb3Mmap : public CDb3Base ~CDb3Mmap();
void StoreKey(void);
+ void SetPassword(const TCHAR *ptszPassword);
protected:
virtual DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName);
diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index 1296808fcf..fa22d1008b 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -127,6 +127,7 @@ bool CDb3Mmap::EnterPassword(const BYTE *pKey, const size_t keyLen) m_crypto->setPassword(ptrA(mir_utf8encodeT(param.newPass)));
if (m_crypto->setKey(pKey, keyLen)) {
+ m_bUsesPassword = true;
SecureZeroMemory(¶m, sizeof(param));
return true;
}
@@ -233,10 +234,7 @@ static INT_PTR ChangePassword(void* obj, LPARAM, LPARAM) CDb3Mmap *db = (CDb3Mmap*)obj;
DlgChangePassParam param = { db };
if (IDOK == DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), 0, sttChangePassword, (LPARAM)¶m)) {
- if (param.newPass[0])
- db->m_crypto->setPassword(ptrA(mir_utf8encodeT(param.newPass)));
- else
- db->m_crypto->setPassword(NULL);
+ db->SetPassword(param.newPass);
db->StoreKey();
}
|