summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-14 22:14:20 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-14 22:14:20 +0000
commit5056234c898e593ba71a01659dbbcd70ca519d89 (patch)
treeb7bc11d33e029add61276b3ebd5c597480677fec
parente18e0c2c88395456cc9c562f69332753bfc9891a (diff)
MS_CRYPTO_GET_PROVIDER - service for looking up crypto providers
git-svn-id: http://svn.miranda-ng.org/main/trunk@6909 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_crypto.h13
-rw-r--r--src/modules/crypt/encrypt.cpp11
2 files changed, 24 insertions, 0 deletions
diff --git a/include/m_crypto.h b/include/m_crypto.h
index 1f7d782113..87e2a61614 100644
--- a/include/m_crypto.h
+++ b/include/m_crypto.h
@@ -105,4 +105,17 @@ __forceinline void Crypto_EnumProviders(int *numProvs, CRYPTO_PROVIDER ***pResul
CallService(MS_CRYPTO_ENUM_PROVIDERS, WPARAM(numProvs), LPARAM(pResult));
}
+///////////////////////////////////////////////////////////////////////////////////////////////
+// retrieves a crypto provider by name
+// wParam = 0 (unused)
+// lParam = (const char*)pszProviderName = CRYPTO_PROVIDER::pszName
+// returns 0 on fail or CRYPTO_PROVIDER* on success
+
+#define MS_CRYPTO_GET_PROVIDER "Crypto/GetProvider"
+
+__forceinline CRYPTO_PROVIDER* Crypto_GetProvider(const char *pszName)
+{
+ return (CRYPTO_PROVIDER*)CallService(MS_CRYPTO_GET_PROVIDER, 0, LPARAM(pszName));
+}
+
#endif // M_CRYPTO_H__
diff --git a/src/modules/crypt/encrypt.cpp b/src/modules/crypt/encrypt.cpp
index 4cb096e3ec..3e5da905ee 100644
--- a/src/modules/crypt/encrypt.cpp
+++ b/src/modules/crypt/encrypt.cpp
@@ -83,6 +83,16 @@ static INT_PTR srvEnumProviders(WPARAM wParam, LPARAM lParam)
return 0;
}
+static INT_PTR srvGetProvider(WPARAM wParam, LPARAM lParam)
+{
+ if (lParam == 0)
+ return 0;
+
+ CRYPTO_PROVIDER tmp;
+ tmp.pszName = (LPSTR)lParam;
+ return (INT_PTR)arProviders.find(&tmp);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int InitCrypt(void)
@@ -92,6 +102,7 @@ int InitCrypt(void)
CreateServiceFunction(MS_CRYPTO_REGISTER_ENGINE, srvRegister);
CreateServiceFunction(MS_CRYPTO_ENUM_PROVIDERS, srvEnumProviders);
+ CreateServiceFunction(MS_CRYPTO_GET_PROVIDER, srvGetProvider);
return 0;
}