From be0ea932723003e4319500883aa7ef2abba38c4b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 1 Dec 2013 21:51:12 +0000 Subject: first lines of password UI code git-svn-id: http://svn.miranda-ng.org/main/trunk@7028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcrypt.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'plugins/Db3x_mmap/src/dbcrypt.cpp') diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 79a3744462..4cd24f2ee9 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -149,26 +149,15 @@ LBL_CreateProvider: if ((m_crypto = pProvider->pFactory()) == NULL) return 3; - size_t iKeyLength = m_crypto->getKeyLength(); - dbv.type = DBVT_BLOB; dbcgs.szSetting = "StoredKey"; if (GetContactSetting(NULL, &dbcgs)) { LBL_SetNewKey: m_crypto->generateKey(); // unencrypted key - - BYTE *pKey = (BYTE*)_alloca(iKeyLength); - m_crypto->getKey(pKey, iKeyLength); - - DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "StoredKey" }; - dbcws.value.type = DBVT_BLOB; - dbcws.value.cpbVal = (WORD)iKeyLength; - dbcws.value.pbVal = pKey; - WriteContactSetting(NULL, &dbcws); - - memset(pKey, 0, iKeyLength); + StoreKey(); } else { + size_t iKeyLength = m_crypto->getKeyLength(); if (dbv.cpbVal != (WORD)iKeyLength) goto LBL_SetNewKey; @@ -186,5 +175,21 @@ LBL_SetNewKey: DBWrite(0, &dbSignature, sizeof(dbSignature)); } + InitDialogs(); return 0; } + +void CDb3Mmap::StoreKey() +{ + size_t iKeyLength = m_crypto->getKeyLength(); + BYTE *pKey = (BYTE*)_alloca(iKeyLength); + m_crypto->getKey(pKey, iKeyLength); + + DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "StoredKey" }; + dbcws.value.type = DBVT_BLOB; + dbcws.value.cpbVal = (WORD)iKeyLength; + dbcws.value.pbVal = pKey; + WriteContactSetting(NULL, &dbcws); + + SecureZeroMemory(pKey, iKeyLength); +} -- cgit v1.2.3