25 #ifdef USE_WINDOWS_SSPI 38 typedef PSecurityFunctionTable (APIENTRY *INITSECURITYINTERFACE_FN)(VOID);
43 # define SECURITYENTRYPOINT L"InitSecurityInterfaceW" 45 # define SECURITYENTRYPOINT "InitSecurityInterfaceW" 48 # define SECURITYENTRYPOINT "InitSecurityInterfaceA" 52 HMODULE s_hSecDll = NULL;
55 PSecurityFunctionTable s_pSecFn = NULL;
76 INITSECURITYINTERFACE_FN pInitSecurityInterface;
85 if(Curl_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
86 s_hSecDll = Curl_load_library(TEXT(
"security.dll"));
88 s_hSecDll = Curl_load_library(TEXT(
"secur32.dll"));
93 pInitSecurityInterface = (INITSECURITYINTERFACE_FN)
94 GetProcAddress(s_hSecDll, SECURITYENTRYPOINT);
95 if(!pInitSecurityInterface)
99 s_pSecFn = pInitSecurityInterface();
116 void Curl_sspi_global_cleanup(
void)
119 FreeLibrary(s_hSecDll);
139 CURLcode Curl_create_sspi_identity(
const char *userp,
const char *passwdp,
140 SEC_WINNT_AUTH_IDENTITY *identity)
142 xcharp_u useranddomain;
143 xcharp_u user, dup_user;
144 xcharp_u domain, dup_domain;
145 xcharp_u passwd, dup_passwd;
148 domain.const_tchar_ptr = TEXT(
"");
151 memset(identity, 0,
sizeof(*identity));
153 useranddomain.tchar_ptr = Curl_convert_UTF8_to_tchar((
char *)userp);
154 if(!useranddomain.tchar_ptr)
157 user.const_tchar_ptr = _tcschr(useranddomain.const_tchar_ptr, TEXT(
'\\'));
158 if(!user.const_tchar_ptr)
159 user.const_tchar_ptr = _tcschr(useranddomain.const_tchar_ptr, TEXT(
'/'));
162 domain.tchar_ptr = useranddomain.tchar_ptr;
163 domlen = user.tchar_ptr - useranddomain.tchar_ptr;
167 user.tchar_ptr = useranddomain.tchar_ptr;
168 domain.const_tchar_ptr = TEXT(
"");
173 dup_user.tchar_ptr = _tcsdup(user.tchar_ptr);
174 if(!dup_user.tchar_ptr) {
175 Curl_unicodefree(useranddomain.tchar_ptr);
178 identity->User = dup_user.tbyte_ptr;
179 identity->UserLength =
curlx_uztoul(_tcslen(dup_user.tchar_ptr));
180 dup_user.tchar_ptr = NULL;
183 dup_domain.tchar_ptr =
malloc(
sizeof(TCHAR) * (domlen + 1));
184 if(!dup_domain.tchar_ptr) {
185 Curl_unicodefree(useranddomain.tchar_ptr);
188 _tcsncpy(dup_domain.tchar_ptr, domain.tchar_ptr, domlen);
189 *(dup_domain.tchar_ptr + domlen) = TEXT(
'\0');
190 identity->Domain = dup_domain.tbyte_ptr;
192 dup_domain.tchar_ptr = NULL;
194 Curl_unicodefree(useranddomain.tchar_ptr);
197 passwd.tchar_ptr = Curl_convert_UTF8_to_tchar((
char *)passwdp);
198 if(!passwd.tchar_ptr)
200 dup_passwd.tchar_ptr = _tcsdup(passwd.tchar_ptr);
201 if(!dup_passwd.tchar_ptr) {
202 Curl_unicodefree(passwd.tchar_ptr);
205 identity->Password = dup_passwd.tbyte_ptr;
206 identity->PasswordLength =
curlx_uztoul(_tcslen(dup_passwd.tchar_ptr));
207 dup_passwd.tchar_ptr = NULL;
209 Curl_unicodefree(passwd.tchar_ptr);
212 identity->Flags = SECFLAG_WINNT_AUTH_IDENTITY;
226 void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity)
unsigned long curlx_uztoul(size_t uznum)
#define Curl_safefree(ptr)