summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_app.libbin97410 -> 98258 bytes
-rw-r--r--bin10/lib/mir_app64.libbin92734 -> 93520 bytes
-rw-r--r--bin12/lib/mir_app.libbin97410 -> 98258 bytes
-rw-r--r--bin12/lib/mir_app64.libbin92734 -> 93520 bytes
-rw-r--r--bin14/lib/mir_app.libbin97410 -> 98258 bytes
-rw-r--r--bin14/lib/mir_app64.libbin92734 -> 93520 bytes
-rw-r--r--include/m_netlib.h64
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp12
-rw-r--r--src/mir_app/src/mir_app.def3
-rw-r--r--src/mir_app/src/mir_app64.def3
-rw-r--r--src/mir_app/src/netlib.cpp1
-rw-r--r--src/mir_app/src/netlib.h4
-rw-r--r--src/mir_app/src/netlibhttp.cpp4
-rw-r--r--src/mir_app/src/netlibsecurity.cpp102
14 files changed, 37 insertions, 156 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib
index 27ee166768..96e2c0ec66 100644
--- a/bin10/lib/mir_app.lib
+++ b/bin10/lib/mir_app.lib
Binary files differ
diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib
index 022371814b..154026dc47 100644
--- a/bin10/lib/mir_app64.lib
+++ b/bin10/lib/mir_app64.lib
Binary files differ
diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib
index 27ee166768..96e2c0ec66 100644
--- a/bin12/lib/mir_app.lib
+++ b/bin12/lib/mir_app.lib
Binary files differ
diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib
index 022371814b..154026dc47 100644
--- a/bin12/lib/mir_app64.lib
+++ b/bin12/lib/mir_app64.lib
Binary files differ
diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib
index 27ee166768..96e2c0ec66 100644
--- a/bin14/lib/mir_app.lib
+++ b/bin14/lib/mir_app.lib
Binary files differ
diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib
index 022371814b..154026dc47 100644
--- a/bin14/lib/mir_app64.lib
+++ b/bin14/lib/mir_app64.lib
Binary files differ
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 6380c34e05..3bdb0391bd 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -731,77 +731,19 @@ EXTERN_C MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, const wchar_t *fmt, ..
// Inits a required security provider. Right now only NTLM is supported
// Returns HANDLE = NULL on error or non-null value on success
// Known providers: Basic, NTLM, Negotiate, Kerberos, GSSAPI - (Kerberos SASL)
-#define MS_NETLIB_INITSECURITYPROVIDER "Netlib/InitSecurityProvider"
-static __inline HANDLE Netlib_InitSecurityProvider(char* szProviderName)
-{
- return (HANDLE)CallService(MS_NETLIB_INITSECURITYPROVIDER, 0, (LPARAM)szProviderName);
-}
-
-typedef struct {
- size_t cbSize;
- const wchar_t* szProviderName;
- const wchar_t* szPrincipal;
- unsigned flags;
-}
- NETLIBNTLMINIT2;
-
-#define MS_NETLIB_INITSECURITYPROVIDER2 "Netlib/InitSecurityProvider2"
-
-static __inline HANDLE Netlib_InitSecurityProvider2(const wchar_t* szProviderName, const wchar_t* szPrincipal)
-{
- NETLIBNTLMINIT2 temp = { sizeof(temp), szProviderName, szPrincipal, NNR_TCHAR };
- return (HANDLE)CallService(MS_NETLIB_INITSECURITYPROVIDER2, 0, (LPARAM)&temp);
-}
+EXTERN_C MIR_APP_DLL(HANDLE) Netlib_InitSecurityProvider(const wchar_t *szProviderName, const wchar_t *szPrincipal = NULL);
/////////////////////////////////////////////////////////////////////////////////////////
// Destroys a security provider's handle, provided by Netlib_InitSecurityProvider.
// Right now only NTLM is supported
-#define MS_NETLIB_DESTROYSECURITYPROVIDER "Netlib/DestroySecurityProvider"
-
-__forceinline void Netlib_DestroySecurityProvider(char* szProviderName, HANDLE hProvider)
-{
- CallService(MS_NETLIB_DESTROYSECURITYPROVIDER, (WPARAM)szProviderName, (LPARAM)hProvider);
-}
+EXTERN_C MIR_APP_DLL(void) Netlib_DestroySecurityProvider(HANDLE hProvider);
/////////////////////////////////////////////////////////////////////////////////////////
// Returns the NTLM response string. The result value should be freed using mir_free
-struct NETLIBNTLMREQUEST
-{
- char *szChallenge;
- char *userName;
- char *password;
-};
-
-#define MS_NETLIB_NTLMCREATERESPONSE "Netlib/NtlmCreateResponse"
-
- __forceinline char* Netlib_NtlmCreateResponse(HANDLE hProvider, char* szChallenge, char* login, char* psw)
-{
- NETLIBNTLMREQUEST temp = { szChallenge, login, psw };
- return (char*)CallService(MS_NETLIB_NTLMCREATERESPONSE, (WPARAM)hProvider, (LPARAM)&temp);
-}
-
-struct NETLIBNTLMREQUEST2
-{
- size_t cbSize;
- const char *szChallenge;
- const wchar_t *szUserName;
- const wchar_t *szPassword;
- unsigned complete;
- unsigned flags;
-};
-
-#define MS_NETLIB_NTLMCREATERESPONSE2 "Netlib/NtlmCreateResponse2"
-
-static __inline char* Netlib_NtlmCreateResponse2(HANDLE hProvider, char* szChallenge, wchar_t* szLogin, wchar_t* szPass, unsigned *complete)
-{
- NETLIBNTLMREQUEST2 temp = { sizeof(temp), szChallenge, szLogin, szPass, *complete, NNR_TCHAR };
- char *res = (char*)CallService(MS_NETLIB_NTLMCREATERESPONSE2, (WPARAM)hProvider, (LPARAM)&temp);
- *complete = temp.complete;
- return res;
-}
+EXTERN_C MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, char *szChallenge, wchar_t *szLogin, wchar_t *szPass, unsigned &complete);
/////////////////////////////////////////////////////////////////////////////////////////
// Netlib hooks (0.8+)
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index dce7c59146..ab0e53d354 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -53,14 +53,14 @@ LBL_Invalid:
if (!getSpn(szSpn, _countof(szSpn)) && !mir_strcmp(mechanism, "GSSAPI"))
goto LBL_Invalid;
- if ((hProvider = Netlib_InitSecurityProvider2(szProvider, szSpn)) == NULL)
+ if ((hProvider = Netlib_InitSecurityProvider(szProvider, szSpn)) == NULL)
bIsValid = false;
}
TNtlmAuth::~TNtlmAuth()
{
if (hProvider != NULL)
- Netlib_DestroySecurityProvider(NULL, hProvider);
+ Netlib_DestroySecurityProvider(hProvider);
}
bool TNtlmAuth::getSpn(wchar_t* szSpn, size_t dwSpnLen)
@@ -106,9 +106,9 @@ char* TNtlmAuth::getInitialRequest()
// This generates login method advertisement packet
if (info->conn.password[0] != 0)
- return Netlib_NtlmCreateResponse2(hProvider, "", info->conn.username, info->conn.password, &complete);
+ return Netlib_NtlmCreateResponse(hProvider, "", info->conn.username, info->conn.password, complete);
- return Netlib_NtlmCreateResponse2(hProvider, "", NULL, NULL, &complete);
+ return Netlib_NtlmCreateResponse(hProvider, "", NULL, NULL, complete);
}
char* TNtlmAuth::getChallenge(const wchar_t *challenge)
@@ -118,9 +118,9 @@ char* TNtlmAuth::getChallenge(const wchar_t *challenge)
ptrA text((!mir_wstrcmp(challenge, L"=")) ? mir_strdup("") : mir_u2a(challenge));
if (info->conn.password[0] != 0)
- return Netlib_NtlmCreateResponse2(hProvider, text, info->conn.username, info->conn.password, &complete);
+ return Netlib_NtlmCreateResponse(hProvider, text, info->conn.username, info->conn.password, complete);
- return Netlib_NtlmCreateResponse2(hProvider, text, NULL, NULL, &complete);
+ return Netlib_NtlmCreateResponse(hProvider, text, NULL, NULL, complete);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 6a1827cab6..cf2ce8a022 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -377,3 +377,6 @@ Netlib_StartSsl @377
Netlib_GetConnectionInfo @378
Netlib_GetMyIp @379
Netlib_SetHttpProxyInfo @380
+Netlib_DestroySecurityProvider @381
+Netlib_InitSecurityProvider @382
+Netlib_NtlmCreateResponse @383
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 5d65d1173e..ba931ff6bc 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -377,3 +377,6 @@ Netlib_StartSsl @377
Netlib_GetConnectionInfo @378
Netlib_GetMyIp @379
Netlib_SetHttpProxyInfo @380
+Netlib_DestroySecurityProvider @381
+Netlib_InitSecurityProvider @382
+Netlib_NtlmCreateResponse @383
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index fcde4a4056..a0051c2dc5 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -465,7 +465,6 @@ int LoadNetlibModule(void)
hSendEvent = CreateHookableEvent(ME_NETLIB_FASTSEND);
NetlibUPnPInit();
- NetlibSecurityInit();
NetlibLoadIeProxy();
return 0;
}
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h
index 7bb9d08c38..087b7d8cb5 100644
--- a/src/mir_app/src/netlib.h
+++ b/src/mir_app/src/netlib.h
@@ -255,9 +255,5 @@ void NetlibUPnPInit(void);
void NetlibUPnPDestroy(void);
// netlibsecurity.c
-void NetlibSecurityInit(void);
-void NetlibDestroySecurityProvider(HANDLE hSecurity);
-HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPrincipal);
-HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal);
char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, const wchar_t* login, const wchar_t* psw,
bool http, unsigned& complete);
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp
index d9f33aa3c0..5209ca6468 100644
--- a/src/mir_app/src/netlibhttp.cpp
+++ b/src/mir_app/src/netlibhttp.cpp
@@ -215,7 +215,7 @@ struct HttpSecurityContext
{
if (!m_hNtlmSecurity) return;
- NetlibDestroySecurityProvider(m_hNtlmSecurity);
+ Netlib_DestroySecurityProvider(m_hNtlmSecurity);
m_hNtlmSecurity = NULL;
mir_free(m_szHost); m_szHost = NULL;
mir_free(m_szProvider); m_szProvider = NULL;
@@ -248,7 +248,7 @@ struct HttpSecurityContext
_strlwr(szSpnStr.GetBuffer() + 5);
Netlib_Logf(nlu, "Host SPN: %s", szSpnStr);
}
- m_hNtlmSecurity = NetlibInitSecurityProvider(szProvider, szSpnStr.IsEmpty() ? NULL : szSpnStr.c_str());
+ m_hNtlmSecurity = Netlib_InitSecurityProvider(_A2T(szProvider), szSpnStr.IsEmpty() ? NULL : _A2T(szSpnStr.c_str()));
if (m_hNtlmSecurity) {
m_szProvider = mir_strdup(szProvider);
m_szHost = mir_strdup(szHost);
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp
index 2cc0ba9f73..ab882bfb90 100644
--- a/src/mir_app/src/netlibsecurity.cpp
+++ b/src/mir_app/src/netlibsecurity.cpp
@@ -73,7 +73,9 @@ static void ReportSecError(SECURITY_STATUS scRet, int line)
Netlib_Logf(NULL, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf);
}
-HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPrincipal)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(HANDLE) Netlib_InitSecurityProvider(const wchar_t *szProvider, const wchar_t *szPrincipal)
{
HANDLE hSecurity = NULL;
@@ -109,12 +111,9 @@ HANDLE NetlibInitSecurityProvider(const wchar_t* szProvider, const wchar_t* szPr
return hSecurity;
}
-HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal)
-{
- return NetlibInitSecurityProvider(_A2T(szProvider), _A2T(szPrincipal));
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-void NetlibDestroySecurityProvider(HANDLE hSecurity)
+MIR_APP_DLL(void) Netlib_DestroySecurityProvider(HANDLE hSecurity)
{
if (hSecurity == NULL)
return;
@@ -137,6 +136,8 @@ void NetlibDestroySecurityProvider(HANDLE hSecurity)
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chlsz)
{
if (!szChallenge || !szChallenge[0]) return NULL;
@@ -201,7 +202,9 @@ char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chls
return mir_base64_encode(response, ressz);
}
-char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, const wchar_t* login, const wchar_t* psw, bool http, unsigned& complete)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, const wchar_t *login, const wchar_t *psw, bool http, unsigned &complete)
{
if (hSecurity == NULL || ntlmCnt == 0)
return NULL;
@@ -212,7 +215,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
ULONG contextAttributes;
char *szOutputToken;
- NtlmHandleType* hNtlm = (NtlmHandleType*)hSecurity;
+ NtlmHandleType *hNtlm = (NtlmHandleType*)hSecurity;
if (mir_wstrcmpi(hNtlm->szProvider, L"Basic")) {
bool isGSSAPI = mir_wstrcmpi(hNtlm->szProvider, L"GSSAPI") == 0;
wchar_t *szProvider = isGSSAPI ? (wchar_t*)L"Kerberos" : hNtlm->szProvider;
@@ -304,9 +307,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
hNtlm->hasDomain = domainLen != 0;
}
- SECURITY_STATUS sc = AcquireCredentialsHandle(NULL, szProvider,
- SECPKG_CRED_OUTBOUND, NULL, hNtlm->hasDomain ? &auth : NULL, NULL, NULL,
- &hNtlm->hClientCredential, &tokenExpiration);
+ SECURITY_STATUS sc = AcquireCredentialsHandle(NULL, szProvider, SECPKG_CRED_OUTBOUND, NULL, hNtlm->hasDomain ? &auth : NULL, NULL, NULL, &hNtlm->hClientCredential, &tokenExpiration);
if (sc != SEC_E_OK) {
ReportSecError(sc, __LINE__);
return NULL;
@@ -339,20 +340,12 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
szOutputToken = mir_base64_encode((PBYTE)outputSecurityToken.pvBuffer, outputSecurityToken.cbBuffer);
}
else {
- if (!login || !psw) return NULL;
-
- char *szLogin = mir_u2a(login);
- char *szPassw = mir_u2a(psw);
-
- size_t authLen = mir_strlen(szLogin) + mir_strlen(szPassw) + 5;
- char *szAuth = (char*)alloca(authLen);
+ if (!login || !psw)
+ return NULL;
- int len = mir_snprintf(szAuth, authLen, "%s:%s", szLogin, szPassw);
- szOutputToken = mir_base64_encode((BYTE*)szAuth, len);
+ CMStringA szAuth(FORMAT, "%S:%S", login, psw);
+ szOutputToken = mir_base64_encode((BYTE*)szAuth.c_str(), szAuth.GetLength());
complete = true;
-
- mir_free(szPassw);
- mir_free(szLogin);
}
if (szOutputToken == NULL)
@@ -361,67 +354,12 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
if (!http)
return szOutputToken;
- ptrA szProvider(mir_u2a(hNtlm->szProvider));
- size_t resLen = mir_strlen(szOutputToken) + mir_strlen(szProvider) + 10;
- char *result = (char*)mir_alloc(resLen);
- mir_snprintf(result, resLen, "%s %s", szProvider, szOutputToken);
+ CMStringA szResult(FORMAT, "%S %s", hNtlm->szProvider, szOutputToken);
mir_free(szOutputToken);
- return result;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static INT_PTR InitSecurityProviderService(WPARAM, LPARAM lParam)
-{
- HANDLE hSecurity = NetlibInitSecurityProvider((char*)lParam, NULL);
- return (INT_PTR)hSecurity;
-}
-
-static INT_PTR InitSecurityProviderService2(WPARAM, LPARAM lParam)
-{
- NETLIBNTLMINIT2 *req = (NETLIBNTLMINIT2*)lParam;
- if (req == NULL || req->cbSize < sizeof(*req))
- return 0;
-
- if (req->flags & NNR_UNICODE)
- return (INT_PTR)NetlibInitSecurityProvider(req->szProviderName, req->szPrincipal);
- return (INT_PTR)NetlibInitSecurityProvider((char*)req->szProviderName, (char*)req->szPrincipal);
-}
-
-static INT_PTR DestroySecurityProviderService(WPARAM, LPARAM lParam)
-{
- NetlibDestroySecurityProvider((HANDLE)lParam);
- return 0;
-}
-
-static INT_PTR NtlmCreateResponseService(WPARAM wParam, LPARAM lParam)
-{
- NETLIBNTLMREQUEST *req = (NETLIBNTLMREQUEST*)lParam;
- if (req == NULL)
- return 0;
-
- unsigned complete = 0;
- char *response = NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge, _A2T(req->userName), _A2T(req->password), false, complete);
- return (INT_PTR)response;
-}
-
-static INT_PTR NtlmCreateResponseService2(WPARAM wParam, LPARAM lParam)
-{
- NETLIBNTLMREQUEST2 *req = (NETLIBNTLMREQUEST2*)lParam;
- if (req == NULL || req->cbSize < sizeof(*req))
- return 0;
-
- if (req->flags & NNR_UNICODE)
- return (INT_PTR)NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge, req->szUserName, req->szPassword, false, req->complete);
-
- return (INT_PTR)NtlmCreateResponseFromChallenge((HANDLE)wParam, req->szChallenge, _A2T((char*)req->szUserName), _A2T((char*)req->szPassword), false, req->complete);
+ return szResult.Detach();
}
-void NetlibSecurityInit(void)
+MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, char *szChallenge, wchar_t *pwszLogin, wchar_t *pwszPassword, unsigned &complete)
{
- CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER, InitSecurityProviderService);
- CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER2, InitSecurityProviderService2);
- CreateServiceFunction(MS_NETLIB_DESTROYSECURITYPROVIDER, DestroySecurityProviderService);
- CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE, NtlmCreateResponseService);
- CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE2, NtlmCreateResponseService2);
+ return NtlmCreateResponseFromChallenge(hProvider, szChallenge, pwszLogin, pwszPassword, false, complete);
}