diff options
author | George Hazan <george.hazan@gmail.com> | 2013-11-12 15:41:26 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-11-12 15:41:26 +0000 |
commit | 3aeddb1952f894ce41b055bc3d49c3fcc994c14e (patch) | |
tree | 32a5255a8ae05b8435b177bbd8004aee5504170e | |
parent | a582e723883bd6ede6e0c910e82cfc4ad23bc161 (diff) |
- changed m_crypto.h;
- crypto-plugins are forced to be loaded in the very beginning, alongside with the database plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@6874 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_crypto.h | 68 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_10.vcxproj | 1 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_11.vcxproj | 1 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_11.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_12.vcxproj | 1 | ||||
-rw-r--r-- | src/core/stdcrypt/stdcrypt_12.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 17 |
8 files changed, 76 insertions, 21 deletions
diff --git a/include/m_crypto.h b/include/m_crypto.h index 1b7751180b..a6679d9e6e 100644 --- a/include/m_crypto.h +++ b/include/m_crypto.h @@ -24,27 +24,67 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_CRYPTO_H__
#define M_CRYPTO_H__ 1
-typedef struct tagCRYPTOAPI
+#include <m_core.h>
+
+typedef struct tagCRYPTOENGINE
{
DWORD dwVersion;
- void (__cdecl *pfnSetKey)( const char* ); // sets the master password
- void (__cdecl *pfnSetKeyT)( const TCHAR* );
+ // get/set the instance key
+ void (__cdecl *pfnGetKey)(const BYTE *pKey, size_t cbKeyLen);
+ BOOL (__cdecl *pfnSetKey)(const BYTE **pKey, size_t *cbKeyLen);
+
+ void(__cdecl *pfnGenerateKey)(void); // creates a new key inside
+ void(__cdecl *pfnPurgeKey)(void); // purges a key from memory
+
+ // sets the master password (in utf-8)
+ void(__cdecl *pfnSetPassword)(const char *pszPassword);
+
+ BYTE* (__cdecl *pfnEncodeString)( const char *src, size_t *cbResultLen);
+ BYTE* (__cdecl *pfnEncodeStringW)(const WCHAR* src, size_t *cbResultLen);
+
+ char* (__cdecl *pfnDecodeString)(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen);
+ WCHAR* (__cdecl *pfnDecodeStringW)(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen);
+}
+CRYPTO_ENGINE;
+
+//registers a crypto provider v0.94+
+//wParam = (int)hLangpack
+//lParam = (CRYPTO_PROVIDER*)
+//returns HANDLE on success or NULL on failure
- void (__cdecl *pfnPurgeKey)( void ); // purges a key from memory
+typedef CRYPTO_ENGINE* (__cdecl *pfnCryptoProviderFactory)(void);
- void (__cdecl *pfnEncodeString)( const char* src, char* buf, size_t buf_len);
- void (__cdecl *pfnEncodeStringT)( const TCHAR* src, char* buf, size_t buf_len);
+#define CPF_UNICODE 1
- void (__cdecl *pfnDecodeString)( const char* src, char* buf, size_t buf_len);
- void (__cdecl *pfnDecodeStringT)( const char* src, TCHAR* buf, size_t buf_len);
+#if defined(_UNICODE)
+ #define CPF_TCHAR CPF_UNICODE
+#else
+ #define CPF_TCHAR 0
+#endif
+
+typedef struct tagCRYPTOPROVIDER
+{
+ DWORD dwSize;
+ DWORD dwFlags; // one of CPF_* constants
+
+ char *pszName; // unique id
+ union {
+ char *pszDescr; // description
+ TCHAR *ptszDescr; // auto translated by core
+ WCHAR *pwszDescr;
+ };
+
+ pfnCryptoProviderFactory pFactory;
}
- CRYPTO_INTERFACE;
+CRYPTO_PROVIDER;
-//retrieves the crypto interface v0.10.0.2+
-//wParam=0
-//lParam=0
-//returns CRYPTO_INTERFACE* on success or NULL on failure
-#define MS_CRYPTO_GETINTERFACE "SRCrypto/GetInterface"
+#define MS_CRYPTO_REGISTER_ENGINE "SRCrypto/RegisterEngine"
+
+__forceinline HANDLE Crypto_RegisterEngine(CRYPTO_PROVIDER *pProvider)
+{
+ extern int hLangpack;
+ return (HANDLE)CallService(MS_CRYPTO_REGISTER_ENGINE, hLangpack, (LPARAM)pProvider);
+}
#endif // M_CRYPTO_H__
diff --git a/src/core/stdcrypt/stdcrypt_10.vcxproj b/src/core/stdcrypt/stdcrypt_10.vcxproj index 9ebb911c39..a8fb8b5b1a 100644 --- a/src/core/stdcrypt/stdcrypt_10.vcxproj +++ b/src/core/stdcrypt/stdcrypt_10.vcxproj @@ -209,6 +209,7 @@ <ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\..\include\m_crypto.h" />
<ClInclude Include="..\stdplug.h" />
<ClInclude Include="commonheaders.h" />
</ItemGroup>
diff --git a/src/core/stdcrypt/stdcrypt_10.vcxproj.filters b/src/core/stdcrypt/stdcrypt_10.vcxproj.filters index ec4b0c8910..f4466c28bd 100644 --- a/src/core/stdcrypt/stdcrypt_10.vcxproj.filters +++ b/src/core/stdcrypt/stdcrypt_10.vcxproj.filters @@ -32,6 +32,9 @@ <ClInclude Include="commonheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\include\m_crypto.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
diff --git a/src/core/stdcrypt/stdcrypt_11.vcxproj b/src/core/stdcrypt/stdcrypt_11.vcxproj index a9888bb36c..890a10e365 100644 --- a/src/core/stdcrypt/stdcrypt_11.vcxproj +++ b/src/core/stdcrypt/stdcrypt_11.vcxproj @@ -212,6 +212,7 @@ <ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\..\include\m_crypto.h" />
<ClInclude Include="..\stdplug.h" />
<ClInclude Include="commonheaders.h" />
</ItemGroup>
diff --git a/src/core/stdcrypt/stdcrypt_11.vcxproj.filters b/src/core/stdcrypt/stdcrypt_11.vcxproj.filters index ec4b0c8910..f4466c28bd 100644 --- a/src/core/stdcrypt/stdcrypt_11.vcxproj.filters +++ b/src/core/stdcrypt/stdcrypt_11.vcxproj.filters @@ -32,6 +32,9 @@ <ClInclude Include="commonheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\include\m_crypto.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
diff --git a/src/core/stdcrypt/stdcrypt_12.vcxproj b/src/core/stdcrypt/stdcrypt_12.vcxproj index e8912f09d9..2d7f5c5881 100644 --- a/src/core/stdcrypt/stdcrypt_12.vcxproj +++ b/src/core/stdcrypt/stdcrypt_12.vcxproj @@ -212,6 +212,7 @@ <ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\..\include\m_crypto.h" />
<ClInclude Include="..\stdplug.h" />
<ClInclude Include="commonheaders.h" />
</ItemGroup>
diff --git a/src/core/stdcrypt/stdcrypt_12.vcxproj.filters b/src/core/stdcrypt/stdcrypt_12.vcxproj.filters index ec4b0c8910..f4466c28bd 100644 --- a/src/core/stdcrypt/stdcrypt_12.vcxproj.filters +++ b/src/core/stdcrypt/stdcrypt_12.vcxproj.filters @@ -32,6 +32,9 @@ <ClInclude Include="commonheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\include\m_crypto.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index f25393feab..b529a1af2c 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -122,8 +122,7 @@ static MuuidReplacement pluginDefault[] = { MIID_SRAWAY, _T("stdaway"), NULL }, // 10
{ MIID_CLIST, _T("stdclist"), NULL }, // 11
{ MIID_CHAT, _T("stdchat"), NULL }, // 12
- { MIID_SRMM, _T("stdmsg"), NULL }, // 13
- { MIID_CRYPTO, _T("stdcrypt"), NULL }, // 14
+ { MIID_SRMM, _T("stdmsg"), NULL } // 13
};
int getDefaultPluginIdx(const MUUID& muuid)
@@ -205,6 +204,7 @@ MUUID miid_clist = MIID_CLIST; MUUID miid_database = MIID_DATABASE;
MUUID miid_protocol = MIID_PROTOCOL;
MUUID miid_servicemode = MIID_SERVICEMODE;
+MUUID miid_crypto = MIID_CRYPTO;
static bool validInterfaceList(MUUID *piface)
{
@@ -407,12 +407,13 @@ pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) return p;
}
- // plugin declared that it's a database. load it asap!
- if ( hasMuuid(pIds, miid_database)) {
+ // plugin declared that it's a database or a cryptor. load it asap!
+ bool bIsDb = hasMuuid(pIds, miid_database);
+ if (bIsDb || hasMuuid(pIds, miid_crypto)) {
BASIC_PLUGIN_INFO bpi;
if ( checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
- // db plugin is valid
- p->pclass |= (PCLASS_DB | PCLASS_BASICAPI);
+ // plugin is valid
+ p->pclass |= ((bIsDb ? PCLASS_DB : PCLASS_OK) | PCLASS_BASICAPI);
// copy the dblink stuff
p->bpi = bpi;
@@ -817,7 +818,9 @@ int LoadNewPluginsModuleInfos(void) PathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini);
// look for all *.dll's
enumPlugins(scanPluginsDir, 0, 0);
- return 0;
+
+ MuuidReplacement stdCrypt = { MIID_CRYPTO, _T("stdcrypt"), NULL };
+ return !LoadCorePlugin(stdCrypt);
}
/////////////////////////////////////////////////////////////////////////////////////////
|