summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-14 23:13:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-14 23:13:59 +0000
commit1c3fd025362de5cfd256f83808f30018410bc4c5 (patch)
treeee4c4e7f0b971a2c478d38e492dac96285b338d3 /plugins
parentbd49c3201234f447a4fc951ea652532d973c07b1 (diff)
missing file
git-svn-id: http://svn.miranda-ng.org/main/trunk@6911 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp
new file mode 100644
index 0000000000..42907f46d1
--- /dev/null
+++ b/plugins/Db3x_mmap/src/dbcrypt.cpp
@@ -0,0 +1,103 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright 2012-13 Miranda NG project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+
+int CDb3Base::InitCrypt()
+{
+ CRYPTO_PROVIDER *pProvider;
+
+ DBVARIANT dbv = { 0 };
+ dbv.type = DBVT_ASCIIZ;
+ DBCONTACTGETSETTING dbcgs = { "CryptoEngine", "Provider", &dbv };
+ if (GetContactSettingStr(NULL, &dbcgs)) {
+ CRYPTO_PROVIDER **ppProvs;
+ int iNumProvs;
+ Crypto_EnumProviders(&iNumProvs, &ppProvs);
+ if (iNumProvs == 0)
+ return 1;
+
+ pProvider = ppProvs[0]; //!!!!!!!!!!!!!!!!!!
+
+ DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" };
+ dbcws.value.type = DBVT_ASCIIZ;
+ dbcws.value.pszVal = pProvider->pszName;
+ WriteContactSetting(NULL, &dbcws);
+ }
+ else {
+ pProvider = Crypto_GetProvider(dbv.pszVal);
+ FreeVariant(&dbv);
+ if (pProvider == NULL)
+ return 2;
+ }
+
+ 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)) {
+ 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);
+ }
+ else {
+ if (dbv.cpbVal != (WORD)iKeyLength)
+ return 4;
+
+ m_crypto->setKey(dbv.pbVal, iKeyLength);
+ FreeVariant(&dbv);
+ }
+ return 0;
+}
+
+void CDb3Base::EncodeCopyMemory(void *dst, void *src, size_t size)
+{
+ MoveMemory(dst, src, size);
+}
+
+void CDb3Base::DecodeCopyMemory(void *dst, void *src, size_t size)
+{
+ MoveMemory(dst, src, size);
+}
+
+void CDb3Base::EncodeDBWrite(DWORD ofs, void *src, int size)
+{
+ DBWrite(ofs, src, size);
+}
+
+void CDb3Base::DecodeDBWrite(DWORD ofs, void *src, int size)
+{
+ DBWrite(ofs, src, size);
+}