diff options
author | George Hazan <george.hazan@gmail.com> | 2013-12-01 21:51:12 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-12-01 21:51:12 +0000 |
commit | be0ea932723003e4319500883aa7ef2abba38c4b (patch) | |
tree | c0eee66c79f8aaf0e3b97f0ec803828b1e0afd68 /plugins/Db3x_mmap/src/dbcrypt.cpp | |
parent | f0dd963ab37b2ff412b4b1e0b9459d61d42ab9d4 (diff) |
first lines of password UI code
git-svn-id: http://svn.miranda-ng.org/main/trunk@7028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbcrypt.cpp')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
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);
+}
|