WinTrust.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:56k
源码类别:

模拟服务器

开发平台:

C/C++

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