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 /include/m_crypto.h | |
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
Diffstat (limited to 'include/m_crypto.h')
-rw-r--r-- | include/m_crypto.h | 68 |
1 files changed, 54 insertions, 14 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__
|