wined3d: Remove IWineD3DDevice::EnumDisplayModes.
[wine/testsucceed.git] / dlls / secur32 / tests / schannel.c
blobb71040a7b06e4e5dac88a2f34e5cb14f659a7c2b
1 /*
2 * Schannel tests
4 * Copyright 2006 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdio.h>
21 #include <stdarg.h>
22 #include <windef.h>
23 #include <winbase.h>
24 #define SECURITY_WIN32
25 #include <security.h>
26 #include <schannel.h>
28 #include "wine/test.h"
30 static HMODULE secdll;
31 static SECURITY_STATUS (SEC_ENTRY * pAcquireCredentialsHandleA)(SEC_CHAR*, SEC_CHAR*,
32 ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID, PCredHandle, PTimeStamp);
33 static SECURITY_STATUS (SEC_ENTRY * pFreeCredentialsHandle)(PCredHandle);
35 static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
36 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
37 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
38 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
39 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
40 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
41 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20,
42 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
43 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
44 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
45 static WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e',
46 'm','p',0 };
47 static BYTE privKey[] = {
48 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x32, 0x00,
49 0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x79, 0x10, 0x1c, 0xd0, 0x6b, 0x10,
50 0x18, 0x30, 0x94, 0x61, 0xdc, 0x0e, 0xcb, 0x96, 0x4e, 0x21, 0x3f, 0x79, 0xcd,
51 0xa9, 0x17, 0x62, 0xbc, 0xbb, 0x61, 0x4c, 0xe0, 0x75, 0x38, 0x6c, 0xf3, 0xde,
52 0x60, 0x86, 0x03, 0x97, 0x65, 0xeb, 0x1e, 0x6b, 0xdb, 0x53, 0x85, 0xad, 0x68,
53 0x21, 0xf1, 0x5d, 0xe7, 0x1f, 0xe6, 0x53, 0xb4, 0xbb, 0x59, 0x3e, 0x14, 0x27,
54 0xb1, 0x83, 0xa7, 0x3a, 0x54, 0xe2, 0x8f, 0x65, 0x8e, 0x6a, 0x4a, 0xcf, 0x3b,
55 0x1f, 0x65, 0xff, 0xfe, 0xf1, 0x31, 0x3a, 0x37, 0x7a, 0x8b, 0xcb, 0xc6, 0xd4,
56 0x98, 0x50, 0x36, 0x67, 0xe4, 0xa1, 0xe8, 0x7e, 0x8a, 0xc5, 0x23, 0xf2, 0x77,
57 0xf5, 0x37, 0x61, 0x49, 0x72, 0x59, 0xe8, 0x3d, 0xf7, 0x60, 0xb2, 0x77, 0xca,
58 0x78, 0x54, 0x6d, 0x65, 0x9e, 0x03, 0x97, 0x1b, 0x61, 0xbd, 0x0c, 0xd8, 0x06,
59 0x63, 0xe2, 0xc5, 0x48, 0xef, 0xb3, 0xe2, 0x6e, 0x98, 0x7d, 0xbd, 0x4e, 0x72,
60 0x91, 0xdb, 0x31, 0x57, 0xe3, 0x65, 0x3a, 0x49, 0xca, 0xec, 0xd2, 0x02, 0x4e,
61 0x22, 0x7e, 0x72, 0x8e, 0xf9, 0x79, 0x84, 0x82, 0xdf, 0x7b, 0x92, 0x2d, 0xaf,
62 0xc9, 0xe4, 0x33, 0xef, 0x89, 0x5c, 0x66, 0x99, 0xd8, 0x80, 0x81, 0x47, 0x2b,
63 0xb1, 0x66, 0x02, 0x84, 0x59, 0x7b, 0xc3, 0xbe, 0x98, 0x45, 0x4a, 0x3d, 0xdd,
64 0xea, 0x2b, 0xdf, 0x4e, 0xb4, 0x24, 0x6b, 0xec, 0xe7, 0xd9, 0x0c, 0x45, 0xb8,
65 0xbe, 0xca, 0x69, 0x37, 0x92, 0x4c, 0x38, 0x6b, 0x96, 0x6d, 0xcd, 0x86, 0x67,
66 0x5c, 0xea, 0x54, 0x94, 0xa4, 0xca, 0xa4, 0x02, 0xa5, 0x21, 0x4d, 0xae, 0x40,
67 0x8f, 0x9d, 0x51, 0x83, 0xf2, 0x3f, 0x33, 0xc1, 0x72, 0xb4, 0x1d, 0x94, 0x6e,
68 0x7d, 0xe4, 0x27, 0x3f, 0xea, 0xff, 0xe5, 0x9b, 0xa7, 0x5e, 0x55, 0x8e, 0x0d,
69 0x69, 0x1c, 0x7a, 0xff, 0x81, 0x9d, 0x53, 0x52, 0x97, 0x9a, 0x76, 0x79, 0xda,
70 0x93, 0x32, 0x16, 0xec, 0x69, 0x51, 0x1a, 0x4e, 0xc3, 0xf1, 0x72, 0x80, 0x78,
71 0x5e, 0x66, 0x4a, 0x8d, 0x85, 0x2f, 0x3f, 0xb2, 0xa7 };
73 static const BYTE selfSignedCert[] = {
74 0x30, 0x82, 0x01, 0x1f, 0x30, 0x81, 0xce, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
75 0x10, 0xeb, 0x0d, 0x57, 0x2a, 0x9c, 0x09, 0xba, 0xa4, 0x4a, 0xb7, 0x25, 0x49,
76 0xd9, 0x3e, 0xb5, 0x73, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d,
77 0x05, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03,
78 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30,
79 0x1e, 0x17, 0x0d, 0x30, 0x36, 0x30, 0x36, 0x32, 0x39, 0x30, 0x35, 0x30, 0x30,
80 0x34, 0x36, 0x5a, 0x17, 0x0d, 0x30, 0x37, 0x30, 0x36, 0x32, 0x39, 0x31, 0x31,
81 0x30, 0x30, 0x34, 0x36, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
82 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e,
83 0x67, 0x00, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
84 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
85 0x00, 0xe2, 0x54, 0x3a, 0xa7, 0x83, 0xb1, 0x27, 0x14, 0x3e, 0x59, 0xbb, 0xb4,
86 0x53, 0xe6, 0x1f, 0xe7, 0x5d, 0xf1, 0x21, 0x68, 0xad, 0x85, 0x53, 0xdb, 0x6b,
87 0x1e, 0xeb, 0x65, 0x97, 0x03, 0x86, 0x60, 0xde, 0xf3, 0x6c, 0x38, 0x75, 0xe0,
88 0x4c, 0x61, 0xbb, 0xbc, 0x62, 0x17, 0xa9, 0xcd, 0x79, 0x3f, 0x21, 0x4e, 0x96,
89 0xcb, 0x0e, 0xdc, 0x61, 0x94, 0x30, 0x18, 0x10, 0x6b, 0xd0, 0x1c, 0x10, 0x79,
90 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
91 0x1d, 0x05, 0x00, 0x03, 0x41, 0x00, 0x25, 0x90, 0x53, 0x34, 0xd9, 0x56, 0x41,
92 0x5e, 0xdb, 0x7e, 0x01, 0x36, 0xec, 0x27, 0x61, 0x5e, 0xb7, 0x4d, 0x90, 0x66,
93 0xa2, 0xe1, 0x9d, 0x58, 0x76, 0xd4, 0x9c, 0xba, 0x2c, 0x84, 0xc6, 0x83, 0x7a,
94 0x22, 0x0d, 0x03, 0x69, 0x32, 0x1a, 0x6d, 0xcb, 0x0c, 0x15, 0xb3, 0x6b, 0xc7,
95 0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f,
96 0xa8, 0x76, 0x57, 0x92, 0x36 };
98 static void InitFunctionPtrs(void)
100 secdll = LoadLibraryA("secur32.dll");
101 if(!secdll)
102 secdll = LoadLibraryA("security.dll");
103 if(secdll)
105 pAcquireCredentialsHandleA = (PVOID)GetProcAddress(secdll, "AcquireCredentialsHandleA");
106 pFreeCredentialsHandle = (PVOID)GetProcAddress(secdll, "FreeCredentialsHandle");
110 static void testAcquireSecurityContext(void)
112 SECURITY_STATUS st;
113 CredHandle cred;
114 TimeStamp exp;
115 SCHANNEL_CRED schanCred;
116 PCCERT_CONTEXT certs[2];
117 HCRYPTPROV csp;
118 static CHAR unisp_name_a[] = UNISP_NAME_A;
119 WCHAR ms_def_prov_w[MAX_PATH];
120 BOOL ret;
121 HCRYPTKEY key;
122 CRYPT_KEY_PROV_INFO keyProvInfo;
124 lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W);
126 keyProvInfo.pwszContainerName = cspNameW;
127 keyProvInfo.pwszProvName = ms_def_prov_w;
128 keyProvInfo.dwProvType = PROV_RSA_FULL;
129 keyProvInfo.dwFlags = 0;
130 keyProvInfo.cProvParam = 0;
131 keyProvInfo.rgProvParam = NULL;
132 keyProvInfo.dwKeySpec = AT_SIGNATURE;
134 certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
135 sizeof(bigCert));
136 certs[1] = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert,
137 sizeof(selfSignedCert));
139 CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
140 CRYPT_DELETEKEYSET);
142 st = pAcquireCredentialsHandleA(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL,
143 NULL);
144 ok(st == SEC_E_SECPKG_NOT_FOUND,
145 "Expected SEC_E_SECPKG_NOT_FOUND, got %08x\n", st);
146 if (0)
148 /* Crashes on Win2K */
149 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, 0, NULL, NULL, NULL,
150 NULL, NULL, NULL);
151 ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08x\n",
152 st);
154 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_BOTH, NULL,
155 NULL, NULL, NULL, NULL, NULL);
156 ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08x\n",
157 st);
158 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
159 NULL, NULL, NULL, NULL, NULL, NULL);
160 ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08x\n",
161 st);
162 if (0)
164 /* Crashes */
165 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
166 NULL, NULL, NULL, NULL, NULL, NULL);
168 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
169 NULL, NULL, NULL, NULL, &cred, NULL);
170 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
171 pFreeCredentialsHandle(&cred);
172 memset(&cred, 0, sizeof(cred));
173 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
174 NULL, NULL, NULL, NULL, &cred, &exp);
175 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
176 ok(exp.HighPart == 0 && exp.LowPart == 0,
177 "Expected 0 expiry, got %08lx%08lx\n", exp.HighPart, exp.LowPart);
178 pFreeCredentialsHandle(&cred);
180 /* Bad version in SCHANNEL_CRED */
181 memset(&schanCred, 0, sizeof(schanCred));
182 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
183 NULL, &schanCred, NULL, NULL, NULL, NULL);
184 ok(st == SEC_E_INTERNAL_ERROR, "Expected SEC_E_INTERNAL_ERROR, got %08x\n",
185 st);
186 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
187 NULL, &schanCred, NULL, NULL, NULL, NULL);
188 ok(st == SEC_E_INTERNAL_ERROR, "Expected SEC_E_INTERNAL_ERROR, got %08x\n",
189 st);
191 /* No cert in SCHANNEL_CRED succeeds for outbound.. */
192 schanCred.dwVersion = SCHANNEL_CRED_VERSION;
193 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
194 NULL, &schanCred, NULL, NULL, &cred, NULL);
195 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
196 pFreeCredentialsHandle(&cred);
197 /* but fails for inbound. */
198 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
199 NULL, &schanCred, NULL, NULL, NULL, NULL);
200 ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08x\n",
201 st);
203 if (0)
205 /* Crashes with bad paCred pointer */
206 schanCred.cCreds = 1;
207 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
208 NULL, &schanCred, NULL, NULL, NULL, NULL);
211 /* Bogus cert in SCHANNEL_CRED. Windows fails with
212 * SEC_E_UNKNOWN_CREDENTIALS, but I'll accept SEC_E_NO_CREDENTIALS too.
214 schanCred.cCreds = 1;
215 schanCred.paCred = &certs[0];
216 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
217 NULL, &schanCred, NULL, NULL, NULL, NULL);
218 ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
219 "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08x\n",
220 st);
221 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
222 NULL, &schanCred, NULL, NULL, NULL, NULL);
223 ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
224 "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08x\n",
225 st);
227 /* Good cert, but missing private key. Windows fails with
228 * SEC_E_NO_CREDENTIALS, but I'll accept SEC_E_UNKNOWN_CREDENTIALS too.
230 schanCred.cCreds = 1;
231 schanCred.paCred = &certs[1];
232 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
233 NULL, &schanCred, NULL, NULL, &cred, NULL);
234 ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
235 "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08x\n",
236 st);
237 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
238 NULL, &schanCred, NULL, NULL, NULL, NULL);
239 ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
240 "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08x\n",
241 st);
243 /* Good cert, with CRYPT_KEY_PROV_INFO set before it's had a key loaded. */
244 ret = CertSetCertificateContextProperty(certs[1],
245 CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo);
246 schanCred.dwVersion = SCH_CRED_V3;
247 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
248 NULL, &schanCred, NULL, NULL, &cred, NULL);
249 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
250 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
251 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
252 NULL, &schanCred, NULL, NULL, &cred, NULL);
253 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
254 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
256 ret = CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
257 CRYPT_NEWKEYSET);
258 ok(ret, "CryptAcquireContextW failed: %08x\n", GetLastError());
259 ret = CryptImportKey(csp, privKey, sizeof(privKey), 0, 0, &key);
260 ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
261 if (ret)
263 PCCERT_CONTEXT tmp;
265 if (0)
267 /* Crashes */
268 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
269 NULL, &schanCred, NULL, NULL, NULL, NULL);
271 /* Good cert with private key, bogus version */
272 schanCred.dwVersion = SCH_CRED_V1;
273 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
274 NULL, &schanCred, NULL, NULL, &cred, NULL);
275 ok(st == SEC_E_INTERNAL_ERROR,
276 "Expected SEC_E_INTERNAL_ERROR, got %08x\n", st);
277 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
278 NULL, &schanCred, NULL, NULL, &cred, NULL);
279 ok(st == SEC_E_INTERNAL_ERROR,
280 "Expected SEC_E_INTERNAL_ERROR, got %08x\n", st);
281 schanCred.dwVersion = SCH_CRED_V2;
282 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
283 NULL, &schanCred, NULL, NULL, &cred, NULL);
284 ok(st == SEC_E_INTERNAL_ERROR,
285 "Expected SEC_E_INTERNAL_ERROR, got %08x\n", st);
286 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
287 NULL, &schanCred, NULL, NULL, &cred, NULL);
288 ok(st == SEC_E_INTERNAL_ERROR,
289 "Expected SEC_E_INTERNAL_ERROR, got %08x\n", st);
291 /* Succeeds on V3 or higher */
292 schanCred.dwVersion = SCH_CRED_V3;
293 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
294 NULL, &schanCred, NULL, NULL, &cred, NULL);
295 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
296 pFreeCredentialsHandle(&cred);
297 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
298 NULL, &schanCred, NULL, NULL, &cred, NULL);
299 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
300 pFreeCredentialsHandle(&cred);
301 schanCred.dwVersion = SCHANNEL_CRED_VERSION;
302 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
303 NULL, &schanCred, NULL, NULL, &cred, NULL);
304 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
305 pFreeCredentialsHandle(&cred);
306 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
307 NULL, &schanCred, NULL, NULL, &cred, NULL);
308 ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st);
309 pFreeCredentialsHandle(&cred);
311 /* How about more than one cert? */
312 schanCred.cCreds = 2;
313 schanCred.paCred = certs;
314 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
315 NULL, &schanCred, NULL, NULL, &cred, NULL);
316 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
317 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
318 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
319 NULL, &schanCred, NULL, NULL, &cred, NULL);
320 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
321 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
322 tmp = certs[0];
323 certs[0] = certs[1];
324 certs[1] = tmp;
325 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_OUTBOUND,
326 NULL, &schanCred, NULL, NULL, &cred, NULL);
327 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
328 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
329 st = pAcquireCredentialsHandleA(NULL, unisp_name_a, SECPKG_CRED_INBOUND,
330 NULL, &schanCred, NULL, NULL, &cred, NULL);
331 ok(st == SEC_E_UNKNOWN_CREDENTIALS,
332 "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08x\n", st);
333 /* FIXME: what about two valid certs? */
335 CryptDestroyKey(key);
338 CryptReleaseContext(csp, 0);
339 CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
340 CRYPT_DELETEKEYSET);
342 CertFreeCertificateContext(certs[0]);
343 CertFreeCertificateContext(certs[1]);
346 START_TEST(schannel)
348 InitFunctionPtrs();
350 if (pAcquireCredentialsHandleA && pFreeCredentialsHandle)
351 testAcquireSecurityContext();
353 if(secdll)
354 FreeLibrary(secdll);