summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-12 19:51:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-12 19:51:48 +0000
commit72eb97b648861bcd03744a027eb09d0410acdf1e (patch)
treee867e779c9ed9edecba9e4e31cd062d338cacad3 /src
parentfd82bb19cb63232fbd5efff23ee2941d648047a9 (diff)
first MS_CRYPTO_REGISTER_ENGINE implementation
git-svn-id: http://svn.miranda-ng.org/main/trunk@6879 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdcrypt/commonheaders.h1
-rw-r--r--src/core/stdcrypt/encrypt.cpp4
-rw-r--r--src/modules/crypt/encrypt.cpp40
-rw-r--r--src/modules/utils/utils.cpp20
4 files changed, 58 insertions, 7 deletions
diff --git a/src/core/stdcrypt/commonheaders.h b/src/core/stdcrypt/commonheaders.h
index 4edcc6e358..a16eb54b8e 100644
--- a/src/core/stdcrypt/commonheaders.h
+++ b/src/core/stdcrypt/commonheaders.h
@@ -65,6 +65,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_icolib.h>
#include <m_modernopt.h>
#include <m_timezones.h>
+#include <m_crypto.h>
#include "version.h"
diff --git a/src/core/stdcrypt/encrypt.cpp b/src/core/stdcrypt/encrypt.cpp
index e86e34437d..fc72e74abc 100644
--- a/src/core/stdcrypt/encrypt.cpp
+++ b/src/core/stdcrypt/encrypt.cpp
@@ -25,5 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int LoadEncryptionModule(void)
{
+ CRYPTO_PROVIDER cp = { sizeof(cp) };
+ cp.pszName = "AES (Rjindale)";
+ cp.pszDescr = LPGEN("Standard crypto provider");
+ Crypto_RegisterEngine(&cp);
return 0;
}
diff --git a/src/modules/crypt/encrypt.cpp b/src/modules/crypt/encrypt.cpp
index 659e75cc53..ab73ac5671 100644
--- a/src/modules/crypt/encrypt.cpp
+++ b/src/modules/crypt/encrypt.cpp
@@ -49,9 +49,49 @@ static INT_PTR DecodeString(WPARAM wParam, LPARAM lParam)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int CompareFunc(const CRYPTO_PROVIDER *p1, const CRYPTO_PROVIDER *p2)
+{
+ return strcmp(p1->pszName, p2->pszName);
+}
+
+static LIST<CRYPTO_PROVIDER> arProviders(5, CompareFunc);
+
+static INT_PTR srvRegister(WPARAM wParam, LPARAM lParam)
+{
+ CRYPTO_PROVIDER *p = (CRYPTO_PROVIDER*)lParam;
+ if (p == NULL || p->dwSize != sizeof(CRYPTO_PROVIDER))
+ return 1;
+
+ CRYPTO_PROVIDER *pNew = new CRYPTO_PROVIDER(*p);
+ pNew->pszName = mir_strdup(p->pszName);
+ if (pNew->dwFlags & CPF_UNICODE)
+ pNew->ptszDescr = mir_u2t(TranslateW_LP(p->pwszDescr, wParam));
+ else
+ pNew->ptszDescr = mir_a2t(TranslateA_LP(p->pszDescr, wParam));
+ arProviders.insert(pNew);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int InitCrypt(void)
{
CreateServiceFunction(MS_DB_CRYPT_ENCODESTRING, EncodeString);
CreateServiceFunction(MS_DB_CRYPT_DECODESTRING, DecodeString);
+
+ CreateServiceFunction(MS_CRYPTO_REGISTER_ENGINE, srvRegister);
return 0;
}
+
+void UninitCrypt(void)
+{
+ for (int i = 0; i < arProviders.getCount(); i++) {
+ CRYPTO_PROVIDER *p = arProviders[i];
+ mir_free(p->pszName);
+ mir_free(p->pszDescr);
+ delete p;
+ }
+ arDbPlugins.destroy();
+}
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index 62322a9ec6..8a62eed3f3 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -26,17 +26,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_SYSTEM_GET_MD5I "Miranda/System/GetMD5I"
INT_PTR ResizeDialog(WPARAM wParam, LPARAM lParam);
-int InitOpenUrl(void);
-int InitWindowList(void);
-int InitPathUtils(void);
+
void FreeWindowList(void);
-int InitHyperlink(void);
-int InitColourPicker(void);
-int InitBitmapFilter(void);
+
+int InitOpenUrl(void);
+int InitWindowList(void);
+int InitPathUtils(void);
+int InitHyperlink(void);
+int InitColourPicker(void);
+int InitBitmapFilter(void);
void InitXmlApi(void);
+
void InitTimeZones(void);
void UninitTimeZones(void);
-int InitCrypt(void);
+
+int InitCrypt(void);
+void UninitCrypt(void);
static BOOL bModuleInitialized = FALSE;
@@ -484,6 +489,7 @@ void UnloadUtilsModule(void)
if ( !bModuleInitialized)
return;
+ UninitCrypt();
FreeWindowList();
UninitTimeZones();
}