WinTrust.h 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: wintrust.h
  8. //
  9. // Contents: Microsoft Internet Security Trust Provider Model
  10. //
  11. // History: 31-May-1997 pberkman created
  12. //
  13. //--------------------------------------------------------------------------
  14. #ifndef WINTRUST_H
  15. #define WINTRUST_H
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include <wincrypt.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. #ifndef WIN_CERT_REVISION_1_0 // there were duplicate definitions in winbase.h
  25. # define WT_DEFINE_ALL_APIS
  26. #else
  27. # undef WT_DEFINE_ALL_APIS
  28. #endif
  29. //////////////////////////////////////////////////////////////////////////////
  30. //////////////////////////////////////////////////////////////////////////////
  31. //
  32. // Client definitions, typedefs, and prototypes
  33. //
  34. //////////////////////////////////////////////////////////////////////////////
  35. //////////////////////////////////////////////////////////////////////////////
  36. #include <pshpack8.h>
  37. //////////////////////////////////////////////////////////////////////////////
  38. //
  39. // WINTRUST_DATA Structure
  40. //----------------------------------------------------------------------------
  41. // Used when calling WinVerifyTrust to pass necessary information into
  42. // the Providers.
  43. //
  44. typedef struct _WINTRUST_DATA
  45. {
  46. DWORD cbStruct; // = sizeof(WINTRUST_DATA)
  47. LPVOID pPolicyCallbackData; // optional: used to pass data between the app and policy
  48. LPVOID pSIPClientData; // optional: used to pass data between the app and SIP.
  49. DWORD dwUIChoice; // required: UI choice. One of the following.
  50. # define WTD_UI_ALL 1
  51. # define WTD_UI_NONE 2
  52. # define WTD_UI_NOBAD 3
  53. # define WTD_UI_NOGOOD 4
  54. DWORD fdwRevocationChecks; // required: certificate revocation check options
  55. # define WTD_REVOKE_NONE 0x00000000
  56. # define WTD_REVOKE_WHOLECHAIN 0x00000001
  57. DWORD dwUnionChoice; // required: which structure is being passed in?
  58. # define WTD_CHOICE_FILE 1
  59. # define WTD_CHOICE_CATALOG 2
  60. # define WTD_CHOICE_BLOB 3
  61. # define WTD_CHOICE_SIGNER 4
  62. # define WTD_CHOICE_CERT 5
  63. union
  64. {
  65. struct WINTRUST_FILE_INFO_ *pFile; // individual file
  66. struct WINTRUST_CATALOG_INFO_ *pCatalog; // member of a Catalog File
  67. struct WINTRUST_BLOB_INFO_ *pBlob; // memory blob
  68. struct WINTRUST_SGNR_INFO_ *pSgnr; // signer structure only
  69. struct WINTRUST_CERT_INFO_ *pCert;
  70. };
  71. DWORD dwStateAction; // optional (Catalog File Processing)
  72. # define WTD_STATEACTION_IGNORE 0x00000000
  73. # define WTD_STATEACTION_VERIFY 0x00000001
  74. # define WTD_STATEACTION_CLOSE 0x00000002
  75. # define WTD_STATEACTION_AUTO_CACHE 0x00000003
  76. # define WTD_STATEACTION_AUTO_CACHE_FLUSH 0x00000004
  77. HANDLE hWVTStateData; // optional (Catalog File Processing)
  78. WCHAR *pwszURLReference; // optional: (future) used to determine zone.
  79. // 17-Feb-1998 philh: added
  80. DWORD dwProvFlags;
  81. # define WTD_PROV_FLAGS_MASK 0x0000FFFF
  82. # define WTD_USE_IE4_TRUST_FLAG 0x00000001
  83. # define WTD_NO_IE4_CHAIN_FLAG 0x00000002
  84. # define WTD_NO_POLICY_USAGE_FLAG 0x00000004
  85. # define WTD_REVOCATION_CHECK_NONE 0x00000010
  86. # define WTD_REVOCATION_CHECK_END_CERT 0x00000020
  87. # define WTD_REVOCATION_CHECK_CHAIN 0x00000040
  88. # define WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x00000080
  89. # define WTD_SAFER_FLAG 0x00000100
  90. # define WTD_HASH_ONLY_FLAG 0x00000200
  91. # define WTD_USE_DEFAULT_OSVER_CHECK 0x00000400
  92. # define WTD_LIFETIME_SIGNING_FLAG 0x00000800
  93. // 07-Jan-2004 tonyschr: added
  94. DWORD dwUIContext; // optional: used to determine action text in UI
  95. # define WTD_UICONTEXT_EXECUTE 0
  96. # define WTD_UICONTEXT_INSTALL 1
  97. } WINTRUST_DATA, *PWINTRUST_DATA;
  98. //////////////////////////////////////////////////////////////////////////////
  99. //
  100. // WINTRUST_FILE_INFO Structure
  101. //----------------------------------------------------------------------------
  102. // Used when calling WinVerifyTrust against an individual file.
  103. //
  104. typedef struct WINTRUST_FILE_INFO_
  105. {
  106. DWORD cbStruct; // = sizeof(WINTRUST_FILE_INFO)
  107. LPCWSTR pcwszFilePath; // required, file name to be verified
  108. HANDLE hFile; // optional, open handle to pcwszFilePath
  109. // 09-Dec-1997 pberkman: added
  110. GUID *pgKnownSubject; // optional: fill if the subject type is known.
  111. } WINTRUST_FILE_INFO, *PWINTRUST_FILE_INFO;
  112. //////////////////////////////////////////////////////////////////////////////
  113. //
  114. // WINTRUST_CATALOG_INFO Structure
  115. //----------------------------------------------------------------------------
  116. // Used when calling WinVerifyTrust against a member of a Microsoft Catalog
  117. // file.
  118. //
  119. typedef struct WINTRUST_CATALOG_INFO_
  120. {
  121. DWORD cbStruct; // = sizeof(WINTRUST_CATALOG_INFO)
  122. DWORD dwCatalogVersion; // optional: Catalog version number
  123. LPCWSTR pcwszCatalogFilePath; // required: path/name to Catalog file
  124. LPCWSTR pcwszMemberTag; // required: tag to member in Catalog
  125. LPCWSTR pcwszMemberFilePath; // required: path/name to member file
  126. HANDLE hMemberFile; // optional: open handle to pcwszMemberFilePath
  127. // 30-Oct-1997 pberkman: added
  128. BYTE *pbCalculatedFileHash; // optional: pass in the calculated hash
  129. DWORD cbCalculatedFileHash; // optional: pass in the count bytes of the calc hash
  130. // 15-Jan-1998 pberkman: added
  131. PCCTL_CONTEXT pcCatalogContext; // optional: pass in to use instead of CatalogFilePath.
  132. } WINTRUST_CATALOG_INFO, *PWINTRUST_CATALOG_INFO;
  133. //////////////////////////////////////////////////////////////////////////////
  134. //
  135. // WINTRUST_BLOB_INFO Structure
  136. //----------------------------------------------------------------------------
  137. // Used when calling WinVerifyTrust against a memory blob.
  138. //
  139. typedef struct WINTRUST_BLOB_INFO_
  140. {
  141. DWORD cbStruct; // = sizeof(WINTRUST_BLOB_INFO)
  142. GUID gSubject; // SIP to load
  143. LPCWSTR pcwszDisplayName; // display name of object
  144. DWORD cbMemObject;
  145. BYTE *pbMemObject;
  146. DWORD cbMemSignedMsg;
  147. BYTE *pbMemSignedMsg;
  148. } WINTRUST_BLOB_INFO, *PWINTRUST_BLOB_INFO;
  149. //////////////////////////////////////////////////////////////////////////////
  150. //
  151. // WINTRUST_SGNR_INFO Structure
  152. //----------------------------------------------------------------------------
  153. // Used when calling WinVerifyTrust against a CMSG_SIGNER_INFO Structure
  154. //
  155. typedef struct WINTRUST_SGNR_INFO_
  156. {
  157. DWORD cbStruct; // = sizeof(WINTRUST_SGNR_INFO)
  158. LPCWSTR pcwszDisplayName; // name of the "thing" the pbMem is pointing to.
  159. CMSG_SIGNER_INFO *psSignerInfo;
  160. DWORD chStores; // number of stores in pahStores
  161. HCERTSTORE *pahStores; // array of stores to add to internal list
  162. } WINTRUST_SGNR_INFO, *PWINTRUST_SGNR_INFO;
  163. //////////////////////////////////////////////////////////////////////////////
  164. //
  165. // WINTRUST_CERT_INFO Structure
  166. //----------------------------------------------------------------------------
  167. // Used when calling WinVerifyTrust against a CERT_CONTEXT Structure
  168. //
  169. typedef struct WINTRUST_CERT_INFO_
  170. {
  171. DWORD cbStruct; // = sizeof(WINTRUST_CERT_INFO)
  172. LPCWSTR pcwszDisplayName; // display name
  173. CERT_CONTEXT *psCertContext;
  174. DWORD chStores; // number of stores in pahStores
  175. HCERTSTORE *pahStores; // array of stores to add to internal list
  176. // 17-Nov-1997 pberkman: added
  177. DWORD dwFlags;
  178. # define WTCI_DONT_OPEN_STORES 0x00000001 // only open dummy "root" all other are in pahStores.
  179. # define WTCI_OPEN_ONLY_ROOT 0x00000002
  180. // 26-Nov-1997 pberkman: added
  181. FILETIME *psftVerifyAsOf; // if not null, each cert will be validated as of this time.
  182. } WINTRUST_CERT_INFO, *PWINTRUST_CERT_INFO;
  183. #include <poppack.h>
  184. //////////////////////////////////////////////////////////////////////////////
  185. //
  186. // WinVerifyTrust
  187. //----------------------------------------------------------------------------
  188. // Exported from WINTRUST.DLL.
  189. // Call this function to verify the trust based on a digital signer.
  190. //
  191. // pWVTData points to a WINTRUST_DATA data structure.
  192. //
  193. // WTD_SAFER_FLAG should be set in WINTRUST_DATA's dwProvFlags to enable
  194. // the following semantics for the WINTRUST_ACTION_GENERIC_VERIFY_V2
  195. // policy provider specified in pgActionID:
  196. // - return TRUST_E_NOSIGNATURE if the subject isn't signed, has an
  197. // invalid signature or unable to find the signer certificate.
  198. // UI will never be displayed when not signed.
  199. // - ignore NO_CHECK revocation errors. Otherwise, continue to return
  200. // CERT_E_REVOCATION_FAILURE.
  201. // - search the code hash and publisher databases for the WTD_UI_NONE
  202. // dwUIChoice case. The default is to only search these databases when
  203. // UI has been enabled or user trust has been disabled.
  204. //
  205. //
  206. // Returns:
  207. // ERROR_SUCCESS If the trust is authenticated or
  208. // if the user accepted the risk.
  209. //
  210. // TRUST_E_PROVIDER_UNKNOWN there was an error loading one of the
  211. // required Providers.
  212. //
  213. // all error codes passed back are based on the Policy Provider used.
  214. //
  215. // The following errors are returned when the
  216. // WINTRUST_ACTION_GENERIC_VERIFY_V2 policy provider is specified in
  217. // pgActionID:
  218. //
  219. // TRUST_E_NOSIGNATURE (when WTD_SAFER_FLAG is set in dwProvFlags)
  220. // The subject isn't signed, has an invalid signature or unable
  221. // to find the signer certificate. All signature verification
  222. // errors will map to this error. Basically all errors except for
  223. // publisher or timestamp certificate verification.
  224. //
  225. // Call GetLastError() to get the underlying reason for not having
  226. // a valid signature.
  227. //
  228. // The following LastErrors indicate that the file doesn't have a
  229. // signature: TRUST_E_NOSIGNATURE, TRUST_E_SUBJECT_FORM_UNKNOWN or
  230. // TRUST_E_PROVIDER_UNKNOWN.
  231. //
  232. // UI will never be displayed for this case.
  233. //
  234. // TRUST_E_EXPLICIT_DISTRUST
  235. // Returned if the hash representing the subject is trusted as
  236. // AUTHZLEVELID_DISALLOWED or the publisher is in the "Disallowed"
  237. // store. Also returned if the publisher certificate is revoked.
  238. //
  239. // UI will never be displayed for this case.
  240. //
  241. // ERROR_SUCCESS
  242. // No UI unless noted below.
  243. //
  244. // Returned for the following:
  245. // - Hash representing the subject is trusted as
  246. // AUTHZLEVELID_FULLYTRUSTED
  247. // - The publisher certificate exists in the
  248. // "TrustedPublisher" store and there weren't any verification errors.
  249. // - UI was enabled and the user clicked "Yes" when asked
  250. // to install and run the signed subject.
  251. // - UI was disabled. No publisher or timestamp chain error.
  252. //
  253. // TRUST_E_SUBJECT_NOT_TRUSTED
  254. // UI was enabled and the the user clicked "No" when asked to install
  255. // and run the signed subject.
  256. //
  257. // CRYPT_E_SECURITY_SETTINGS
  258. // The subject hash or publisher wasn't explicitly trusted and
  259. // user trust wasn't allowed in the safer authenticode flags.
  260. // No UI will be displayed for this case.
  261. //
  262. // The subject is signed and its signature successfully
  263. // verified.
  264. //
  265. // Any publisher or timestamp chain error. If WTD_SAFER_FLAG wasn't set in
  266. // dwProvFlags, any signed code verification error.
  267. //
  268. extern LONG WINAPI WinVerifyTrust(HWND hwnd, GUID *pgActionID,
  269. LPVOID pWVTData);
  270. //////////////////////////////////////////////////////////////////////////////
  271. //////////////////////////////////////////////////////////////////////////////
  272. //
  273. // Trust, Policy, and UI Provider definitions, typedefs, and prototypes
  274. //
  275. // Model:
  276. // A client wishing to validate trust through WinVerifyTrust will
  277. // select an appropriate Action ID guid for the call.
  278. // This guid is defined by each Policy Provider and represents the
  279. // functions called based on the policy for the given object.
  280. //
  281. // In this model, the Policy Provider determines which style of UI
  282. // will be shown to the user (this only applies to style, the
  283. // determination of whether UI is displayed is set by the calling client
  284. // in the UI flags member of WINTRUST_DATA).
  285. //
  286. // Since the function entry points are common (same return value and
  287. // parameters), it allows Policy Provider developers to take advantage
  288. // of existing, generic, code to fill the CRYPT_PROVIDER_DATA structure.
  289. //
  290. // This also allows the developer to simply add the specific policy they
  291. // need, then, call the generic Policy Provider - if appropriate.
  292. //
  293. //////////////////////////////////////////////////////////////////////////////
  294. //////////////////////////////////////////////////////////////////////////////
  295. //////////////////////////////////////////////////////////////////////////////
  296. //
  297. // Wintrust Policy Flags
  298. //----------------------------------------------------------------------------
  299. // These are set during install and can be modified by the user
  300. // through various means. The SETREG.EXE utility (found in the Authenticode
  301. // Tools Pack) will select/deselect each of them.
  302. //
  303. #define WTPF_TRUSTTEST 0x00000020 // trust any "TEST" certificate
  304. #define WTPF_TESTCANBEVALID 0x00000080
  305. #define WTPF_IGNOREEXPIRATION 0x00000100 // Use expiration date
  306. #define WTPF_IGNOREREVOKATION 0x00000200 // Do revocation check
  307. #define WTPF_OFFLINEOK_IND 0x00000400 // off-line is ok individual certs
  308. #define WTPF_OFFLINEOK_COM 0x00000800 // off-line is ok commercial certs
  309. #define WTPF_OFFLINEOKNBU_IND 0x00001000 // off-line is ok individual certs, no bad ui
  310. #define WTPF_OFFLINEOKNBU_COM 0x00002000 // off-line is ok commercial certs, no bad ui
  311. #define WTPF_VERIFY_V1_OFF 0x00010000 // turn verify of v1 certs off
  312. #define WTPF_IGNOREREVOCATIONONTS 0x00020000 // ignore TimeStamp revocation checks
  313. #define WTPF_ALLOWONLYPERTRUST 0x00040000 // allow only items in personal trust db.
  314. //////////////////////////////////////////////////////////////////////////////
  315. //
  316. // WintrustGetRegPolicyFlags
  317. //----------------------------------------------------------------------------
  318. // This API call is exported from WINTRUST.DLL and is the recommended method
  319. // of retrieving the DWORD representing the Policy Flags.
  320. //
  321. extern void WINAPI WintrustGetRegPolicyFlags(DWORD *pdwPolicyFlags);
  322. //////////////////////////////////////////////////////////////////////////////
  323. //
  324. // WintrustSetRegPolicyFlags
  325. //----------------------------------------------------------------------------
  326. // This API call is exported from WINTRUST.DLL and is the recommended method
  327. // of setting the DWORD representing the Policy Flags. MAKE SURE to call
  328. // WintrustGetRegPolicyFlags to get the current value and or/and the value
  329. // you need then call the set the flags.
  330. //
  331. extern BOOL WINAPI WintrustSetRegPolicyFlags(DWORD dwPolicyFlags);
  332. //////////////////////////////////////////////////////////////////////////////
  333. //
  334. // Trust Provider "Step" Error defines
  335. //----------------------------------------------------------------------------
  336. // Each "step" of the Trust process has an error "slot" associated with it.
  337. // If an error occurs, the "step" will assign its result to this "slot". These
  338. // errors can be any valid WINERROR.H HRESULT code.
  339. //
  340. //
  341. // step errors 0 through 20 are reserved for Authenticode specific. If
  342. // you are not calling any of the SOFTPUB.DLL (Authenticode) providers, you
  343. // may use these as needed.
  344. //
  345. #define TRUSTERROR_STEP_WVTPARAMS 0
  346. #define TRUSTERROR_STEP_FILEIO 2
  347. #define TRUSTERROR_STEP_SIP 3
  348. #define TRUSTERROR_STEP_SIPSUBJINFO 5
  349. #define TRUSTERROR_STEP_CATALOGFILE 6
  350. #define TRUSTERROR_STEP_CERTSTORE 7
  351. #define TRUSTERROR_STEP_MESSAGE 8
  352. #define TRUSTERROR_STEP_MSG_SIGNERCOUNT 9
  353. #define TRUSTERROR_STEP_MSG_INNERCNTTYPE 10
  354. #define TRUSTERROR_STEP_MSG_INNERCNT 11
  355. #define TRUSTERROR_STEP_MSG_STORE 12
  356. #define TRUSTERROR_STEP_MSG_SIGNERINFO 13
  357. #define TRUSTERROR_STEP_MSG_SIGNERCERT 14
  358. #define TRUSTERROR_STEP_MSG_CERTCHAIN 15
  359. #define TRUSTERROR_STEP_MSG_COUNTERSIGINFO 16
  360. #define TRUSTERROR_STEP_MSG_COUNTERSIGCERT 17
  361. #define TRUSTERROR_STEP_VERIFY_MSGHASH 18
  362. #define TRUSTERROR_STEP_VERIFY_MSGINDIRECTDATA 19
  363. //
  364. // step errors 30 through 37 are reserved for the ending error code for each
  365. // entry point in the Trust Model.
  366. //
  367. #define TRUSTERROR_STEP_FINAL_WVTINIT 30
  368. #define TRUSTERROR_STEP_FINAL_INITPROV 31
  369. #define TRUSTERROR_STEP_FINAL_OBJPROV 32
  370. #define TRUSTERROR_STEP_FINAL_SIGPROV 33
  371. #define TRUSTERROR_STEP_FINAL_CERTPROV 34
  372. #define TRUSTERROR_STEP_FINAL_CERTCHKPROV 35
  373. #define TRUSTERROR_STEP_FINAL_POLICYPROV 36
  374. #define TRUSTERROR_STEP_FINAL_UIPROV 37
  375. #define TRUSTERROR_MAX_STEPS 38
  376. //////////////////////////////////////////////////////////////////////////////
  377. //
  378. // allocation and free function prototypes
  379. //----------------------------------------------------------------------------
  380. //
  381. typedef void *(*PFN_CPD_MEM_ALLOC)(IN DWORD cbSize);
  382. typedef void (*PFN_CPD_MEM_FREE)(IN void *pvMem2Free);
  383. typedef BOOL (*PFN_CPD_ADD_STORE)(IN struct _CRYPT_PROVIDER_DATA *pProvData,
  384. IN HCERTSTORE hStore2Add);
  385. typedef BOOL (*PFN_CPD_ADD_SGNR)(IN struct _CRYPT_PROVIDER_DATA *pProvData,
  386. IN BOOL fCounterSigner,
  387. IN OPTIONAL DWORD idxSigner,
  388. IN struct _CRYPT_PROVIDER_SGNR *pSgnr2Add);
  389. typedef BOOL (*PFN_CPD_ADD_CERT)(IN struct _CRYPT_PROVIDER_DATA *pProvData,
  390. IN DWORD idxSigner,
  391. IN BOOL fCounterSigner,
  392. IN OPTIONAL DWORD idxCounterSigner,
  393. IN PCCERT_CONTEXT pCert2Add);
  394. typedef BOOL (*PFN_CPD_ADD_PRIVDATA)(IN struct _CRYPT_PROVIDER_DATA *pProvData,
  395. IN struct _CRYPT_PROVIDER_PRIVDATA *pPrivData2Add);
  396. //////////////////////////////////////////////////////////////////////////////
  397. //
  398. // Provider function prototypes
  399. //----------------------------------------------------------------------------
  400. //
  401. //
  402. // entry point for the object provider
  403. //
  404. typedef HRESULT (*PFN_PROVIDER_INIT_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  405. //
  406. // entry point for the object provider
  407. //
  408. typedef HRESULT (*PFN_PROVIDER_OBJTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  409. //
  410. // entry point for the Signature Provider
  411. //
  412. typedef HRESULT (*PFN_PROVIDER_SIGTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  413. //
  414. // entry point for the Certificate Provider
  415. //
  416. typedef HRESULT (*PFN_PROVIDER_CERTTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  417. //
  418. // entry point for the Policy Provider's final call (from the trust provider)
  419. //
  420. typedef HRESULT (*PFN_PROVIDER_FINALPOLICY_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  421. //
  422. // entry point for the Policy Provider's "dump structure" call
  423. //
  424. typedef HRESULT (*PFN_PROVIDER_TESTFINALPOLICY_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  425. //
  426. // entry point for the Policy Provider's clean up routine for any PRIVDATA allocated
  427. //
  428. typedef HRESULT (*PFN_PROVIDER_CLEANUP_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  429. //
  430. // entry point for the Policy Provider's Cert Check call. This will return
  431. // true if the Trust Provider is to continue building the certificate chain.
  432. // If the PP returns FALSE, it is assumed that we have reached a "TRUSTED",
  433. // self-signed, root. it is also the CertCheck's responsibility to set the
  434. // fTrustedRoot flag in the certificate structure.
  435. //
  436. typedef BOOL (*PFN_PROVIDER_CERTCHKPOLICY_CALL)( IN struct _CRYPT_PROVIDER_DATA *pProvData,
  437. IN DWORD idxSigner,
  438. IN BOOL fCounterSignerChain,
  439. IN OPTIONAL DWORD idxCounterSigner);
  440. #define WVT_OFFSETOF(t,f) ((ULONG)((ULONG_PTR)(&((t*)0)->f)))
  441. #define WVT_ISINSTRUCT(structtypedef, structpassedsize, member) \
  442. ((WVT_OFFSETOF(structtypedef, member) < structpassedsize) ? TRUE : FALSE)
  443. #define WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(structtypedef, structpassedsize, member) \
  444. WVT_ISINSTRUCT(structtypedef, structpassedsize, member)
  445. #include <pshpack8.h>
  446. //////////////////////////////////////////////////////////////////////////////
  447. //
  448. // CRYPT_PROVIDER_DATA Structure
  449. //----------------------------------------------------------------------------
  450. // Used to pass information between WinVerifyTrust and all of the Provider
  451. // calls.
  452. //
  453. // IMPORTANT: 1. All dynamically allocated members MUST use the allocation
  454. // and Add2 functions provided.
  455. //
  456. typedef struct _CRYPT_PROVIDER_DATA
  457. {
  458. DWORD cbStruct; // = sizeof(TRUST_PROVIDER_DATA) (set in WVT)
  459. WINTRUST_DATA *pWintrustData; // NOT verified (set in WVT)
  460. BOOL fOpenedFile; // the provider opened the file handle (if applicable)
  461. HWND hWndParent; // if passed in, else, Desktop hWnd (set in WVT).
  462. GUID *pgActionID; // represents the Provider combination (set in WVT).
  463. HCRYPTPROV hProv; // set to NULL to let CryptoAPI to assign.
  464. DWORD dwError; // error if a low-level, system error was encountered
  465. DWORD dwRegSecuritySettings; // ie security settings (set in WVT)
  466. DWORD dwRegPolicySettings; // setreg settings (set in WVT)
  467. struct _CRYPT_PROVIDER_FUNCTIONS *psPfns; // set in WVT.
  468. DWORD cdwTrustStepErrors; // set in WVT.
  469. DWORD *padwTrustStepErrors; // allocated in WVT. filled in WVT & Trust Provider
  470. DWORD chStores; // number of stores in pahStores (root set in WVT)
  471. HCERTSTORE *pahStores; // array of known stores (root set in WVT) root is ALWAYS #0!!!
  472. DWORD dwEncoding; // message encoding type (set in WVT and Signature Prov)
  473. HCRYPTMSG hMsg; // set in Signature Prov.
  474. DWORD csSigners; // use Add2 and Get functions!
  475. struct _CRYPT_PROVIDER_SGNR *pasSigners; // use Add2 and Get functions!
  476. DWORD csProvPrivData; // use Add2 and Get functions!
  477. struct _CRYPT_PROVIDER_PRIVDATA *pasProvPrivData; // use Add2 and Get functions!
  478. DWORD dwSubjectChoice;
  479. # define CPD_CHOICE_SIP 1
  480. union
  481. {
  482. struct _PROVDATA_SIP *pPDSip;
  483. };
  484. char *pszUsageOID; // set in Init Provider
  485. // 03-Oct-1997 pberkman: added
  486. BOOL fRecallWithState; // state was maintained for Catalog Files.
  487. // 10-Nov-1997 pberkman: added
  488. FILETIME sftSystemTime;
  489. // 16-Jan-1998 pberkman: added
  490. char *pszCTLSignerUsageOID;
  491. // 17-Feb-1998 philh: added
  492. // LOWORD intialized from WINTRUST_DATA's dwProvFlags.
  493. DWORD dwProvFlags;
  494. # define CPD_USE_NT5_CHAIN_FLAG 0x80000000
  495. # define CPD_REVOCATION_CHECK_NONE 0x00010000
  496. # define CPD_REVOCATION_CHECK_END_CERT 0x00020000
  497. # define CPD_REVOCATION_CHECK_CHAIN 0x00040000
  498. # define CPD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x00080000
  499. // 24-Feb-1998 philh: added
  500. DWORD dwFinalError;
  501. // 20-May-1998 KeithV: added
  502. PCERT_USAGE_MATCH pRequestUsage;
  503. // 02-Aug-2000 philh: added
  504. DWORD dwTrustPubSettings;
  505. // 02-Sep-2003 tonyschr: added
  506. DWORD dwUIStateFlags;
  507. # define CPD_UISTATE_MODE_PROMPT 0x00000000
  508. # define CPD_UISTATE_MODE_BLOCK 0x00000001
  509. # define CPD_UISTATE_MODE_ALLOW 0x00000002
  510. # define CPD_UISTATE_MODE_MASK 0x00000003
  511. } CRYPT_PROVIDER_DATA, *PCRYPT_PROVIDER_DATA;
  512. //////////////////////////////////////////////////////////////////////////////
  513. //
  514. // CRYPT_PROVIDER_FUNCTIONS structure
  515. //----------------------------------------------------------------------------
  516. //
  517. typedef struct _CRYPT_PROVIDER_FUNCTIONS
  518. {
  519. DWORD cbStruct;
  520. PFN_CPD_MEM_ALLOC pfnAlloc; // set in WVT
  521. PFN_CPD_MEM_FREE pfnFree; // set in WVT
  522. PFN_CPD_ADD_STORE pfnAddStore2Chain; // call to add a store to the chain.
  523. PFN_CPD_ADD_SGNR pfnAddSgnr2Chain; // call to add a sgnr struct to a msg struct sgnr chain
  524. PFN_CPD_ADD_CERT pfnAddCert2Chain; // call to add a cert struct to a sgnr struct cert chain
  525. PFN_CPD_ADD_PRIVDATA pfnAddPrivData2Chain; // call to add provider private data to struct.
  526. PFN_PROVIDER_INIT_CALL pfnInitialize; // initialize Policy data.
  527. PFN_PROVIDER_OBJTRUST_CALL pfnObjectTrust; // build info up to the signer info(s).
  528. PFN_PROVIDER_SIGTRUST_CALL pfnSignatureTrust; // build info to the signing cert
  529. PFN_PROVIDER_CERTTRUST_CALL pfnCertificateTrust; // build the chain
  530. PFN_PROVIDER_FINALPOLICY_CALL pfnFinalPolicy; // final call to policy
  531. PFN_PROVIDER_CERTCHKPOLICY_CALL pfnCertCheckPolicy; // check each cert will building chain
  532. PFN_PROVIDER_TESTFINALPOLICY_CALL pfnTestFinalPolicy; // dump structures to a file (or whatever the policy chooses)
  533. struct _CRYPT_PROVUI_FUNCS *psUIpfns;
  534. // 23-Jul-1997 pberkman: added
  535. PFN_PROVIDER_CLEANUP_CALL pfnCleanupPolicy; // PRIVDATA cleanup routine.
  536. } CRYPT_PROVIDER_FUNCTIONS, *PCRYPT_PROVIDER_FUNCTIONS;
  537. //////////////////////////////////////////////////////////////////////////////
  538. //
  539. // CRYPT_PROVUI_FUNCS structure
  540. //----------------------------------------------------------------------------
  541. //
  542. typedef BOOL (*PFN_PROVUI_CALL)(IN HWND hWndSecurityDialog, IN struct _CRYPT_PROVIDER_DATA *pProvData);
  543. typedef struct _CRYPT_PROVUI_FUNCS
  544. {
  545. DWORD cbStruct;
  546. struct _CRYPT_PROVUI_DATA *psUIData;
  547. PFN_PROVUI_CALL pfnOnMoreInfoClick;
  548. PFN_PROVUI_CALL pfnOnMoreInfoClickDefault;
  549. PFN_PROVUI_CALL pfnOnAdvancedClick;
  550. PFN_PROVUI_CALL pfnOnAdvancedClickDefault;
  551. } CRYPT_PROVUI_FUNCS, *PCRYPT_PROVUI_FUNCS;
  552. //////////////////////////////////////////////////////////////////////////////
  553. //
  554. // CRYPT_PROVUI_DATA
  555. //----------------------------------------------------------------------------
  556. //
  557. typedef struct _CRYPT_PROVUI_DATA
  558. {
  559. DWORD cbStruct;
  560. DWORD dwFinalError;
  561. WCHAR *pYesButtonText; // default: "&Yes"
  562. WCHAR *pNoButtonText; // default: "&No"
  563. WCHAR *pMoreInfoButtonText; // default: "&More Info"
  564. WCHAR *pAdvancedLinkText; // default: <none>
  565. // 15-Sep-1997 pberkman: added
  566. // good: default:
  567. // "Do you want to install and run ""%1"" signed on %2 and distributed by:"
  568. WCHAR *pCopyActionText;
  569. // good no time stamp: default:
  570. // "Do you want to install and run ""%1"" signed on an unknown date/time and distributed by:"
  571. WCHAR *pCopyActionTextNoTS;
  572. // bad: default:
  573. // "Do you want to install and run ""%1""?"
  574. WCHAR *pCopyActionTextNotSigned;
  575. } CRYPT_PROVUI_DATA, *PCRYPT_PROVUI_DATA;
  576. //////////////////////////////////////////////////////////////////////////////
  577. //
  578. // CRYPT_PROVIDER_SGNR structure
  579. //----------------------------------------------------------------------------
  580. // After the Signature Provider is finished there will be zero to many of these
  581. // filled out. One for each signer of the message. Also, there will be zero
  582. // to many of these filled out inside this structure. One for each counter
  583. // signer of the signer.
  584. //
  585. // IMPORTANT: 1. All dynamically allocated members MUST use allocation
  586. // and Add2 functions provided.
  587. //
  588. typedef struct _CRYPT_PROVIDER_SGNR
  589. {
  590. DWORD cbStruct;
  591. FILETIME sftVerifyAsOf; // either today's filetime or the timestamps
  592. DWORD csCertChain; // use Add2 and Get functions!
  593. struct _CRYPT_PROVIDER_CERT *pasCertChain; // use Add2 and Get functions!
  594. DWORD dwSignerType; // set if known by policy
  595. # define SGNR_TYPE_TIMESTAMP 0x00000010
  596. CMSG_SIGNER_INFO *psSigner; // must use the pfnAlloc allocator!
  597. DWORD dwError; // error encounted while building/verifying the signer.
  598. DWORD csCounterSigners; // use Add2 and Get functions!
  599. struct _CRYPT_PROVIDER_SGNR *pasCounterSigners; // use Add2 and Get functions!
  600. // 11-Feb-1998 philh: added
  601. PCCERT_CHAIN_CONTEXT pChainContext;
  602. } CRYPT_PROVIDER_SGNR, *PCRYPT_PROVIDER_SGNR;
  603. //////////////////////////////////////////////////////////////////////////////
  604. //
  605. // CRYPT_PROVIDER_CERT structure
  606. //----------------------------------------------------------------------------
  607. // After the Signature and Certificate Providers are finished there will
  608. // be zero to many of these filled out in the CRYPT_PROVIDER_SGNR
  609. // structure. One for each certificate in the chain.
  610. //
  611. //
  612. typedef struct _CRYPT_PROVIDER_CERT
  613. {
  614. DWORD cbStruct;
  615. PCCERT_CONTEXT pCert; // must have its own ref-count!
  616. BOOL fCommercial;
  617. BOOL fTrustedRoot; // certchk policy should set this.
  618. BOOL fSelfSigned; // set in cert provider
  619. BOOL fTestCert; // certchk policy will set
  620. DWORD dwRevokedReason;
  621. DWORD dwConfidence; // set in the Certificate Provider
  622. # define CERT_CONFIDENCE_SIG 0x10000000 // this cert
  623. # define CERT_CONFIDENCE_TIME 0x01000000 // issuer cert
  624. # define CERT_CONFIDENCE_TIMENEST 0x00100000 // this cert
  625. # define CERT_CONFIDENCE_AUTHIDEXT 0x00010000 // this cert
  626. # define CERT_CONFIDENCE_HYGIENE 0x00001000 // this cert
  627. # define CERT_CONFIDENCE_HIGHEST 0x11111000
  628. DWORD dwError;
  629. CTL_CONTEXT *pTrustListContext;
  630. // 16-Jan-1998 pberkman: added
  631. BOOL fTrustListSignerCert;
  632. // 25-Feb-1998 philh: added
  633. //
  634. // The following two are only applicable to Self Signed certificates
  635. // residing in a CTL.
  636. PCCTL_CONTEXT pCtlContext;
  637. DWORD dwCtlError;
  638. // 12-Mar-1998 philh: added
  639. BOOL fIsCyclic;
  640. // 12-Oct-2000 DSIE: added
  641. PCERT_CHAIN_ELEMENT pChainElement;
  642. } CRYPT_PROVIDER_CERT, *PCRYPT_PROVIDER_CERT;
  643. //////////////////////////////////////////////////////////////////////////////
  644. //
  645. // CRYPT_PROVIDER_PRIVDATA structure
  646. //----------------------------------------------------------------------------
  647. // This structure is to allow Policy Provider functions to share
  648. // POLICY SPECIFIC data between Policy Functions.
  649. // The Policy must use the pfnAddPrivateData2Chain function and
  650. // must free any data within the member before the Final Policy returns
  651. // to WVT.
  652. // To allow multiple providers to use this feature, each provider that
  653. // uses this member must set the provider ID to it's Action ID so that
  654. // the provider can find its data and ignore any other.
  655. //
  656. typedef struct _CRYPT_PROVIDER_PRIVDATA
  657. {
  658. DWORD cbStruct;
  659. GUID gProviderID;
  660. DWORD cbProvData;
  661. void *pvProvData;
  662. } CRYPT_PROVIDER_PRIVDATA, *PCRYPT_PROVIDER_PRIVDATA;
  663. //////////////////////////////////////////////////////////////////////////////
  664. //
  665. // PROVDATA_SIP
  666. //----------------------------------------------------------------------------
  667. //
  668. typedef struct _PROVDATA_SIP
  669. {
  670. DWORD cbStruct; // = sizeof(PROVDATA_SIP)
  671. GUID gSubject; // subject guid of file/member file. (set in Sig Prov)
  672. struct SIP_DISPATCH_INFO_ *pSip; // set in Sig Prov - defined in sipbase.h
  673. struct SIP_DISPATCH_INFO_ *pCATSip; // set in Sig Prov - defined in sipbase.h
  674. struct SIP_SUBJECTINFO_ *psSipSubjectInfo; // set in Sig Prov - defined in sipbase.h
  675. struct SIP_SUBJECTINFO_ *psSipCATSubjectInfo; // set in Sig Prov - defined in sipbase.h
  676. struct SIP_INDIRECT_DATA_ *psIndirectData; // set in Sig Prov - defined in sipbase.h
  677. } PROVDATA_SIP, *PPROVDATA_SIP;
  678. //////////////////////////////////////////////////////////////////////////////
  679. //
  680. // structures used to register action IDs
  681. //----------------------------------------------------------------------------
  682. //
  683. #define WT_CURRENT_VERSION 0x00000200
  684. typedef struct _CRYPT_TRUST_REG_ENTRY
  685. {
  686. DWORD cbStruct;
  687. WCHAR *pwszDLLName;
  688. WCHAR *pwszFunctionName; // no more than WT_MAX_FUNC_NAME!
  689. } CRYPT_TRUST_REG_ENTRY, *PCRYPT_TRUST_REG_ENTRY;
  690. typedef struct _CRYPT_REGISTER_ACTIONID
  691. {
  692. DWORD cbStruct;
  693. CRYPT_TRUST_REG_ENTRY sInitProvider;
  694. CRYPT_TRUST_REG_ENTRY sObjectProvider;
  695. CRYPT_TRUST_REG_ENTRY sSignatureProvider;
  696. CRYPT_TRUST_REG_ENTRY sCertificateProvider;
  697. CRYPT_TRUST_REG_ENTRY sCertificatePolicyProvider;
  698. CRYPT_TRUST_REG_ENTRY sFinalPolicyProvider;
  699. CRYPT_TRUST_REG_ENTRY sTestPolicyProvider;
  700. // 23-Jul-1997 pberkman: added
  701. CRYPT_TRUST_REG_ENTRY sCleanupProvider;
  702. } CRYPT_REGISTER_ACTIONID, *PCRYPT_REGISTER_ACTIONID;
  703. typedef BOOL (*PFN_ALLOCANDFILLDEFUSAGE)(IN const char *pszUsageOID,
  704. IN struct _CRYPT_PROVIDER_DEFUSAGE *psDefUsage);
  705. typedef BOOL (*PFN_FREEDEFUSAGE)(IN const char *pszUsageOID,
  706. IN struct _CRYPT_PROVIDER_DEFUSAGE *psDefUsage);
  707. typedef struct _CRYPT_PROVIDER_REGDEFUSAGE
  708. {
  709. DWORD cbStruct; // = sizeof CRYPT_PROVIDER_REGDEFUSAGE
  710. GUID *pgActionID;
  711. WCHAR *pwszDllName;
  712. char *pwszLoadCallbackDataFunctionName;
  713. char *pwszFreeCallbackDataFunctionName;
  714. } CRYPT_PROVIDER_REGDEFUSAGE, *PCRYPT_PROVIDER_REGDEFUSAGE;
  715. typedef struct _CRYPT_PROVIDER_DEFUSAGE
  716. {
  717. DWORD cbStruct; // = sizeof CRYPT_PROVIDER_DEFUSAGE
  718. GUID gActionID; // ActionID of provider
  719. LPVOID pDefPolicyCallbackData; // normally filled in WINTRUST_DATA
  720. LPVOID pDefSIPClientData; // normally filled in WINTRUST_DATA
  721. } CRYPT_PROVIDER_DEFUSAGE, *PCRYPT_PROVIDER_DEFUSAGE;
  722. #include <poppack.h>
  723. //////////////////////////////////////////////////////////////////////////////
  724. //
  725. // WINTRUST.DLL Provider defines
  726. //----------------------------------------------------------------------------
  727. // The following are definitions of the Microsoft Generic Cert Provider
  728. //
  729. #define WT_PROVIDER_DLL_NAME L"WINTRUST.DLL"
  730. #define WT_PROVIDER_CERTTRUST_FUNCTION L"WintrustCertificateTrust"
  731. //////////////////////////////////////////////////////////////////////////////
  732. //
  733. // WintrustAddActionID
  734. //----------------------------------------------------------------------------
  735. // Adds a new Provider combination to the users'
  736. // system. Creates all necessary registry entries, etc. This should be done
  737. // during the Policy Provider's DllRegisterServer.
  738. //
  739. // *** THE ONLY ONE WHO SHOULD CALL THIS IS THE POLICY PROVIDER ***
  740. //
  741. // Returns:
  742. // TRUE: No fatal errors
  743. // FALSE: Errors occured. See GetLastError()
  744. //
  745. extern BOOL WINAPI WintrustAddActionID(IN GUID *pgActionID,
  746. IN DWORD fdwFlags,
  747. IN CRYPT_REGISTER_ACTIONID *psProvInfo);
  748. // By default, WintrustAddActionID doesn't return registry errors.
  749. // Set this flag to return registry errors. If FALSE is returned,
  750. // LastError is set.
  751. #define WT_ADD_ACTION_ID_RET_RESULT_FLAG 0x1
  752. //////////////////////////////////////////////////////////////////////////////
  753. //
  754. // WintrustRemoveActionID
  755. //----------------------------------------------------------------------------
  756. // Removes the Provider action combination from the users'
  757. // system.
  758. //
  759. // Returns:
  760. // TRUE: No fatal errors
  761. // FALSE: Errors occured. See GetLastError()
  762. //
  763. extern BOOL WINAPI WintrustRemoveActionID(IN GUID *pgActionID);
  764. //////////////////////////////////////////////////////////////////////////////
  765. //
  766. // WintrustLoadFunctionPointers
  767. //----------------------------------------------------------------------------
  768. // Retrieves the function entry points based on the Action ID given.
  769. //
  770. // Returns:
  771. // TRUE success.
  772. // FALSE fail.
  773. //
  774. extern BOOL WINAPI WintrustLoadFunctionPointers(GUID *pgActionID, CRYPT_PROVIDER_FUNCTIONS *pPfns);
  775. //////////////////////////////////////////////////////////////////////////////
  776. //
  777. // WintrustAddDefaultForUsage
  778. //----------------------------------------------------------------------------
  779. // Sets the default Action ID for the usage. If the provider uses this
  780. // function, and the provider requires any of the "callback" data in
  781. // WINTRUST_DATA to be filled out, it MUST completely fill out the
  782. // CRYPT_PROVIDER_REGDEFUSAGE structure.
  783. //
  784. // Returns:
  785. // TRUE success.
  786. // FALSE fail.
  787. //
  788. extern BOOL WINAPI WintrustAddDefaultForUsage(IN const char *pszUsageOID,
  789. IN CRYPT_PROVIDER_REGDEFUSAGE *psDefUsage);
  790. //////////////////////////////////////////////////////////////////////////////
  791. //
  792. // WintrustGetDefaultForUsage
  793. //----------------------------------------------------------------------------
  794. // Retrieves the Action ID and default callback data for the specified usage
  795. //
  796. // this function must be called again with dwAction set to FREE to deallocate
  797. //
  798. //
  799. // Returns:
  800. // TRUE success.
  801. // FALSE fail.
  802. //
  803. #define DWACTION_ALLOCANDFILL 1
  804. #define DWACTION_FREE 2
  805. extern BOOL WINAPI WintrustGetDefaultForUsage(IN DWORD dwAction,
  806. IN const char *pszUsageOID,
  807. IN OUT CRYPT_PROVIDER_DEFUSAGE *psUsage);
  808. extern CRYPT_PROVIDER_SGNR * WINAPI WTHelperGetProvSignerFromChain(CRYPT_PROVIDER_DATA *pProvData,
  809. DWORD idxSigner,
  810. BOOL fCounterSigner,
  811. DWORD idxCounterSigner);
  812. extern CRYPT_PROVIDER_CERT * WINAPI WTHelperGetProvCertFromChain(CRYPT_PROVIDER_SGNR *pSgnr,
  813. DWORD idxCert);
  814. extern CRYPT_PROVIDER_DATA * WINAPI WTHelperProvDataFromStateData(HANDLE hStateData);
  815. extern CRYPT_PROVIDER_PRIVDATA * WINAPI WTHelperGetProvPrivateDataFromChain(CRYPT_PROVIDER_DATA *pProvData,
  816. GUID *pgProviderID);
  817. extern BOOL WINAPI WTHelperCertIsSelfSigned(DWORD dwEncoding, CERT_INFO *pCert);
  818. extern HRESULT WINAPI WTHelperCertCheckValidSignature(CRYPT_PROVIDER_DATA *pProvData);
  819. //////////////////////////////////////////////////////////////////////////////
  820. //
  821. // Supported ASN structures contained in WINTRUST.DLL
  822. //----------------------------------------------------------------------------
  823. //
  824. #include <pshpack8.h>
  825. //
  826. // CTL Trusted CA Lists
  827. //
  828. #define szOID_TRUSTED_CODESIGNING_CA_LIST "1.3.6.1.4.1.311.2.2.1"
  829. #define szOID_TRUSTED_CLIENT_AUTH_CA_LIST "1.3.6.1.4.1.311.2.2.2"
  830. #define szOID_TRUSTED_SERVER_AUTH_CA_LIST "1.3.6.1.4.1.311.2.2.3"
  831. //
  832. // encode/decode OID defines
  833. //
  834. #define SPC_COMMON_NAME_OBJID szOID_COMMON_NAME
  835. #define SPC_TIME_STAMP_REQUEST_OBJID "1.3.6.1.4.1.311.3.2.1"
  836. #define SPC_INDIRECT_DATA_OBJID "1.3.6.1.4.1.311.2.1.4"
  837. #define SPC_SP_AGENCY_INFO_OBJID "1.3.6.1.4.1.311.2.1.10"
  838. #define SPC_STATEMENT_TYPE_OBJID "1.3.6.1.4.1.311.2.1.11"
  839. #define SPC_SP_OPUS_INFO_OBJID "1.3.6.1.4.1.311.2.1.12"
  840. #define SPC_CERT_EXTENSIONS_OBJID "1.3.6.1.4.1.311.2.1.14"
  841. #define SPC_PE_IMAGE_DATA_OBJID "1.3.6.1.4.1.311.2.1.15"
  842. #define SPC_RAW_FILE_DATA_OBJID "1.3.6.1.4.1.311.2.1.18"
  843. #define SPC_STRUCTURED_STORAGE_DATA_OBJID "1.3.6.1.4.1.311.2.1.19"
  844. #define SPC_JAVA_CLASS_DATA_OBJID "1.3.6.1.4.1.311.2.1.20"
  845. #define SPC_INDIVIDUAL_SP_KEY_PURPOSE_OBJID "1.3.6.1.4.1.311.2.1.21"
  846. #define SPC_COMMERCIAL_SP_KEY_PURPOSE_OBJID "1.3.6.1.4.1.311.2.1.22"
  847. #define SPC_CAB_DATA_OBJID "1.3.6.1.4.1.311.2.1.25"
  848. #define SPC_GLUE_RDN_OBJID "1.3.6.1.4.1.311.2.1.25" // obsolete!
  849. #define SPC_MINIMAL_CRITERIA_OBJID "1.3.6.1.4.1.311.2.1.26"
  850. #define SPC_FINANCIAL_CRITERIA_OBJID "1.3.6.1.4.1.311.2.1.27"
  851. #define SPC_LINK_OBJID "1.3.6.1.4.1.311.2.1.28"
  852. #define SPC_SIGINFO_OBJID "1.3.6.1.4.1.311.2.1.30"
  853. #define CAT_NAMEVALUE_OBJID "1.3.6.1.4.1.311.12.2.1"
  854. #define CAT_MEMBERINFO_OBJID "1.3.6.1.4.1.311.12.2.2"
  855. //
  856. // encode/decode internal defines
  857. //
  858. #define SPC_SP_AGENCY_INFO_STRUCT ((LPCSTR) 2000)
  859. #define SPC_MINIMAL_CRITERIA_STRUCT ((LPCSTR) 2001)
  860. #define SPC_FINANCIAL_CRITERIA_STRUCT ((LPCSTR) 2002)
  861. #define SPC_INDIRECT_DATA_CONTENT_STRUCT ((LPCSTR) 2003)
  862. #define SPC_PE_IMAGE_DATA_STRUCT ((LPCSTR) 2004)
  863. #define SPC_LINK_STRUCT ((LPCSTR) 2005)
  864. #define SPC_STATEMENT_TYPE_STRUCT ((LPCSTR) 2006)
  865. #define SPC_SP_OPUS_INFO_STRUCT ((LPCSTR) 2007)
  866. #define SPC_CAB_DATA_STRUCT ((LPCSTR) 2008)
  867. #define SPC_JAVA_CLASS_DATA_STRUCT ((LPCSTR) 2009)
  868. #define SPC_SIGINFO_STRUCT ((LPCSTR) 2130)
  869. #define CAT_NAMEVALUE_STRUCT ((LPCSTR) 2221)
  870. #define CAT_MEMBERINFO_STRUCT ((LPCSTR) 2222)
  871. #define SPC_UUID_LENGTH 16
  872. typedef BYTE SPC_UUID[SPC_UUID_LENGTH];
  873. typedef struct _SPC_SERIALIZED_OBJECT
  874. {
  875. SPC_UUID ClassId;
  876. CRYPT_DATA_BLOB SerializedData;
  877. } SPC_SERIALIZED_OBJECT, *PSPC_SERIALIZED_OBJECT;
  878. typedef struct SPC_SIGINFO_
  879. {
  880. DWORD dwSipVersion;
  881. GUID gSIPGuid;
  882. DWORD dwReserved1;
  883. DWORD dwReserved2;
  884. DWORD dwReserved3;
  885. DWORD dwReserved4;
  886. DWORD dwReserved5;
  887. } SPC_SIGINFO, *PSPC_SIGINFO;
  888. typedef struct SPC_LINK_
  889. {
  890. DWORD dwLinkChoice;
  891. # define SPC_URL_LINK_CHOICE 1
  892. # define SPC_MONIKER_LINK_CHOICE 2
  893. # define SPC_FILE_LINK_CHOICE 3
  894. union
  895. {
  896. LPWSTR pwszUrl;
  897. SPC_SERIALIZED_OBJECT Moniker;
  898. LPWSTR pwszFile;
  899. };
  900. } SPC_LINK, *PSPC_LINK;
  901. typedef struct _SPC_PE_IMAGE_DATA
  902. {
  903. CRYPT_BIT_BLOB Flags;
  904. PSPC_LINK pFile;
  905. } SPC_PE_IMAGE_DATA, *PSPC_PE_IMAGE_DATA;
  906. typedef struct _SPC_INDIRECT_DATA_CONTENT
  907. {
  908. CRYPT_ATTRIBUTE_TYPE_VALUE Data;
  909. CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
  910. CRYPT_HASH_BLOB Digest;
  911. } SPC_INDIRECT_DATA_CONTENT, *PSPC_INDIRECT_DATA_CONTENT;
  912. typedef struct _SPC_FINANCIAL_CRITERIA
  913. {
  914. BOOL fFinancialInfoAvailable;
  915. BOOL fMeetsCriteria;
  916. } SPC_FINANCIAL_CRITERIA, *PSPC_FINANCIAL_CRITERIA;
  917. typedef struct _SPC_IMAGE
  918. {
  919. struct SPC_LINK_ *pImageLink;
  920. CRYPT_DATA_BLOB Bitmap;
  921. CRYPT_DATA_BLOB Metafile;
  922. CRYPT_DATA_BLOB EnhancedMetafile;
  923. CRYPT_DATA_BLOB GifFile;
  924. } SPC_IMAGE, *PSPC_IMAGE;
  925. typedef struct _SPC_SP_AGENCY_INFO
  926. {
  927. struct SPC_LINK_ *pPolicyInformation;
  928. LPWSTR pwszPolicyDisplayText;
  929. PSPC_IMAGE pLogoImage;
  930. struct SPC_LINK_ *pLogoLink;
  931. } SPC_SP_AGENCY_INFO, *PSPC_SP_AGENCY_INFO;
  932. typedef struct _SPC_STATEMENT_TYPE
  933. {
  934. DWORD cKeyPurposeId;
  935. LPSTR *rgpszKeyPurposeId; // pszObjId
  936. } SPC_STATEMENT_TYPE, *PSPC_STATEMENT_TYPE;
  937. typedef struct _SPC_SP_OPUS_INFO
  938. {
  939. LPCWSTR pwszProgramName;
  940. struct SPC_LINK_ *pMoreInfo;
  941. struct SPC_LINK_ *pPublisherInfo;
  942. } SPC_SP_OPUS_INFO, *PSPC_SP_OPUS_INFO;
  943. typedef struct _CAT_NAMEVALUE
  944. {
  945. LPWSTR pwszTag;
  946. DWORD fdwFlags;
  947. CRYPT_DATA_BLOB Value;
  948. } CAT_NAMEVALUE, *PCAT_NAMEVALUE;
  949. typedef struct _CAT_MEMBERINFO
  950. {
  951. LPWSTR pwszSubjGuid;
  952. DWORD dwCertVersion;
  953. } CAT_MEMBERINFO, *PCAT_MEMBERINFO;
  954. #include <poppack.h>
  955. //////////////////////////////////////////////////////////////////////////////////
  956. //
  957. // support for old calling convention: *** DO NOT USE ***
  958. //
  959. #ifdef WT_DEFINE_ALL_APIS
  960. typedef struct _WIN_CERTIFICATE
  961. {
  962. DWORD dwLength;
  963. WORD wRevision;
  964. WORD wCertificateType; // WIN_CERT_TYPE_xxx
  965. BYTE bCertificate[ANYSIZE_ARRAY];
  966. } WIN_CERTIFICATE, *LPWIN_CERTIFICATE;
  967. #define WIN_CERT_REVISION_1_0 (0x0100)
  968. #define WIN_CERT_REVISION_2_0 (0x0200)
  969. #define WIN_CERT_TYPE_X509 (0x0001) // bCertificate contains an X.509 Certificate
  970. #define WIN_CERT_TYPE_PKCS_SIGNED_DATA (0x0002) // bCertificate contains a PKCS SignedData structure
  971. #define WIN_CERT_TYPE_RESERVED_1 (0x0003) // Reserved
  972. #define WIN_CERT_TYPE_TS_STACK_SIGNED (0x0004) // Terminal Server Protocol Stack Certificate signing
  973. typedef LPVOID WIN_TRUST_SUBJECT;
  974. typedef struct _WIN_TRUST_ACTDATA_CONTEXT_WITH_SUBJECT
  975. {
  976. HANDLE hClientToken;
  977. GUID * SubjectType;
  978. WIN_TRUST_SUBJECT Subject;
  979. } WIN_TRUST_ACTDATA_CONTEXT_WITH_SUBJECT, *LPWIN_TRUST_ACTDATA_CONTEXT_WITH_SUBJECT ;
  980. typedef struct _WIN_TRUST_ACTDATA_SUBJECT_ONLY
  981. {
  982. GUID * SubjectType;
  983. WIN_TRUST_SUBJECT Subject;
  984. } WIN_TRUST_ACTDATA_SUBJECT_ONLY, *LPWIN_TRUST_ACTDATA_SUBJECT_ONLY;
  985. /* RawFile == 959dc450-8d9e-11cf-8736-00aa00a485eb */
  986. #define WIN_TRUST_SUBJTYPE_RAW_FILE \
  987. { 0x959dc450, \
  988. 0x8d9e, \
  989. 0x11cf, \
  990. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  991. }
  992. /* PeImage == 43c9a1e0-8da0-11cf-8736-00aa00a485eb */
  993. #define WIN_TRUST_SUBJTYPE_PE_IMAGE \
  994. { 0x43c9a1e0, \
  995. 0x8da0, \
  996. 0x11cf, \
  997. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  998. }
  999. /* JavaClass = 08ad3990-8da1-11cf-8736-00aa00a485eb */
  1000. #define WIN_TRUST_SUBJTYPE_JAVA_CLASS \
  1001. { 0x08ad3990, \
  1002. 0x8da1, \
  1003. 0x11cf, \
  1004. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  1005. }
  1006. /* Cabinet = d17c5374-a392-11cf-9df5-00aa00c184e0 */
  1007. #define WIN_TRUST_SUBJTYPE_CABINET \
  1008. { 0xd17c5374, \
  1009. 0xa392, \
  1010. 0x11cf, \
  1011. { 0x9d, 0xf5, 0x0, 0xaa, 0x0, 0xc1, 0x84, 0xe0 } \
  1012. }
  1013. typedef struct _WIN_TRUST_SUBJECT_FILE
  1014. {
  1015. HANDLE hFile;
  1016. LPCWSTR lpPath;
  1017. } WIN_TRUST_SUBJECT_FILE, *LPWIN_TRUST_SUBJECT_FILE;
  1018. #define WIN_TRUST_SUBJTYPE_RAW_FILEEX \
  1019. { 0x6f458110, \
  1020. 0xc2f1, \
  1021. 0x11cf, \
  1022. { 0x8a, 0x69, 0x0, 0xaa, 0x0, 0x6c, 0x37, 0x6 } \
  1023. }
  1024. #define WIN_TRUST_SUBJTYPE_PE_IMAGEEX \
  1025. { 0x6f458111, \
  1026. 0xc2f1, \
  1027. 0x11cf, \
  1028. { 0x8a, 0x69, 0x0, 0xaa, 0x0, 0x6c, 0x37, 0x6 } \
  1029. }
  1030. #define WIN_TRUST_SUBJTYPE_JAVA_CLASSEX \
  1031. { 0x6f458113, \
  1032. 0xc2f1, \
  1033. 0x11cf, \
  1034. { 0x8a, 0x69, 0x0, 0xaa, 0x0, 0x6c, 0x37, 0x6 } \
  1035. }
  1036. #define WIN_TRUST_SUBJTYPE_CABINETEX \
  1037. { 0x6f458114, \
  1038. 0xc2f1, \
  1039. 0x11cf, \
  1040. { 0x8a, 0x69, 0x0, 0xaa, 0x0, 0x6c, 0x37, 0x6 } \
  1041. }
  1042. typedef struct _WIN_TRUST_SUBJECT_FILE_AND_DISPLAY
  1043. {
  1044. HANDLE hFile; // handle to the open file if you got it
  1045. LPCWSTR lpPath; // the path to open if you don't
  1046. LPCWSTR lpDisplayName; // (optional) display name to show to user
  1047. } WIN_TRUST_SUBJECT_FILE_AND_DISPLAY, *LPWIN_TRUST_SUBJECT_FILE_AND_DISPLAY;
  1048. /* OleStorage == c257e740-8da0-11cf-8736-00aa00a485eb */
  1049. #define WIN_TRUST_SUBJTYPE_OLE_STORAGE \
  1050. { 0xc257e740, \
  1051. 0x8da0, \
  1052. 0x11cf, \
  1053. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  1054. }
  1055. /* TrustedPublisher == 66426730-8da1-11cf-8736-00aa00a485eb */
  1056. #define WIN_SPUB_ACTION_TRUSTED_PUBLISHER \
  1057. { 0x66426730, \
  1058. 0x8da1, \
  1059. 0x11cf, \
  1060. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  1061. }
  1062. /* NtActivateImage == 8bc96b00-8da1-11cf-8736-00aa00a485eb */
  1063. #define WIN_SPUB_ACTION_NT_ACTIVATE_IMAGE \
  1064. { 0x8bc96b00, \
  1065. 0x8da1, \
  1066. 0x11cf, \
  1067. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  1068. }
  1069. /* PublishedSoftware == 64b9d180-8da2-11cf-8736-00aa00a485eb */
  1070. #define WIN_SPUB_ACTION_PUBLISHED_SOFTWARE \
  1071. { 0x64b9d180, \
  1072. 0x8da2, \
  1073. 0x11cf, \
  1074. {0x87, 0x36, 0x00, 0xaa, 0x00, 0xa4, 0x85, 0xeb} \
  1075. }
  1076. typedef struct _WIN_SPUB_TRUSTED_PUBLISHER_DATA
  1077. {
  1078. HANDLE hClientToken;
  1079. LPWIN_CERTIFICATE lpCertificate;
  1080. } WIN_SPUB_TRUSTED_PUBLISHER_DATA, *LPWIN_SPUB_TRUSTED_PUBLISHER_DATA;
  1081. #endif
  1082. #ifdef __cplusplus
  1083. }
  1084. #endif
  1085. #endif // WINTRUST_H