dnsapi: Add DNS message parsing routines from BIND.
[wine/gsoc_dplay.git] / dlls / secur32 / schannel.c
blob0fa449c915a879720dd222b502e909cb2e7d2aa0
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
19 * implementation.
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "sspi.h"
25 #include "schannel.h"
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)
34 SECURITY_STATUS ret;
36 switch (ulAttribute)
38 case SECPKG_ATTR_SUPPORTED_ALGS:
39 if (pBuffer)
41 /* FIXME: get from CryptoAPI */
42 FIXME("%ld: stub\n", ulAttribute);
43 ret = SEC_E_UNSUPPORTED_FUNCTION;
45 else
46 ret = SEC_E_INTERNAL_ERROR;
47 break;
48 case SECPKG_ATTR_CIPHER_STRENGTHS:
49 if (pBuffer)
51 /* FIXME: get from CryptoAPI */
52 FIXME("%ld: stub\n", ulAttribute);
53 ret = SEC_E_UNSUPPORTED_FUNCTION;
55 else
56 ret = SEC_E_INTERNAL_ERROR;
57 break;
58 case SECPKG_ATTR_SUPPORTED_PROTOCOLS:
59 if (pBuffer)
61 /* FIXME: get from OpenSSL? */
62 FIXME("%ld: stub\n", ulAttribute);
63 ret = SEC_E_UNSUPPORTED_FUNCTION;
65 else
66 ret = SEC_E_INTERNAL_ERROR;
67 break;
68 default:
69 ret = SEC_E_UNSUPPORTED_FUNCTION;
71 return ret;
74 static SECURITY_STATUS SEC_ENTRY schan_QueryCredentialsAttributesA(
75 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
77 SECURITY_STATUS ret;
79 TRACE("(%p, %ld, %p)\n", phCredential, ulAttribute, pBuffer);
81 switch (ulAttribute)
83 case SECPKG_CRED_ATTR_NAMES:
84 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
85 ret = SEC_E_UNSUPPORTED_FUNCTION;
86 break;
87 default:
88 ret = schan_QueryCredentialsAttributes(phCredential, ulAttribute,
89 pBuffer);
91 return ret;
94 static SECURITY_STATUS SEC_ENTRY schan_QueryCredentialsAttributesW(
95 PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer)
97 SECURITY_STATUS ret;
99 TRACE("(%p, %ld, %p)\n", phCredential, ulAttribute, pBuffer);
101 switch (ulAttribute)
103 case SECPKG_CRED_ATTR_NAMES:
104 FIXME("SECPKG_CRED_ATTR_NAMES: stub\n");
105 ret = SEC_E_UNSUPPORTED_FUNCTION;
106 break;
107 default:
108 ret = schan_QueryCredentialsAttributes(phCredential, ulAttribute,
109 pBuffer);
111 return ret;
114 static SECURITY_STATUS schan_AcquireCredentialsHandle(ULONG fCredentialUse,
115 PCredHandle phCredential, PTimeStamp ptsExpiry)
117 SECURITY_STATUS ret;
119 if (fCredentialUse == SECPKG_CRED_BOTH)
120 ret = SEC_E_NO_CREDENTIALS;
121 else
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 */
128 if (ptsExpiry)
129 ptsExpiry->QuadPart = 0;
130 ret = SEC_E_OK;
132 return ret;
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,
144 ptsExpiry);
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,
156 ptsExpiry);
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)
168 SECURITY_STATUS ret;
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);
173 if(phCredential){
174 ret = SEC_E_UNSUPPORTED_FUNCTION;
176 else
178 ret = SEC_E_INVALID_HANDLE;
180 return ret;
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)
192 SECURITY_STATUS ret;
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);
197 if (phCredential)
199 ret = SEC_E_UNSUPPORTED_FUNCTION;
201 else
203 ret = SEC_E_INVALID_HANDLE;
205 return ret;
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 */
225 FreeContextBuffer,
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 */
256 FreeContextBuffer,
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,
276 NULL);
278 if (provider)
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 |
292 SECPKG_FLAG_STREAM;
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,
305 info);