~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/crypt32/tests/sip.c

Version: ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Subject Interface Package tests
  3  *
  4  * Copyright 2006 Paul Vriens
  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 
 21 #include <stdio.h>
 22 #include <stdarg.h>
 23 #include <windef.h>
 24 #include <winbase.h>
 25 #include <winerror.h>
 26 #include <winnls.h>
 27 #include <wincrypt.h>
 28 #include <mssip.h>
 29 
 30 #include "wine/test.h"
 31 
 32 static BOOL (WINAPI * funcCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *,DWORD *,DWORD,DWORD *,BYTE *);
 33 static BOOL (WINAPI * funcCryptSIPPutSignedDataMsg)(SIP_SUBJECTINFO *,DWORD,DWORD *,DWORD,BYTE *);
 34 static BOOL (WINAPI * funcCryptSIPCreateIndirectData)(SIP_SUBJECTINFO *,DWORD *,SIP_INDIRECT_DATA *);
 35 static BOOL (WINAPI * funcCryptSIPVerifyIndirectData)(SIP_SUBJECTINFO *,SIP_INDIRECT_DATA *);
 36 static BOOL (WINAPI * funcCryptSIPRemoveSignedDataMsg)(SIP_SUBJECTINFO *,DWORD);
 37 
 38 static char *show_guid(const GUID *guid)
 39 {
 40     static char guidstring[39];
 41 
 42     sprintf(guidstring,
 43         "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
 44         guid->Data1, guid->Data2, guid->Data3,
 45         guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
 46         guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
 47 
 48     return guidstring;
 49 }
 50 
 51 static void test_AddRemoveProvider(void)
 52 {
 53     BOOL ret;
 54     SIP_ADD_NEWPROVIDER newprov;
 55     GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }};
 56     static WCHAR dummydll[]      = {'d','e','a','d','b','e','e','f','.','d','l','l',0 };
 57     static WCHAR dummyfunction[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 };
 58 
 59     /* NULL check */
 60     SetLastError(0xdeadbeef);
 61     ret = CryptSIPRemoveProvider(NULL);
 62     ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
 63     ok (GetLastError() == ERROR_INVALID_PARAMETER,
 64         "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
 65 
 66     /* nonexistent provider should result in a registry error */
 67     SetLastError(0xdeadbeef);
 68     ret = CryptSIPRemoveProvider(&actionid);
 69     if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
 70     {
 71         /* Apparently the needed rights are checked before the existence of the provider */
 72         skip("Need admin rights\n");
 73     }
 74     else
 75     {
 76         ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
 77         ok (GetLastError() == ERROR_FILE_NOT_FOUND,
 78             "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
 79     }
 80 
 81     /* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL
 82      * as allowed */
 83 
 84     memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
 85     newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
 86     newprov.pgSubject = &actionid;
 87     newprov.pwszDLLFileName = dummydll;
 88     newprov.pwszGetFuncName = dummyfunction;
 89     newprov.pwszPutFuncName = dummyfunction;
 90     newprov.pwszCreateFuncName = dummyfunction;
 91     newprov.pwszVerifyFuncName = dummyfunction;
 92     newprov.pwszRemoveFuncName = dummyfunction;
 93     SetLastError(0xdeadbeef);
 94     ret = CryptSIPAddProvider(&newprov);
 95     if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
 96     {
 97         skip("Need admin rights\n");
 98         return;
 99     }
100     ok ( ret, "CryptSIPAddProvider should have succeeded\n");
101 
102     /* Dummy provider will be deleted, but the function still fails because
103      * pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the
104      * registry.
105      */
106     SetLastError(0xdeadbeef);
107     ret = CryptSIPRemoveProvider(&actionid);
108     ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
109     ok (GetLastError() == ERROR_FILE_NOT_FOUND,
110         "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
111 
112     /* Everything OK */
113     memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
114     newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
115     newprov.pgSubject = &actionid;
116     newprov.pwszDLLFileName = dummydll;
117     newprov.pwszGetFuncName = dummyfunction;
118     newprov.pwszPutFuncName = dummyfunction;
119     newprov.pwszCreateFuncName = dummyfunction;
120     newprov.pwszVerifyFuncName = dummyfunction;
121     newprov.pwszRemoveFuncName = dummyfunction;
122     newprov.pwszIsFunctionNameFmt2 = dummyfunction;
123     newprov.pwszIsFunctionName = dummyfunction;
124     SetLastError(0xdeadbeef);
125     ret = CryptSIPAddProvider(&newprov);
126     ok ( ret, "CryptSIPAddProvider should have succeeded\n");
127 
128     /* Dummy provider should be deleted */
129     SetLastError(0xdeadbeef);
130     ret = CryptSIPRemoveProvider(&actionid);
131     ok ( ret, "CryptSIPRemoveProvider should have succeeded\n");
132 }
133 
134 static void test_SIPRetrieveSubjectGUID(void)
135 {
136     BOOL ret;
137     GUID subject;
138     HANDLE file;
139     static const CHAR windir[] = "windir";
140     static const CHAR regeditExe[] = "regedit.exe";
141     static const GUID nullSubject  = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }};
142     static const WCHAR deadbeef[]  = { 'c',':','\\','d','e','a','d','b','e','e','f','.','d','b','f',0 };
143     /* Couldn't find a name for this GUID, it's the one used for 95% of the files */
144     static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
145     static CHAR  regeditPath[MAX_PATH];
146     static WCHAR regeditPathW[MAX_PATH];
147     static CHAR path[MAX_PATH];
148     static CHAR tempfile[MAX_PATH];
149     static WCHAR tempfileW[MAX_PATH];
150     DWORD written;
151 
152     /* NULL check */
153     SetLastError(0xdeadbeef);
154     ret = CryptSIPRetrieveSubjectGuid(NULL, NULL, NULL);
155     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
156     ok (GetLastError() == ERROR_INVALID_PARAMETER,
157         "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
158 
159     /* Test with a nonexistent file (hopefully) */
160     SetLastError(0xdeadbeef);
161     /* Set subject to something other than zeros */
162     memset(&subject, 1, sizeof(GUID));
163     ret = CryptSIPRetrieveSubjectGuid(deadbeef, NULL, &subject);
164     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
165     ok (GetLastError() == ERROR_FILE_NOT_FOUND,
166         "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
167     ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
168         "Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", show_guid(&subject));
169 
170     /* Now with an executable that should exist
171      *
172      * Use A-functions where possible as that should be available on all platforms
173      */
174     ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH);
175     ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError());
176     strcat(regeditPath, "\\");
177     strcat(regeditPath, regeditExe);
178     MultiByteToWideChar( CP_ACP, 0, regeditPath,
179                          strlen(regeditPath)+1, regeditPathW,
180                          sizeof(regeditPathW)/sizeof(regeditPathW[0]) );
181 
182     SetLastError(0xdeadbeef);
183     memset(&subject, 1, sizeof(GUID));
184     ret = CryptSIPRetrieveSubjectGuid(regeditPathW, NULL, &subject);
185     ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
186     ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
187         "Expected (%s), got (%s).\n", show_guid(&unknownGUID), show_guid(&subject));
188 
189     /* The same thing but now with a handle instead of a filename */
190     file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
191     SetLastError(0xdeadbeef);
192     memset(&subject, 1, sizeof(GUID));
193     ret = CryptSIPRetrieveSubjectGuid(NULL, file, &subject);
194     ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
195     ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
196         "Expected (%s), got (%s).\n", show_guid(&unknownGUID), show_guid(&subject));
197     CloseHandle(file);
198 
199     /* And both */
200     file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
201     SetLastError(0xdeadbeef);
202     memset(&subject, 1, sizeof(GUID));
203     ret = CryptSIPRetrieveSubjectGuid(regeditPathW, file, &subject);
204     ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
205     ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
206         "Expected (%s), got (%s).\n", show_guid(&unknownGUID), show_guid(&subject));
207     CloseHandle(file);
208 
209     /* Now with an empty file */
210     GetTempPathA(sizeof(path), path);
211     GetTempFileNameA(path, "sip", 0 , tempfile);
212     MultiByteToWideChar( CP_ACP, 0, tempfile,
213                          strlen(tempfile)+1, tempfileW,
214                          sizeof(tempfileW)/sizeof(tempfileW[0]) );
215 
216     SetLastError(0xdeadbeef);
217     memset(&subject, 1, sizeof(GUID));
218     ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
219     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
220     ok ( GetLastError() == ERROR_FILE_INVALID ||
221          GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ ||
222          GetLastError() == ERROR_SUCCESS /* Win98 */,
223         "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
224     ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
225         "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject));
226 
227     /* Use a file with a size of 3 (at least < 4) */
228     file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
229     WriteFile(file, "123", 3, &written, NULL);
230     CloseHandle(file);
231 
232     SetLastError(0xdeadbeef);
233     memset(&subject, 1, sizeof(GUID));
234     ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
235     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
236     ok ( GetLastError() == ERROR_INVALID_PARAMETER ||
237          GetLastError() == ERROR_SUCCESS /* Win98 */,
238         "Expected ERROR_INVALID_PARAMETER or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
239     ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
240         "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject));
241 
242     /* And now >= 4 */
243     file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
244     WriteFile(file, "1234", 4, &written, NULL);
245     CloseHandle(file);
246 
247     SetLastError(0xdeadbeef);
248     memset(&subject, 1, sizeof(GUID));
249     ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
250     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
251     ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN ||
252          GetLastError() == ERROR_SUCCESS /* Win98 */,
253         "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
254     ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
255         "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject));
256 
257     /* Clean up */
258     DeleteFileA(tempfile);
259 }
260 
261 static void test_SIPLoad(void)
262 {
263     BOOL ret;
264     GUID subject;
265     static GUID dummySubject = { 0xdeadbeef, 0xdead, 0xbeef, { 0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef }};
266     static GUID unknown      = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
267     static GUID unknown2     = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
268     /* The next SIP is available on Windows (not on a clean Wine install) */
269     static GUID unknown3     = { 0x000C10F1, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 }}; /* MSISIP.DLL */
270     SIP_DISPATCH_INFO sdi;
271     HMODULE hCrypt;
272 
273     /* All NULL */
274     SetLastError(0xdeadbeef);
275     ret = CryptSIPLoad(NULL, 0, NULL);
276     ok ( !ret, "Expected CryptSIPLoad to fail\n");
277     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
278         "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
279 
280     /* Only pSipDispatch NULL */
281     SetLastError(0xdeadbeef);
282     ret = CryptSIPLoad(&subject, 0, NULL);
283     ok ( !ret, "Expected CryptSIPLoad to fail\n");
284     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
285         "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
286 
287     /* No NULLs, but nonexistent pgSubject */
288     SetLastError(0xdeadbeef);
289     memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
290     sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
291     sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
292     ret = CryptSIPLoad(&dummySubject, 0, &sdi);
293     ok ( !ret, "Expected CryptSIPLoad to fail\n");
294     ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN,
295         "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
296     ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
297 
298     hCrypt = GetModuleHandleA("crypt32.dll");
299     funcCryptSIPGetSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPGetSignedDataMsg");
300     funcCryptSIPPutSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPPutSignedDataMsg");
301     funcCryptSIPCreateIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPCreateIndirectData");
302     funcCryptSIPVerifyIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPVerifyIndirectData");
303     funcCryptSIPRemoveSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPRemoveSignedDataMsg");
304 
305     /* All OK */
306     SetLastError(0xdeadbeef);
307     memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
308     sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
309     sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
310     ret = CryptSIPLoad(&unknown, 0, &sdi);
311     ok ( ret, "Expected CryptSIPLoad to succeed\n");
312     /* On native the last error will always be ERROR_PROC_NOT_FOUND as native searches for the function DllCanUnloadNow
313      * in WINTRUST.DLL (in this case). This function is not available in WINTRUST.DLL.
314      * For now there's no need to implement this is Wine as I doubt any program will rely on
315      * this last error when the call succeeded.
316      */
317     ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
318 
319     /* The function addresses returned by CryptSIPLoad are actually the addresses of
320      * crypt32's own functions. A function calling these addresses will end up first
321      * calling crypt32 functions which in its turn call the equivalent in the SIP
322      * as dictated by the given GUID.
323      */
324     if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
325         funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
326         ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
327             sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
328             sdi.pfCreate == funcCryptSIPCreateIndirectData &&
329             sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
330             sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
331             "Expected function addresses to be from crypt32\n");
332     else
333         trace("Couldn't load function pointers\n");
334 
335     /* All OK, but different GUID (same SIP though) */
336     SetLastError(0xdeadbeef);
337     memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
338     sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
339     sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
340     ret = CryptSIPLoad(&unknown2, 0, &sdi);
341     ok ( ret, "Expected CryptSIPLoad to succeed\n");
342     /* This call on its own would have resulted in an ERROR_PROC_NOT_FOUND, but the previous
343      * call to CryptSIPLoad already loaded wintrust.dll. As this information is cached,
344      * CryptSIPLoad will not try to search for the already mentioned DllCanUnloadNow.
345      */
346     ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
347 
348     /* All OK, but other SIP */
349     SetLastError(0xdeadbeef);
350     memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
351     sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
352     sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
353     ret = CryptSIPLoad(&unknown3, 0, &sdi);
354     if (ret)
355     {
356         /* The SIP is known so we can safely assume that the next tests can be done */
357 
358         /* As msisip.dll is not checked yet by any of the previous calls, the
359          * function DllCanUnloadNow will be checked again in msisip.dll (it's not present)
360          */
361         todo_wine
362         {
363             ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
364 
365             /* This is another SIP but this test proves the function addresses are the same as
366              * in the previous test.
367              */
368             if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
369                 funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
370                 ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
371                     sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
372                     sdi.pfCreate == funcCryptSIPCreateIndirectData &&
373                     sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
374                     sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
375                     "Expected function addresses to be from crypt32\n");
376             else
377                 trace("Couldn't load function pointers\n");
378         }
379     }
380 
381     /* Reserved parameter not 0 */
382     SetLastError(0xdeadbeef);
383     memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
384     sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
385     sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
386     ret = CryptSIPLoad(&unknown, 1, &sdi);
387     ok ( !ret, "Expected CryptSIPLoad to fail\n");
388     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
389         "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
390     ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
391 }
392 
393 START_TEST(sip)
394 {
395     test_AddRemoveProvider();
396     /* It seems that the caching for loaded dlls is shared between CryptSIPRetrieveSubjectGUID
397      * and CryptSIPLoad. The tests have to be in this order to succeed. This is because in the last
398      * test for CryptSIPRetrieveSubjectGUID, several SIPs will be loaded (on Windows).
399      */
400     test_SIPLoad();
401     test_SIPRetrieveSubjectGUID();
402 }
403 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.