home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / wintrust.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  52.7 KB  |  1,254 lines

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