ReactOS 0.4.17-dev-470-gf9e3448
sip.c
Go to the documentation of this file.
1/*
2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2005-2008 Juan Lang
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 <stdarg.h>
22#include <stdio.h>
23
24#include "windef.h"
25#include "winbase.h"
26#include "wincrypt.h"
27#include "winreg.h"
28#include "winnls.h"
29#include "mssip.h"
30#include "winuser.h"
31#include "crypt32_private.h"
32
33#include "wine/debug.h"
34#include "wine/list.h"
35
37
38/* convert a guid to a wide character string */
39static void CRYPT_guid2wstr( const GUID *guid, LPWSTR wstr )
40{
41 char str[40];
42
43 sprintf(str, "{%08lX-%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 MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 40 );
48}
49
50/***********************************************************************
51 * CRYPT_SIPDeleteFunction
52 *
53 * Helper function for CryptSIPRemoveProvider
54 */
56{
57 WCHAR szFullKey[ 0x100 ];
59
60 /* max length of szFullKey depends on our code only, so we won't overrun */
61 lstrcpyW( szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll" );
62 lstrcatW( szFullKey, szKey );
63 CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
64
66
67 return r;
68}
69
70/***********************************************************************
71 * CryptSIPRemoveProvider (CRYPT32.@)
72 *
73 * Remove a SIP provider and its functions from the registry.
74 *
75 * PARAMS
76 * pgProv [I] Pointer to a GUID for this SIP provider
77 *
78 * RETURNS
79 * Success: TRUE.
80 * Failure: FALSE. (Look at GetLastError()).
81 *
82 * NOTES
83 * Registry errors are always reported via SetLastError(). Every registry
84 * deletion will be tried.
85 */
87{
89 LONG remove_error = ERROR_SUCCESS;
90
91 TRACE("%s\n", debugstr_guid(pgProv));
92
93 if (!pgProv)
94 {
96 return FALSE;
97 }
98
99
100#define CRYPT_SIPREMOVEPROV( key ) \
101 r = CRYPT_SIPDeleteFunction( pgProv, key); \
102 if (r != ERROR_SUCCESS) remove_error = r
103
104 CRYPT_SIPREMOVEPROV( L"PutSignedDataMsg\\" );
105 CRYPT_SIPREMOVEPROV( L"GetSignedDataMsg\\" );
106 CRYPT_SIPREMOVEPROV( L"RemoveSignedDataMsg\\" );
107 CRYPT_SIPREMOVEPROV( L"CreateIndirectData\\" );
108 CRYPT_SIPREMOVEPROV( L"VerifyIndirectData\\" );
109 CRYPT_SIPREMOVEPROV( L"IsMyFileType\\" );
110 CRYPT_SIPREMOVEPROV( L"IsMyFileType2\\" );
111
112#undef CRYPT_SIPREMOVEPROV
113
114 if (remove_error != ERROR_SUCCESS)
115 {
116 SetLastError(remove_error);
117 return FALSE;
118 }
119
120 return TRUE;
121}
122
123/*
124 * Helper for CryptSIPAddProvider
125 *
126 * Add a registry key containing a dll name and function under
127 * "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\<func>\<guid>"
128 */
130 LPCWSTR szDll, LPCWSTR szFunction )
131{
132 WCHAR szFullKey[ 0x100 ];
134 HKEY hKey;
135
136 if( !szFunction )
137 return ERROR_SUCCESS;
138
139 /* max length of szFullKey depends on our code only, so we won't overrun */
140 lstrcpyW( szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll" );
141 lstrcatW( szFullKey, szKey );
142 CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
143
144 TRACE("key is %s\n", debugstr_w( szFullKey ) );
145
146 r = RegCreateKeyW( HKEY_LOCAL_MACHINE, szFullKey, &hKey );
147 if( r != ERROR_SUCCESS ) goto error_close_key;
148
149 /* write the values */
150 r = RegSetValueExW( hKey, L"FuncName", 0, REG_SZ, (const BYTE*) szFunction,
151 ( lstrlenW( szFunction ) + 1 ) * sizeof (WCHAR) );
152 if( r != ERROR_SUCCESS ) goto error_close_key;
153 r = RegSetValueExW( hKey, L"Dll", 0, REG_SZ, (const BYTE*) szDll,
154 ( lstrlenW( szDll ) + 1) * sizeof (WCHAR) );
155
156error_close_key:
157
158 RegCloseKey( hKey );
159
160 return r;
161}
162
163/***********************************************************************
164 * CryptSIPAddProvider (CRYPT32.@)
165 *
166 * Add a SIP provider and its functions to the registry.
167 *
168 * PARAMS
169 * psNewProv [I] Pointer to a structure with information about
170 * the functions this SIP provider can perform.
171 *
172 * RETURNS
173 * Success: TRUE.
174 * Failure: FALSE. (Look at GetLastError()).
175 *
176 * NOTES
177 * Registry errors are always reported via SetLastError(). If a
178 * registry error occurs the rest of the registry write operations
179 * will be skipped.
180 */
182{
184
185 TRACE("%p\n", psNewProv);
186
187 if (!psNewProv ||
188 psNewProv->cbStruct < FIELD_OFFSET(SIP_ADD_NEWPROVIDER, pwszGetCapFuncName) ||
189 !psNewProv->pwszGetFuncName ||
190 !psNewProv->pwszPutFuncName ||
191 !psNewProv->pwszCreateFuncName ||
192 !psNewProv->pwszVerifyFuncName ||
193 !psNewProv->pwszRemoveFuncName)
194 {
196 return FALSE;
197 }
198
199 TRACE("%s %s %s %s %s\n",
200 debugstr_guid( psNewProv->pgSubject ),
201 debugstr_w( psNewProv->pwszDLLFileName ),
202 debugstr_w( psNewProv->pwszMagicNumber ),
203 debugstr_w( psNewProv->pwszIsFunctionName ),
204 debugstr_w( psNewProv->pwszIsFunctionNameFmt2 ) );
205
206#define CRYPT_SIPADDPROV( key, field ) \
207 r = CRYPT_SIPWriteFunction( psNewProv->pgSubject, key, \
208 psNewProv->pwszDLLFileName, psNewProv->field); \
209 if (r != ERROR_SUCCESS) goto end_function
210
211 CRYPT_SIPADDPROV( L"PutSignedDataMsg\\", pwszPutFuncName );
212 CRYPT_SIPADDPROV( L"GetSignedDataMsg\\", pwszGetFuncName );
213 CRYPT_SIPADDPROV( L"RemoveSignedDataMsg\\", pwszRemoveFuncName );
214 CRYPT_SIPADDPROV( L"CreateIndirectData\\", pwszCreateFuncName );
215 CRYPT_SIPADDPROV( L"VerifyIndirectData\\", pwszVerifyFuncName );
216 CRYPT_SIPADDPROV( L"IsMyFileType\\", pwszIsFunctionName );
217 CRYPT_SIPADDPROV( L"IsMyFileType2\\", pwszIsFunctionNameFmt2 );
218
219#undef CRYPT_SIPADDPROV
220
221end_function:
222
223 if (r != ERROR_SUCCESS)
224 {
226 return FALSE;
227 }
228
229 return TRUE;
230}
231
233{
234 LONG r;
235 DWORD size;
236 WCHAR dllName[MAX_PATH];
237 char functionName[MAX_PATH];
238 HMODULE lib;
239 void *func = NULL;
240
241 /* Read the DLL entry */
242 size = sizeof(dllName);
243 r = RegQueryValueExW(key, L"Dll", NULL, NULL, (LPBYTE)dllName, &size);
244 if (r) goto end;
245
246 /* Read the Function entry */
247 size = sizeof(functionName);
248 r = RegQueryValueExA(key, "FuncName", NULL, NULL, (LPBYTE)functionName,
249 &size);
250 if (r) goto end;
251
252 lib = LoadLibraryW(dllName);
253 if (!lib)
254 goto end;
255 func = GetProcAddress(lib, functionName);
256 if (func)
257 *pLib = lib;
258 else
259 FreeLibrary(lib);
260
261end:
262 return func;
263}
264
265/***********************************************************************
266 * CryptSIPRetrieveSubjectGuid (CRYPT32.@)
267 *
268 * Determine the right SIP GUID for the given file.
269 *
270 * PARAMS
271 * FileName [I] Filename.
272 * hFileIn [I] Optional handle to the file.
273 * pgSubject [O] The SIP's GUID.
274 *
275 * RETURNS
276 * Success: TRUE. pgSubject contains the SIP GUID.
277 * Failure: FALSE. (Look at GetLastError()).
278 *
279 * NOTES
280 * On failure pgSubject will contain a NULL GUID.
281 * The handle is always preferred above the filename.
282 */
284 (LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
285{
287 BOOL bRet = FALSE;
288 DWORD count;
289 LARGE_INTEGER zero, oldPos;
290 /* FIXME, find out if there is a name for this GUID */
291 static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
292 static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }};
293 static const GUID catGUID = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
294 static const WORD dosHdr = IMAGE_DOS_SIGNATURE;
295 static const BYTE cabHdr[] = { 'M','S','C','F' };
298 HKEY key;
299
300 TRACE("(%s %p %p)\n", wine_dbgstr_w(FileName), hFileIn, pgSubject);
301
302 if (!pgSubject || (!FileName && !hFileIn))
303 {
305 return FALSE;
306 }
307
308 /* Set pgSubject to zero's */
309 memset(pgSubject, 0 , sizeof(GUID));
310
311 if (hFileIn)
312 /* Use the given handle, make sure not to close this one ourselves */
313 hFile = hFileIn;
314 else
315 {
317 /* Last error is set by CreateFile */
318 if (hFile == INVALID_HANDLE_VALUE) return FALSE;
319 }
320
321 zero.QuadPart = 0;
324 if (!ReadFile(hFile, hdr, sizeof(hdr), &count, NULL))
325 goto cleanup;
326
328 {
330 goto cleanup;
331 }
332
333 TRACE("file magic = 0x%02x%02x%02x%02x\n", hdr[0], hdr[1], hdr[2], hdr[3]);
334 /* As everything is in place now we start looking at the file header */
335 if (!memcmp(hdr, &dosHdr, sizeof(dosHdr)))
336 {
337 *pgSubject = unknown;
339 bRet = TRUE;
340 goto cleanup;
341 }
342 /* Quick-n-dirty check for a cab file. */
343 if (!memcmp(hdr, cabHdr, sizeof(cabHdr)))
344 {
345 *pgSubject = cabGUID;
347 bRet = TRUE;
348 goto cleanup;
349 }
350 /* If it's asn.1-encoded, it's probably a .cat file. */
351 if (hdr[0] == 0x30)
352 {
353 DWORD fileLen = GetFileSize(hFile, NULL);
354
355 TRACE("fileLen = %ld\n", fileLen);
356 /* Sanity-check length */
357 if (hdr[1] < 0x80 && fileLen == 2 + hdr[1])
358 {
359 *pgSubject = catGUID;
361 bRet = TRUE;
362 goto cleanup;
363 }
364 else if (hdr[1] == 0x80)
365 {
366 /* Indefinite length, can't verify with just the header, assume it
367 * is.
368 */
369 *pgSubject = catGUID;
371 bRet = TRUE;
372 goto cleanup;
373 }
374 else
375 {
376 BYTE lenBytes = hdr[1] & 0x7f;
377
378 if (lenBytes == 1 && fileLen == 2 + lenBytes + hdr[2])
379 {
380 *pgSubject = catGUID;
382 bRet = TRUE;
383 goto cleanup;
384 }
385 else if (lenBytes == 2 && fileLen == 2 + lenBytes +
386 (hdr[2] << 8 | hdr[3]))
387 {
388 *pgSubject = catGUID;
390 bRet = TRUE;
391 goto cleanup;
392 }
393 else if (fileLen > 0xffff)
394 {
395 /* The file size must be greater than 2 bytes in length, so
396 * assume it is a .cat file
397 */
398 *pgSubject = catGUID;
400 bRet = TRUE;
401 goto cleanup;
402 }
403 }
404 }
405
406 /* Check for supported functions using CryptSIPDllIsMyFileType */
407 r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDllIsMyFileType\\", 0, KEY_READ, &key);
408 if (r == ERROR_SUCCESS)
409 {
410 DWORD index = 0, size;
411 WCHAR subKeyName[MAX_PATH];
412
413 do {
414 size = ARRAY_SIZE(subKeyName);
415 r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
416 NULL, NULL);
417 if (r == ERROR_SUCCESS)
418 {
419 HKEY subKey;
420
421 r = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
422 if (r == ERROR_SUCCESS)
423 {
424 HMODULE lib;
426 &lib);
427
428 if (isMy)
429 {
430 bRet = isMy(hFile, pgSubject);
431 FreeLibrary(lib);
432 }
433 RegCloseKey(subKey);
434 }
435 }
436 } while (!bRet && r == ERROR_SUCCESS);
438 }
439
440 /* Check for supported functions using CryptSIPDllIsMyFileType2 */
441 if (!bRet)
442 {
443 r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDllIsMyFileType2\\", 0, KEY_READ, &key);
444 if (r == ERROR_SUCCESS)
445 {
446 DWORD index = 0, size;
447 WCHAR subKeyName[MAX_PATH];
448
449 do {
450 size = ARRAY_SIZE(subKeyName);
451 r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
452 NULL, NULL);
453 if (r == ERROR_SUCCESS)
454 {
455 HKEY subKey;
456
457 r = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
458 if (r == ERROR_SUCCESS)
459 {
460 HMODULE lib;
462 CRYPT_LoadSIPFuncFromKey(subKey, &lib);
463
464 if (isMy2)
465 {
466 bRet = isMy2((LPWSTR)FileName, pgSubject);
467 FreeLibrary(lib);
468 }
469 RegCloseKey(subKey);
470 }
471 }
472 } while (!bRet && r == ERROR_SUCCESS);
474 }
475 }
476
477 if (!bRet)
479
480cleanup:
481 /* If we didn't open this one we shouldn't close it (hFile is a copy),
482 * but we should reset the file pointer to its original position.
483 */
484 if (!hFileIn)
486 else
488
489 return bRet;
490}
491
493 HKEY *key)
494{
495 WCHAR szFullKey[ 0x100 ];
496
497 lstrcpyW(szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll");
498 lstrcatW(szFullKey, function);
499 CRYPT_guid2wstr(guid, &szFullKey[lstrlenW(szFullKey)]);
500 return RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, key);
501}
502
503/* Loads the function named function for the SIP specified by pgSubject, and
504 * returns it if found. Returns NULL on error. If the function is loaded,
505 * *pLib is set to the library in which it is found.
506 */
507static void *CRYPT_LoadSIPFunc(const GUID *pgSubject, LPCWSTR function,
508 HMODULE *pLib)
509{
510 LONG r;
511 HKEY key;
512 void *func = NULL;
513
514 TRACE("(%s, %s)\n", debugstr_guid(pgSubject), debugstr_w(function));
515
516 r = CRYPT_OpenSIPFunctionKey(pgSubject, function, &key);
517 if (!r)
518 {
521 }
522 TRACE("returning %p\n", func);
523 return func;
524}
525
526typedef struct _WINE_SIP_PROVIDER {
529 struct list entry;
531
532static struct list providers = { &providers, &providers };
535{
536 0, 0, &providers_cs,
539 0, 0, { (DWORD_PTR)(__FILE__ ": providers_cs") }
540};
541static CRITICAL_SECTION providers_cs = { &providers_cs_debug, -1, 0, 0, 0, 0 };
542
543static void CRYPT_CacheSIP(const GUID *pgSubject, SIP_DISPATCH_INFO *info)
544{
546
547 if (prov)
548 {
549 prov->subject = *pgSubject;
550 prov->info = *info;
552 list_add_tail(&providers, &prov->entry);
554 }
555}
556
558{
559 WINE_SIP_PROVIDER *provider = NULL, *ret = NULL;
560
563 {
564 if (IsEqualGUID(pgSubject, &provider->subject))
565 break;
566 }
567 if (provider && IsEqualGUID(pgSubject, &provider->subject))
568 ret = provider;
570 return ret;
571}
572
573static inline BOOL CRYPT_IsSIPCached(const GUID *pgSubject)
574{
575 return CRYPT_GetCachedSIP(pgSubject) != NULL;
576}
577
579{
580 WINE_SIP_PROVIDER *prov, *next;
581
583 {
584 list_remove(&prov->entry);
585 FreeLibrary(prov->info.hSIP);
586 CryptMemFree(prov);
587 }
589}
590
591/* Loads the SIP for pgSubject into the global cache. Returns FALSE if the
592 * SIP isn't registered or is invalid.
593 */
594static BOOL CRYPT_LoadSIP(const GUID *pgSubject)
595{
596 SIP_DISPATCH_INFO sip = { 0 };
597 HMODULE lib = NULL, temp = NULL;
598
599 sip.pfGet = CRYPT_LoadSIPFunc(pgSubject, L"GetSignedDataMsg\\", &lib);
600 if (!sip.pfGet)
601 goto error;
602 sip.pfPut = CRYPT_LoadSIPFunc(pgSubject, L"PutSignedDataMsg\\", &temp);
603 if (!sip.pfPut || temp != lib)
604 goto error;
606 temp = NULL;
607 sip.pfCreate = CRYPT_LoadSIPFunc(pgSubject, L"CreateIndirectData\\", &temp);
608 if (!sip.pfCreate || temp != lib)
609 goto error;
611 temp = NULL;
612 sip.pfVerify = CRYPT_LoadSIPFunc(pgSubject, L"VerifyIndirectData\\", &temp);
613 if (!sip.pfVerify || temp != lib)
614 goto error;
616 temp = NULL;
617 sip.pfRemove = CRYPT_LoadSIPFunc(pgSubject, L"RemoveSignedDataMsg\\", &temp);
618 if (!sip.pfRemove || temp != lib)
619 goto error;
621 sip.hSIP = lib;
622 CRYPT_CacheSIP(pgSubject, &sip);
623 return TRUE;
624
625error:
626 FreeLibrary(lib);
629 return FALSE;
630}
631
632/***********************************************************************
633 * CryptSIPLoad (CRYPT32.@)
634 *
635 * Load some internal crypt32 functions into a SIP_DISPATCH_INFO structure.
636 *
637 * PARAMS
638 * pgSubject [I] The GUID.
639 * dwFlags [I] Flags.
640 * pSipDispatch [I] The loaded functions.
641 *
642 * RETURNS
643 * Success: TRUE. pSipDispatch contains the functions.
644 * Failure: FALSE. (Look at GetLastError()).
645 *
646 * NOTES
647 * CryptSIPLoad uses caching for the list of GUIDs and whether a SIP is
648 * already loaded.
649 *
650 * An application calls CryptSipLoad which will return a structure with the
651 * function addresses of some internal crypt32 functions. The application will
652 * then call these functions which will be forwarded to the appropriate SIP.
653 *
654 * CryptSIPLoad will load the needed SIP but doesn't unload this dll. The unloading
655 * is done when crypt32 is unloaded.
656 */
658 (const GUID *pgSubject, DWORD dwFlags, SIP_DISPATCH_INFO *pSipDispatch)
659{
660 TRACE("(%s %ld %p)\n", debugstr_guid(pgSubject), dwFlags, pSipDispatch);
661
662 if (!pgSubject || dwFlags != 0 || !pSipDispatch)
663 {
665 return FALSE;
666 }
667 if (!CRYPT_IsSIPCached(pgSubject) && !CRYPT_LoadSIP(pgSubject))
668 return FALSE;
669
670 pSipDispatch->hSIP = NULL;
671 pSipDispatch->pfGet = CryptSIPGetSignedDataMsg;
672 pSipDispatch->pfPut = CryptSIPPutSignedDataMsg;
673 pSipDispatch->pfCreate = CryptSIPCreateIndirectData;
674 pSipDispatch->pfVerify = CryptSIPVerifyIndirectData;
676
677 return TRUE;
678}
679
680/***********************************************************************
681 * CryptSIPCreateIndirectData (CRYPT32.@)
682 */
684 SIP_INDIRECT_DATA* pIndirectData)
685{
687 BOOL ret = FALSE;
688
689 TRACE("(%p %p %p)\n", pSubjectInfo, pcbIndirectData, pIndirectData);
690
691 if (!pSubjectInfo || !pSubjectInfo->pgSubjectType || !pcbIndirectData)
692 {
694 return FALSE;
695 }
696 if ((sip = CRYPT_GetCachedSIP(pSubjectInfo->pgSubjectType)))
697 ret = sip->info.pfCreate(pSubjectInfo, pcbIndirectData, pIndirectData);
698 TRACE("returning %d\n", ret);
699 return ret;
700}
701
702/***********************************************************************
703 * CryptSIPGetSignedDataMsg (CRYPT32.@)
704 */
706 DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
707{
709 BOOL ret = FALSE;
710
711 TRACE("(%p %p %ld %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
712 pcbSignedDataMsg, pbSignedDataMsg);
713
714 if ((sip = CRYPT_GetCachedSIP(pSubjectInfo->pgSubjectType)))
715 ret = sip->info.pfGet(pSubjectInfo, pdwEncodingType, dwIndex,
716 pcbSignedDataMsg, pbSignedDataMsg);
717 TRACE("returning %d\n", ret);
718 return ret;
719}
720
721/***********************************************************************
722 * CryptSIPPutSignedDataMsg (CRYPT32.@)
723 */
725 DWORD* pdwIndex, DWORD cbSignedDataMsg, BYTE* pbSignedDataMsg)
726{
728 BOOL ret = FALSE;
729
730 TRACE("(%p %ld %p %ld %p)\n", pSubjectInfo, pdwEncodingType, pdwIndex,
731 cbSignedDataMsg, pbSignedDataMsg);
732
733 if ((sip = CRYPT_GetCachedSIP(pSubjectInfo->pgSubjectType)))
734 ret = sip->info.pfPut(pSubjectInfo, pdwEncodingType, pdwIndex,
735 cbSignedDataMsg, pbSignedDataMsg);
736 TRACE("returning %d\n", ret);
737 return ret;
738}
739
740/***********************************************************************
741 * CryptSIPRemoveSignedDataMsg (CRYPT32.@)
742 */
744 DWORD dwIndex)
745{
747 BOOL ret = FALSE;
748
749 TRACE("(%p %ld)\n", pSubjectInfo, dwIndex);
750
751 if ((sip = CRYPT_GetCachedSIP(pSubjectInfo->pgSubjectType)))
752 ret = sip->info.pfRemove(pSubjectInfo, dwIndex);
753 TRACE("returning %d\n", ret);
754 return ret;
755}
756
757/***********************************************************************
758 * CryptSIPVerifyIndirectData (CRYPT32.@)
759 */
761 SIP_INDIRECT_DATA* pIndirectData)
762{
764 BOOL ret = FALSE;
765
766 TRACE("(%p %p)\n", pSubjectInfo, pIndirectData);
767
768 if ((sip = CRYPT_GetCachedSIP(pSubjectInfo->pgSubjectType)))
769 ret = sip->info.pfVerify(pSubjectInfo, pIndirectData);
770 TRACE("returning %d\n", ret);
771 return ret;
772}
773
774/***********************************************************************
775 * CryptSIPRetrieveSubjectGuidForCatalogFile (CRYPT32.@)
776 */
778{
779 FIXME("(%s %p %p)\n", debugstr_w(filename), handle, subject);
781 return FALSE;
782}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define FIXME(fmt,...)
Definition: precomp.h:53
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: list.h:37
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:136
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:146
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674
static void CRYPT_guid2wstr(const GUID *guid, LPWSTR wstr)
Definition: sip.c:39
BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
Definition: sip.c:86
BOOL WINAPI CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: sip.c:724
BOOL WINAPI CryptSIPRetrieveSubjectGuidForCatalogFile(LPCWSTR filename, HANDLE handle, GUID *subject)
Definition: sip.c:777
#define CRYPT_SIPREMOVEPROV(key)
static struct list providers
Definition: sip.c:532
static CRITICAL_SECTION providers_cs
Definition: sip.c:533
static void * CRYPT_LoadSIPFuncFromKey(HKEY key, HMODULE *pLib)
Definition: sip.c:232
static WINE_SIP_PROVIDER * CRYPT_GetCachedSIP(const GUID *pgSubject)
Definition: sip.c:557
BOOL WINAPI CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD dwIndex)
Definition: sip.c:743
struct _WINE_SIP_PROVIDER WINE_SIP_PROVIDER
static BOOL CRYPT_IsSIPCached(const GUID *pgSubject)
Definition: sip.c:573
static LONG CRYPT_SIPWriteFunction(const GUID *guid, LPCWSTR szKey, LPCWSTR szDll, LPCWSTR szFunction)
Definition: sip.c:129
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:284
static LONG CRYPT_OpenSIPFunctionKey(const GUID *guid, LPCWSTR function, HKEY *key)
Definition: sip.c:492
BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: sip.c:705
BOOL WINAPI CryptSIPCreateIndirectData(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pcbIndirectData, SIP_INDIRECT_DATA *pIndirectData)
Definition: sip.c:683
static BOOL CRYPT_LoadSIP(const GUID *pgSubject)
Definition: sip.c:594
#define CRYPT_SIPADDPROV(key, field)
static CRITICAL_SECTION_DEBUG providers_cs_debug
Definition: sip.c:534
BOOL WINAPI CryptSIPLoad(const GUID *pgSubject, DWORD dwFlags, SIP_DISPATCH_INFO *pSipDispatch)
Definition: sip.c:658
static void * CRYPT_LoadSIPFunc(const GUID *pgSubject, LPCWSTR function, HMODULE *pLib)
Definition: sip.c:507
BOOL WINAPI CryptSIPVerifyIndirectData(SIP_SUBJECTINFO *pSubjectInfo, SIP_INDIRECT_DATA *pIndirectData)
Definition: sip.c:760
static LONG CRYPT_SIPDeleteFunction(const GUID *guid, LPCWSTR szKey)
Definition: sip.c:55
BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
Definition: sip.c:181
void crypt_sip_free(void)
Definition: sip.c:578
static void CRYPT_CacheSIP(const GUID *pgSubject, SIP_DISPATCH_INFO *info)
Definition: sip.c:543
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_BEGIN
Definition: compat.h:761
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define LoadLibraryW(x)
Definition: compat.h:747
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
static void cleanup(void)
Definition: main.c:1335
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
BOOL WINAPI SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
Definition: fileinfo.c:177
GUID guid
Definition: version.c:147
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static const GUID catGUID
Definition: crypt.c:1619
static const GUID cabGUID
Definition: crypt.c:1617
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum func
Definition: glext.h:6028
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
#define S_OK
Definition: intsafe.h:52
const char * filename
Definition: ioapi.h:137
char hdr[14]
Definition: iptest.cpp:33
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define error(str)
Definition: mkdosfs.c:1605
#define sprintf
Definition: sprintf.c:45
BOOL(WINAPI * pfnIsFileSupportedName)(WCHAR *, GUID *)
Definition: mssip.h:138
BOOL(WINAPI * pfnIsFileSupported)(HANDLE, GUID *)
Definition: mssip.h:137
#define SIP_MAX_MAGIC_NUMBER
Definition: mssip.h:45
_In_ HANDLE hFile
Definition: mswsock.h:90
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define KEY_READ
Definition: nt_native.h:1026
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static unsigned __int64 next
Definition: rand_nt.c:6
const WCHAR * str
static calc_node_t temp
Definition: rpn_ieee.c:38
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define memset(x, y, z)
Definition: compat.h:39
int zero
Definition: sehframes.cpp:29
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * pwszPutFuncName
Definition: mssip.h:153
WCHAR * pwszCreateFuncName
Definition: mssip.h:154
GUID * pgSubject
Definition: mssip.h:145
WCHAR * pwszMagicNumber
Definition: mssip.h:148
WCHAR * pwszRemoveFuncName
Definition: mssip.h:156
WCHAR * pwszIsFunctionName
Definition: mssip.h:150
WCHAR * pwszGetFuncName
Definition: mssip.h:152
WCHAR * pwszIsFunctionNameFmt2
Definition: mssip.h:158
WCHAR * pwszVerifyFuncName
Definition: mssip.h:155
WCHAR * pwszDLLFileName
Definition: mssip.h:147
pCryptSIPVerifyIndirectData pfVerify
Definition: mssip.h:132
pCryptSIPRemoveSignedDataMsg pfRemove
Definition: mssip.h:133
pCryptSIPGetSignedDataMsg pfGet
Definition: mssip.h:129
pCryptSIPPutSignedDataMsg pfPut
Definition: mssip.h:130
pCryptSIPCreateIndirectData pfCreate
Definition: mssip.h:131
GUID * pgSubjectType
Definition: mssip.h:52
struct list entry
Definition: sip.c:529
SIP_DISPATCH_INFO info
Definition: sip.c:528
GUID subject
Definition: sip.c:527
Definition: copy.c:22
#define DWORD_PTR
Definition: treelist.c:76
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define FILE_CURRENT
Definition: winbase.h:116
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WINAPI
Definition: msvc.h:6
#define TRUST_E_SUBJECT_FORM_UNKNOWN
Definition: winerror.h:4621
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
unsigned char BYTE
Definition: xxhash.c:193