1 /* Copyright (C) 2005 Juan Lang
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 * This file implements the schannel provider, or, the SSL/TLS implementations.
18 * FIXME: It should be rather obvious that this file is empty of any
26 #include "secur32_priv.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(secur32
);
31 static SECURITY_STATUS
schan_QueryCredentialsAttributes(
32 PCredHandle phCredential
, ULONG ulAttribute
, PVOID pBuffer
)
38 case SECPKG_ATTR_SUPPORTED_ALGS
:
41 /* FIXME: get from CryptoAPI */
42 FIXME("%ld: stub\n", ulAttribute
);
43 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
46 ret
= SEC_E_INTERNAL_ERROR
;
48 case SECPKG_ATTR_CIPHER_STRENGTHS
:
51 /* FIXME: get from CryptoAPI */
52 FIXME("%ld: stub\n", ulAttribute
);
53 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
56 ret
= SEC_E_INTERNAL_ERROR
;
58 case SECPKG_ATTR_SUPPORTED_PROTOCOLS
:
61 /* FIXME: get from OpenSSL? */
62 FIXME("%ld: stub\n", ulAttribute
);
63 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
66 ret
= SEC_E_INTERNAL_ERROR
;
69 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
74 static SECURITY_STATUS SEC_ENTRY
schan_QueryCredentialsAttributesA(
75 PCredHandle phCredential
, ULONG ulAttribute
, PVOID pBuffer
)
79 TRACE("(%p, %ld, %p)\n", phCredential
, ulAttribute
, pBuffer
);
83 case SECPKG_CRED_ATTR_NAMES
:
84 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
85 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
88 ret
= schan_QueryCredentialsAttributes(phCredential
, ulAttribute
,
94 static SECURITY_STATUS SEC_ENTRY
schan_QueryCredentialsAttributesW(
95 PCredHandle phCredential
, ULONG ulAttribute
, PVOID pBuffer
)
99 TRACE("(%p, %ld, %p)\n", phCredential
, ulAttribute
, pBuffer
);
103 case SECPKG_CRED_ATTR_NAMES
:
104 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
105 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
108 ret
= schan_QueryCredentialsAttributes(phCredential
, ulAttribute
,
114 static SECURITY_STATUS
schan_AcquireCredentialsHandle(ULONG fCredentialUse
,
115 PCredHandle phCredential
, PTimeStamp ptsExpiry
)
119 if (fCredentialUse
== SECPKG_CRED_BOTH
)
120 ret
= SEC_E_NO_CREDENTIALS
;
123 /* For now, the only thing I'm interested in is the direction of the
124 * connection, so just store it.
126 phCredential
->dwUpper
= fCredentialUse
;
127 /* According to MSDN, all versions prior to XP do this */
129 ptsExpiry
->QuadPart
= 0;
135 static SECURITY_STATUS SEC_ENTRY
schan_AcquireCredentialsHandleA(
136 SEC_CHAR
*pszPrincipal
, SEC_CHAR
*pszPackage
, ULONG fCredentialUse
,
137 PLUID pLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
138 PVOID pGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
140 TRACE("(%s, %s, 0x%08lx, %p, %p, %p, %p, %p, %p)\n",
141 debugstr_a(pszPrincipal
), debugstr_a(pszPackage
), fCredentialUse
,
142 pLogonID
, pAuthData
, pGetKeyFn
, pGetKeyArgument
, phCredential
, ptsExpiry
);
143 return schan_AcquireCredentialsHandle(fCredentialUse
, phCredential
,
147 static SECURITY_STATUS SEC_ENTRY
schan_AcquireCredentialsHandleW(
148 SEC_WCHAR
*pszPrincipal
, SEC_WCHAR
*pszPackage
, ULONG fCredentialUse
,
149 PLUID pLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
150 PVOID pGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
152 TRACE("(%s, %s, 0x%08lx, %p, %p, %p, %p, %p, %p)\n",
153 debugstr_w(pszPrincipal
), debugstr_w(pszPackage
), fCredentialUse
,
154 pLogonID
, pAuthData
, pGetKeyFn
, pGetKeyArgument
, phCredential
, ptsExpiry
);
155 return schan_AcquireCredentialsHandle(fCredentialUse
, phCredential
,
159 /***********************************************************************
160 * InitializeSecurityContextA
162 static SECURITY_STATUS SEC_ENTRY
schan_InitializeSecurityContextA(
163 PCredHandle phCredential
, PCtxtHandle phContext
, SEC_CHAR
*pszTargetName
,
164 ULONG fContextReq
, ULONG Reserved1
, ULONG TargetDataRep
,
165 PSecBufferDesc pInput
, ULONG Reserved2
, PCtxtHandle phNewContext
,
166 PSecBufferDesc pOutput
, ULONG
*pfContextAttr
, PTimeStamp ptsExpiry
)
170 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
171 debugstr_a(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
172 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
174 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
178 ret
= SEC_E_INVALID_HANDLE
;
183 /***********************************************************************
184 * InitializeSecurityContextW
186 static SECURITY_STATUS SEC_ENTRY
schan_InitializeSecurityContextW(
187 PCredHandle phCredential
, PCtxtHandle phContext
, SEC_WCHAR
*pszTargetName
,
188 ULONG fContextReq
, ULONG Reserved1
, ULONG TargetDataRep
,
189 PSecBufferDesc pInput
,ULONG Reserved2
, PCtxtHandle phNewContext
,
190 PSecBufferDesc pOutput
, ULONG
*pfContextAttr
, PTimeStamp ptsExpiry
)
194 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
195 debugstr_w(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
196 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
199 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
203 ret
= SEC_E_INVALID_HANDLE
;
208 static SecurityFunctionTableA schanTableA
= {
210 NULL
, /* EnumerateSecurityPackagesA */
211 schan_QueryCredentialsAttributesA
,
212 schan_AcquireCredentialsHandleA
,
213 NULL
, /* FreeCredentialsHandle */
214 NULL
, /* Reserved2 */
215 schan_InitializeSecurityContextA
,
216 NULL
, /* AcceptSecurityContext */
217 NULL
, /* CompleteAuthToken */
218 NULL
, /* DeleteSecurityContext */
219 NULL
, /* ApplyControlToken */
220 NULL
, /* QueryContextAttributesA */
221 NULL
, /* ImpersonateSecurityContext */
222 NULL
, /* RevertSecurityContext */
223 NULL
, /* MakeSignature */
224 NULL
, /* VerifySignature */
226 NULL
, /* QuerySecurityPackageInfoA */
227 NULL
, /* Reserved3 */
228 NULL
, /* Reserved4 */
229 NULL
, /* ExportSecurityContext */
230 NULL
, /* ImportSecurityContextA */
231 NULL
, /* AddCredentialsA */
232 NULL
, /* Reserved8 */
233 NULL
, /* QuerySecurityContextToken */
234 NULL
, /* EncryptMessage */
235 NULL
, /* DecryptMessage */
236 NULL
, /* SetContextAttributesA */
239 static SecurityFunctionTableW schanTableW
= {
241 NULL
, /* EnumerateSecurityPackagesW */
242 schan_QueryCredentialsAttributesW
,
243 schan_AcquireCredentialsHandleW
,
244 NULL
, /* FreeCredentialsHandle */
245 NULL
, /* Reserved2 */
246 schan_InitializeSecurityContextW
,
247 NULL
, /* AcceptSecurityContext */
248 NULL
, /* CompleteAuthToken */
249 NULL
, /* DeleteSecurityContext */
250 NULL
, /* ApplyControlToken */
251 NULL
, /* QueryContextAttributesW */
252 NULL
, /* ImpersonateSecurityContext */
253 NULL
, /* RevertSecurityContext */
254 NULL
, /* MakeSignature */
255 NULL
, /* VerifySignature */
257 NULL
, /* QuerySecurityPackageInfoW */
258 NULL
, /* Reserved3 */
259 NULL
, /* Reserved4 */
260 NULL
, /* ExportSecurityContext */
261 NULL
, /* ImportSecurityContextW */
262 NULL
, /* AddCredentialsW */
263 NULL
, /* Reserved8 */
264 NULL
, /* QuerySecurityContextToken */
265 NULL
, /* EncryptMessage */
266 NULL
, /* DecryptMessage */
267 NULL
, /* SetContextAttributesW */
270 static const WCHAR schannelComment
[] = { 'S','c','h','a','n','n','e','l',' ',
271 'S','e','c','u','r','i','t','y',' ','P','a','c','k','a','g','e',0 };
273 void SECUR32_initSchannelSP(void)
275 SecureProvider
*provider
= SECUR32_addProvider(&schanTableA
, &schanTableW
,
280 /* This is what Windows reports. This shouldn't break any applications
281 * even though the functions are missing, because the wrapper will
282 * return SEC_E_UNSUPPORTED_FUNCTION if our function is NULL.
284 static const long caps
=
285 SECPKG_FLAG_INTEGRITY
|
286 SECPKG_FLAG_PRIVACY
|
287 SECPKG_FLAG_CONNECTION
|
288 SECPKG_FLAG_MULTI_REQUIRED
|
289 SECPKG_FLAG_EXTENDED_ERROR
|
290 SECPKG_FLAG_IMPERSONATION
|
291 SECPKG_FLAG_ACCEPT_WIN32_NAME
|
293 static const short version
= 1;
294 static const long maxToken
= 16384;
295 SEC_WCHAR
*uniSPName
= (SEC_WCHAR
*)UNISP_NAME_W
,
296 *schannel
= (SEC_WCHAR
*)SCHANNEL_NAME_W
;
298 const SecPkgInfoW info
[] = {
299 { caps
, version
, UNISP_RPC_ID
, maxToken
, uniSPName
, uniSPName
},
300 { caps
, version
, UNISP_RPC_ID
, maxToken
, schannel
,
301 (SEC_WCHAR
*)schannelComment
},
304 SECUR32_addPackages(provider
, sizeof(info
) / sizeof(info
[0]), NULL
,