ntdll: More compatible exception information for protection faults.
[wine/multimedia.git] / dlls / secur32 / schannel.c
blobc6f80bbed26e33ad7fabf5e67547e92abab218eb
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 static SecurityFunctionTableA schanTableA = {
161 NULL, /* EnumerateSecurityPackagesA */
162 schan_QueryCredentialsAttributesA,
163 schan_AcquireCredentialsHandleA,
164 NULL, /* FreeCredentialsHandle */
165 NULL, /* Reserved2 */
166 NULL, /* InitializeSecurityContextA */
167 NULL, /* AcceptSecurityContext */
168 NULL, /* CompleteAuthToken */
169 NULL, /* DeleteSecurityContext */
170 NULL, /* ApplyControlToken */
171 NULL, /* QueryContextAttributesA */
172 NULL, /* ImpersonateSecurityContext */
173 NULL, /* RevertSecurityContext */
174 NULL, /* MakeSignature */
175 NULL, /* VerifySignature */
176 FreeContextBuffer,
177 NULL, /* QuerySecurityPackageInfoA */
178 NULL, /* Reserved3 */
179 NULL, /* Reserved4 */
180 NULL, /* ExportSecurityContext */
181 NULL, /* ImportSecurityContextA */
182 NULL, /* AddCredentialsA */
183 NULL, /* Reserved8 */
184 NULL, /* QuerySecurityContextToken */
185 NULL, /* EncryptMessage */
186 NULL, /* DecryptMessage */
187 NULL, /* SetContextAttributesA */
190 static SecurityFunctionTableW schanTableW = {
192 NULL, /* EnumerateSecurityPackagesW */
193 schan_QueryCredentialsAttributesW,
194 schan_AcquireCredentialsHandleW,
195 NULL, /* FreeCredentialsHandle */
196 NULL, /* Reserved2 */
197 NULL, /* InitializeSecurityContextW */
198 NULL, /* AcceptSecurityContext */
199 NULL, /* CompleteAuthToken */
200 NULL, /* DeleteSecurityContext */
201 NULL, /* ApplyControlToken */
202 NULL, /* QueryContextAttributesW */
203 NULL, /* ImpersonateSecurityContext */
204 NULL, /* RevertSecurityContext */
205 NULL, /* MakeSignature */
206 NULL, /* VerifySignature */
207 FreeContextBuffer,
208 NULL, /* QuerySecurityPackageInfoW */
209 NULL, /* Reserved3 */
210 NULL, /* Reserved4 */
211 NULL, /* ExportSecurityContext */
212 NULL, /* ImportSecurityContextW */
213 NULL, /* AddCredentialsW */
214 NULL, /* Reserved8 */
215 NULL, /* QuerySecurityContextToken */
216 NULL, /* EncryptMessage */
217 NULL, /* DecryptMessage */
218 NULL, /* SetContextAttributesW */
221 static const WCHAR schannelComment[] = { 'S','c','h','a','n','n','e','l',' ',
222 'S','e','c','u','r','i','t','y',' ','P','a','c','k','a','g','e',0 };
224 void SECUR32_initSchannelSP(void)
226 SecureProvider *provider = SECUR32_addProvider(&schanTableA, &schanTableW,
227 NULL);
229 if (provider)
231 /* This is what Windows reports. This shouldn't break any applications
232 * even though the functions are missing, because the wrapper will
233 * return SEC_E_UNSUPPORTED_FUNCTION if our function is NULL.
235 static const long caps =
236 SECPKG_FLAG_INTEGRITY |
237 SECPKG_FLAG_PRIVACY |
238 SECPKG_FLAG_CONNECTION |
239 SECPKG_FLAG_MULTI_REQUIRED |
240 SECPKG_FLAG_EXTENDED_ERROR |
241 SECPKG_FLAG_IMPERSONATION |
242 SECPKG_FLAG_ACCEPT_WIN32_NAME |
243 SECPKG_FLAG_STREAM;
244 static const short version = 1;
245 static const long maxToken = 16384;
246 SEC_WCHAR *uniSPName = (SEC_WCHAR *)UNISP_NAME_W,
247 *schannel = (SEC_WCHAR *)SCHANNEL_NAME_W;
249 const SecPkgInfoW info[] = {
250 { caps, version, UNISP_RPC_ID, maxToken, uniSPName, uniSPName },
251 { caps, version, UNISP_RPC_ID, maxToken, schannel,
252 (SEC_WCHAR *)schannelComment },
255 SECUR32_addPackages(provider, sizeof(info) / sizeof(info[0]), NULL,
256 info);