msi: Write-strings warnings fix.
[wine] / dlls / secur32 / tests / schannel.c
1 /*
2  * Schannel tests
3  *
4  * Copyright 2006 Juan Lang
5  *
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.
10  *
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.
15  *
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
19  */
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>
27
28 #include "wine/test.h"
29
30 static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
31  0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
32  0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
33  0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
34  0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
35  0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
36  0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20,
37  0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
38  0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
39  0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
40 static const WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e',
41  'm','p',0 };
42 static const BYTE privKey[] = {
43  0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x32, 0x00,
44  0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x79, 0x10, 0x1c, 0xd0, 0x6b, 0x10,
45  0x18, 0x30, 0x94, 0x61, 0xdc, 0x0e, 0xcb, 0x96, 0x4e, 0x21, 0x3f, 0x79, 0xcd,
46  0xa9, 0x17, 0x62, 0xbc, 0xbb, 0x61, 0x4c, 0xe0, 0x75, 0x38, 0x6c, 0xf3, 0xde,
47  0x60, 0x86, 0x03, 0x97, 0x65, 0xeb, 0x1e, 0x6b, 0xdb, 0x53, 0x85, 0xad, 0x68,
48  0x21, 0xf1, 0x5d, 0xe7, 0x1f, 0xe6, 0x53, 0xb4, 0xbb, 0x59, 0x3e, 0x14, 0x27,
49  0xb1, 0x83, 0xa7, 0x3a, 0x54, 0xe2, 0x8f, 0x65, 0x8e, 0x6a, 0x4a, 0xcf, 0x3b,
50  0x1f, 0x65, 0xff, 0xfe, 0xf1, 0x31, 0x3a, 0x37, 0x7a, 0x8b, 0xcb, 0xc6, 0xd4,
51  0x98, 0x50, 0x36, 0x67, 0xe4, 0xa1, 0xe8, 0x7e, 0x8a, 0xc5, 0x23, 0xf2, 0x77,
52  0xf5, 0x37, 0x61, 0x49, 0x72, 0x59, 0xe8, 0x3d, 0xf7, 0x60, 0xb2, 0x77, 0xca,
53  0x78, 0x54, 0x6d, 0x65, 0x9e, 0x03, 0x97, 0x1b, 0x61, 0xbd, 0x0c, 0xd8, 0x06,
54  0x63, 0xe2, 0xc5, 0x48, 0xef, 0xb3, 0xe2, 0x6e, 0x98, 0x7d, 0xbd, 0x4e, 0x72,
55  0x91, 0xdb, 0x31, 0x57, 0xe3, 0x65, 0x3a, 0x49, 0xca, 0xec, 0xd2, 0x02, 0x4e,
56  0x22, 0x7e, 0x72, 0x8e, 0xf9, 0x79, 0x84, 0x82, 0xdf, 0x7b, 0x92, 0x2d, 0xaf,
57  0xc9, 0xe4, 0x33, 0xef, 0x89, 0x5c, 0x66, 0x99, 0xd8, 0x80, 0x81, 0x47, 0x2b,
58  0xb1, 0x66, 0x02, 0x84, 0x59, 0x7b, 0xc3, 0xbe, 0x98, 0x45, 0x4a, 0x3d, 0xdd,
59  0xea, 0x2b, 0xdf, 0x4e, 0xb4, 0x24, 0x6b, 0xec, 0xe7, 0xd9, 0x0c, 0x45, 0xb8,
60  0xbe, 0xca, 0x69, 0x37, 0x92, 0x4c, 0x38, 0x6b, 0x96, 0x6d, 0xcd, 0x86, 0x67,
61  0x5c, 0xea, 0x54, 0x94, 0xa4, 0xca, 0xa4, 0x02, 0xa5, 0x21, 0x4d, 0xae, 0x40,
62  0x8f, 0x9d, 0x51, 0x83, 0xf2, 0x3f, 0x33, 0xc1, 0x72, 0xb4, 0x1d, 0x94, 0x6e,
63  0x7d, 0xe4, 0x27, 0x3f, 0xea, 0xff, 0xe5, 0x9b, 0xa7, 0x5e, 0x55, 0x8e, 0x0d,
64  0x69, 0x1c, 0x7a, 0xff, 0x81, 0x9d, 0x53, 0x52, 0x97, 0x9a, 0x76, 0x79, 0xda,
65  0x93, 0x32, 0x16, 0xec, 0x69, 0x51, 0x1a, 0x4e, 0xc3, 0xf1, 0x72, 0x80, 0x78,
66  0x5e, 0x66, 0x4a, 0x8d, 0x85, 0x2f, 0x3f, 0xb2, 0xa7 };
67
68 static const BYTE selfSignedCert[] = {
69  0x30, 0x82, 0x01, 0x1f, 0x30, 0x81, 0xce, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
70  0x10, 0xeb, 0x0d, 0x57, 0x2a, 0x9c, 0x09, 0xba, 0xa4, 0x4a, 0xb7, 0x25, 0x49,
71  0xd9, 0x3e, 0xb5, 0x73, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d,
72  0x05, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03,
73  0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30,
74  0x1e, 0x17, 0x0d, 0x30, 0x36, 0x30, 0x36, 0x32, 0x39, 0x30, 0x35, 0x30, 0x30,
75  0x34, 0x36, 0x5a, 0x17, 0x0d, 0x30, 0x37, 0x30, 0x36, 0x32, 0x39, 0x31, 0x31,
76  0x30, 0x30, 0x34, 0x36, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
77  0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e,
78  0x67, 0x00, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
79  0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
80  0x00, 0xe2, 0x54, 0x3a, 0xa7, 0x83, 0xb1, 0x27, 0x14, 0x3e, 0x59, 0xbb, 0xb4,
81  0x53, 0xe6, 0x1f, 0xe7, 0x5d, 0xf1, 0x21, 0x68, 0xad, 0x85, 0x53, 0xdb, 0x6b,
82  0x1e, 0xeb, 0x65, 0x97, 0x03, 0x86, 0x60, 0xde, 0xf3, 0x6c, 0x38, 0x75, 0xe0,
83  0x4c, 0x61, 0xbb, 0xbc, 0x62, 0x17, 0xa9, 0xcd, 0x79, 0x3f, 0x21, 0x4e, 0x96,
84  0xcb, 0x0e, 0xdc, 0x61, 0x94, 0x30, 0x18, 0x10, 0x6b, 0xd0, 0x1c, 0x10, 0x79,
85  0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
86  0x1d, 0x05, 0x00, 0x03, 0x41, 0x00, 0x25, 0x90, 0x53, 0x34, 0xd9, 0x56, 0x41,
87  0x5e, 0xdb, 0x7e, 0x01, 0x36, 0xec, 0x27, 0x61, 0x5e, 0xb7, 0x4d, 0x90, 0x66,
88  0xa2, 0xe1, 0x9d, 0x58, 0x76, 0xd4, 0x9c, 0xba, 0x2c, 0x84, 0xc6, 0x83, 0x7a,
89  0x22, 0x0d, 0x03, 0x69, 0x32, 0x1a, 0x6d, 0xcb, 0x0c, 0x15, 0xb3, 0x6b, 0xc7,
90  0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f,
91  0xa8, 0x76, 0x57, 0x92, 0x36 };
92
93 static void testAcquireSecurityContext(void)
94 {
95     SECURITY_STATUS st;
96     CredHandle cred;
97     TimeStamp exp;
98     SCHANNEL_CRED schanCred;
99     PCCERT_CONTEXT certs[2];
100     HCRYPTPROV csp;
101     BOOL ret;
102     HCRYPTKEY key;
103     CRYPT_KEY_PROV_INFO keyProvInfo;
104
105     keyProvInfo.pwszContainerName = (LPWSTR)cspNameW;
106     keyProvInfo.pwszProvName = (LPWSTR)MS_DEF_PROV_W;
107     keyProvInfo.dwProvType = PROV_RSA_FULL;
108     keyProvInfo.dwFlags = 0;
109     keyProvInfo.cProvParam = 0;
110     keyProvInfo.rgProvParam = NULL;
111     keyProvInfo.dwKeySpec = AT_SIGNATURE;
112
113     certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
114      sizeof(bigCert));
115     certs[1] = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert,
116      sizeof(selfSignedCert));
117
118     CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
119      CRYPT_DELETEKEYSET);
120
121     st = AcquireCredentialsHandleA(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL,
122      NULL);
123     ok(st == SEC_E_SECPKG_NOT_FOUND,
124      "Expected SEC_E_SECPKG_NOT_FOUND, got %08lx\n", st);
125     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, 0, NULL, NULL, NULL,
126      NULL, NULL, NULL);
127     ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08lx\n",
128      st);
129     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_BOTH, NULL,
130      NULL, NULL, NULL, NULL, NULL);
131     ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08lx\n",
132      st);
133     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
134      NULL, NULL, NULL, NULL, NULL, NULL);
135     ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08lx\n",
136      st);
137     /* Crashes
138     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
139      NULL, NULL, NULL, NULL, NULL, NULL);
140      */
141     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
142      NULL, NULL, NULL, NULL, &cred, NULL);
143     ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
144     FreeCredentialsHandle(&cred);
145     memset(&cred, 0, sizeof(cred));
146     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
147      NULL, NULL, NULL, NULL, &cred, &exp);
148     ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
149     ok(exp.HighPart == 0 && exp.LowPart == 0,
150      "Expected 0 expiry, got %08lx%08lx\n", exp.HighPart, exp.LowPart);
151     FreeCredentialsHandle(&cred);
152
153     /* Bad version in SCHANNEL_CRED */
154     memset(&schanCred, 0, sizeof(schanCred));
155     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
156      NULL, &schanCred, NULL, NULL, NULL, NULL);
157     ok(st == SEC_E_INTERNAL_ERROR, "Expected SEC_E_INTERNAL_ERROR, got %08lx\n",
158      st);
159     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
160      NULL, &schanCred, NULL, NULL, NULL, NULL);
161     ok(st == SEC_E_INTERNAL_ERROR, "Expected SEC_E_INTERNAL_ERROR, got %08lx\n",
162      st);
163
164     /* No cert in SCHANNEL_CRED succeeds for outbound.. */
165     schanCred.dwVersion = SCHANNEL_CRED_VERSION;
166     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
167      NULL, &schanCred, NULL, NULL, &cred, NULL);
168     ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
169     FreeCredentialsHandle(&cred);
170     /* but fails for inbound. */
171     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
172      NULL, &schanCred, NULL, NULL, NULL, NULL);
173     ok(st == SEC_E_NO_CREDENTIALS, "Expected SEC_E_NO_CREDENTIALS, got %08lx\n",
174      st);
175
176     /* Crashes with bad paCred pointer
177     schanCred.cCreds = 1;
178     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
179      NULL, &schanCred, NULL, NULL, NULL, NULL);
180      */
181
182     /* Bogus cert in SCHANNEL_CRED. Windows fails with
183      * SEC_E_UNKNOWN_CREDENTIALS, but I'll accept SEC_E_NO_CREDENTIALS too.
184      */
185     schanCred.cCreds = 1;
186     schanCred.paCred = &certs[0];
187     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
188      NULL, &schanCred, NULL, NULL, NULL, NULL);
189     ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
190      "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08lx\n",
191      st);
192     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
193      NULL, &schanCred, NULL, NULL, NULL, NULL);
194     ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
195      "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08lx\n",
196      st);
197
198     /* Good cert, but missing private key. Windows fails with
199      * SEC_E_NO_CREDENTIALS, but I'll accept SEC_E_UNKNOWN_CREDENTIALS too.
200      */
201     schanCred.cCreds = 1;
202     schanCred.paCred = &certs[1];
203     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
204      NULL, &schanCred, NULL, NULL, &cred, NULL);
205     ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
206      "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08lx\n",
207      st);
208     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
209      NULL, &schanCred, NULL, NULL, NULL, NULL);
210     ok(st == SEC_E_UNKNOWN_CREDENTIALS || SEC_E_NO_CREDENTIALS,
211      "Expected SEC_E_UNKNOWN_CREDENTIALS or SEC_E_NO_CREDENTIALS, got %08lx\n",
212      st);
213
214     /* Good cert, with CRYPT_KEY_PROV_INFO set before it's had a key loaded. */
215     ret = CertSetCertificateContextProperty(certs[1],
216      CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo);
217     schanCred.dwVersion = SCH_CRED_V3;
218     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
219      NULL, &schanCred, NULL, NULL, &cred, NULL);
220     ok(st == SEC_E_UNKNOWN_CREDENTIALS,
221      "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
222     st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
223      NULL, &schanCred, NULL, NULL, &cred, NULL);
224     ok(st == SEC_E_UNKNOWN_CREDENTIALS,
225      "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
226
227     ret = CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
228      CRYPT_NEWKEYSET);
229     ok(ret, "CryptAcquireContextW failed: %08lx\n", GetLastError());
230     ret = CryptImportKey(csp, (LPBYTE)privKey, sizeof(privKey), 0, 0, &key);
231     ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
232     if (ret)
233     {
234         PCCERT_CONTEXT tmp;
235
236         /* Crashes
237         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
238          NULL, &schanCred, NULL, NULL, NULL, NULL);
239          */
240         /* Good cert with private key, bogus version */
241         schanCred.dwVersion = SCH_CRED_V1;
242         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
243          NULL, &schanCred, NULL, NULL, &cred, NULL);
244         ok(st == SEC_E_INTERNAL_ERROR,
245          "Expected SEC_E_INTERNAL_ERROR, got %08lx\n", st);
246         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
247          NULL, &schanCred, NULL, NULL, &cred, NULL);
248         ok(st == SEC_E_INTERNAL_ERROR,
249          "Expected SEC_E_INTERNAL_ERROR, got %08lx\n", st);
250         schanCred.dwVersion = SCH_CRED_V2;
251         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
252          NULL, &schanCred, NULL, NULL, &cred, NULL);
253         ok(st == SEC_E_INTERNAL_ERROR,
254          "Expected SEC_E_INTERNAL_ERROR, got %08lx\n", st);
255         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
256          NULL, &schanCred, NULL, NULL, &cred, NULL);
257         ok(st == SEC_E_INTERNAL_ERROR,
258          "Expected SEC_E_INTERNAL_ERROR, got %08lx\n", st);
259
260         /* Succeeds on V3 or higher */
261         schanCred.dwVersion = SCH_CRED_V3;
262         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
263          NULL, &schanCred, NULL, NULL, &cred, NULL);
264         ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
265         FreeCredentialsHandle(&cred);
266         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
267          NULL, &schanCred, NULL, NULL, &cred, NULL);
268         ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
269         FreeCredentialsHandle(&cred);
270         schanCred.dwVersion = SCHANNEL_CRED_VERSION;
271         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
272          NULL, &schanCred, NULL, NULL, &cred, NULL);
273         ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
274         FreeCredentialsHandle(&cred);
275         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
276          NULL, &schanCred, NULL, NULL, &cred, NULL);
277         ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08lx\n", st);
278         FreeCredentialsHandle(&cred);
279
280         /* How about more than one cert? */
281         schanCred.cCreds = 2;
282         schanCred.paCred = certs;
283         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
284          NULL, &schanCred, NULL, NULL, &cred, NULL);
285         ok(st == SEC_E_UNKNOWN_CREDENTIALS,
286          "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
287         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
288          NULL, &schanCred, NULL, NULL, &cred, NULL);
289         ok(st == SEC_E_UNKNOWN_CREDENTIALS,
290          "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
291         tmp = certs[0];
292         certs[0] = certs[1];
293         certs[1] = tmp;
294         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND,
295          NULL, &schanCred, NULL, NULL, &cred, NULL);
296         ok(st == SEC_E_UNKNOWN_CREDENTIALS,
297          "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
298         st = AcquireCredentialsHandleA(NULL, UNISP_NAME_A, SECPKG_CRED_INBOUND,
299          NULL, &schanCred, NULL, NULL, &cred, NULL);
300         ok(st == SEC_E_UNKNOWN_CREDENTIALS,
301          "Expected SEC_E_UNKNOWN_CREDENTIALS, got %08lx\n", st);
302         /* FIXME: what about two valid certs? */
303
304         CryptDestroyKey(key);
305     }
306
307     CryptReleaseContext(csp, 0);
308     CryptAcquireContextW(&csp, cspNameW, MS_DEF_PROV_W, PROV_RSA_FULL,
309      CRYPT_DELETEKEYSET);
310
311     CertFreeCertificateContext(certs[0]);
312     CertFreeCertificateContext(certs[1]);
313 }
314
315 START_TEST(schannel)
316 {
317     testAcquireSecurityContext();
318 }