home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / WINTRUST.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  29.1 KB  |  656 lines

  1. //+-------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //
  5. //  Copyright 1996 - 1998 Microsoft Corporation.
  6. //
  7. //  File:       wintrust.h
  8. //
  9. //  Contents:   Microsoft Internet Security Trust Provider Model
  10. //
  11. //  History:    31-May-1997 created
  12. //
  13. //--------------------------------------------------------------------------
  14.  
  15. #ifndef WINTRUST_H
  16. #pragma option push -b -a8 -pc -A- /*P_O_Push_S*/
  17. #define WINTRUST_H
  18.  
  19. //////////////////////////////////////////////////////////////////////////////
  20. //////////////////////////////////////////////////////////////////////////////
  21. //
  22. //      Client definitions, typedefs, and prototypes
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26.  
  27. #pragma pack(8)
  28.  
  29. //////////////////////////////////////////////////////////////////////////////
  30. //
  31. // WINTRUST_DATA Structure
  32. //----------------------------------------------------------------------------
  33. //  Used when calling WinVerifyTrust to pass necessary information into
  34. //  the Providers.
  35. //
  36. typedef struct _WINTRUST_DATA
  37. {
  38.     DWORD           cbStruct;                   // = sizeof(WINTRUST_DATA)
  39.  
  40.     LPVOID          pPolicyCallbackData;        // optional: used to pass data between the app and policy
  41.  
  42.     DWORD           dwUIChoice;                 // required: UI choice.  One of the following.
  43. #                       define      WTD_UI_ALL              1
  44. #                       define      WTD_UI_NONE             2
  45. #                       define      WTD_UI_NOBAD            3
  46. #                       define      WTD_UI_NOGOOD           4
  47.  
  48.     DWORD           fdwRevocationChecks;        // required: certificate revocation check options
  49. #                       define      WTD_REVOKE_NONE         0x00000000
  50. #                       define      WTD_REVOKE_WHOLECHAIN   0x00000001
  51.  
  52.     DWORD           dwUnionChoice;              // required: which structure is being passed in?
  53. #                       define      WTD_CHOICE_FILE         1
  54. #                       define      WTD_CHOICE_CATALOG      2
  55. #                       define      WTD_CHOICE_BLOB         3
  56. #                       define      WTD_CHOICE_SIGNER       4
  57. #                       define      WTD_CHOICE_CERT         5
  58.     union
  59.     {
  60.         struct WINTRUST_FILE_INFO_      *pFile;         // individual file
  61.         struct WINTRUST_CATALOG_INFO_   *pCatalog;      // member of a Catalog File
  62.         struct WINTRUST_BLOB_INFO_      *pBlob;         // memory blob
  63.         struct WINTRUST_SGNR_INFO_      *pSgnr;         // signer structure only
  64.         struct WINTRUST_CERT_INFO_      *pCert;
  65.     };
  66.  
  67.     DWORD           dwStateAction;                      // future. DO NOT USE!!! (optional)
  68. #                       define      WTD_STATEACTION_OPEN    1
  69. #                       define      WTD_STATEACTION_VERIFY  2
  70. #                       define      WTD_STATEACTION_CLOSE   3
  71.  
  72.     HANDLE          hWVTStateData;                      // future. DO NOT USE!!! (optional)
  73.  
  74. } WINTRUST_DATA, *PWINTRUST_DATA;
  75.  
  76. //////////////////////////////////////////////////////////////////////////////
  77. //
  78. // WINTRUST_FILE_INFO Structure
  79. //----------------------------------------------------------------------------
  80. //  Used when calling WinVerifyTrust against an individual file.
  81. //
  82. typedef struct WINTRUST_FILE_INFO_
  83. {
  84.     DWORD           cbStruct;                   // = sizeof(WINTRUST_FILE_INFO)
  85.  
  86.     LPCWSTR         pcwszFilePath;              // required, file name to be verified
  87.     HANDLE          hFile;                      // optional, open handle to pcwszFilePath
  88.       
  89. } WINTRUST_FILE_INFO, *PWINTRUST_FILE_INFO;
  90.  
  91. //////////////////////////////////////////////////////////////////////////////
  92. //
  93. // WINTRUST_CATALOG_INFO Structure
  94. //----------------------------------------------------------------------------
  95. //  Used when calling WinVerifyTrust against a member of a Microsoft Catalog
  96. //  file.
  97. //
  98. typedef struct WINTRUST_CATALOG_INFO_
  99. {
  100.     DWORD               cbStruct;               // = sizeof(WINTRUST_CATALOG_INFO)
  101.  
  102.     DWORD               dwCatalogVersion;       // optional: Catalog version number
  103.     LPCWSTR             pcwszCatalogFilePath;   // required: path/name to Catalog file
  104.  
  105.     LPCWSTR             pcwszMemberTag;         // required: tag to member in Catalog
  106.     LPCWSTR             pcwszMemberFilePath;    // required: path/name to member file
  107.     HANDLE              hMemberFile;            // optional: open handle to pcwszMemberFilePath
  108.  
  109. } WINTRUST_CATALOG_INFO, *PWINTRUST_CATALOG_INFO;
  110.  
  111. //////////////////////////////////////////////////////////////////////////////
  112. //
  113. // WINTRUST_BLOB_INFO Structure
  114. //----------------------------------------------------------------------------
  115. //  Used when calling WinVerifyTrust against a memory blob.
  116. //
  117. typedef struct WINTRUST_BLOB_INFO_
  118. {
  119.     DWORD               cbStruct;               // = sizeof(WINTRUST_BLOB_INFO)
  120.  
  121.     LPCWSTR             pcwszDisplayName;       // name of the "thing" the pbMem is pointing to.
  122.  
  123.     DWORD               cbMem;
  124.     BYTE                *pbMem;
  125.  
  126. } WINTRUST_BLOB_INFO, *PWINTRUST_BLOB_INFO;
  127.  
  128. //////////////////////////////////////////////////////////////////////////////
  129. //
  130. // WINTRUST_SGNR_INFO Structure
  131. //----------------------------------------------------------------------------
  132. //  Used when calling WinVerifyTrust against a CMSG_SIGNER_INFO Structure
  133. //
  134. typedef struct WINTRUST_SGNR_INFO_
  135. {
  136.     DWORD               cbStruct;               // = sizeof(WINTRUST_SGNR_INFO)
  137.  
  138.     LPCWSTR             pcwszDisplayName;       // name of the "thing" the pbMem is pointing to.
  139.  
  140.     CMSG_SIGNER_INFO    *psSignerInfo;
  141.  
  142.     DWORD               chStores;               // number of stores in pahStores
  143.     HCERTSTORE          *pahStores;             // array of stores to add to internal list
  144.  
  145. } WINTRUST_SGNR_INFO, *PWINTRUST_SGNR_INFO;
  146.  
  147. //////////////////////////////////////////////////////////////////////////////
  148. //
  149. // WINTRUST_CERT_INFO Structure
  150. //----------------------------------------------------------------------------
  151. //  Used when calling WinVerifyTrust against a CERT_CONTEXT Structure
  152. //
  153. typedef struct WINTRUST_CERT_INFO_
  154. {
  155.     DWORD               cbStruct;               // = sizeof(WINTRUST_CERT_INFO)
  156.  
  157.     LPCWSTR             pcwszDisplayName;       // name of the "thing" the pbMem is pointing to.
  158.  
  159.     CERT_CONTEXT        *psCertContext;
  160.  
  161.     DWORD               chStores;               // number of stores in pahStores
  162.     HCERTSTORE          *pahStores;             // array of stores to add to internal list
  163.  
  164. } WINTRUST_CERT_INFO, *PWINTRUST_CERT_INFO;
  165.  
  166. #pragma pack()
  167.  
  168.  
  169. //////////////////////////////////////////////////////////////////////////////
  170. //
  171. // WinVerifyTrust
  172. //----------------------------------------------------------------------------
  173. //  Exported from WINTRUST.DLL.
  174. //  Call this function to verify the trust based on a digital signer.
  175. //
  176. //  Returns:
  177. //          ERROR_SUCCESS               If the trust is authenticated or
  178. //                                      if the user accepted the risk.
  179. //
  180. //          TRUST_E_PROVIDER_UNKNOWN    there was an error loading one of the 
  181. //                                      required Providers.
  182. //
  183. //          all error codes passed back are based on the Policy Provider used.
  184. //
  185.  
  186. LONG WINAPI WinVerifyTrust(IN OPTIONAL HWND hwnd,
  187.                               IN          GUID *pgActionID,
  188.                               IN          LPVOID pWintrustData);
  189.  
  190.  
  191. //////////////////////////////////////////////////////////////////////////////
  192. //////////////////////////////////////////////////////////////////////////////
  193. //
  194. //      Trust, Policy, and UI Provider definitions, typedefs, and prototypes
  195. //
  196. //  Model:
  197. //      A client wishing to validate trust through WinVerifyTrust will
  198. //      select an appropriate Action ID guid for the call.
  199. //      This guid is defined by each Policy Provider and represents the 
  200. //      functions called based on the policy for the given object.
  201. //
  202. //      In this model, the Policy Provider determines which style of UI
  203. //      will be shown to the user (this only applies to style, the 
  204. //      determination of whether UI is displayed is set by the calling client
  205. //      in the UI flags member of WINTRUST_DATA).
  206. //
  207. //      Since the function entry points are common (same return value and
  208. //      parameters), it allows Policy Provider developers to take advantage 
  209. //      of existing, generic, code to fill the CRYPT_PROVIDER_DATA structure.
  210. //    
  211. //      This also allows the developer to simply add the specific policy they
  212. //      need, then, call the generic Policy Provider - if appropriate.
  213. //
  214. //////////////////////////////////////////////////////////////////////////////
  215. //////////////////////////////////////////////////////////////////////////////
  216.  
  217. //////////////////////////////////////////////////////////////////////////////
  218. //
  219. // Supported ASN structures contained in WINTRUST.DLL
  220. //----------------------------------------------------------------------------
  221. //  
  222. #pragma pack (8)
  223.  
  224. #define SPC_INDIRECT_DATA_CONTENT_STRUCT    ((LPCSTR)2003)
  225. #define SPC_INDIRECT_DATA_OBJID             "1.3.6.1.4.1.311.2.1.4"
  226. #define SPC_GLUE_RDN_OBJID                  "1.3.6.1.4.1.311.2.1.25"
  227.  
  228. typedef struct _SPC_INDIRECT_DATA_CONTENT 
  229. {
  230.     CRYPT_ATTRIBUTE_TYPE_VALUE    Data;
  231.     CRYPT_ALGORITHM_IDENTIFIER    DigestAlgorithm;
  232.     CRYPT_HASH_BLOB               Digest;
  233.  
  234. } SPC_INDIRECT_DATA_CONTENT, *PSPC_INDIRECT_DATA_CONTENT;
  235.  
  236. #pragma pack()
  237.  
  238.  
  239. //////////////////////////////////////////////////////////////////////////////
  240. //
  241. // Wintrust Policy Flags
  242. //----------------------------------------------------------------------------
  243. //  These are set during install and can be modified by the user
  244. //  through various means.  The SETREG.EXE utility (found in the Authenticode
  245. //  Tools Pack) will select/deselect each of them.
  246. //
  247. #define WTPF_TRUSTTEST              0x00000020  // trust any "TEST" generated certificate
  248. #define WTPF_TESTCANBEVALID         0x00000080 
  249. #define WTPF_IGNOREEXPIRATION       0x00000100  // Use expiration date
  250. #define WTPF_IGNOREREVOKATION       0x00000200  // Do revocation check
  251. #define WTPF_OFFLINEOK_IND          0x00000400  // off-line is ok for individual certs
  252. #define WTPF_OFFLINEOK_COM          0x00000800  // off-line is ok for commercial certs
  253. #define WTPF_OFFLINEOKNBU_IND       0x00001000  // off-line is ok for individual certs, no bad ui
  254. #define WTPF_OFFLINEOKNBU_COM       0x00002000  // off-line is ok for commercial certs, no bad ui
  255. #define WTPF_TIMESTAMP_IND          0x00004000  // Use timestamp for individual certs
  256. #define WTPF_TIMESTAMP_COM          0x00008000  // Use timestamp for commerical certs
  257. #define WTPF_VERIFY_V1_OFF          0x00010000  // turn verify of v1 certs off
  258. #define WTPF_IGNOREREVOCATIONONTS   0x00020000  // ignore TimeStamp revocation checks
  259.  
  260. //////////////////////////////////////////////////////////////////////////////
  261. //
  262. // WintrustGetRegPolicyFlags
  263. //----------------------------------------------------------------------------
  264. //  This API call is exported from WINTRUST.DLL and is the recommended method
  265. //  of retrieving the DWORD representing the Policy Flags.
  266. //
  267. extern void WINAPI      WintrustGetRegPolicyFlags(DWORD *pdwPolicyFlags);
  268.  
  269.  
  270. //////////////////////////////////////////////////////////////////////////////
  271. //
  272. // Trust Provider "Step" Error defines
  273. //----------------------------------------------------------------------------
  274. //  Each "step" of the Trust process has an error "slot" associated with it.
  275. //  If an error occurs, the "step" will assign its result to this "slot".  These
  276. //  errors can be any valid WINERROR.H HRESULT code.
  277. //
  278. #define TRUSTERROR_STEP_WVTPARAMS                   0
  279. #define TRUSTERROR_STEP_FILEIO                      2
  280. #define TRUSTERROR_STEP_SIP                         3
  281. #define TRUSTERROR_STEP_SIPSUBJINFO                 5
  282. #define TRUSTERROR_STEP_CATALOGFILE                 6
  283. #define TRUSTERROR_STEP_CERTSTORE                   7
  284. #define TRUSTERROR_STEP_MESSAGE                     8
  285. #define TRUSTERROR_STEP_MSG_SIGNERCOUNT             9
  286. #define TRUSTERROR_STEP_MSG_INNERCNTTYPE            10
  287. #define TRUSTERROR_STEP_MSG_INNERCNT                11
  288. #define TRUSTERROR_STEP_MSG_STORE                   12
  289. #define TRUSTERROR_STEP_MSG_SIGNERINFO              13
  290. #define TRUSTERROR_STEP_MSG_SIGNERCERT              14
  291. #define TRUSTERROR_STEP_MSG_CERTCHAIN               15
  292. #define TRUSTERROR_STEP_MSG_COUNTERSIGINFO          16
  293. #define TRUSTERROR_STEP_MSG_COUNTERSIGCERT          17
  294. #define TRUSTERROR_STEP_VERIFY_MSGHASH              18
  295. #define TRUSTERROR_STEP_VERIFY_MSGINDIRECTDATA      19
  296.  
  297. #define TRUSTERROR_STEP_FINAL_WVTINIT               30
  298. #define TRUSTERROR_STEP_FINAL_INITPROV              31
  299. #define TRUSTERROR_STEP_FINAL_OBJPROV               32
  300. #define TRUSTERROR_STEP_FINAL_SIGPROV               33
  301. #define TRUSTERROR_STEP_FINAL_CERTPROV              34
  302. #define TRUSTERROR_STEP_FINAL_CERTCHKPROV           35
  303. #define TRUSTERROR_STEP_FINAL_POLICYPROV            36
  304. #define TRUSTERROR_STEP_FINAL_UIPROV                37
  305.  
  306. #define TRUSTERROR_MAX_STEPS                        38
  307.  
  308. //////////////////////////////////////////////////////////////////////////////
  309. //
  310. //  allocation and free function prototypes
  311. //----------------------------------------------------------------------------
  312. //
  313. typedef void        *(*PFN_CPD_MEM_ALLOC)(IN DWORD cbSize);
  314. typedef void        (*PFN_CPD_MEM_FREE)(IN void *pvMem2Free);
  315.  
  316. typedef BOOL        (*PFN_CPD_ADD_STORE)(IN struct _CRYPT_PROVIDER_DATA *pProvData, 
  317.                                          IN HCERTSTORE hStore2Add);
  318.  
  319. typedef BOOL        (*PFN_CPD_ADD_SGNR)(IN          struct _CRYPT_PROVIDER_DATA *pProvData, 
  320.                                         IN          BOOL fCounterSigner,
  321.                                         IN OPTIONAL DWORD idxSigner,
  322.                                         IN          struct _CRYPT_PROVIDER_SGNR *pSgnr2Add);
  323.  
  324. typedef BOOL        (*PFN_CPD_ADD_CERT)(IN          struct _CRYPT_PROVIDER_DATA *pProvData, 
  325.                                         IN          DWORD idxSigner,
  326.                                         IN          BOOL fCounterSigner,
  327.                                         IN OPTIONAL DWORD idxCounterSigner,
  328.                                         IN          PCCERT_CONTEXT pCert2Add);
  329.  
  330. typedef BOOL        (*PFN_CPD_ADD_PRIVDATA)(IN struct _CRYPT_PROVIDER_DATA *pProvData,
  331.                                             IN struct _CRYPT_PROVIDER_PRIVDATA *pPrivData2Add);
  332.  
  333. //////////////////////////////////////////////////////////////////////////////
  334. //
  335. //  Provider function prototypes
  336. //----------------------------------------------------------------------------
  337. //
  338.  
  339. //
  340. //  entry point for the object provider
  341. //
  342. typedef HRESULT     (*PFN_PROVIDER_INIT_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  343.  
  344. //
  345. //  entry point for the object provider
  346. //
  347. typedef HRESULT     (*PFN_PROVIDER_OBJTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  348.  
  349. //
  350. //  entry point for the Signature Provider
  351. //
  352. typedef HRESULT     (*PFN_PROVIDER_SIGTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  353.  
  354. //
  355. //  entry point for the Certificate Provider
  356. //
  357. typedef HRESULT     (*PFN_PROVIDER_CERTTRUST_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  358.  
  359. //
  360. //  entry point for the Policy Provider's final call (from the trust provider)
  361. //
  362. typedef HRESULT     (*PFN_PROVIDER_FINALPOLICY_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  363.  
  364. //
  365. //  entry point for the Policy Provider's "dump structure" call 
  366. //
  367. typedef HRESULT     (*PFN_PROVIDER_TESTFINALPOLICY_CALL)(IN OUT struct _CRYPT_PROVIDER_DATA *pProvData);
  368.  
  369. //
  370. //  entry point for the Policy Provider's Cert Check call.  This will return
  371. //  true if the Trust Provider is to continue building the certificate chain.
  372. //  If the PP returns FALSE, it is assumed that we have reached a "TRUSTED",
  373. //  self-signed, root.
  374. //
  375. typedef BOOL        (*PFN_PROVIDER_CERTCHKPOLICY_CALL)( IN          struct _CRYPT_PROVIDER_DATA *pProvData, 
  376.                                                         IN          DWORD idxSigner,
  377.                                                         IN          BOOL fCounterSignerChain,
  378.                                                         IN OPTIONAL DWORD idxCounterSigner);
  379.  
  380. #pragma pack(8)
  381.  
  382. //////////////////////////////////////////////////////////////////////////////
  383. //
  384. // CRYPT_PROVIDER_FUNCTIONS structure
  385. //----------------------------------------------------------------------------
  386. //
  387. //
  388. typedef struct _CRYPT_PROVIDER_FUNCTIONS
  389. {
  390.     DWORD                               cbStruct;
  391.  
  392.     PFN_CPD_MEM_ALLOC                   pfnAlloc;               // set in WVT
  393.     PFN_CPD_MEM_FREE                    pfnFree;                // set in WVT
  394.  
  395.     PFN_CPD_ADD_STORE                   pfnAddStore2Chain;      // call to add a store to the chain.
  396.     PFN_CPD_ADD_SGNR                    pfnAddSgnr2Chain;       // call to add a sgnr struct to a msg struct sgnr chain
  397.     PFN_CPD_ADD_CERT                    pfnAddCert2Chain;       // call to add a cert struct to a sgnr struct cert chain
  398.     PFN_CPD_ADD_PRIVDATA                pfnAddPrivData2Chain;   // call to add provider private data to struct.
  399.  
  400.     PFN_PROVIDER_INIT_CALL              pfnInitialize;          // initialize Policy data.
  401.     PFN_PROVIDER_OBJTRUST_CALL          pfnObjectTrust;         // build info up to the signer info(s).
  402.     PFN_PROVIDER_SIGTRUST_CALL          pfnSignatureTrust;      // build info to the signing cert
  403.     PFN_PROVIDER_CERTTRUST_CALL         pfnCertificateTrust;    // build the chain
  404.     PFN_PROVIDER_FINALPOLICY_CALL       pfnFinalPolicy;         // final call to policy
  405.     PFN_PROVIDER_CERTCHKPOLICY_CALL     pfnCertCheckPolicy;     // check each cert will building chain
  406.     PFN_PROVIDER_TESTFINALPOLICY_CALL   pfnTestFinalPolicy;     // dump structures to a file (or whatever the policy chooses)
  407.  
  408. } CRYPT_PROVIDER_FUNCTIONS, *PCRYPT_PROVIDER_FUNCTIONS;
  409.  
  410. //////////////////////////////////////////////////////////////////////////////
  411. //
  412. // CRYPT_PROVIDER_CERT structure
  413. //----------------------------------------------------------------------------
  414. //  After the Signature and Certificate Providers are finished there will 
  415. //  be zero to many of these filled out in the CRYPT_PROVIDER_SGNR 
  416. //  structure.  One for each certificate in the chain.
  417. //  
  418. //
  419. typedef struct _CRYPT_PROVIDER_CERT
  420. {
  421.     DWORD                       cbStruct;
  422.  
  423.     PCCERT_CONTEXT              pCert;              // must have its own ref-count!
  424.  
  425.     BOOL                        fCommercial;
  426.     BOOL                        fTrustedRoot;       // certchk policy should set this.
  427.     BOOL                        fSelfSigned;        // set in cert provider
  428.  
  429.     BOOL                        fTestCert;          // certchk policy will set
  430.  
  431.     DWORD                       dwRevokedReason;
  432.  
  433.     DWORD                       dwConfidence;       // set in the Certificate Provider
  434. #                                   define  CERT_CONFIDENCE_SIG          0x10000000
  435. #                                   define  CERT_CONFIDENCE_TIME         0x01000000
  436. #                                   define  CERT_CONFIDENCE_TIMENEST     0x00100000
  437. #                                   define  CERT_CONFIDENCE_AUTHIDEXT    0x00010000
  438. #                                   define  CERT_CONFIDENCE_HIGHEST      0x11110000
  439.  
  440.     DWORD                       dwError;
  441.  
  442. } CRYPT_PROVIDER_CERT, *PCRYPT_PROVIDER_CERT;
  443.  
  444. //////////////////////////////////////////////////////////////////////////////
  445. //
  446. // CRYPT_PROVIDER_SGNR structure
  447. //----------------------------------------------------------------------------
  448. //  After the Signature Provider is finished there will be zero to many of these
  449. //  filled out.  One for each signer of the message.  Also, there will be zero 
  450. //  to many of these filled out inside this structure.  One for each counter 
  451. //  signer of the signer.
  452. //  
  453. //  IMPORTANT:  1.  All dynamically allocated members MUST use allocation
  454. //                  and Add2 functions provided.
  455. //
  456. typedef struct _CRYPT_PROVIDER_SGNR
  457. {
  458.     DWORD                       cbStruct;
  459.  
  460.     FILETIME                    sftVerifyAsOf;      // either today's filetime or the timestamps
  461.  
  462.     DWORD                       csCertChain;        // do NOT set manually.
  463.     CRYPT_PROVIDER_CERT         *pasCertChain;      // use the Add2 allocator
  464.  
  465.     DWORD                       dwSignerType;       // set if known by policy
  466. #                                   define  SGNR_TYPE_TIMESTAMP     0x00000010
  467.  
  468.     CMSG_SIGNER_INFO            *psSigner;          // must use the pfnAlloc allocator!
  469.  
  470.     DWORD                       dwError;            // error encounted while building/verifying the signer.
  471.  
  472.     DWORD                       csCounterSigners;   // do NOT set manually.
  473.     struct _CRYPT_PROVIDER_SGNR *pasCounterSigners; // use the Add2 allocator.
  474.  
  475. } CRYPT_PROVIDER_SGNR, *PCRYPT_PROVIDER_SGNR;
  476.  
  477. //////////////////////////////////////////////////////////////////////////////
  478. //
  479. // CRYPT_PROVIDER_PRIVDATA structure
  480. //----------------------------------------------------------------------------
  481. //  This structure is to allow Policy Provider functions to share
  482. //  POLICY SPECIFIC data between Policy Functions.
  483. //  The Policy must use the pfnAddPrivateData2Chain function and 
  484. //  must free any data within the member before the Final Policy returns
  485. //  to WVT.  
  486. //  To allow multiple providers to use this feature, each provider that
  487. //  uses this member must set the provider ID to it's Action ID so that 
  488. //  the provider can find its data and ignore any other.
  489. //
  490. typedef struct _CRYPT_PROVIDER_PRIVDATA
  491. {
  492.     DWORD                           cbStruct;
  493.  
  494.     GUID                            gProviderID;
  495.  
  496.     DWORD                           cbProvData;
  497.     void                            *pvProvData;
  498.  
  499. } CRYPT_PROVIDER_PRIVDATA, *PCRYPT_PROVIDER_PRIVDATA;
  500.  
  501. //////////////////////////////////////////////////////////////////////////////
  502. //
  503. // CRYPT_PROVIDER_DATA Structure
  504. //----------------------------------------------------------------------------
  505. //  Used to pass information between WinVerifyTrust and all of the Provider
  506. //  calls.
  507. //
  508. //  IMPORTANT:  1.  All dynamically allocated members MUST use the allocation
  509. //                  and Add2 functions provided.
  510. //
  511. typedef struct _CRYPT_PROVIDER_DATA
  512. {
  513.     DWORD                       cbStruct;               // = sizeof(TRUST_PROVIDER_DATA) (set in WVT)
  514.  
  515.     WINTRUST_DATA               *pWintrustData;         // NOT verified (set in WVT)
  516.     BOOL                        fOpenedFile;            // the provider opened the file handle (if applicable)
  517.     HWND                        hWndParent;             // if passed in, else, Desktop hWnd (set in WVT).
  518.     GUID                        *pgActionID;            // represents the Provider combination (set in WVT).
  519.  
  520.     HCRYPTPROV                  hProv;                  // set in WVT
  521.  
  522.     DWORD                       dwError;                // error to be returned
  523.  
  524.     DWORD                       dwRegSecuritySettings;  // ie security settings (set in WVT)
  525.     DWORD                       dwRegPolicySettings;    // setreg settings (set in WVT)
  526.  
  527.     CRYPT_PROVIDER_FUNCTIONS    sPfns;                  // set in WVT.
  528.  
  529.     DWORD                       cdwTrustStepErrors;     // set in WVT.
  530.     DWORD                       *padwTrustStepErrors;   // allocated in WVT.  filled in WVT & Trust Provider
  531.  
  532.     DWORD                       chStores;               // number of stores in pahStores (root set in WVT)
  533.     HCERTSTORE                  *pahStores;             // array of known stores (root set in WVT) root is ALWAYS #0!!!
  534.  
  535.     DWORD                       dwEncoding;             // message encoding type (set in WVT and Signature Prov)
  536.     HCRYPTMSG                   hMsg;                   // set in Signature Prov.
  537.  
  538.     GUID                        gSubject;               // subject guid of file/member file. (set in Sig Prov)
  539.     struct SIP_DISPATCH_INFO_   *pSip;                  // set in Sig Prov - defined in sipbase.h
  540.     struct SIP_DISPATCH_INFO_   *pCATSip;               // set in Sig Prov - defined in sipbase.h
  541.     struct SIP_SUBJECTINFO_     *psSipSubjectInfo;      // set in Sig Prov - defined in sipbase.h
  542.     struct SIP_SUBJECTINFO_     *psSipCATSubjectInfo;   // set in Sig Prov - defined in sipbase.h
  543.     struct SIP_INDIRECT_DATA_   *psIndirectData;        // set in Sig Prov - defined in sipbase.h
  544.  
  545.     DWORD                       csSigners;              // use Add2 function!
  546.     CRYPT_PROVIDER_SGNR         *pasSigners;            // use Add2 function!
  547.  
  548.     DWORD                       csProvPrivData;         // use Add2 function!
  549.     CRYPT_PROVIDER_PRIVDATA     *pasProvPrivData;       // use Add2 function!
  550.  
  551. } CRYPT_PROVIDER_DATA, *PCRYPT_PROVIDER_DATA;
  552.  
  553.  
  554. //////////////////////////////////////////////////////////////////////////////
  555. //
  556. // structures used to register action IDs
  557. //----------------------------------------------------------------------------
  558. //
  559. typedef struct _CRYPT_TRUST_REG_ENTRY
  560. {
  561.     DWORD                   cbStruct;
  562.  
  563.     WCHAR                   *pwszDLLName;
  564.     WCHAR                   *pwszFunctionName;
  565.  
  566. } CRYPT_TRUST_REG_ENTRY, *PCRYPT_TRUST_REG_ENTRY;
  567.  
  568. typedef struct _CRYPT_REGISTER_ACTIONID
  569. {
  570.     DWORD                   cbStruct;
  571.  
  572.     CRYPT_TRUST_REG_ENTRY   sInitProvider;
  573.     CRYPT_TRUST_REG_ENTRY   sObjectProvider;
  574.     CRYPT_TRUST_REG_ENTRY   sSignatureProvider;
  575.     CRYPT_TRUST_REG_ENTRY   sCertificateProvider;
  576.     CRYPT_TRUST_REG_ENTRY   sCertificatePolicyProvider;
  577.     CRYPT_TRUST_REG_ENTRY   sFinalPolicyProvider;
  578.     CRYPT_TRUST_REG_ENTRY   sTestPolicyProvider;
  579.  
  580. } CRYPT_REGISTER_ACTIONID, *PCRYPT_REGISTER_ACTIONID;
  581.  
  582. #pragma pack()
  583.  
  584. //////////////////////////////////////////////////////////////////////////////
  585. //
  586. // WINTRUST.DLL Provider defines
  587. //----------------------------------------------------------------------------
  588. //  The following are definitions of the Microsoft Generic Cert Provider
  589. //  
  590. #define WT_CURRENT_VERSION                  0x00000200
  591. #define WT_MAX_FUNC_NAME                    128
  592.  
  593. #define WT_PROVIDER_DLL_NAME                L"WINTRUST.DLL"
  594. #define WT_PROVIDER_CERTTRUST_FUNCTION      L"WintrustCertificateTrust"
  595.  
  596. //////////////////////////////////////////////////////////////////////////////
  597. //
  598. // WintrustAddActionID
  599. //----------------------------------------------------------------------------
  600. //  Adds a new Provider combination to the users' 
  601. //  system.  Creates all necessary registry entries, etc.  This should be done
  602. //  during the Policy Provider's DllRegisterServer.
  603. //
  604. //  *** THE ONLY ONE WHO SHOULD CALL THIS IS THE POLICY PROVIDER ***
  605. // 
  606. // Returns: 
  607. //      TRUE:                           No fatal errors
  608. //      FALSE:                          Errors occured.  See GetLastError()
  609. //
  610. extern BOOL WINAPI  WintrustAddActionID(IN GUID *pgActionID, 
  611.                                         IN DWORD fdwReserved,    // future use.
  612.                                         IN CRYPT_REGISTER_ACTIONID *psProvInfo);
  613.  
  614.  
  615. //////////////////////////////////////////////////////////////////////////////
  616. //
  617. // WintrustRemoveActionID
  618. //----------------------------------------------------------------------------
  619. //  Removes the Provider action combination from the users'
  620. //  system.
  621. // 
  622. // Returns: 
  623. //      TRUE:                           No fatal errors
  624. //      FALSE:                          Errors occured.  See GetLastError()
  625. //
  626. extern BOOL WINAPI  WintrustRemoveActionID(IN GUID *pgActionID);
  627.  
  628. //////////////////////////////////////////////////////////////////////////////
  629. //
  630. // WintrustLoadFunctionPointers
  631. //----------------------------------------------------------------------------
  632. //  Retrieves the function entry points based on the Action ID given.
  633. // 
  634. // Returns: 
  635. //      TRUE                            success.
  636. //      FALSE                           fail.
  637. //
  638. extern BOOL WINAPI WintrustLoadFunctionPointers(GUID *pgActionID, CRYPT_PROVIDER_FUNCTIONS *pPfns);
  639.  
  640. //
  641. //  helper functions exported from wintrust.dll
  642. //
  643. extern HANDLE WINAPI            WTHelperGetFileHandle(WINTRUST_DATA *pWintrustData);
  644. extern WCHAR * WINAPI           WTHelperGetFileName(WINTRUST_DATA *pWintrustData);
  645. extern PCCERT_CONTEXT WINAPI    WTHelperCertFindIssuerCertificate(CRYPT_PROVIDER_DATA *pProvData, 
  646.                                                                   CRYPT_PROVIDER_SGNR *pSgnr,
  647.                                                                   PCCERT_CONTEXT pChildContext,
  648.                                                                   DWORD *pdwConfidence,
  649.                                                                   DWORD *pdwError);
  650. extern BOOL WINAPI              WTHelperCertIsSelfSigned(DWORD dwEncoding, CERT_INFO *pCert);
  651. extern BOOL WINAPI              WTHelperOpenKnownStores(CRYPT_PROVIDER_DATA *pProvData);
  652.  
  653.  
  654. #pragma option pop /*P_O_Pop*/
  655. #endif // WINTRUST_H
  656.