From 268d637031d98cd88ef29dbac4a7c862f678cfc0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 13 Nov 2013 12:47:58 +0000 Subject: initial version of stdcrypt, without encryption git-svn-id: http://svn.miranda-ng.org/main/trunk@6888 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_crypto.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/m_crypto.h b/include/m_crypto.h index a6679d9e6e..9cd971b5bd 100644 --- a/include/m_crypto.h +++ b/include/m_crypto.h @@ -26,34 +26,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -typedef struct tagCRYPTOENGINE +struct MICryptoEngine { DWORD dwVersion; + STDMETHOD_(void, destroy)(void) PURE; + // get/set the instance key - void (__cdecl *pfnGetKey)(const BYTE *pKey, size_t cbKeyLen); - BOOL (__cdecl *pfnSetKey)(const BYTE **pKey, size_t *cbKeyLen); + STDMETHOD_(size_t, getKeyLength)(void) PURE; + STDMETHOD_(bool, getKey)(BYTE *pKey, size_t cbKeyLen) PURE; + STDMETHOD_(int, setKey)(const BYTE *pKey, size_t cbKeyLen) PURE; - void(__cdecl *pfnGenerateKey)(void); // creates a new key inside - void(__cdecl *pfnPurgeKey)(void); // purges a key from memory + STDMETHOD_(void, generateKey)(void)PURE; // creates a new key inside + STDMETHOD_(void, purgeKey)(void)PURE; // purges a key from memory // sets the master password (in utf-8) - void(__cdecl *pfnSetPassword)(const char *pszPassword); + STDMETHOD_(void, setPassword)(const char *pszPassword) PURE; - BYTE* (__cdecl *pfnEncodeString)( const char *src, size_t *cbResultLen); - BYTE* (__cdecl *pfnEncodeStringW)(const WCHAR* src, size_t *cbResultLen); + // result must be freed using mir_free or assigned to mir_ptr + STDMETHOD_(BYTE*, encodeString)(const char *src, size_t *cbResultLen) PURE; + STDMETHOD_(BYTE*, encodeStringW)(const WCHAR* src, size_t *cbResultLen) PURE; - 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; + // result must be freed using mir_free or assigned to ptrA/ptrT + STDMETHOD_(char*, decodeString)(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen) PURE; + STDMETHOD_(WCHAR*, decodeStringW)(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen) PURE; +}; //registers a crypto provider v0.94+ //wParam = (int)hLangpack //lParam = (CRYPTO_PROVIDER*) //returns HANDLE on success or NULL on failure -typedef CRYPTO_ENGINE* (__cdecl *pfnCryptoProviderFactory)(void); +typedef MICryptoEngine* (__cdecl *pfnCryptoProviderFactory)(void); #define CPF_UNICODE 1 @@ -77,7 +81,7 @@ typedef struct tagCRYPTOPROVIDER pfnCryptoProviderFactory pFactory; } -CRYPTO_PROVIDER; + CRYPTO_PROVIDER; #define MS_CRYPTO_REGISTER_ENGINE "SRCrypto/RegisterEngine" -- cgit v1.2.3