Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2530 lines
133 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-1999.
  5. //
  6. // File: cryptui.h
  7. //
  8. // Contents: Common Cryptographic Dialog API Prototypes and Definitions
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef __CRYPTUI_H__
  12. #define __CRYPTUI_H__
  13. #if defined (_MSC_VER) && (_MSC_VER >= 1020)
  14. #pragma once
  15. #endif
  16. #include <prsht.h>
  17. #include <wintrust.h>
  18. #include <certca.h>
  19. #include <cryptuiapi.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include <pshpack8.h>
  24. /////////////////////////////////////////////////////////////////////////////////////////////////////
  25. //
  26. // the functions which return property sheet pages take this callback as one of the parameters in
  27. // the input structure. it is then called when each page is about to be created and when each page
  28. // is about to be destroyed. the messages are PSPCB_CREATE when a page is about to be created and
  29. // PSPCB_RELEASE when a page is about to be destroyed. the pvCallbackData parameter in the callback
  30. // is the pvoid that was passed in with the callback in the input structure.
  31. typedef BOOL (WINAPI * PFNCPROPPAGECALLBACK)(
  32. HWND hWndPropPage,
  33. UINT uMsg,
  34. void *pvCallbackData);
  35. /////////////////////////////////////////////////////////////////////////////////////////////////////
  36. //
  37. // dwSize size of this struct
  38. // hwndParent parent of this dialog (OPTIONAL)
  39. // dwFlags flags, may a combination of any of the flags below (OPTIONAL)
  40. // szTitle title for the window (OPTIONAL)
  41. // pCertContext the cert context that is to be displayed
  42. // rgszPurposes array of purposes that this cert is to be validated for (OPTIONAL)
  43. // cPurposes number of purposes (OPTIONAL)
  44. // pCryptProviderData/hWVTStateData if WinVerifyTrust has already been called for the cert (OPTIONAL)
  45. // then pass in a pointer to the state struct that was
  46. // acquired through a call to WTHelperProvDataFromStateData(),
  47. // or pass in the hWVTStateData of the WINTRUST_DATA struct
  48. // if WTHelperProvDataFromStateData() was not called.
  49. // if pCryptProviderData/hWVTStateData is used then
  50. // fpCryptProviderDataTrustedUsage, idxSigner, idxCert, and
  51. // fCounterSignature must be set
  52. // fpCryptProviderDataTrustedUsage if WinVerifyTrust was called this is the result of whether (OPTIONAL)
  53. // the cert was trusted
  54. // idxSigner the index of the signer to view (OPTIONAL)
  55. // idxCert the index of the cert that is being viewed within the (OPTIONAL)
  56. // signer chain. the cert context of this cert MUST match
  57. // pCertContext
  58. // fCounterSigner set to TRUE if a counter signature is being viewed. if (OPTIONAL)
  59. // this is TRUE then idxCounterSigner must be valid
  60. // idxCounterSigner the index of the counter signer to view (OPTIONAL)
  61. // cStores Count of other stores to search when building and (OPTIONAL)
  62. // validating chain
  63. // rghStores Array of other stores to search when buliding and (OPTIONAL)
  64. // validating chain
  65. // cPropSheetPages number of extra pages to add to the dialog. (OPTIONAL)
  66. // rgPropSheetPages extra pages to add to the dialog. (OPTIONAL)
  67. // each page in this array will NOT recieve the lParam in
  68. // the PROPSHEET structure as the lParam in the
  69. // WM_INITDIALOG, instead it will receive a pointer to a
  70. // CRYPTUI_INITDIALOG_STRUCT (defined below) which contains
  71. // the lParam in the PROPSSHEET structure AND the
  72. // PCCERT_CONTEXT for which the page is being displayed.
  73. // nStartPage this is the index of the initial page that will be
  74. // displayed. if the upper most bit (0x8000) is set then
  75. // the index is assumed to index rgPropSheetPages
  76. // (after the upper most bit has been stripped off. eg.
  77. // 0x8000 will indicate the first page in rgPropSheetPages),
  78. // if the upper most bit is 0 then nStartPage will be the
  79. // starting index of the default certificate dialog pages.
  80. //
  81. /////////////////////////////////////////////////////////////////////////////////////////////////////
  82. // dwFlags
  83. #define CRYPTUI_HIDE_HIERARCHYPAGE 0x00000001
  84. #define CRYPTUI_HIDE_DETAILPAGE 0x00000002
  85. #define CRYPTUI_DISABLE_EDITPROPERTIES 0x00000004
  86. #define CRYPTUI_ENABLE_EDITPROPERTIES 0x00000008
  87. #define CRYPTUI_DISABLE_ADDTOSTORE 0x00000010
  88. #define CRYPTUI_ENABLE_ADDTOSTORE 0x00000020
  89. #define CRYPTUI_ACCEPT_DECLINE_STYLE 0x00000040
  90. #define CRYPTUI_IGNORE_UNTRUSTED_ROOT 0x00000080
  91. #define CRYPTUI_DONT_OPEN_STORES 0x00000100
  92. #define CRYPTUI_ONLY_OPEN_ROOT_STORE 0x00000200
  93. #define CRYPTUI_WARN_UNTRUSTED_ROOT 0x00000400 // For use with viewing of certificates on remote
  94. // machines only. If this flag is used rghStores[0]
  95. // must be the handle of the root store on the remote machine.
  96. #define CRYPTUI_ENABLE_REVOCATION_CHECKING 0x00000800 // This flag is only valid if pCryptProviderData/hWVTStateData
  97. // is not passed in.
  98. #define CRYPTUI_WARN_REMOTE_TRUST 0x00001000
  99. #define CRYPTUI_DISABLE_EXPORT 0x00002000 // If this flag is set, then the "Copy to file" button will be
  100. // disabled on the Detail page.
  101. // Revocation flags is only valid if pCryptProviderData/hWVTStateData is not passed in.
  102. #define CRYPTUI_ENABLE_REVOCATION_CHECK_END_CERT 0x00004000
  103. #define CRYPTUI_ENABLE_REVOCATION_CHECK_CHAIN 0x00008000
  104. #define CRYPTUI_ENABLE_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT CRYPTUI_ENABLE_REVOCATION_CHECKING // Changed the default behavior
  105. // to not check root.
  106. // Following is a flag for internal use only!!
  107. #define CRYPTUI_TREEVIEW_PAGE_FLAG 0x80000000
  108. typedef struct tagCRYPTUI_VIEWCERTIFICATE_STRUCTW {
  109. DWORD dwSize;
  110. HWND hwndParent; // OPTIONAL
  111. DWORD dwFlags; // OPTIONAL
  112. LPCWSTR szTitle; // OPTIONAL
  113. PCCERT_CONTEXT pCertContext;
  114. LPCSTR * rgszPurposes; // OPTIONAL
  115. DWORD cPurposes; // OPTIONAL
  116. union
  117. {
  118. CRYPT_PROVIDER_DATA const * pCryptProviderData; // OPTIONAL
  119. HANDLE hWVTStateData; // OPTIONAL
  120. };
  121. BOOL fpCryptProviderDataTrustedUsage;// OPTIONAL
  122. DWORD idxSigner; // OPTIONAL
  123. DWORD idxCert; // OPTIONAL
  124. BOOL fCounterSigner; // OPTIONAL
  125. DWORD idxCounterSigner; // OPTIONAL
  126. DWORD cStores; // OPTIONAL
  127. HCERTSTORE * rghStores; // OPTIONAL
  128. DWORD cPropSheetPages; // OPTIONAL
  129. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  130. DWORD nStartPage;
  131. } CRYPTUI_VIEWCERTIFICATE_STRUCTW, *PCRYPTUI_VIEWCERTIFICATE_STRUCTW;
  132. typedef const CRYPTUI_VIEWCERTIFICATE_STRUCTW *PCCRYPTUI_VIEWCERTIFICATE_STRUCTW;
  133. typedef struct tagCRYPTUI_VIEWCERTIFICATE_STRUCTA {
  134. DWORD dwSize;
  135. HWND hwndParent; // OPTIONAL
  136. DWORD dwFlags; // OPTIONAL
  137. LPCSTR szTitle; // OPTIONAL
  138. PCCERT_CONTEXT pCertContext;
  139. LPCSTR * rgszPurposes; // OPTIONAL
  140. DWORD cPurposes; // OPTIONAL
  141. union
  142. {
  143. CRYPT_PROVIDER_DATA const * pCryptProviderData; // OPTIONAL
  144. HANDLE hWVTStateData; // OPTIONAL
  145. };
  146. BOOL fpCryptProviderDataTrustedUsage;// OPTIONAL
  147. DWORD idxSigner; // OPTIONAL
  148. DWORD idxCert; // OPTIONAL
  149. BOOL fCounterSigner; // OPTIONAL
  150. DWORD idxCounterSigner; // OPTIONAL
  151. DWORD cStores; // OPTIONAL
  152. HCERTSTORE * rghStores; // OPTIONAL
  153. DWORD cPropSheetPages; // OPTIONAL
  154. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  155. DWORD nStartPage;
  156. } CRYPTUI_VIEWCERTIFICATE_STRUCTA, *PCRYPTUI_VIEWCERTIFICATE_STRUCTA;
  157. typedef const CRYPTUI_VIEWCERTIFICATE_STRUCTA *PCCRYPTUI_VIEWCERTIFICATE_STRUCTA;
  158. //
  159. // pfPropertiesChanged this will be set by the dialog proc to inform the caller
  160. // if any properties have been changed on certs in the chain
  161. // while the dialog was open
  162. //
  163. BOOL
  164. WINAPI
  165. CryptUIDlgViewCertificateW(
  166. IN PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertViewInfo,
  167. OUT BOOL *pfPropertiesChanged // OPTIONAL
  168. );
  169. BOOL
  170. WINAPI
  171. CryptUIDlgViewCertificateA(
  172. IN PCCRYPTUI_VIEWCERTIFICATE_STRUCTA pCertViewInfo,
  173. OUT BOOL *pfPropertiesChanged // OPTIONAL
  174. );
  175. #ifdef UNICODE
  176. #define CryptUIDlgViewCertificate CryptUIDlgViewCertificateW
  177. #define PCRYPTUI_VIEWCERTIFICATE_STRUCT PCRYPTUI_VIEWCERTIFICATE_STRUCTW
  178. #define CRYPTUI_VIEWCERTIFICATE_STRUCT CRYPTUI_VIEWCERTIFICATE_STRUCTW
  179. #define PCCRYPTUI_VIEWCERTIFICATE_STRUCT PCCRYPTUI_VIEWCERTIFICATE_STRUCTW
  180. #else
  181. #define CryptUIDlgViewCertificate CryptUIDlgViewCertificateA
  182. #define PCRYPTUI_VIEWCERTIFICATE_STRUCT PCRYPTUI_VIEWCERTIFICATE_STRUCTA
  183. #define CRYPTUI_VIEWCERTIFICATE_STRUCT CRYPTUI_VIEWCERTIFICATE_STRUCTA
  184. #define PCCRYPTUI_VIEWCERTIFICATE_STRUCT PCCRYPTUI_VIEWCERTIFICATE_STRUCTA
  185. #endif
  186. //
  187. // this struct is passed as the lParam in the WM_INITDIALOG call to each
  188. // property sheet that is in the rgPropSheetPages array of the
  189. // CRYPTUI_VIEWCERTIFICATE_STRUCT structure
  190. //
  191. typedef struct tagCRYPTUI_INITDIALOG_STRUCT {
  192. LPARAM lParam;
  193. PCCERT_CONTEXT pCertContext;
  194. } CRYPTUI_INITDIALOG_STRUCT, *PCRYPTUI_INITDIALOG_STRUCT;
  195. //
  196. // this structure is used in CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT,
  197. // and allows users of MMC to recieve notifications that properties
  198. // on certificates have changed
  199. //
  200. typedef HRESULT (__stdcall * PFNCMMCCALLBACK)(LONG_PTR lNotifyHandle, LPARAM param);
  201. typedef struct tagCRYPTUI_MMCCALLBACK_STRUCT {
  202. PFNCMMCCALLBACK pfnCallback; // the address of MMCPropertyChangeNotify()
  203. LONG_PTR lNotifyHandle; // the lNotifyHandle passed to MMCPropertyChangeNotify()
  204. LPARAM param; // the param passed to MMCPropertyChangeNotify()
  205. } CRYPTUI_MMCCALLBACK_STRUCT, *PCRYPTUI_MMCCALLBACK_STRUCT;
  206. /////////////////////////////////////////////////////////////////////////////////////////////////////
  207. //
  208. // dwSize size of this struct
  209. // hwndParent parent of this dialog (OPTIONAL)
  210. // dwFlags flags, must be set to 0
  211. // union the szTitle field of the union is only valid if
  212. // CryptUIDlgViewCertificateProperties is being called.
  213. // the pMMCCallback field of the union is only valid if
  214. // CryptUIGetCertificatePropertiesPages is being called.
  215. // Note that if pMMCCallback is non-NULL and
  216. // CryptUIGetCertificatePropertiesPages was called, the
  217. // struct pointed to by pMMCCallback will not be referenced
  218. // by cryptui.dll after the callback has been made to MMC.
  219. // this will allow the original caller of
  220. // CryptUIGetCertificatePropertiesPages to free the struct
  221. // pointed to by pMMCCallback in the actual callback.
  222. // szTitle title for the window (OPTIONAL)
  223. // pMMCCallback this structure is used to callback MMC if properties (OPTIONAL)
  224. // have changed
  225. // pCertContext the cert context that is to be displayed
  226. // pPropPageCallback this callback will be called when each page that is (OPTIONAL)
  227. // returned in the CryptUIGetCertificatePropertiesPages call
  228. // is about to be created or destroyed. if this is NULL no
  229. // callback is made. Note that this is not used if
  230. // CryptUIDlgViewCertificateProperties is called
  231. // pvCallbackData this is uniterpreted data that is passed back when the (OPTIONAL)
  232. // when pPropPageCallback is made
  233. // cStores Count of other stores to search when building and (OPTIONAL)
  234. // validating chain
  235. // rghStores Array of other stores to search when buliding and (OPTIONAL)
  236. // validating chain
  237. // cPropSheetPages number of extra pages to add to the dialog (OPTIONAL)
  238. // rgPropSheetPages extra pages to add to the dialog (OPTIONAL)
  239. //
  240. /////////////////////////////////////////////////////////////////////////////////////////////////////
  241. typedef struct tagCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW {
  242. DWORD dwSize;
  243. HWND hwndParent; // OPTIONAL
  244. DWORD dwFlags; // OPTIONAL
  245. union
  246. {
  247. LPCWSTR szTitle; // OPTIONAL
  248. PCRYPTUI_MMCCALLBACK_STRUCT pMMCCallback;// OPTIONAL
  249. };
  250. PCCERT_CONTEXT pCertContext;
  251. PFNCPROPPAGECALLBACK pPropPageCallback; // OPTIONAL
  252. void * pvCallbackData; // OPTIONAL
  253. DWORD cStores; // OPTIONAL
  254. HCERTSTORE * rghStores; // OPTIONAL
  255. DWORD cPropSheetPages; // OPTIONAL
  256. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  257. } CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW, *PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW;
  258. typedef const CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW *PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW;
  259. typedef struct tagCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA {
  260. DWORD dwSize;
  261. HWND hwndParent; // OPTIONAL
  262. DWORD dwFlags; // OPTIONAL
  263. union
  264. {
  265. LPCSTR szTitle; // OPTIONAL
  266. PCRYPTUI_MMCCALLBACK_STRUCT pMMCCallback;// OPTIONAL
  267. };
  268. PCCERT_CONTEXT pCertContext;
  269. PFNCPROPPAGECALLBACK pPropPageCallback; // OPTIONAL
  270. void * pvCallbackData; // OPTIONAL
  271. DWORD cStores; // OPTIONAL
  272. HCERTSTORE * rghStores; // OPTIONAL
  273. DWORD cPropSheetPages; // OPTIONAL
  274. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  275. } CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA, *PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA;
  276. typedef const CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA *PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA;
  277. // pfPropertiesChanged this will be set by the dialog proc to inform the caller
  278. // if any properties have been changed on certs in the chain
  279. // while the dialog was open
  280. BOOL
  281. WINAPI
  282. CryptUIDlgViewCertificatePropertiesW(
  283. IN PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW pcsp,
  284. OUT BOOL *pfPropertiesChanged // OPTIONAL
  285. );
  286. BOOL
  287. WINAPI
  288. CryptUIDlgViewCertificatePropertiesA(
  289. IN PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA pcsp,
  290. OUT BOOL *pfPropertiesChanged // OPTIONAL
  291. );
  292. // NOTE!! when calling this function, the following parameters of the
  293. // CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT struct are unused
  294. // cPropSheetPages
  295. // rgPropSheetPages
  296. BOOL
  297. WINAPI
  298. CryptUIGetCertificatePropertiesPagesW(
  299. IN PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW pcsp,
  300. OUT BOOL *pfPropertiesChanged, // OPTIONAL
  301. OUT PROPSHEETPAGEW **prghPropPages,
  302. OUT DWORD *pcPropPages
  303. );
  304. BOOL
  305. WINAPI
  306. CryptUIGetCertificatePropertiesPagesA(
  307. IN PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA pcsp,
  308. OUT BOOL *pfPropertiesChanged, // OPTIONAL
  309. OUT PROPSHEETPAGEA **prghPropPages,
  310. OUT DWORD *pcPropPages
  311. );
  312. BOOL
  313. WINAPI
  314. CryptUIFreeCertificatePropertiesPagesW(
  315. IN PROPSHEETPAGEW *rghPropPages,
  316. IN DWORD cPropPages
  317. );
  318. BOOL
  319. WINAPI
  320. CryptUIFreeCertificatePropertiesPagesA(
  321. IN PROPSHEETPAGEA *rghPropPages,
  322. IN DWORD cPropPages
  323. );
  324. #ifdef UNICODE
  325. #define CryptUIDlgViewCertificateProperties CryptUIDlgViewCertificatePropertiesW
  326. #define PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW
  327. #define CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW
  328. #define PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTW
  329. #define CryptUIGetCertificatePropertiesPages CryptUIGetCertificatePropertiesPagesW
  330. #define CryptUIFreeCertificatePropertiesPages CryptUIFreeCertificatePropertiesPagesW
  331. #else
  332. #define CryptUIDlgViewCertificateProperties CryptUIDlgViewCertificatePropertiesA
  333. #define PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT PCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA
  334. #define CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT CRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA
  335. #define PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCT PCCRYPTUI_VIEWCERTIFICATEPROPERTIES_STRUCTA
  336. #define CryptUIGetCertificatePropertiesPages CryptUIGetCertificatePropertiesPagesA
  337. #define CryptUIFreeCertificatePropertiesPages CryptUIFreeCertificatePropertiesPagesA
  338. #endif
  339. //
  340. // The certificate properties property sheet dialog is extensible via a callback mechanism.
  341. // A client needs to register their callback using CryptRegisterDefaultOIDFunction, and,
  342. // if they need to unregister it they should use CryptUnregisterDefaultOIDFunction.
  343. // The form for calling these functions is given below
  344. //
  345. // CryptRegisterDefaultOIDFunction(
  346. // 0,
  347. // CRYPTUILDLG_CERTPROP_PAGES_CALLBACK,
  348. // CRYPT_REGISTER_FIRST_INDEX,
  349. // L"c:\\fully qualified path\\dll_being_registered.dll"); <<----- your dll name
  350. //
  351. // CryptUnregisterDefaultOIDFunction(
  352. // 0,
  353. // CRYPTUILDLG_CERTPROP_PAGES_CALLBACK,
  354. // L"c:\\fully qualified path\\dll_being_registered.dll"); <<----- your dll name
  355. //
  356. // NOTE: Per the documentation on CryptRegisterDefaultOIDFunction in wincrypt.h,
  357. // the dll name may contain environment-variable strings
  358. // which are ExpandEnvironmentStrings()'ed before loading the Dll.
  359. //
  360. #define MAX_CLIENT_PAGES 20
  361. #define CRYPTUILDLG_CERTPROP_PAGES_CALLBACK "CryptUIDlgClientCertPropPagesCallback"
  362. //
  363. //
  364. // The typedef for the callback function which resides in the registered dll is given
  365. // below. Note that the callback must have the name #defined by
  366. // CRYPTUILDLG_CERTPROP_PAGES_CALLBACK
  367. //
  368. // pCertContext - The certificate for which the properties are being displayed.
  369. // rgPropPages - An array of PropSheetPageW structures that are to be filled in by
  370. // the client with the property pages to be shown.
  371. // pcPropPages - A pointer to a DWORD that on input contains the maximum number of
  372. // PropSheetPages the client may supply, and on output must have been
  373. // filled in by the client with the number of pages they supplied in
  374. // rgPropPages.
  375. //
  376. // Return Value: The client should return TRUE if they wish to show extra property pages,
  377. // in this case pcPropPages must >= 1 and rgPropPages must have the
  378. // corresponding number of pages. or, return FALSE if no pages are suplied.
  379. typedef BOOL (WINAPI *PFN_CRYPTUIDLG_CERTPROP_PAGES_CALLBACK)
  380. (IN PCCERT_CONTEXT pCertContext,
  381. OUT PROPSHEETPAGEW *rgPropPages,
  382. IN OUT DWORD *pcPropPages);
  383. /////////////////////////////////////////////////////////////////////////////////////////////////////
  384. /////////////////////////////////////////////////////////////////////////////////////////////////////
  385. //
  386. // dwSize size of this struct
  387. // hwndParent parent of this dialog (OPTIONAL)
  388. // dwFlags flags, may a combination of any of the flags below
  389. // szTitle title for the window (OPTIONAL)
  390. // pCTLContext the ctl context that is to be displayed
  391. // cCertSearchStores; count of other stores to search for the certs contained (OPTIONAL)
  392. // in the ctl
  393. // rghCertSearchStores; array of other stores to search for the certs contained (OPTIONAL)
  394. // in the ctl
  395. // cStores Count of other stores to search when building and (OPTIONAL)
  396. // validating chain of the cert which signed the ctl
  397. // and the certs contained in the ctl
  398. // rghStores Array of other stores to search when buliding and (OPTIONAL)
  399. // validating chain of the cert which signed the ctl
  400. // and the certs contained in the ctl
  401. // cPropSheetPages number of extra pages to add to the dialog (OPTIONAL)
  402. // rgPropSheetPages extra pages to add to the dialog (OPTIONAL)
  403. //
  404. /////////////////////////////////////////////////////////////////////////////////////////////////////
  405. // dwFlags
  406. #define CRYPTUI_HIDE_TRUSTLIST_PAGE 0x00000001
  407. typedef struct tagCRYPTUI_VIEWCTL_STRUCTW {
  408. DWORD dwSize;
  409. HWND hwndParent; // OPTIONAL
  410. DWORD dwFlags; // OPTIONAL
  411. LPCWSTR szTitle; // OPTIONAL
  412. PCCTL_CONTEXT pCTLContext;
  413. DWORD cCertSearchStores; // OPTIONAL
  414. HCERTSTORE * rghCertSearchStores;// OPTIONAL
  415. DWORD cStores; // OPTIONAL
  416. HCERTSTORE * rghStores; // OPTIONAL
  417. DWORD cPropSheetPages; // OPTIONAL
  418. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  419. } CRYPTUI_VIEWCTL_STRUCTW, *PCRYPTUI_VIEWCTL_STRUCTW;
  420. typedef const CRYPTUI_VIEWCTL_STRUCTW *PCCRYPTUI_VIEWCTL_STRUCTW;
  421. typedef struct tagCRYPTUI_VIEWCTL_STRUCTA {
  422. DWORD dwSize;
  423. HWND hwndParent; // OPTIONAL
  424. DWORD dwFlags; // OPTIONAL
  425. LPCSTR szTitle; // OPTIONAL
  426. PCCTL_CONTEXT pCTLContext;
  427. DWORD cCertSearchStores; // OPTIONAL
  428. HCERTSTORE * rghCertSearchStores;// OPTIONAL
  429. DWORD cStores; // OPTIONAL
  430. HCERTSTORE * rghStores; // OPTIONAL
  431. DWORD cPropSheetPages; // OPTIONAL
  432. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  433. } CRYPTUI_VIEWCTL_STRUCTA, *PCRYPTUI_VIEWCTL_STRUCTA;
  434. typedef const CRYPTUI_VIEWCTL_STRUCTA *PCCRYPTUI_VIEWCTL_STRUCTA;
  435. BOOL
  436. WINAPI
  437. CryptUIDlgViewCTLW(
  438. IN PCCRYPTUI_VIEWCTL_STRUCTW pcvctl
  439. );
  440. BOOL
  441. WINAPI
  442. CryptUIDlgViewCTLA(
  443. IN PCCRYPTUI_VIEWCTL_STRUCTA pcvctl
  444. );
  445. #ifdef UNICODE
  446. #define CryptUIDlgViewCTL CryptUIDlgViewCTLW
  447. #define PCRYPTUI_VIEWCTL_STRUCT PCRYPTUI_VIEWCTL_STRUCTW
  448. #define CRYPTUI_VIEWCTL_STRUCT CRYPTUI_VIEWCTL_STRUCTW
  449. #define PCCRYPTUI_VIEWCTL_STRUCT PCCRYPTUI_VIEWCTL_STRUCTW
  450. #else
  451. #define CryptUIDlgViewCTL CryptUIDlgViewCTLA
  452. #define PCRYPTUI_VIEWCTL_STRUCT PCRYPTUI_VIEWCTL_STRUCTA
  453. #define CRYPTUI_VIEWCTL_STRUCT CRYPTUI_VIEWCTL_STRUCTA
  454. #define PCCRYPTUI_VIEWCTL_STRUCT PCCRYPTUI_VIEWCTL_STRUCTA
  455. #endif
  456. /////////////////////////////////////////////////////////////////////////////////////////////////////
  457. /////////////////////////////////////////////////////////////////////////////////////////////////////
  458. //
  459. // dwSize size of this struct
  460. // hwndParent parent of this dialog (OPTIONAL)
  461. // dwFlags flags, may a combination of any of the flags below
  462. // szTitle title for the window (OPTIONAL)
  463. // pCTLContext the ctl context that is to be displayed
  464. // cStores count of other stores to search for the cert which (OPTIONAL)
  465. // signed the crl and to build and validate the
  466. // cert's chain
  467. // rghStores array of other stores to search for the cert which (OPTIONAL)
  468. // signed the crl and to build and validate the
  469. // cert's chain
  470. // cPropSheetPages number of extra pages to add to the dialog (OPTIONAL)
  471. // rgPropSheetPages extra pages to add to the dialog (OPTIONAL)
  472. //
  473. /////////////////////////////////////////////////////////////////////////////////////////////////////
  474. // dwFlags
  475. #define CRYPTUI_HIDE_REVOCATIONLIST_PAGE 0x00000001
  476. typedef struct tagCRYPTUI_VIEWCRL_STRUCTW {
  477. DWORD dwSize;
  478. HWND hwndParent; // OPTIONAL
  479. DWORD dwFlags; // OPTIONAL
  480. LPCWSTR szTitle; // OPTIONAL
  481. PCCRL_CONTEXT pCRLContext;
  482. DWORD cStores; // OPTIONAL
  483. HCERTSTORE * rghStores; // OPTIONAL
  484. DWORD cPropSheetPages; // OPTIONAL
  485. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  486. } CRYPTUI_VIEWCRL_STRUCTW, *PCRYPTUI_VIEWCRL_STRUCTW;
  487. typedef const CRYPTUI_VIEWCRL_STRUCTW *PCCRYPTUI_VIEWCRL_STRUCTW;
  488. typedef struct tagCRYPTUI_VIEWCRL_STRUCTA {
  489. DWORD dwSize;
  490. HWND hwndParent; // OPTIONAL
  491. DWORD dwFlags; // OPTIONAL
  492. LPCSTR szTitle; // OPTIONAL
  493. PCCRL_CONTEXT pCRLContext;
  494. DWORD cStores; // OPTIONAL
  495. HCERTSTORE * rghStores; // OPTIONAL
  496. DWORD cPropSheetPages; // OPTIONAL
  497. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  498. } CRYPTUI_VIEWCRL_STRUCTA, *PCRYPTUI_VIEWCRL_STRUCTA;
  499. typedef const CRYPTUI_VIEWCRL_STRUCTA *PCCRYPTUI_VIEWCRL_STRUCTA;
  500. BOOL
  501. WINAPI
  502. CryptUIDlgViewCRLW(
  503. IN PCCRYPTUI_VIEWCRL_STRUCTW pcvcrl
  504. );
  505. BOOL
  506. WINAPI
  507. CryptUIDlgViewCRLA(
  508. IN PCCRYPTUI_VIEWCRL_STRUCTA pcvcrl
  509. );
  510. #ifdef UNICODE
  511. #define CryptUIDlgViewCRL CryptUIDlgViewCRLW
  512. #define PCRYPTUI_VIEWCRL_STRUCT PCRYPTUI_VIEWCRL_STRUCTW
  513. #define CRYPTUI_VIEWCRL_STRUCT CRYPTUI_VIEWCRL_STRUCTW
  514. #define PCCRYPTUI_VIEWCRL_STRUCT PCCRYPTUI_VIEWCRL_STRUCTW
  515. #else
  516. #define CryptUIDlgViewCRL CryptUIDlgViewCRLA
  517. #define PCRYPTUI_VIEWCRL_STRUCT PCRYPTUI_VIEWCRL_STRUCTA
  518. #define CRYPTUI_VIEWCRL_STRUCT CRYPTUI_VIEWCRL_STRUCTA
  519. #define PCCRYPTUI_VIEWCRL_STRUCT PCCRYPTUI_VIEWCRL_STRUCTA
  520. #endif
  521. /////////////////////////////////////////////////////////////////////////////////////////////////////
  522. /////////////////////////////////////////////////////////////////////////////////////////////////////
  523. //
  524. // dwSize size of this struct
  525. // hwndParent parent of this dialog (OPTIONAL)
  526. // dwFlags flags, may a combination of any of the flags below
  527. // szTitle title for the window (OPTIONAL)
  528. // pSignerInfo the signer info struct that is to be displayed
  529. // hMsg the HCRYPTMSG that the signer info was extracted from
  530. // pszOID an OID that signifies what the certificate that did the (OPTIONAL)
  531. // signing whould be validated for. for instance if this is
  532. // being called to view the signature of a CTL the
  533. // szOID_KP_CTL_USAGE_SIGNING OID should be passed in.
  534. // if this is NULL then the certificate is only validated
  535. // cryptographicaly and not for usages.
  536. // dwReserved reserved for future use and must be set to NULL
  537. // cStores count of other stores to search for the cert which (OPTIONAL)
  538. // did the signing and to build and validate the
  539. // cert's chain
  540. // rghStores array of other stores to search for the cert which (OPTIONAL)
  541. // did the signing and to build and validate the
  542. // cert's chain
  543. // cPropSheetPages number of extra pages to add to the dialog (OPTIONAL)
  544. // rgPropSheetPages extra pages to add to the dialog (OPTIONAL)
  545. //
  546. /////////////////////////////////////////////////////////////////////////////////////////////////////
  547. // dwFlags
  548. #define CRYPTUI_HIDE_TRUSTLIST_PAGE 0x00000001
  549. typedef struct tagCRYPTUI_VIEWSIGNERINFO_STRUCTW {
  550. DWORD dwSize;
  551. HWND hwndParent; // OPTIONAL
  552. DWORD dwFlags; // OPTIONAL
  553. LPCWSTR szTitle; // OPTIONAL
  554. CMSG_SIGNER_INFO const *pSignerInfo;
  555. HCRYPTMSG hMsg;
  556. LPCSTR pszOID; // OPTIONAL
  557. DWORD_PTR dwReserved;
  558. DWORD cStores; // OPTIONAL
  559. HCERTSTORE *rghStores; // OPTIONAL
  560. DWORD cPropSheetPages; // OPTIONAL
  561. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  562. } CRYPTUI_VIEWSIGNERINFO_STRUCTW, *PCRYPTUI_VIEWSIGNERINFO_STRUCTW;
  563. typedef const CRYPTUI_VIEWSIGNERINFO_STRUCTW *PCCRYPTUI_VIEWSIGNERINFO_STRUCTW;
  564. typedef struct tagCRYPTUI_VIEWSIGNERINFO_STRUCTA {
  565. DWORD dwSize;
  566. HWND hwndParent; // OPTIONAL
  567. DWORD dwFlags; // OPTIONAL
  568. LPCSTR szTitle; // OPTIONAL
  569. CMSG_SIGNER_INFO const *pSignerInfo;
  570. HCRYPTMSG hMsg;
  571. LPCSTR pszOID; // OPTIONAL
  572. DWORD_PTR dwReserved;
  573. DWORD cStores; // OPTIONAL
  574. HCERTSTORE *rghStores; // OPTIONAL
  575. DWORD cPropSheetPages; // OPTIONAL
  576. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  577. } CRYPTUI_VIEWSIGNERINFO_STRUCTA, *PCRYPTUI_VIEWSIGNERINFO_STRUCTA;
  578. typedef const CRYPTUI_VIEWSIGNERINFO_STRUCTA *PCCRYPTUI_VIEWSIGNERINFO_STRUCTA;
  579. BOOL
  580. WINAPI
  581. CryptUIDlgViewSignerInfoW(
  582. IN PCCRYPTUI_VIEWSIGNERINFO_STRUCTW pcvsi
  583. );
  584. BOOL
  585. WINAPI
  586. CryptUIDlgViewSignerInfoA(
  587. IN PCCRYPTUI_VIEWSIGNERINFO_STRUCTA pcvsi
  588. );
  589. #ifdef UNICODE
  590. #define CryptUIDlgViewSignerInfo CryptUIDlgViewSignerInfoW
  591. #define PCRYPTUI_VIEWSIGNERINFO_STRUCT PCRYPTUI_VIEWSIGNERINFO_STRUCTW
  592. #define CRYPTUI_VIEWSIGNERINFO_STRUCT CRYPTUI_VIEWSIGNERINFO_STRUCTW
  593. #define PCCRYPTUI_VIEWSIGNERINFO_STRUCT PCCRYPTUI_VIEWSIGNERINFO_STRUCTW
  594. #else
  595. #define CryptUIDlgViewSignerInfo CryptUIDlgViewSignerInfoA
  596. #define PCRYPTUI_VIEWSIGNERINFO_STRUCT PCRYPTUI_VIEWSIGNERINFO_STRUCTA
  597. #define CRYPTUI_VIEWSIGNERINFO_STRUCT CRYPTUI_VIEWSIGNERINFO_STRUCTA
  598. #define PCCRYPTUI_VIEWSIGNERINFO_STRUCT PCCRYPTUI_VIEWSIGNERINFO_STRUCTA
  599. #endif
  600. /////////////////////////////////////////////////////////////////////////////////////////////////////
  601. /////////////////////////////////////////////////////////////////////////////////////////////////////
  602. //
  603. // dwSize size of this struct
  604. // hwndParent parent of this dialog (OPTIONAL)
  605. // dwFlags flags, must be set to 0
  606. // szTitle title for the window (OPTIONAL)
  607. // choice the form of the message that is to have its signers displayed
  608. // u either an encoded message or a message handle
  609. // EncodedMessage a data blob which contains a pointer to the encoded data
  610. // and the count of encoded bytes
  611. // hMsg a message handle
  612. // szFileName the fully qualified file name, should be passed in if (OPTIONAL)
  613. // signatures on a file are being viewed
  614. // pPropPageCallback this callback will be called when each page that is (OPTIONAL)
  615. // returned in the CryptUIGetViewSignaturesPages call
  616. // is about to be created or destroyed. if this is NULL no
  617. // callback is made.
  618. // pvCallbackData this is uniterpreted data that is passed back when the (OPTIONAL)
  619. // when pPropPageCallback is made
  620. // cStores count of other stores to search for the cert which (OPTIONAL)
  621. // did the signing and to build and validate the
  622. // cert's chain
  623. // rghStores array of other stores to search for the cert which (OPTIONAL)
  624. // did the signing and to build and validate the
  625. // cert's chain
  626. // cPropSheetPages number of extra pages to add to the dialog (OPTIONAL)
  627. // rgPropSheetPages extra pages to add to the dialog (OPTIONAL)
  628. //
  629. /////////////////////////////////////////////////////////////////////////////////////////////////////
  630. // for the coice field of the CRYPTUI_VIEWSIGNATURES_STRUCT structure
  631. #define EncodedMessage_Chosen 1
  632. #define hMsg_Chosen 2
  633. typedef struct tagCRYPTUI_VIEWSIGNATURES_STRUCTW {
  634. DWORD dwSize;
  635. HWND hwndParent; // OPTIONAL
  636. DWORD dwFlags; // OPTIONAL
  637. LPCWSTR szTitle; // OPTIONAL
  638. unsigned short choice;
  639. union {
  640. CRYPT_DATA_BLOB EncodedMessage;
  641. HCRYPTMSG hMsg;
  642. } u;
  643. LPCWSTR szFileName; // OPTIONAL
  644. PFNCPROPPAGECALLBACK pPropPageCallback; // OPTIONAL
  645. void * pvCallbackData; // OPTIONAL
  646. DWORD cStores; // OPTIONAL
  647. HCERTSTORE * rghStores; // OPTIONAL
  648. DWORD cPropSheetPages; // OPTIONAL
  649. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  650. } CRYPTUI_VIEWSIGNATURES_STRUCTW, *PCRYPTUI_VIEWSIGNATURES_STRUCTW;
  651. typedef const CRYPTUI_VIEWSIGNATURES_STRUCTW *PCCRYPTUI_VIEWSIGNATURES_STRUCTW;
  652. typedef struct tagCRYPTUI_VIEWSIGNATURES_STRUCTA {
  653. DWORD dwSize;
  654. HWND hwndParent; // OPTIONAL
  655. DWORD dwFlags; // OPTIONAL
  656. LPCSTR szTitle; // OPTIONAL
  657. unsigned short choice;
  658. union {
  659. CRYPT_DATA_BLOB EncodedMessage;
  660. HCRYPTMSG hMsg;
  661. } u;
  662. LPCSTR szFileName; // OPTIONAL
  663. PFNCPROPPAGECALLBACK pPropPageCallback; // OPTIONAL
  664. void * pvCallbackData; // OPTIONAL
  665. DWORD cStores; // OPTIONAL
  666. HCERTSTORE * rghStores; // OPTIONAL
  667. DWORD cPropSheetPages; // OPTIONAL
  668. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  669. } CRYPTUI_VIEWSIGNATURES_STRUCTA, *PCRYPTUI_VIEWSIGNATURES_STRUCTA;
  670. typedef const CRYPTUI_VIEWSIGNATURES_STRUCTA *PCCRYPTUI_VIEWSIGNATURES_STRUCTA;
  671. // NOTE!! when calling this function, the following parameters of the
  672. // CRYPTUI_VIEWSIGNATURES_STRUCT struct are unused
  673. // cPropSheetPages
  674. // rgPropSheetPages
  675. // szTitle
  676. BOOL
  677. WINAPI
  678. CryptUIGetViewSignaturesPagesW(
  679. IN PCCRYPTUI_VIEWSIGNATURES_STRUCTW pcvs,
  680. OUT PROPSHEETPAGEW **prghPropPages,
  681. OUT DWORD *pcPropPages
  682. );
  683. BOOL
  684. WINAPI
  685. CryptUIGetViewSignaturesPagesA(
  686. IN PCCRYPTUI_VIEWSIGNATURES_STRUCTA pcvs,
  687. OUT PROPSHEETPAGEA **prghPropPages,
  688. OUT DWORD *pcPropPages
  689. );
  690. BOOL
  691. WINAPI
  692. CryptUIFreeViewSignaturesPagesW(
  693. IN PROPSHEETPAGEW *rghPropPages,
  694. IN DWORD cPropPages
  695. );
  696. BOOL
  697. WINAPI
  698. CryptUIFreeViewSignaturesPagesA(
  699. IN PROPSHEETPAGEA *rghPropPages,
  700. IN DWORD cPropPages
  701. );
  702. #ifdef UNICODE
  703. #define CryptUIGetViewSignaturesPages CryptUIGetViewSignaturesPagesW
  704. #define CryptUIFreeViewSignaturesPages CryptUIFreeViewSignaturesPagesW
  705. #define PCRYPTUI_VIEWSIGNATURES_STRUCT PCRYPTUI_VIEWSIGNATURES_STRUCTW
  706. #define CRYPTUI_VIEWSIGNATURES_STRUCT CRYPTUI_VIEWSIGNATURES_STRUCTW
  707. #define PCCRYPTUI_VIEWSIGNATURES_STRUCT PCCRYPTUI_VIEWSIGNATURES_STRUCTW
  708. #else
  709. #define CryptUIGetViewSignaturesPages CryptUIGetViewSignaturesPagesA
  710. #define CryptUIFreeViewSignaturesPages CryptUIFreeViewSignaturesPagesA
  711. #define PCRYPTUI_VIEWSIGNATURES_STRUCT PCRYPTUI_VIEWSIGNATURES_STRUCTA
  712. #define CRYPTUI_VIEWSIGNATURES_STRUCT CRYPTUI_VIEWSIGNATURES_STRUCTA
  713. #define PCCRYPTUI_VIEWSIGNATURES_STRUCT PCCRYPTUI_VIEWSIGNATURES_STRUCTA
  714. #endif
  715. /////////////////////////////////////////////////////////////////////////////////////////////////////
  716. //
  717. // the select store dialog can be passed a callback which is called to validate the store that the
  718. // user selected. Return TRUE to accept the store, or FALSE to reject the store. It TRUE is
  719. // returned then the store will be returned to the caller of CryptUIDlg\, if FALSE is returned
  720. // then the select store dialog will remain displayed so the user may make another selection
  721. typedef BOOL (WINAPI * PFNCVALIDATESTOREPROC)(
  722. HCERTSTORE hStore,
  723. HWND hWndSelectStoreDialog,
  724. void *pvCallbackData);
  725. /////////////////////////////////////////////////////////////////////////////////////////////////////
  726. // these two parameters are passed to the CertEnumSystemStore call and the stores that are
  727. // enumerated via that call are added to the store selection list.
  728. //
  729. // dwFlags CertEnumSystemStore
  730. // pvSystemStoreLocationPara CertEnumSystemStore
  731. typedef struct _STORENUMERATION_STRUCT {
  732. DWORD dwFlags;
  733. void * pvSystemStoreLocationPara;
  734. } STORENUMERATION_STRUCT, *PSTORENUMERATION_STRUCT;
  735. typedef const STORENUMERATION_STRUCT *PCSTORENUMERATION_STRUCT;
  736. /////////////////////////////////////////////////////////////////////////////////////////////////////
  737. // both the array of store handles and the array of enumeration strucs may be used to
  738. // populate the store selection list. if either is not used the count must be set to 0.
  739. // if the array of store handles is used the cert stores must have either been opened
  740. // with the CERT_STORE_SET_LOCALIZED_NAME_FLAG flag, or the CertSetStoreProperty function
  741. // must have been called with the CERT_STORE_LOCALIZED_NAME_PROP_ID flag. if the
  742. // CryptUIDlgSelectStore function is unable to obtain a name for a store that store will not
  743. // be displayed.
  744. //
  745. // cStores count of stores to select from
  746. // rghStores array of stores to select from
  747. // cEnumerationStructs count of enumeration structs
  748. // rgEnumerationStructs array of enumeration structs
  749. typedef struct _STORESFORSELCTION_STRUCT {
  750. DWORD cStores;
  751. HCERTSTORE * rghStores;
  752. DWORD cEnumerationStructs;
  753. PCSTORENUMERATION_STRUCT rgEnumerationStructs;
  754. } STORESFORSELCTION_STRUCT, *PSTORESFORSELCTION_STRUCT;
  755. typedef const STORESFORSELCTION_STRUCT *PCSTORESFORSELCTION_STRUCT;
  756. /////////////////////////////////////////////////////////////////////////////////////////////////////
  757. //
  758. // dwSize size of this struct
  759. // hwndParent parent of this dialog (OPTIONAL)
  760. // dwFlags flags, may a combination of any of the flags below
  761. // szTitle title of the dialog (OPTIONAL)
  762. // szDisplayString a string that will be displayed in the dialog that may (OPTIONAL)
  763. // be used to infor the user what they are selecting a store
  764. // for. if it is not set a default string will be displayed,
  765. // the default resource is IDS_SELECT_STORE_DEFAULT
  766. // pStoresForSelection a struct that contains the stores that are to be selected
  767. // from. the stores can be in two different formats, an array
  768. // of store handles and/or an array of enumeration structs
  769. // which will be used to call CertEnumSystemStore
  770. // pValidateStoreCallback a pointer to a PFNCVALIDATESTOREPROC which is used to (OPTIONAL)
  771. // callback the caller of CryptUIDlgSelectStore when the
  772. // user hasselected a store and pressed OK
  773. // pvCallbackData if pValidateStoreCallback is being used this value is (OPTIONAL)
  774. // passed back to the caller when the pValidateStoreCallback
  775. // is made
  776. //
  777. /////////////////////////////////////////////////////////////////////////////////////////////////////
  778. // dwFlags
  779. #define CRYPTUI_ALLOW_PHYSICAL_STORE_VIEW 0x00000001
  780. #define CRYPTUI_RETURN_READ_ONLY_STORE 0x00000002
  781. #define CRYPTUI_DISPLAY_WRITE_ONLY_STORES 0x00000004
  782. #define CRYPTUI_VALIDATE_STORES_AS_WRITABLE 0x00000008
  783. typedef struct tagCRYPTUI_SELECTSTORE_STRUCTW {
  784. DWORD dwSize;
  785. HWND hwndParent; // OPTIONAL
  786. DWORD dwFlags; // OPTIONAL
  787. LPCWSTR szTitle; // OPTIONAL
  788. LPCWSTR szDisplayString; // OPTIONAL
  789. PCSTORESFORSELCTION_STRUCT pStoresForSelection;
  790. PFNCVALIDATESTOREPROC pValidateStoreCallback; // OPTIONAL
  791. void * pvCallbackData; // OPTIONAL
  792. } CRYPTUI_SELECTSTORE_STRUCTW, *PCRYPTUI_SELECTSTORE_STRUCTW;
  793. typedef const CRYPTUI_SELECTSTORE_STRUCTW *PCCRYPTUI_SELECTSTORE_STRUCTW;
  794. typedef struct tagCRYPTUI_SELECTSTORE_STRUCTA {
  795. DWORD dwSize;
  796. HWND hwndParent; // OPTIONAL
  797. DWORD dwFlags; // OPTIONAL
  798. LPCSTR szTitle; // OPTIONAL
  799. LPCSTR szDisplayString; // OPTIONAL
  800. PCSTORESFORSELCTION_STRUCT pStoresForSelection;
  801. PFNCVALIDATESTOREPROC pValidateStoreCallback; // OPTIONAL
  802. void * pvCallbackData; // OPTIONAL
  803. } CRYPTUI_SELECTSTORE_STRUCTA, *PCRYPTUI_SELECTSTORE_STRUCTA;
  804. typedef const CRYPTUI_SELECTSTORE_STRUCTA *PCCRYPTUI_SELECTSTORE_STRUCTA;
  805. //
  806. // the HCERTSTORE that is returned must be closed by calling CertCloseStore
  807. //
  808. HCERTSTORE
  809. WINAPI
  810. CryptUIDlgSelectStoreW(
  811. IN PCCRYPTUI_SELECTSTORE_STRUCTW pcss
  812. );
  813. HCERTSTORE
  814. WINAPI
  815. CryptUIDlgSelectStoreA(
  816. IN PCCRYPTUI_SELECTSTORE_STRUCTA pcss
  817. );
  818. #ifdef UNICODE
  819. #define CryptUIDlgSelectStore CryptUIDlgSelectStoreW
  820. #define PCRYPTUI_SELECTSTORE_STRUCT PCRYPTUI_SELECTSTORE_STRUCTW
  821. #define CRYPTUI_SELECTSTORE_STRUCT CRYPTUI_SELECTSTORE_STRUCTW
  822. #define PCCRYPTUI_SELECTSTORE_STRUCT PCCRYPTUI_SELECTSTORE_STRUCTW
  823. #else
  824. #define CryptUIDlgSelectStore CryptUIDlgSelectStoreA
  825. #define PCRYPTUI_SELECTSTORE_STRUCT PCRYPTUI_SELECTSTORE_STRUCTA
  826. #define CRYPTUI_SELECTSTORE_STRUCT CRYPTUI_SELECTSTORE_STRUCTA
  827. #define PCCRYPTUI_SELECTSTORE_STRUCT PCCRYPTUI_SELECTSTORE_STRUCTA
  828. #endif
  829. /////////////////////////////////////////////////////////////////////////////////////////////////////
  830. #if (0) //DSIE: 7/02/2002 moved to CryptUIAPI.h per consent degree.
  831. /////////////////////////////////////////////////////////////////////////////////////////////////////
  832. //
  833. // The select cert dialog can be passed a filter proc to reduce the set of certificates
  834. // displayed. Return TRUE to display the certificate and FALSE to hide it. If TRUE is
  835. // returned then optionally the pfInitialSelectedCert boolean may be set to TRUE to indicate
  836. // to the dialog that this cert should be the initially selected cert. Note that the
  837. // most recent cert that had the pfInitialSelectedCert boolean set during the callback will
  838. // be the initially selected cert.
  839. typedef BOOL (WINAPI * PFNCFILTERPROC)(
  840. PCCERT_CONTEXT pCertContext,
  841. BOOL *pfInitialSelectedCert,
  842. void *pvCallbackData);
  843. #endif
  844. /////////////////////////////////////////////////////////////////////////////////////////////////////
  845. //
  846. // Certificates may be viewed by the user when selecting certificates from the select certificate
  847. // dialog. This callback will allow the caller of the select certificate dialog to handle the
  848. // displaying of those certificates. This may be useful if the caller wishes to call WinVerifyTrust
  849. // with their own policy module and display the certificate with that WinVerifyTrust state. If
  850. // FALSE is returned from this callback it is assumed that the select certificate dialog will be
  851. // responsible for dislaying the certificate in question. If TRUE is returned it is assumed that the
  852. // display of the certificate was already handled.
  853. typedef BOOL (WINAPI * PFNCCERTDISPLAYPROC)(
  854. PCCERT_CONTEXT pCertContext,
  855. HWND hWndSelCertDlg,
  856. void *pvCallbackData);
  857. /////////////////////////////////////////////////////////////////////////////////////////////////////
  858. //
  859. // dwSize size of this struct
  860. // hwndParent parent of this dialog (OPTIONAL)
  861. // dwFlags flags:
  862. // CRYPTUI_SELECTCERT_MULTISELECT -
  863. // if this flag is set then CryptUIDlgSelectCertificate
  864. // will return NULL, and the hSelectedCertStore
  865. // parameter must contain a valid store handle that
  866. // will be populated with all the selected certificates.
  867. // dwDontUseColumn This can be used to disable the display of certain (OPTIONAL)
  868. // columns. It can be set with any comibnation of the
  869. // column flags below
  870. // szTitle title of the dialog (OPTIONAL)
  871. // szDisplayString a string that will be displayed in the dialog that may (OPTIONAL)
  872. // be used to inform the user what they are selecting a
  873. // a certificate for. if it is not set a default string
  874. // will be displayed. the defualt strings resourece is
  875. // IDS_SELECT_CERT_DEFAULT
  876. // pFilterCallback a pointer to a PFNCMFILTERPROC which is used to filter (OPTIONAL)
  877. // the certificates which are displayed for selection
  878. // pDisplayCallback a pointer to a PFNCCERTDISPLAYPROC which is used to
  879. // handle displaying certificates
  880. // pvCallbackData if either or both pFilterCallback or pDisplayCallback (OPTIONAL)
  881. // are being used this value is passed back to the caller
  882. // when the callbacks are made
  883. // cDisplayStores count of stores that contain the certs to display
  884. // for selection
  885. // rghDisplayStores array of stores that contain the certs to display
  886. // for selection
  887. // cStores count of other stores to search when building chain and (OPTIONAL)
  888. // validating trust of the certs which are displayed, if
  889. // the user choosing a cert would like to view a particular
  890. // cert which is displayed for selection, these stores
  891. // are passed to the CertViewCert dialog
  892. // rghStores array of other stores to search when building chain and (OPTIONAL)
  893. // validating trust of the certs which are displayed, if
  894. // the user choosing a cert would like to view a particular
  895. // cert which is displayed for selection, these stores
  896. // are passed to the CertViewCert dialog
  897. // cPropSheetPages PASS THROUGH - number of pages in rgPropSheetPages array (OPTIONAL)
  898. // rgPropSheetPages PASS THROUGH - extra pages that are passed through (OPTIONAL)
  899. // to the certificate viewing dialog when it is invoked from
  900. // the selection dialog
  901. // hSelectedCertStore This certificate store is passed in by the caller if the (OPTIONAL)
  902. // CRYPTUI_SELECTCERT_MULTISELECT flag is set. The store
  903. // will contain all the selected certificates on return.
  904. //
  905. /////////////////////////////////////////////////////////////////////////////////////////////////////
  906. // flags for dwDontUseColumn
  907. //
  908. // The following are defined in cryptuiapi.h
  909. // #define CRYPTUI_SELECT_ISSUEDTO_COLUMN 0x000000001
  910. // #define CRYPTUI_SELECT_ISSUEDBY_COLUMN 0x000000002
  911. // #define CRYPTUI_SELECT_INTENDEDUSE_COLUMN 0x000000004
  912. // #define CRYPTUI_SELECT_FRIENDLYNAME_COLUMN 0x000000008
  913. // #define CRYPTUI_SELECT_LOCATION_COLUMN 0x000000010
  914. // #define CRYPTUI_SELECT_EXPIRATION_COLUMN 0x000000020
  915. typedef struct tagCRYPTUI_SELECTCERTIFICATE_STRUCTW {
  916. DWORD dwSize;
  917. HWND hwndParent; // OPTIONAL
  918. DWORD dwFlags; // OPTIONAL
  919. LPCWSTR szTitle; // OPTIONAL
  920. DWORD dwDontUseColumn; // OPTIONAL
  921. LPCWSTR szDisplayString; // OPTIONAL
  922. PFNCFILTERPROC pFilterCallback; // OPTIONAL
  923. PFNCCERTDISPLAYPROC pDisplayCallback; // OPTIONAL
  924. void * pvCallbackData; // OPTIONAL
  925. DWORD cDisplayStores;
  926. HCERTSTORE * rghDisplayStores;
  927. DWORD cStores; // OPTIONAL
  928. HCERTSTORE * rghStores; // OPTIONAL
  929. DWORD cPropSheetPages; // OPTIONAL
  930. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  931. HCERTSTORE hSelectedCertStore; // OPTIONAL
  932. } CRYPTUI_SELECTCERTIFICATE_STRUCTW, *PCRYPTUI_SELECTCERTIFICATE_STRUCTW;
  933. typedef const CRYPTUI_SELECTCERTIFICATE_STRUCTW *PCCRYPTUI_SELECTCERTIFICATE_STRUCTW;
  934. typedef struct tagCRYPTUI_SELECTCERTIFICATE_STRUCT_A {
  935. DWORD dwSize;
  936. HWND hwndParent; // OPTIONAL
  937. DWORD dwFlags; // OPTIONAL
  938. LPCSTR szTitle; // OPTIONAL
  939. DWORD dwDontUseColumn; // OPTIONAL
  940. LPCSTR szDisplayString; // OPTIONAL
  941. PFNCFILTERPROC pFilterCallback; // OPTIONAL
  942. PFNCCERTDISPLAYPROC pDisplayCallback; // OPTIONAL
  943. void * pvCallbackData; // OPTIONAL
  944. DWORD cDisplayStores;
  945. HCERTSTORE * rghDisplayStores;
  946. DWORD cStores; // OPTIONAL
  947. HCERTSTORE * rghStores; // OPTIONAL
  948. DWORD cPropSheetPages; // OPTIONAL
  949. LPCPROPSHEETPAGEA rgPropSheetPages; // OPTIONAL
  950. HCERTSTORE hSelectedCertStore; // OPTIONAL
  951. } CRYPTUI_SELECTCERTIFICATE_STRUCTA, *PCRYPTUI_SELECTCERTIFICATE_STRUCTA;
  952. typedef const CRYPTUI_SELECTCERTIFICATE_STRUCTA *PCCRYPTUI_SELECTCERTIFICATE_STRUCTA;
  953. //
  954. // the PCCERT_CONTEXT that is returned must be released by calling CertFreeCertificateContext().
  955. // if NULL is returned and GetLastError() == 0 then the user dismissed the dialog by hitting the
  956. // "cancel" button, otherwise GetLastError() will contain the last error.
  957. //
  958. PCCERT_CONTEXT
  959. WINAPI
  960. CryptUIDlgSelectCertificateW(
  961. IN PCCRYPTUI_SELECTCERTIFICATE_STRUCTW pcsc
  962. );
  963. PCCERT_CONTEXT
  964. WINAPI
  965. CryptUIDlgSelectCertificateA(
  966. IN PCCRYPTUI_SELECTCERTIFICATE_STRUCTA pcsc
  967. );
  968. #ifdef UNICODE
  969. #define CryptUIDlgSelectCertificate CryptUIDlgSelectCertificateW
  970. #define PCRYPTUI_SELECTCERTIFICATE_STRUCT PCRYPTUI_SELECTCERTIFICATE_STRUCTW
  971. #define CRYPTUI_SELECTCERTIFICATE_STRUCT CRYPTUI_SELECTCERTIFICATE_STRUCTW
  972. #define PCCRYPTUI_SELECTCERTIFICATE_STRUCT PCCRYPTUI_SELECTCERTIFICATE_STRUCTW
  973. #else
  974. #define CryptUIDlgSelectCertificate CryptUIDlgSelectCertificateA
  975. #define PCRYPTUI_SELECTCERTIFICATE_STRUCT PCRYPTUI_SELECTCERTIFICATE_STRUCTA
  976. #define CRYPTUI_SELECTCERTIFICATE_STRUCT CRYPTUI_SELECTCERTIFICATE_STRUCTA
  977. #define PCCRYPTUI_SELECTCERTIFICATE_STRUCT PCCRYPTUI_SELECTCERTIFICATE_STRUCTA
  978. #endif
  979. // dwFlags
  980. #define CRYPTUI_SELECTCERT_MULTISELECT 0x00000001
  981. #define CRYPTUI_SELECTCERT_ADDFROMDS 0x00010000
  982. //flags for dwFlags in CRYPTUI_SELECT_CA_STRUCT struct
  983. #define CRYPTUI_DLG_SELECT_CA_FROM_NETWORK 0x0001
  984. #define CRYPTUI_DLG_SELECT_CA_USE_DN 0x0002
  985. #define CRYPTUI_DLG_SELECT_CA_LOCAL_MACHINE_ENUMERATION 0x0004
  986. //-------------------------------------------------------------------------
  987. //
  988. // CRYPTUI_CA_CONTEXT
  989. //
  990. //-------------------------------------------------------------------------
  991. typedef struct _CRYPTUI_CA_CONTEXT
  992. {
  993. DWORD dwSize;
  994. LPCWSTR pwszCAName;
  995. LPCWSTR pwszCAMachineName;
  996. }CRYPTUI_CA_CONTEXT, *PCRYPTUI_CA_CONTEXT;
  997. typedef const CRYPTUI_CA_CONTEXT *PCCRYPTUI_CA_CONTEXT;
  998. //-------------------------------------------------------------------------
  999. //
  1000. //
  1001. //
  1002. // The select certificate authoritiy (CA) dialog can be passed a filter proc to reduce the set of CAs
  1003. // displayed. Return TRUE to display the CA and FALSE to hide it. If TRUE is
  1004. // returned then optionally the pfInitialSelectedCert boolean may be set to TRUE to indicate
  1005. // to the dialog that this CA should be the initially selected CA. Note that the
  1006. // most recent cert that had the pfInitialSelectedCert boolean set during the callback will
  1007. // be the initially selected CA.
  1008. //
  1009. //-------------------------------------------------------------------------
  1010. typedef BOOL (WINAPI * PFN_CRYPTUI_SELECT_CA_FUNC)(
  1011. PCCRYPTUI_CA_CONTEXT pCAContext,
  1012. BOOL *pfInitialSelected,
  1013. void *pvCallbackData);
  1014. //-------------------------------------------------------------------------
  1015. //
  1016. // CRYPTUI_SELECT_CA_STRUCT
  1017. //
  1018. // dwSize Required: Must be set to sizeof(CRYPTUI_SELECT_CA_STRUCT)
  1019. // hwndParent Optional: Parent of this dialog
  1020. // dwFlags Optional: Flags, Can be set to any combination of the following:
  1021. // CRYPTUI_DLG_SELECT_CA_FROM_NETWORK:
  1022. // All the available CAs from the network will be displayed
  1023. // CRYPTUI_DLG_SELECT_CA_USE_DN:
  1024. // Use the full DN (Distinguished Name) as the CA name.
  1025. // By default, CN (common name) is used.
  1026. // CRYPTUI_DLG_SELECT_CA_LOCAL_MACHINE_ENUMERATION:
  1027. // Display the CAs available to the local machine only.
  1028. // By Default, CAs available to the current user will be displayed
  1029. // wszTitle Optional: Title of the dialog
  1030. // wszDisplayString Optional: A string that will be displayed in the dialog that may (OPTIONAL)
  1031. // be used to inform the user what they are selecting a
  1032. // a certificate for. if it is not set a default string
  1033. // will be displayed. the defualt strings resourece is
  1034. // IDS_SELECT_CA_DISPLAY_DEFAULT
  1035. // cCAContext Optional: The count of additional CA contexts that will be displayed
  1036. // in the dialogs
  1037. // *rgCAContext Optioanl: The array of additional CA contexts that will be displayed
  1038. // in the dialogs
  1039. // pSelectCACallback Optional: a pointer to a PCCRYPTUI_CA_CONTEXT which is used to filter
  1040. // the certificate autorities which are displayed for selection
  1041. // pvCallbackData Optional: if pSelectCACallback is being used this value is passed
  1042. // back to the caller when the pSelectCACallback is made
  1043. //-------------------------------------------------------------------------
  1044. typedef struct _CRYPTUI_SELECT_CA_STRUCT
  1045. {
  1046. DWORD dwSize; // REQUIRED
  1047. HWND hwndParent; // OPTIONAL
  1048. DWORD dwFlags; // OPTIONAL
  1049. LPCWSTR wszTitle; // OPTIONAL
  1050. LPCWSTR wszDisplayString; // OPTIONAL
  1051. DWORD cCAContext; // OPTIONAL
  1052. PCCRYPTUI_CA_CONTEXT *rgCAContext; // OPTIONAL
  1053. PFN_CRYPTUI_SELECT_CA_FUNC pSelectCACallback; // OPTIONAL
  1054. void *pvCallbackData; // OPTIONAL
  1055. }CRYPTUI_SELECT_CA_STRUCT, *PCRYPTUI_SELECT_CA_STRUCT;
  1056. typedef const CRYPTUI_SELECT_CA_STRUCT *PCCRYPTUI_SELECT_CA_STRUCT;
  1057. //--------------------------------------------------------------
  1058. //
  1059. // Parameters:
  1060. // pCryptUISelectCA IN Required
  1061. //
  1062. // the PCCRYPTUI_CA_CONTEXT that is returned must be released by calling
  1063. // CryptUIDlgFreeCAContext
  1064. // if NULL is returned and GetLastError() == 0 then the user dismissed the dialog by hitting the
  1065. // "cancel" button, otherwise GetLastError() will contain the last error.
  1066. //
  1067. //
  1068. //--------------------------------------------------------------
  1069. PCCRYPTUI_CA_CONTEXT
  1070. WINAPI
  1071. CryptUIDlgSelectCA(
  1072. IN PCCRYPTUI_SELECT_CA_STRUCT pCryptUISelectCA
  1073. );
  1074. BOOL
  1075. WINAPI
  1076. CryptUIDlgFreeCAContext(
  1077. IN PCCRYPTUI_CA_CONTEXT pCAContext
  1078. );
  1079. #if (0) //DSIE: 7/02/2002 moved to CryptUIAPI.h per consent degree.
  1080. //-------------------------------------------------------------------------
  1081. //
  1082. // CRYPTUI_CERT_MGR_STRUCT
  1083. //
  1084. // dwSize Required: Must be set to sizeof(CRYPTUI_CERT_MGR_STRUCT)
  1085. // hwndParent Optional: Parent of this dialog
  1086. // dwFlags Optional: Personal is the default initially selected
  1087. // tab.
  1088. // CRYPTUI_CERT_MGR_PUBLISHER_TAB may be set
  1089. // to select Trusted Publishers as the
  1090. // initially selected tab.
  1091. // CRYPTUI_CERT_MGR_SINGLE_TAB_FLAG may also
  1092. // be set to only display the Trusted
  1093. // Publishers tab.
  1094. // wszTitle Optional: Title of the dialog
  1095. // pszInitUsageOID Optional: The enhanced key usage object identifier (OID).
  1096. // Certificates with this OID will initially
  1097. // be shown as a default. User
  1098. // can then choose different OIDs.
  1099. // NULL means all certificates will be shown initially.
  1100. //-------------------------------------------------------------------------
  1101. typedef struct _CRYPTUI_CERT_MGR_STRUCT
  1102. {
  1103. DWORD dwSize; // REQUIRED
  1104. HWND hwndParent; // OPTIONAL
  1105. DWORD dwFlags; // OPTIONAL
  1106. LPCWSTR pwszTitle; // OPTIONAL
  1107. LPCSTR pszInitUsageOID; // OPTIONAL
  1108. }CRYPTUI_CERT_MGR_STRUCT, *PCRYPTUI_CERT_MGR_STRUCT;
  1109. typedef const CRYPTUI_CERT_MGR_STRUCT *PCCRYPTUI_CERT_MGR_STRUCT;
  1110. #define CRYPTUI_CERT_MGR_TAB_MASK 0x0000000F
  1111. #define CRYPTUI_CERT_MGR_PUBLISHER_TAB 0x00000004
  1112. #define CRYPTUI_CERT_MGR_SINGLE_TAB_FLAG 0x00008000
  1113. //--------------------------------------------------------------
  1114. //
  1115. // Parameters:
  1116. // pCryptUICertMgr IN Required
  1117. //
  1118. //
  1119. //--------------------------------------------------------------
  1120. BOOL
  1121. WINAPI
  1122. CryptUIDlgCertMgr(
  1123. IN PCCRYPTUI_CERT_MGR_STRUCT pCryptUICertMgr);
  1124. #endif
  1125. /////////////////////////////////////////////////////////////////////////////////////////////////////
  1126. /////////////////////////////////////////////////////////////////////////////////////////////////////
  1127. //-----------------------------------------------------------------------
  1128. // The valid values for dwFlags for the CryptUIWiz APIs
  1129. //
  1130. //------------------------------------------------------------------------
  1131. #if (0) //DSIE: 7/02/2002 moved to CryptUIAPI.h per consent degree.
  1132. #define CRYPTUI_WIZ_NO_UI 0x0001
  1133. #endif
  1134. #define CRYPTUI_WIZ_IGNORE_NO_UI_FLAG_FOR_CSPS 0x0002
  1135. #define CRYPTUI_WIZ_NO_UI_EXCEPT_CSP 0x0003
  1136. #define CRYPTUI_WIZ_ALLOW_ALL_TEMPLATES 0x0004
  1137. #define CRYPTUI_WIZ_ALLOW_ALL_CAS 0x0008
  1138. #define CRYPTUI_WIZ_CERT_REQUEST_REQUIRE_NEW_KEY 0x0040 // The enrollment API may not reuse an existing private key
  1139. // Valid only for CryptUIWizExport.
  1140. #define CRYPTUI_WIZ_EXPORT_PRIVATE_KEY 0x0100 // This will skip the Export Private Key page,
  1141. // and assume private key is to be exported.
  1142. #define CRYPTUI_WIZ_EXPORT_NO_DELETE_PRIVATE_KEY 0x0200 // This will disable the "Delete the priate key..."
  1143. // check box in the Export File Format page.
  1144. //CRYPTUI_WIZ_NO_INSTALL_ROOT is only valid for CryptUIWizCertRequest API
  1145. //the wizard will not install the issued certificate chain into the root store,
  1146. //instead, it will put the certificate chain into the CA store.
  1147. #define CRYPTUI_WIZ_NO_INSTALL_ROOT 0x0010
  1148. //CRYPTUI_WIZ_BUILDCTL_SKIP_DESTINATION only valid for CryptUIWizBuildCTL API.
  1149. //the wizard will skip the page which asks user to enter destination where the CTL will
  1150. //be stored.
  1151. #define CRYPTUI_WIZ_BUILDCTL_SKIP_DESTINATION 0x0004
  1152. //CRYPTUI_WIZ_BUILDCTL_SKIP_SIGNING only valid for CryptUIWizBuildCTL API.
  1153. //the wizard will skip the page which asks user to sign the CTL.
  1154. //the CTLContext returned by CryptUIWizBuildCTL will not be signed.
  1155. //Caller can then use CryptUIWizDigitalSign to sign the CTL.
  1156. #define CRYPTUI_WIZ_BUILDCTL_SKIP_SIGNING 0x0008
  1157. //CRYPTUI_WIZ_BUILDCTL_SKIP_PURPOSE only valid for CryptUIWizBuildCTL API.
  1158. //the wizard will skip the page which asks user for the purpose, validity,
  1159. //and list ID of the CTL.
  1160. #define CRYPTUI_WIZ_BUILDCTL_SKIP_PURPOSE 0x0010
  1161. #define CRYPTUI_WIZ_NO_ARCHIVE_RENEW_CERT 0x0020
  1162. #define CRYPTUI_WIZ_CREATE_ONLY 0x00010000
  1163. #define CRYPTUI_WIZ_SUBMIT_ONLY 0x00020000
  1164. #define CRYPTUI_WIZ_FREE_ONLY 0x00040000
  1165. #define CRYPTUI_WIZ_QUERY_ONLY 0x00080000
  1166. #define CRYPTUI_WIZ_NODS_MASK 0x000F0000
  1167. ///-----------------------------------------------------------------------
  1168. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CERT
  1169. //
  1170. //------------------------------------------------------------------------
  1171. typedef struct _CRYPTUI_WIZ_CERT_REQUEST_PVK_CERT
  1172. {
  1173. DWORD dwSize; //Required: Set to the sizeof(CRYPTUI_WIZ_CERT_REQUEST_PVK_CERT)
  1174. PCCERT_CONTEXT pCertContext; //Required: Use the private key of the certificate context
  1175. // The certificate context
  1176. // has to have CERT_KEY_PROV_INFO_PROP_ID property
  1177. // and the private key has to exist
  1178. }CRYPTUI_WIZ_CERT_REQUEST_PVK_CERT, *PCRYPTUI_WIZ_CERT_REQUEST_PVK_CERT;
  1179. typedef const CRYPTUI_WIZ_CERT_REQUEST_PVK_CERT *PCCRYPTUI_WIZ_CERT_REQUEST_PVK_CERT;
  1180. ///-----------------------------------------------------------------------
  1181. // CRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING
  1182. //
  1183. //------------------------------------------------------------------------
  1184. typedef struct _CRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING
  1185. {
  1186. DWORD dwSize; //Required: Set to the sizeof(CRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING)
  1187. PCRYPT_KEY_PROV_INFO pKeyProvInfo; //Required: The information about the provider and the private key
  1188. // The optional CRYPT_KEY_PROV_PARAM fields in PCRYPT_KEY_PROV_INFO
  1189. // are ignored.
  1190. }CRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING, *PCRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING;
  1191. typedef const CRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING *PCCRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING;
  1192. ///-----------------------------------------------------------------------
  1193. // CERT_REQUEST_PVK_NEW
  1194. //
  1195. //------------------------------------------------------------------------
  1196. typedef struct _CRYPTUI_WIZ_CERT_REQUEST_PVK_NEW
  1197. {
  1198. DWORD dwSize; //Required: Set to the sizeof(CRYPTUI_WIZ_CERT_REQUEST_PVK_NEW)
  1199. PCRYPT_KEY_PROV_INFO pKeyProvInfo; //Optional: The information about the provider and the private key
  1200. // NULL means use the default
  1201. // The optional CRYPT_KEY_PROV_PARAM fields in PCRYPT_KEY_PROV_INFO
  1202. // are ignored.
  1203. DWORD dwGenKeyFlags; //Optional: The flags for CryptGenKey
  1204. }CRYPTUI_WIZ_CERT_REQUEST_PVK_NEW, *PCRYPTUI_WIZ_CERT_REQUEST_PVK_NEW;
  1205. typedef const CRYPTUI_WIZ_CERT_REQUEST_PVK_NEW *PCCRYPTUI_WIZ_CERT_REQUEST_PVK_NEW;
  1206. ///-----------------------------------------------------------------------
  1207. // CRYPTUI_WIZ_CERT_TYPE
  1208. //
  1209. //------------------------------------------------------------------------
  1210. typedef struct _CRYPTUI_WIZ_CERT_TYPE
  1211. {
  1212. DWORD dwSize; //Required: Set to the sizeof(CRYPTUI_WIZ_CERT_TYPE)
  1213. DWORD cCertType; //the count of rgwszCertType. cCertType should be 1.
  1214. LPWSTR *rgwszCertType; //the array of certificate type name
  1215. }CRYPTUI_WIZ_CERT_TYPE, *PCRYPTUI_WIZ_CERT_TYPE;
  1216. typedef const CRYPTUI_WIZ_CERT_TYPE *PCCRYPTUI_WIZ_CERT_TYPE;
  1217. //-----------------------------------------------------------------------
  1218. // dwPvkChoice
  1219. //-----------------------------------------------------------------------
  1220. #define CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_CERT 1
  1221. #define CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_EXISTING 2
  1222. #define CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_NEW 3
  1223. //-----------------------------------------------------------------------
  1224. // dwPurpose
  1225. //-----------------------------------------------------------------------
  1226. #define CRYPTUI_WIZ_CERT_ENROLL 0x00010000
  1227. #define CRYPTUI_WIZ_CERT_RENEW 0x00020000
  1228. //-----------------------------------------------------------------------
  1229. //
  1230. // valid flags for dwPostOption
  1231. //-----------------------------------------------------------------------
  1232. //post the requested certificate on the directory serivce
  1233. #define CRYPTUI_WIZ_CERT_REQUEST_POST_ON_DS 0x01
  1234. //post the requested certificate with the private key container.
  1235. #define CRYPTUI_WIZ_CERT_REQUEST_POST_ON_CSP 0x02
  1236. //-----------------------------------------------------------------------
  1237. //
  1238. // valid flags for dwCertChoice
  1239. //-----------------------------------------------------------------------
  1240. #define CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE 0x01
  1241. #define CRYPTUI_WIZ_CERT_REQUEST_CERT_TYPE 0x02
  1242. //-------------------------------------------------------------------------
  1243. //
  1244. //
  1245. // CRYPTUI_WIZ_CERT_REQUEST_INFO
  1246. //-------------------------------------------------------------------------
  1247. typedef struct _CRYPTUI_WIZ_CERT_REQUEST_INFO
  1248. {
  1249. DWORD dwSize; //Required: Has to be set to sizeof(CRYPTUI_WIZ_CERT_REQUEST_INFO)
  1250. DWORD dwPurpose; //Required: If CRYPTUI_WIZ_CERT_ENROLL is set, a certificate will be enrolled,
  1251. // If CRYPTUI_WIZ_CERT_RENEW is set, a certificate will be renewed.
  1252. // CRYPTUI_WIZ_CERT_ENROLL and CRYPTUI_WIZ_CERT_RENEW can not be set
  1253. // at the same time
  1254. LPCWSTR pwszMachineName; //Optional: The machine name for which to enroll.
  1255. LPCWSTR pwszAccountName; //Optional: The account name(user or service) for which to enroll
  1256. //
  1257. // pwszMachineName pwszAccountName Meaning
  1258. //---------------------------------------------------
  1259. // NULL NULL Request for current account on the current machine
  1260. // "fooMachine" NULL Request for the machine named "fooMachine"
  1261. // NULL "fooUser" Request for the "fooUser" account on the current machine
  1262. // "fooMachine" "fooUser" Request for the "fooUser" accunt on the "fooMachine" machine
  1263. //
  1264. void *pAuthentication; //Reserved: authenticate info. Must be set to NULL.
  1265. LPCWSTR pCertRequestString; //Reserved: The additional request string. Must be set to NULL.
  1266. LPCWSTR pwszDesStore; //Optional: The desination store where to put
  1267. // the enrolled certificate. Default to "My" if the value is NULL
  1268. DWORD dwCertOpenStoreFlag; //Optional: The value passed to dwFlags of CertOpenStore for the
  1269. // destination store
  1270. // If this value is 0, we use CERT_SYSTEM_STORE_CURRENT_USER for
  1271. // an accout and CERT_SYSTEM_STORE_LOCAL_MACHINE for a machine
  1272. LPCSTR pszHashAlg; //Optional: The oid string of the hash algorithm of the certificate.
  1273. PCCERT_CONTEXT pRenewCertContext; //Required if CRYPTUI_WIZ_CERT_RENEW is set in dwPurpose
  1274. //Ignored otherwise and shoule be set to NULL.
  1275. DWORD dwPvkChoice; //Required: Specify the private key information
  1276. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_CERT
  1277. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_EXISTING
  1278. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_NEW
  1279. union //Required.
  1280. {
  1281. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_CERT pPvkCert;
  1282. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING pPvkExisting;
  1283. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_NEW pPvkNew;
  1284. };
  1285. LPCWSTR pwszCALocation; //Required if dwCertChoice==CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE //Optional Otherwise
  1286. //Optional Otherwise
  1287. // The machine name of the Certiviate Authority (CA)
  1288. LPCWSTR pwszCAName; //Required if dwCertChoice==CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE
  1289. //Optional Otherwise
  1290. // The name of the Certificate Authority (CA)
  1291. DWORD dwPostOption; //Optional Can set to any combination of the following flag:
  1292. // CRYPTUI_WIZ_CERT_REQUEST_POST_ON_DS
  1293. //
  1294. DWORD dwCertChoice; //Optional if CRYPTUI_WIZ_CERT_ENROLL is set in dwPurpose
  1295. // and CRYPTUI_WIZ_NO_UI is not set
  1296. //Required if CRYPTUI_WIZ_CERT_ENROLL is set in dwPurpose
  1297. // and CRYPTUI_WIZ_NO_UI is set
  1298. //ignored otherwise and should be set to 0.
  1299. // Specify the type of the requested certificate
  1300. // it can be one of the following flag:
  1301. // CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE
  1302. // CRYPTUI_WIZ_CERT_REQUEST_CERT_TYPE
  1303. union
  1304. {
  1305. PCERT_ENHKEY_USAGE pKeyUsage; // Indicate the enhanced key usage OIDs for the requested certificate.
  1306. PCCRYPTUI_WIZ_CERT_TYPE pCertType; // Indicate the certificate type of the requested certificate
  1307. };
  1308. LPCWSTR pwszFriendlyName; //Optional if CRYPTUI_WIZ_CERT_ENROLL is set in dwPurpose
  1309. //Ignored otherwise and should be set to NULL.
  1310. // The friendly name of the certificate
  1311. LPCWSTR pwszDescription; //Optional if CRYPTUI_WIZ_CERT_ENROLL is set in dwPurpose
  1312. //Ignored otherwise and should be set to NULL.
  1313. // The description of the certificate
  1314. PCERT_EXTENSIONS pCertRequestExtensions; //Optional The extensions to add to the certificate request
  1315. LPWSTR pwszCertDNName; //Optional The certificate DN string
  1316. }CRYPTUI_WIZ_CERT_REQUEST_INFO, *PCRYPTUI_WIZ_CERT_REQUEST_INFO;
  1317. typedef const CRYPTUI_WIZ_CERT_REQUEST_INFO *PCCRYPTUI_WIZ_CERT_REQUEST_INFO;
  1318. //-------------------------------------------------------------------------
  1319. //
  1320. //
  1321. // CRYPTUI_WIZ_CERT_REQUEST_INFO:
  1322. // Used for three-stage no-DS enrollment API, exposed through
  1323. //
  1324. // CryptUIWizCreateCertRequestNoDS()
  1325. // CryptUIWizSubmitCertRequestNoDS()
  1326. // CryptUIWizFreeCertRequestNoDS()
  1327. //
  1328. //
  1329. //-------------------------------------------------------------------------
  1330. typedef struct _CRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO {
  1331. DWORD dwSize; //Required: Has to be set to sizeof(CRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO)
  1332. DWORD dwPurpose; //Required: If CRYPTUI_WIZ_CERT_ENROLL is set, a certificate will be enrolled,
  1333. // If CRYPTUI_WIZ_CERT_RENEW is set, a certificate will be renewed.
  1334. // CRYPTUI_WIZ_CERT_ENROLL and CRYPTUI_WIZ_CERT_RENEW can not be set
  1335. // at the same time
  1336. HCERTTYPE hCertType; //Required: A handle to the cert type to use in request creation.
  1337. BOOL fMachineContext; //Required: TRUE if running under machine context, FALSE otherwise.
  1338. DWORD dwCertOpenStoreFlag; //Optional: The value passed to dwFlags of CertOpenStore for the
  1339. // destination store.
  1340. // If this value is 0, we use CERT_SYSTEM_STORE_CURRENT_USER for
  1341. // an accout and CERT_SYSTEM_STORE_LOCAL_MACHINE for a machine
  1342. PCCERT_CONTEXT pRenewCertContext; //Required if CRYPTUI_WIZ_CERT_RENEW is set in dwPurpose
  1343. //Ignored otherwise and shoule be set to NULL.
  1344. DWORD dwPvkChoice; //Required: Specify the private key information
  1345. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_CERT
  1346. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_EXISTING
  1347. // CRYPTUI_WIZ_CERT_REQUEST_PVK_CHOICE_NEW
  1348. union //Required.
  1349. {
  1350. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_CERT pPvkCert;
  1351. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_EXISTING pPvkExisting;
  1352. PCCRYPTUI_WIZ_CERT_REQUEST_PVK_NEW pPvkNew;
  1353. };
  1354. LPCWSTR pwszCALocation; //Required if dwCertChoice==CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE //Optional Otherwise
  1355. //Optional Otherwise
  1356. // The machine name of the Certiviate Authority (CA)
  1357. LPCWSTR pwszCAName; //Required if dwCertChoice==CRYPTUI_WIZ_CERT_REQUEST_KEY_USAGE
  1358. //Optional Otherwise
  1359. // The name of the Certificate Authority (CA)
  1360. } CRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO, *PCRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO;
  1361. typedef const CRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO * PCCRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO;
  1362. //-------------------------------------------------------------------------
  1363. //
  1364. //
  1365. // CRYPTUI_WIZ_CERT_REQUEST_INFO:
  1366. // Used to query the requests created by the no-DS enrollment API, exposed through
  1367. //
  1368. // CryptUIWizCreateCertRequestNoDS()
  1369. // CryptUIWizSubmitCertRequestNoDS()
  1370. // CryptUIWizFreeCertRequestNoDS()
  1371. // CryptUIWizQueryCertRequestNoDS()
  1372. //
  1373. //
  1374. //-------------------------------------------------------------------------
  1375. typedef struct _CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO {
  1376. DWORD dwSize; // sizeof(CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO)
  1377. DWORD dwStatus; // set of flags, see below
  1378. } CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO, *PCRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO;
  1379. typedef const CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO * PCCRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO;
  1380. //-----------------------------------------------------------------------
  1381. //
  1382. // possible flags for CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO::dwStatus.
  1383. //
  1384. //-----------------------------------------------------------------------
  1385. #define CRYPTUI_WIZ_QUERY_CERT_REQUEST_STATUS_CREATE_REUSED_PRIVATE_KEY 0x00000001
  1386. //-----------------------------------------------------------------------
  1387. //
  1388. // possible status for pdwStatus
  1389. // Those status indicate the status value returned
  1390. // from the certificate authority (certificate server).
  1391. //-----------------------------------------------------------------------
  1392. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_SUCCEEDED 0
  1393. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_ERROR 1
  1394. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_DENIED 2
  1395. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_ISSUED_SEPARATELY 3
  1396. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNDER_SUBMISSION 4
  1397. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNKNOWN 5
  1398. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_CERT_ISSUED 6
  1399. #define CRYPTUI_WIZ_CERT_REQUEST_STATUS_CONNECTION_FAILED 7
  1400. //-----------------------------------------------------------------------
  1401. //
  1402. // CryptUIWizCertRequest
  1403. //
  1404. // Request a certificate via a wizard.
  1405. //
  1406. // dwFlags: IN Optional
  1407. // If CRYPTUI_WIZ_NO_UI is set in dwFlags, no UI will be shown.
  1408. // If CRYPTUI_WIZ_NO_INSTALL_ROOT is set in dwFlags, the wizard will not
  1409. // install the issued certificate chain into the root store,
  1410. // instead, it will put the certificate chain into the CA store.
  1411. //
  1412. // hwndParent: IN Optional
  1413. // The parent window for the UI. Ignored if CRYPTUI_WIZ_NO_UI is set in dwFlags
  1414. //
  1415. // pwszWizardTitle: IN Optional
  1416. // The title of the wizard. Ignored if CRYPTUI_WIZ_NO_UI is set in dwFlags
  1417. //
  1418. // pCertRequestInfo: IN Required
  1419. // A pointer to CRYPTUI_WIZ_CERT_REQUEST_INFO struct
  1420. //
  1421. // ppCertContext: Out Optional
  1422. // The issued certificate. The certificate is in a memory store for remote enrollment.
  1423. // The certificate is in a system cert store for local enrollment.
  1424. //
  1425. // Even the function return TRUE, it does not mean the certificate is issued. Use should
  1426. // check for the *pdwCAStatus. If the status is CRYPTUI_WIZ_CERT_REQUEST_STATUS_ISSUED_SEPERATELY
  1427. // of CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNDER_SUBMISSION, *ppCertContext will be NULL.
  1428. // It is valid only if *pdwCAStatus==CRYPTUI_WIZ_CERT_REQUEST_STATUS_SUCCEEDED
  1429. //
  1430. // pdwCAStatus: Out Optional.
  1431. // The return status of the certificate authority cerver. The dwStatus can be one of
  1432. /// the following:
  1433. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_SUCCEEDED
  1434. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_ERROR
  1435. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_DENIED
  1436. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_ISSUED_SEPERATELY
  1437. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNDER_SUBMISSION
  1438. //------------------------------------------------------------------------
  1439. BOOL
  1440. WINAPI
  1441. CryptUIWizCertRequest(
  1442. IN DWORD dwFlags,
  1443. IN OPTIONAL HWND hwndParent,
  1444. IN OPTIONAL LPCWSTR pwszWizardTitle,
  1445. IN PCCRYPTUI_WIZ_CERT_REQUEST_INFO pCertRequestInfo,
  1446. OUT OPTIONAL PCCERT_CONTEXT *ppCertContext,
  1447. OUT OPTIONAL DWORD *pCAdwStatus
  1448. );
  1449. //-----------------------------------------------------------------------
  1450. //
  1451. // CryptUIWizCreateCertRequestNoDS
  1452. //
  1453. // Create a certificate request using the supplied parameters.
  1454. //
  1455. // dwFlags: IN Required.
  1456. // CRYPTUI_WIZ_NO_UI: must be set.
  1457. // CRYPTUI_WIZ_NO_INSTALL_ROOT: if set, the issued certificate chain will not
  1458. // be installed into the root store. Instead,
  1459. // it will be installed in the CA store.
  1460. // pCreateCertRequestInfo: IN Required
  1461. // A pointer to CRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO struct
  1462. //
  1463. // phRequest: OUT Required.
  1464. // A HANDLE to the created request. This HANDLE can be passed
  1465. // to CryptUIWizSubmitCertRequestNoDS(), and, of course, should not
  1466. // be used for any other purpose.
  1467. //
  1468. // Returns: TRUE if successful, FALSE otherwise. Get extended error information
  1469. // using GetLastError().
  1470. //
  1471. //------------------------------------------------------------------------
  1472. BOOL
  1473. WINAPI
  1474. CryptUIWizCreateCertRequestNoDS
  1475. (IN DWORD dwFlags,
  1476. IN HWND hwndParent,
  1477. IN PCCRYPTUI_WIZ_CREATE_CERT_REQUEST_INFO pCreateCertRequestInfo,
  1478. OUT HANDLE *phRequest
  1479. );
  1480. //-----------------------------------------------------------------------
  1481. //
  1482. // CryptUIWizSubmitCertRequestNoDS
  1483. //
  1484. // Request a certificate using a request created by CryptUIWizCreateCertRequestNoDS().
  1485. //
  1486. // hRequest: IN Required.
  1487. // A HANDLE to the request to submit. Must have been created through
  1488. // CryptUIWizCreateCertRequest().
  1489. //
  1490. // ppCertContext: OUT Required.
  1491. // The issued certificate. The certificate is in a memory store for remote enrollment.
  1492. // The certificate is in a system cert store for local enrollment.
  1493. //
  1494. // Even the function return TRUE, it does not mean the certificate is issued. Use should
  1495. // check for the *pdwCAStatus. If the status is CRYPTUI_WIZ_CERT_REQUEST_STATUS_ISSUED_SEPERATELY
  1496. // of CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNDER_SUBMISSION, *ppCertContext will be NULL.
  1497. // It is valid only if *pdwCAStatus==CRYPTUI_WIZ_CERT_REQUEST_STATUS_SUCCEEDED
  1498. //
  1499. // pdwCAStatus: Out Optional.
  1500. // The return status of the certificate authority cerver. The dwStatus can be one of
  1501. /// the following:
  1502. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_SUCCEEDED
  1503. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_ERROR
  1504. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_REQUEST_DENIED
  1505. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_ISSUED_SEPERATELY
  1506. // CRYPTUI_WIZ_CERT_REQUEST_STATUS_UNDER_SUBMISSION
  1507. //
  1508. // Returns: TRUE if the procedure executed without an error, FALSE otherwise. Check
  1509. // pdwStatus to verify that the certificate was issued. Get extended
  1510. // error information using GetLastError().
  1511. //
  1512. //------------------------------------------------------------------------
  1513. BOOL
  1514. WINAPI
  1515. CryptUIWizSubmitCertRequestNoDS
  1516. (IN HANDLE hRequest,
  1517. IN HWND hwndParent,
  1518. IN LPCWSTR pwszCAName,
  1519. IN LPCWSTR pwszCALocation,
  1520. OUT DWORD *pdwStatus,
  1521. OUT PCCERT_CONTEXT *ppCertContext // Optional
  1522. );
  1523. //------------------------------------------------------------------------
  1524. //
  1525. // CryptUIWizFreeCertRequestNoDS
  1526. //
  1527. // Frees a certificate request created by CryptUIWizCreateCertRequestNoDS().
  1528. //
  1529. // hRequest: IN Required.
  1530. // A HANDLE to the request to be freed.
  1531. //
  1532. //------------------------------------------------------------------------
  1533. void
  1534. WINAPI
  1535. CryptUIWizFreeCertRequestNoDS
  1536. (IN HANDLE hRequest);
  1537. //------------------------------------------------------------------------
  1538. //
  1539. // CryptUIWizQueryCertRequestNoDS
  1540. //
  1541. // Queries status information about a created request.
  1542. //
  1543. // hRequest: IN Required.
  1544. // A HANDLE to the request to be freed.
  1545. //
  1546. //------------------------------------------------------------------------
  1547. BOOL
  1548. WINAPI
  1549. CryptUIWizQueryCertRequestNoDS
  1550. (IN HANDLE hRequest, OUT CRYPTUI_WIZ_QUERY_CERT_REQUEST_INFO *pQueryInfo);
  1551. //-------------------------------------------------------------------------
  1552. //
  1553. // Valid values for dwSubjectChoice in IMPORT_SUBJECT_INFO
  1554. //-------------------------------------------------------------------------
  1555. #define CRYPTUI_WIZ_IMPORT_SUBJECT_FILE 1
  1556. #define CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT 2
  1557. #define CRYPTUI_WIZ_IMPORT_SUBJECT_CTL_CONTEXT 3
  1558. #define CRYPTUI_WIZ_IMPORT_SUBJECT_CRL_CONTEXT 4
  1559. #define CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_STORE 5
  1560. //-------------------------------------------------------------------------
  1561. //
  1562. // Struct to define the subject CertImportWizard
  1563. //
  1564. // CRYPTUI_WIZ_IMPORT_SUBJECT_INFO
  1565. //
  1566. //-------------------------------------------------------------------------
  1567. typedef struct _CRYPTUI_WIZ_IMPORT_SUBJECT_INFO
  1568. {
  1569. DWORD dwSize; //Required: should be set to sizeof(IMPORT_SUBJECT_INFO)
  1570. DWORD dwSubjectChoice; //Required: indicate the type of the subject:
  1571. // If can one of the following:
  1572. // CRYPTUI_WIZ_IMPORT_SUBJECT_FILE
  1573. // CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT
  1574. // CRYPTUI_WIZ_IMPORT_SUBJECT_CTL_CONTEXT
  1575. // CRYPTUI_WIZ_IMPORT_SUBJECT_CRL_CONTEXT
  1576. // CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_STORE
  1577. union
  1578. {
  1579. LPCWSTR pwszFileName;
  1580. PCCERT_CONTEXT pCertContext;
  1581. PCCTL_CONTEXT pCTLContext;
  1582. PCCRL_CONTEXT pCRLContext;
  1583. HCERTSTORE hCertStore;
  1584. };
  1585. DWORD dwFlags; //Required if pwszFileName contains a PFX BLOB.
  1586. //Ignored otherwise
  1587. //This is the same flag for PFXImportCertStore
  1588. LPCWSTR pwszPassword; //Required if pwszFileName contains a PFX BLOB.
  1589. //ignored otherwise
  1590. }CRYPTUI_WIZ_IMPORT_SRC_INFO, *PCRYPTUI_WIZ_IMPORT_SRC_INFO;
  1591. typedef const CRYPTUI_WIZ_IMPORT_SRC_INFO *PCCRYPTUI_WIZ_IMPORT_SRC_INFO;
  1592. //-----------------------------------------------------------------------
  1593. //
  1594. // Valid flags for dwFlags in CryptUIWizImport
  1595. //
  1596. //-----------------------------------------------------------------------
  1597. //if this flag is set in dwFlags, user will not be allowed to change
  1598. //the hDesCertStore in the wizard page
  1599. #define CRYPTUI_WIZ_IMPORT_NO_CHANGE_DEST_STORE 0x00010000
  1600. //Allow importing certificate
  1601. #define CRYPTUI_WIZ_IMPORT_ALLOW_CERT 0x00020000
  1602. //Allow importing certificate revocation list
  1603. #define CRYPTUI_WIZ_IMPORT_ALLOW_CRL 0x00040000
  1604. //Allow importing certificate trust list
  1605. #define CRYPTUI_WIZ_IMPORT_ALLOW_CTL 0x00080000
  1606. //import contents to local machine (currently only applicable for PFX imports)
  1607. #define CRYPTUI_WIZ_IMPORT_TO_LOCALMACHINE 0x00100000
  1608. //import contents to current user (currently only applicable for PFX imports)
  1609. #define CRYPTUI_WIZ_IMPORT_TO_CURRENTUSER 0x00200000
  1610. //if the hDesCertStore is a remote store handle, this flag should be set
  1611. #define CRYPTUI_WIZ_IMPORT_REMOTE_DEST_STORE 0x00400000
  1612. //-----------------------------------------------------------------------
  1613. //
  1614. // CryptUIWizImport
  1615. //
  1616. // The import wizard to import public key related files to a certificate
  1617. // store
  1618. //
  1619. // dwFlags can be set to any combination of the following flags:
  1620. // CRYPTUI_WIZ_NO_UI No UI will be shown. Otherwise, User will be
  1621. // prompted by a wizard.
  1622. // CRYPTUI_WIZ_IMPORT_ALLOW_CERT Allow importing certificate
  1623. // CRYPTUI_WIZ_IMPORT_ALLOW_CRL Allow importing CRL(certificate revocation list)
  1624. // CRYPTUI_WIZ_IMPORT_ALLOW_CTL Allow importing CTL(certificate trust list)
  1625. // CRYPTUI_WIZ_IMPORT_NO_CHANGE_DEST_STORE user will not be allowed to change
  1626. // the hDesCertStore in the wizard page
  1627. // CRYPTUI_WIZ_IMPORT_TO_LOCALMACHINE the contents should be imported to local machine
  1628. // (currently only applicable for PFX imports)
  1629. // CRYPTUI_WIZ_IMPORT_TO_CURRENTUSER the contents should be imported to current user
  1630. // (currently only applicable for PFX imports)
  1631. //
  1632. // Please notice that if neither of following three flags is in dwFlags, default to is
  1633. // allow everything.
  1634. // CRYPTUI_WIZ_IMPORT_ALLOW_CERT
  1635. // CRYPTUI_WIZ_IMPORT_ALLOW_CRL
  1636. // CRYPTUI_WIZ_IMPORT_ALLOW_CTL
  1637. //
  1638. // Also, note that the CRYPTUI_WIZ_IMPORT_TO_LOCALMACHINE and CRYPTUI_WIZ_IMPORT_TO_CURRENTUSER
  1639. // flags are used force the content of a pfx blob into either local machine or current user.
  1640. // If neither of these flags are used and hDesCertStore is NULL then:
  1641. // 1) The private key in the pfx blob will be forced to be imported into current user.
  1642. // 2) If CRYPTUI_WIZ_NO_UI is NOT set, the wizard will prompt the user to select a certificate
  1643. // store from the current user stores.
  1644. //
  1645. //
  1646. //
  1647. // If CRYPTUI_WIZ_NO_UI is set in dwFlags:
  1648. // hwndParent: Ignored
  1649. // pwszWizardTitle: Ignored
  1650. // pImportSubject: IN Required: The subject to import.
  1651. // hDesCertStore: IN Optional: The destination certficate store
  1652. //
  1653. // If CRYPTUI_WIZ_NO_UI is not set in dwFlags:
  1654. // hwndPrarent: IN Optional: The parent window for the wizard
  1655. // pwszWizardTitle: IN Optional: The title of the wizard
  1656. // If NULL, the default will be IDS_IMPORT_WIZARD_TITLE
  1657. // pImportSubject: IN Optional: The file name to import.
  1658. // If NULL, the wizard will prompt user to enter the file name
  1659. // hDesCertStore: IN Optional: The destination certificate store where the file wil be
  1660. // imported to. The store should be opened with
  1661. // flag CERT_STORE_SET_LOCALIZED_NAME_FLAG. If NULL, the wizard will prompt user to select
  1662. // a certificate store.
  1663. //------------------------------------------------------------------------
  1664. BOOL
  1665. WINAPI
  1666. CryptUIWizImport(
  1667. DWORD dwFlags,
  1668. HWND hwndParent,
  1669. LPCWSTR pwszWizardTitle,
  1670. PCCRYPTUI_WIZ_IMPORT_SRC_INFO pImportSrc,
  1671. HCERTSTORE hDestCertStore
  1672. );
  1673. //-------------------------------------------------------------------------
  1674. //
  1675. // Struct to define the information needed to build a new CTL
  1676. //
  1677. // CRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO
  1678. //
  1679. //
  1680. //-------------------------------------------------------------------------
  1681. typedef struct _CRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO
  1682. {
  1683. DWORD dwSize; //Required: should be set to sizeof(CRYPTUI_WIZ_BUILDCTL_NEW_CTL)
  1684. PCERT_ENHKEY_USAGE pSubjectUsage; //Optioanl: The purpose of the CTL
  1685. LPWSTR pwszListIdentifier; //Optional: The string to identify the CTL
  1686. LPCSTR pszSubjectAlgorithm; //Optional: The hashing algorithm.
  1687. // Currently, only SHA1 or MD5 hashing is supported
  1688. HCERTSTORE hCertStore; //Optional: The certificate in the CTL. Only the certificates
  1689. // with the enhanced key usage specified by pSubjectUsage
  1690. // will be included in the CTL
  1691. FILETIME NextUpdate; //Optional: The next update time of the CTL. If the value
  1692. // is more than 99 month from the current system time,
  1693. // the value will be ignored.
  1694. LPWSTR pwszFriendlyName; //Optional: The friendly name of the CTL
  1695. LPWSTR pwszDescription; //Optional: The description of the CTL
  1696. }CRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO, *PCRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO;
  1697. typedef const CRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO *PCCRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO;
  1698. //-------------------------------------------------------------------------
  1699. //
  1700. // Valid values for dwSourceChoice for CRYPTUI_WIZ_BUILDCTL_SRC_INFO
  1701. //-------------------------------------------------------------------------
  1702. #define CRYPTUI_WIZ_BUILDCTL_SRC_EXISTING_CTL 1
  1703. #define CRYPTUI_WIZ_BUILDCTL_SRC_NEW_CTL 2
  1704. //-------------------------------------------------------------------------
  1705. //
  1706. // Struct to define the source of certBuildCTL wizard
  1707. //
  1708. // CRYPTUI_WIZ_BUILDCTL_SRC_INFO
  1709. //
  1710. //
  1711. //-------------------------------------------------------------------------
  1712. typedef struct _CRYPTUI_WIZ_BUILDCTL_SRC_INFO
  1713. {
  1714. DWORD dwSize; //Required: should be set to sizeof(CRYPTUI_WIZ_BUILDCTL_SRC_INFO)
  1715. DWORD dwSourceChoice; //Required: indicate the source from which to build the CTL
  1716. // if can be one of the following:
  1717. // CRYPTUI_WIZ_BUILDCTL_SRC_EXISTING_CTL
  1718. // CRYPTUI_WIZ_BUILDCTL_SRC_NEW_CTL
  1719. union
  1720. {
  1721. PCCTL_CONTEXT pCTLContext; //Required if dwSourceChoice == CRYPTUI_WIZ_BUILDCTL_SRC_EXISTING_CTL
  1722. // An existing CTL based on which a new CTL is to be built
  1723. PCCRYPTUI_WIZ_BUILDCTL_NEW_CTL_INFO pNewCTLInfo; //Required if dwSourceChoise == CRYPTUI_WIZ_BUILDCTL_SRC_NEW_CTL
  1724. };
  1725. }CRYPTUI_WIZ_BUILDCTL_SRC_INFO, *PCRYPTUI_WIZ_BUILDCTL_SRC_INFO;
  1726. typedef const CRYPTUI_WIZ_BUILDCTL_SRC_INFO *PCCRYPTUI_WIZ_BUILDCTL_SRC_INFO;
  1727. //-------------------------------------------------------------------------
  1728. //
  1729. // Valid values for dwDestinationChoice for CRYPTUI_WIZ_BUILDCTL_DEST_INFO
  1730. //-------------------------------------------------------------------------
  1731. #define CRYPTUI_WIZ_BUILDCTL_DEST_CERT_STORE 1
  1732. #define CRYPTUI_WIZ_BUILDCTL_DEST_FILE 2
  1733. //-------------------------------------------------------------------------
  1734. //
  1735. // Struct to define the desination of certBuildCTL wizard
  1736. //
  1737. // CRYPTUI_WIZ_BUILDCTL_DEST_INFO
  1738. //
  1739. //
  1740. //-------------------------------------------------------------------------
  1741. typedef struct _CRYPTUI_WIZ_BUILDCTL_DEST_INFO
  1742. {
  1743. DWORD dwSize; //Required: should be set to sizeof(CRYPTUI_WIZ_BUILDCTL_DEST_INFO)
  1744. DWORD dwDestinationChoice; //Required: indicate the type of the desination:
  1745. // If can one of the following:
  1746. // CRYPTUI_WIZ_BUILDCTL_DEST_CERT_STORE
  1747. // CRYPTUI_WIZ_BUILDCTL_DEST_FILE
  1748. union
  1749. {
  1750. LPCWSTR pwszFileName;
  1751. HCERTSTORE hCertStore;
  1752. };
  1753. }CRYPTUI_WIZ_BUILDCTL_DEST_INFO, *PCRYPTUI_WIZ_BUILDCTL_DEST_INFO;
  1754. typedef const CRYPTUI_WIZ_BUILDCTL_DEST_INFO *PCCRYPTUI_WIZ_BUILDCTL_DEST_INFO;
  1755. //-----------------------------------------------------------------------
  1756. //
  1757. // CryptUIWizBuildCTL
  1758. //
  1759. // Build a new CTL or modify an existing CTL. The UI for wizard will
  1760. // always show in this case
  1761. //
  1762. //
  1763. // dwFlags: IN Optional: Can be set to the any combination of the following:
  1764. // CRYPTUI_WIZ_BUILDCTL_SKIP_DESTINATION.
  1765. // CRYPTUI_WIZ_BUILDCTL_SKIP_SIGNING
  1766. // CRYPTUI_WIZ_BUILDCTL_SKIP_PURPOSE
  1767. // hwndParnet: IN Optional: The parent window handle
  1768. // pwszWizardTitle: IN Optional: The title of the wizard
  1769. // If NULL, the default will be IDS_BUILDCTL_WIZARD_TITLE
  1770. // pBuildCTLSrc: IN Optional: The source from which the CTL will be built
  1771. // pBuildCTLDest: IN Optional: The desination where the newly
  1772. // built CTL will be stored
  1773. // ppCTLContext: OUT Optaionl: The newly build CTL
  1774. //
  1775. //------------------------------------------------------------------------
  1776. BOOL
  1777. WINAPI
  1778. CryptUIWizBuildCTL(
  1779. IN DWORD dwFlags,
  1780. IN OPTIONAL HWND hwndParent,
  1781. IN OPTIONAL LPCWSTR pwszWizardTitle,
  1782. IN OPTIONAL PCCRYPTUI_WIZ_BUILDCTL_SRC_INFO pBuildCTLSrc,
  1783. IN OPTIONAL PCCRYPTUI_WIZ_BUILDCTL_DEST_INFO pBuildCTLDest,
  1784. OUT OPTIONAL PCCTL_CONTEXT *ppCTLContext
  1785. );
  1786. //-------------------------------------------------------------------------
  1787. //
  1788. // Valid values for dwSubjectChoice in CRYPTUI_WIZ_EXPORT_INFO
  1789. //-------------------------------------------------------------------------
  1790. #define CRYPTUI_WIZ_EXPORT_CERT_CONTEXT 1
  1791. #define CRYPTUI_WIZ_EXPORT_CTL_CONTEXT 2
  1792. #define CRYPTUI_WIZ_EXPORT_CRL_CONTEXT 3
  1793. #define CRYPTUI_WIZ_EXPORT_CERT_STORE 4
  1794. #define CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY 5
  1795. //-------------------------------------------------------------------------
  1796. //
  1797. // Struct to define the object to be exported and where to export it to
  1798. //
  1799. // CRYPTUI_WIZ_EXPORT_SUBJECT_INFO
  1800. //
  1801. //-------------------------------------------------------------------------
  1802. typedef struct _CRYPTUI_WIZ_EXPORT_INFO
  1803. {
  1804. DWORD dwSize; //Required: should be set to sizeof(CRYPTUI_WIZ_EXPORT_INFO)
  1805. LPCWSTR pwszExportFileName; //Required if the CRYPTUI_WIZ_NO_UI flag is set, Optional otherwise.
  1806. //The fully qualified file name to export to, if this is
  1807. //non-NULL and the CRYPTUI_WIZ_NO_UI flag is NOT set, then it is
  1808. //displayed to the user as the default file name
  1809. DWORD dwSubjectChoice; //Required: indicate the type of the subject:
  1810. // If can one of the following:
  1811. // CRYPTUI_WIZ_EXPORT_CERT_CONTEXT
  1812. // CRYPTUI_WIZ_EXPORT_CTL_CONTEXT
  1813. // CRYPTUI_WIZ_EXPORT_CRL_CONTEXT
  1814. // CRYPTUI_WIZ_EXPORT_CERT_STORE
  1815. // CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY
  1816. union
  1817. {
  1818. PCCERT_CONTEXT pCertContext;
  1819. PCCTL_CONTEXT pCTLContext;
  1820. PCCRL_CONTEXT pCRLContext;
  1821. HCERTSTORE hCertStore;
  1822. };
  1823. DWORD cStores; // Optional: count of extra stores to search for the certs in the
  1824. // trust chain if the chain is being exported with a cert.
  1825. // this is ignored if dwSubjectChoice is anything other
  1826. // than CRYPTUI_WIZ_EXPORT_CERT_CONTEXT
  1827. HCERTSTORE * rghStores; // Optional: array of extra stores to search for the certs in the
  1828. // trust chain if the chain is being exported with a cert.
  1829. // this is ignored if dwSubjectChoice is anything other
  1830. // than CRYPTUI_WIZ_EXPORT_CERT_CONTEXT
  1831. }CRYPTUI_WIZ_EXPORT_INFO, *PCRYPTUI_WIZ_EXPORT_INFO;
  1832. typedef const CRYPTUI_WIZ_EXPORT_INFO *PCCRYPTUI_WIZ_EXPORT_INFO;
  1833. //-------------------------------------------------------------------------
  1834. //
  1835. // Valid values for dwExportFormat in CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO
  1836. //-------------------------------------------------------------------------
  1837. #define CRYPTUI_WIZ_EXPORT_FORMAT_DER 1
  1838. #define CRYPTUI_WIZ_EXPORT_FORMAT_PFX 2
  1839. #define CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7 3
  1840. #define CRYPTUI_WIZ_EXPORT_FORMAT_BASE64 4
  1841. #define CRYPTUI_WIZ_EXPORT_FORMAT_SERIALIZED_CERT_STORE 5 // NOTE: not currently supported!!
  1842. //-------------------------------------------------------------------------
  1843. //
  1844. // Struct to define the information needed to export a CERT_CONTEXT
  1845. //
  1846. // CRYPTUI_WIZ_EXPORT_NOUI_INFO
  1847. //
  1848. //-------------------------------------------------------------------------
  1849. typedef struct _CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO
  1850. {
  1851. DWORD dwSize; //Required: should be set to sizeof(CRYPTUI_WIZ_EXPORT_NOUI_INFO)
  1852. DWORD dwExportFormat; //Required:
  1853. // It can be one of the following:
  1854. // CRYPTUI_WIZ_EXPORT_FORMAT_DER
  1855. // CRYPTUI_WIZ_EXPORT_FORMAT_PFX
  1856. // CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7
  1857. // CRYPTUI_WIZ_EXPORT_FORMAT_SERIALIZED_CERT_STORE
  1858. BOOL fExportChain; //Required
  1859. BOOL fExportPrivateKeys; //Required
  1860. LPCWSTR pwszPassword; //Required if the fExportPrivateKeys boolean is TRUE, otherwise,
  1861. //it is ignored
  1862. BOOL fStrongEncryption; //Required if dwExportFormat is CRYPTUI_WIZ_EXPORT_FORMAT_PFX
  1863. //Note that if this flag is TRUE then the PFX blob produced is
  1864. //NOT compatible with IE4.
  1865. }CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO, *PCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO;
  1866. typedef const CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO *PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO;
  1867. //-----------------------------------------------------------------------
  1868. //
  1869. // CryptUIWizExport
  1870. //
  1871. // The export wizard to export public key related objects to a file
  1872. //
  1873. // If dwFlags is set to CRYPTUI_WIZ_NO_UI, no UI will be shown. Otherwise,
  1874. // User will be prompted for input through a wizard.
  1875. //
  1876. // If CRYPTUI_WIZ_NO_UI is set in dwFlags:
  1877. // hwndParent: Ignored
  1878. // pwszWizardTitle: Ignored
  1879. // pExportInfo: IN Required: The subject to export.
  1880. // pvoid: IN Required: Contains information about how to do the export based on what
  1881. // is being exported
  1882. //
  1883. // dwSubjectChoice INPUT TYPE
  1884. // -------------------------------------------------------------------------
  1885. // CRYPTUI_WIZ_EXPORT_CERT_CONTEXT PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO
  1886. // CRYPTUI_WIZ_EXPORT_CTL_CONTEXT NULL
  1887. // CRYPTUI_WIZ_EXPORT_CRL_CONTEXT NULL
  1888. // CRYPTUI_WIZ_EXPORT_CERT_STORE NULL
  1889. //
  1890. // If CRYPTUI_WIZ_NO_UI is not set in dwFlags:
  1891. // hwndPrarent: IN Optional: The parent window for the wizard
  1892. // pwszWizardTitle: IN Optional: The title of the wizard
  1893. // If NULL, the default will be IDS_EXPORT_WIZARD_TITLE
  1894. // pExportInfo: IN Required: The subject to export.
  1895. // pvoid: IN Optional: Contains information about how to do the export based on what
  1896. // is being exported. See above table for values, if this is non-NULL
  1897. // the values are displayed to the user as the default choices.
  1898. //------------------------------------------------------------------------
  1899. BOOL
  1900. WINAPI
  1901. CryptUIWizExport(
  1902. DWORD dwFlags,
  1903. HWND hwndParent,
  1904. LPCWSTR pwszWizardTitle,
  1905. PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo,
  1906. void *pvoid
  1907. );
  1908. #if (0) //DSIE: 7/02/2002 moved to CryptUIAPI.h per consent degree.
  1909. //-------------------------------------------------------------------------
  1910. //valid values for dwSubjectChoice in CRYPTUI_WIZ_DIGITAL_SIGN_INFO struct
  1911. //-------------------------------------------------------------------------
  1912. #define CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE 0x01
  1913. #define CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_BLOB 0x02
  1914. //-------------------------------------------------------------------------
  1915. //valid values for dwSigningCertChoice in CRYPTUI_WIZ_DIGITAL_SIGN_INFO struct
  1916. //-------------------------------------------------------------------------
  1917. #define CRYPTUI_WIZ_DIGITAL_SIGN_CERT 0x01
  1918. #define CRYPTUI_WIZ_DIGITAL_SIGN_STORE 0x02
  1919. #define CRYPTUI_WIZ_DIGITAL_SIGN_PVK 0x03
  1920. //-------------------------------------------------------------------------
  1921. //valid values for dwAddtionalCertChoice in CRYPTUI_WIZ_DIGITAL_SIGN_INFO struct
  1922. //-------------------------------------------------------------------------
  1923. //include the entire certificate trust chain in the signature
  1924. #define CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN 0x00000001
  1925. //include the entilre certificate trust chain, with the exception of the root
  1926. //certificate, in the signature
  1927. #define CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN_NO_ROOT 0x00000002
  1928. //-------------------------------------------------------------------------
  1929. //
  1930. // CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO
  1931. //
  1932. // dwSize IN Required: should be set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO)
  1933. // pGuidSubject IN Required: Idenfity the sip functions to load
  1934. // cbBlob IN Required: the size of BLOB, in bytes
  1935. // pbBlob IN Required: the pointer to the BLOB
  1936. // pwszDispalyName IN Optional: the display name of the BLOB to sign.
  1937. //-------------------------------------------------------------------------
  1938. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO
  1939. {
  1940. DWORD dwSize;
  1941. GUID *pGuidSubject;
  1942. DWORD cbBlob;
  1943. BYTE *pbBlob;
  1944. LPCWSTR pwszDisplayName;
  1945. }CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO;
  1946. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO;
  1947. //-------------------------------------------------------------------------
  1948. //
  1949. // CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO
  1950. //
  1951. // dwSize IN Required: should be set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO)
  1952. // cCertStore IN Required: The acount of certificate store array that includes potentical sining certs
  1953. // rghCertStore IN Required: The certificate store array that includes potential signing certs
  1954. // pFilterCallback IN Optional: The filter call back function for display the certificate
  1955. // pvCallbackData IN Optional: The call back data
  1956. //-------------------------------------------------------------------------
  1957. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO
  1958. {
  1959. DWORD dwSize;
  1960. DWORD cCertStore;
  1961. HCERTSTORE *rghCertStore;
  1962. PFNCFILTERPROC pFilterCallback;
  1963. void * pvCallbackData;
  1964. }CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO;
  1965. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO;
  1966. //-------------------------------------------------------------------------
  1967. //
  1968. // CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO
  1969. //
  1970. // dwSize IN Required: should be set to sizeof(CRYPT_WIZ_DIGITAL_SIGN_PVK_FILE_INFO)
  1971. // pwszPvkFileName IN Required: the PVK file name
  1972. // pwszProvName IN Required: the provider name
  1973. // dwProvType IN Required: the provider type
  1974. //
  1975. //-------------------------------------------------------------------------
  1976. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO
  1977. {
  1978. DWORD dwSize;
  1979. LPWSTR pwszPvkFileName;
  1980. LPWSTR pwszProvName;
  1981. DWORD dwProvType;
  1982. }CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO;
  1983. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO;
  1984. //-------------------------------------------------------------------------
  1985. //
  1986. // valid values for dwPvkChoice in CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO struct
  1987. //-------------------------------------------------------------------------
  1988. #define CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE 0x01
  1989. #define CRYPTUI_WIZ_DIGITAL_SIGN_PVK_PROV 0x02
  1990. //-------------------------------------------------------------------------
  1991. //
  1992. // CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO
  1993. //
  1994. // dwSize IN Required: should be set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO)
  1995. // pwszSigningCertFileName IN Required: the file name that contains the signing cert(s)
  1996. // dwPvkChoice IN Required: Indicate the private key type:
  1997. // It can be one of the following:
  1998. // CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE
  1999. // CRYPTUI_WIZ_DIGITAL_SIGN_PVK_PROV
  2000. // pPvkFileInfo IN Required if dwPvkChoice == CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE
  2001. // pPvkProvInfo IN Required if dwPvkContainer== CRYPTUI_WIZ_DIGITAL_SIGN_PVK_PROV
  2002. //
  2003. //-------------------------------------------------------------------------
  2004. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO
  2005. {
  2006. DWORD dwSize;
  2007. LPWSTR pwszSigningCertFileName;
  2008. DWORD dwPvkChoice;
  2009. union
  2010. {
  2011. PCCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO pPvkFileInfo;
  2012. PCRYPT_KEY_PROV_INFO pPvkProvInfo;
  2013. };
  2014. }CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO;
  2015. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO;
  2016. //-------------------------------------------------------------------------
  2017. //
  2018. // valid values for dwAttrFlags in CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO struct
  2019. //-------------------------------------------------------------------------
  2020. #define CRYPTUI_WIZ_DIGITAL_SIGN_COMMERCIAL 0x0001
  2021. #define CRYPTUI_WIZ_DIGITAL_SIGN_INDIVIDUAL 0x0002
  2022. //-------------------------------------------------------------------------
  2023. //
  2024. // CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO
  2025. //
  2026. // dwSize IN Required: should be set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO)
  2027. // dwAttrFlags IN Required: Flag to indicate signing options.
  2028. // It can be one of the following:
  2029. // CRYPTUI_WIZ_DIGITAL_SIGN_COMMERCIAL
  2030. // CRYPTUI_WIZ_DIGITAL_SIGN_INDIVIDUAL
  2031. // pwszDescription IN Optional: The description of the signing subject
  2032. // pwszMoreInfoLocation IN Optional: the localtion to get more information about file
  2033. // this information will be shown upon download time
  2034. // pszHashAlg IN Optional: the hashing algorithm for the signature
  2035. // NULL means using SHA1 hashing algorithm
  2036. // pwszSigningCertDisplayString IN Optional: The display string to be displayed on the
  2037. // signing certificate wizard page. The string should
  2038. // prompt user to select a certificate for a particular purpose
  2039. // hAddtionalCertStores IN Optional: the addtional cert store to add to the signature
  2040. // psAuthenticated IN Optional: user supplied authenticated attributes added to the signature
  2041. // psUnauthenticated IN Optional: user supplied unauthenticated attributes added to the signature
  2042. //
  2043. //-------------------------------------------------------------------------
  2044. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO
  2045. {
  2046. DWORD dwSize;
  2047. DWORD dwAttrFlags;
  2048. LPCWSTR pwszDescription;
  2049. LPCWSTR pwszMoreInfoLocation;
  2050. LPCSTR pszHashAlg;
  2051. LPCWSTR pwszSigningCertDisplayString;
  2052. HCERTSTORE hAdditionalCertStore;
  2053. PCRYPT_ATTRIBUTES psAuthenticated;
  2054. PCRYPT_ATTRIBUTES psUnauthenticated;
  2055. }CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO;
  2056. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO;
  2057. //-------------------------------------------------------------------------
  2058. //
  2059. //
  2060. // CRYPTUI_WIZ_DIGITAL_SIGN_INFO
  2061. //
  2062. // dwSize IN Required: Has to be set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_INFO)
  2063. // dwSubjectChoice IN Required if CRYPTUI_WIZ_NO_UI is set in dwFlags of the CryptUIWizDigitalSigning, :
  2064. // Optional if CRYPTUI_WIZ_NO_UI is not set in dwFlags of the CryptUIWizDigitalSigning
  2065. // Indicate whether to sign a file or to sign a memory BLOB.
  2066. // 0 means promting user for the file to sign
  2067. // It can be one of the following:
  2068. // CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE
  2069. // CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_BLOB
  2070. //
  2071. //
  2072. //pwszFileName IN Required if dwSubjectChoice==CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE
  2073. //pSignBlobInfo IN Required if dwSubhectChoice==CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_BLOB
  2074. //
  2075. //dwSigningCertChoice IN Optional: Indicate the signing certificate.
  2076. // 0 means using the certificates in "My" store"
  2077. // It can be one of the following choices:
  2078. // CRYPTUI_WIZ_DIGITAL_SIGN_CERT
  2079. // CRYPTUI_WIZ_DIGITAL_SIGN_STORE
  2080. // CRYPTUI_WIZ_DIGITAL_SIGN_PVK
  2081. // If CRYPTUI_WIZ_NO_UI is set in dwFlags of the CryptUIWizDigitalSigning,
  2082. // dwSigningCertChoice has to be CRYPTUI_WIZ_DIGITAL_SIGN_CERT or
  2083. // CRYPTUI_WIZ_DIGITAL_SIGN_PVK
  2084. //
  2085. //pSigningCertContext IN Required if dwSigningCertChoice==CRYPTUI_WIZ_DIGITAL_SIGN_CERT
  2086. //pSigningCertStore IN Required if dwSigningCertChoice==CRYPTUI_WIZ_DIGITAL_SIGN_STORE
  2087. //pSigningCertPvkInfo IN Required if dwSigningCertChoise==CRYPTUI_WIZ_DIGITAL_SIGN_PVK
  2088. //
  2089. //pwszTimestampURL IN Optional: The timestamp URL address
  2090. //
  2091. //dwAdditionalCertChoice IN Optional: Indicate additional certificates to be included in the signature. //
  2092. // 0 means no addtional certificates will be added
  2093. // The following flags are mutually exclusive.
  2094. // Only one of them can be set:
  2095. // CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN
  2096. // CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN_NO_ROOT
  2097. //
  2098. //
  2099. //pSignExtInfo IN Optional: The extended information for signing
  2100. //
  2101. //-------------------------------------------------------------------------
  2102. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_INFO
  2103. {
  2104. DWORD dwSize;
  2105. DWORD dwSubjectChoice;
  2106. union
  2107. {
  2108. LPCWSTR pwszFileName;
  2109. PCCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO pSignBlobInfo;
  2110. };
  2111. DWORD dwSigningCertChoice;
  2112. union
  2113. {
  2114. PCCERT_CONTEXT pSigningCertContext;
  2115. PCCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO pSigningCertStore;
  2116. PCCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO pSigningCertPvkInfo;
  2117. };
  2118. LPCWSTR pwszTimestampURL;
  2119. DWORD dwAdditionalCertChoice;
  2120. PCCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO pSignExtInfo;
  2121. }CRYPTUI_WIZ_DIGITAL_SIGN_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_INFO;
  2122. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_INFO;
  2123. //-------------------------------------------------------------------------
  2124. //
  2125. // CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT
  2126. //
  2127. // dwSize set to sizeof(CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT)
  2128. // cbBlob the size of pbBlob. In bytes
  2129. // pbBlob the signed BLOB
  2130. //-------------------------------------------------------------------------
  2131. typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT
  2132. {
  2133. DWORD dwSize;
  2134. DWORD cbBlob;
  2135. BYTE *pbBlob;
  2136. }CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT, *PCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT;
  2137. typedef const CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT *PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT;
  2138. //-----------------------------------------------------------------------
  2139. //
  2140. // CryptUIWizDigitalSign
  2141. //
  2142. // The wizard to digitally sign a document or a BLOB.
  2143. //
  2144. // If CRYPTUI_WIZ_NO_UI is set in dwFlags, no UI will be shown. Otherwise,
  2145. // User will be prompted for input through a wizard.
  2146. //
  2147. // dwFlags: IN Required:
  2148. // hwndParnet: IN Optional: The parent window handle
  2149. // pwszWizardTitle: IN Optional: The title of the wizard
  2150. // If NULL, the default will be IDS_DIGITAL_SIGN_WIZARD_TITLE
  2151. // pDigitalSignInfo: IN Required: The information about the signing process
  2152. // ppSignContext OUT Optional: The context pointer points to the signed BLOB
  2153. //------------------------------------------------------------------------
  2154. BOOL
  2155. WINAPI
  2156. CryptUIWizDigitalSign(
  2157. IN DWORD dwFlags,
  2158. IN OPTIONAL HWND hwndParent,
  2159. IN OPTIONAL LPCWSTR pwszWizardTitle,
  2160. IN PCCRYPTUI_WIZ_DIGITAL_SIGN_INFO pDigitalSignInfo,
  2161. OUT OPTIONAL PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT *ppSignContext);
  2162. BOOL
  2163. WINAPI
  2164. CryptUIWizFreeDigitalSignContext(
  2165. IN PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT pSignContext);
  2166. #endif
  2167. //-------------------------------------------------------------------------
  2168. //valid values for dwPageChoice in CRYPTUI_WIZ_SIGN_GET_PAGE_INFO
  2169. //-------------------------------------------------------------------------
  2170. #define CRYPTUI_WIZ_DIGITAL_SIGN_TYPICAL_SIGNING_OPTION_PAGES 0x0001
  2171. #define CRYPTUI_WIZ_DIGITAL_SIGN_MINIMAL_SIGNING_OPTION_PAGES 0x0002
  2172. #define CRYPTUI_WIZ_DIGITAL_SIGN_CUSTOM_SIGNING_OPTION_PAGES 0x0004
  2173. #define CRYPTUI_WIZ_DIGITAL_SIGN_ALL_SIGNING_OPTION_PAGES 0x0008
  2174. #define CRYPTUI_WIZ_DIGITAL_SIGN_WELCOME_PAGE 0x0100
  2175. #define CRYPTUI_WIZ_DIGITAL_SIGN_FILE_NAME_PAGE 0x0200
  2176. #define CRYPTUI_WIZ_DIGITAL_SIGN_CONFIRMATION_PAGE 0x0400
  2177. //-------------------------------------------------------------------------
  2178. //
  2179. // CRYPTUI_WIZ_SIGN_GET_PAGE_INFO
  2180. //
  2181. // dwSize IN Required: should be set to sizeof(CRYPTUI_WIZ_SIGN_GET_PAGE_INFO)
  2182. // dwPageChoice: IN Required: It should one of the following:
  2183. // CRYPTUI_WIZ_DIGITAL_SIGN_ALL_SIGNING_OPTION_PAGES
  2184. // CRYPTUI_WIZ_DIGITAL_SIGN_TYPICAL_SIGNING_OPTION_PAGES
  2185. // CRYPTUI_WIZ_DIGITAL_SIGN_MINIMAL_SIGNING_OPTION_PAGES
  2186. // CRYPTUI_WIZ_DIGITAL_SIGN_CUSTOM_SIGNING_OPTION_PAGES
  2187. // It can also be ORed with any of the following:
  2188. // CRYPTUI_WIZ_DIGITAL_SIGN_WELCOME_PAGE
  2189. // CRYPTUI_WIZ_DIGITAL_SIGN_CONFIRMATION_PAGE
  2190. // CRYPTUI_WIZ_DIGITAL_SIGN_FILE_NAME_PAGE
  2191. // If user tries to sign a BLOB, CRYPTUI_WIZ_DIGITAL_SIGN_FILE_NAME_PAGE
  2192. // should not be set
  2193. // dwFlags; IN Optional: Flags and has to be set to 0
  2194. // hwndParent IN Optional: The parent window of the dialogue
  2195. // pwszPageTitle IN Optional: The title for the pages and the message boxes.
  2196. // pDigitalSignInfo IN Optional: the addtional information for signing
  2197. // pPropPageCallback IN Optional: this callback will be called when each page that is
  2198. // returned in the CryptUIGetViewSignaturesPages call
  2199. // is about to be created or destroyed. if this is NULL no
  2200. // callback is made.
  2201. // pvCallbackData IN Optional: this is uniterpreted data that is passed back when the
  2202. // when pPropPageCallback is made
  2203. // fResult OUT: The result of signing
  2204. // dwError OUT: The value of GetLastError() if fResult is FALSE
  2205. // pSignContext OUT: The context pointer to the signed BLOB. User needs to free
  2206. // the blob by CryptUIWizDigitalSignFreeContext
  2207. // dwReserved Reserved: The private data used by the signing process.
  2208. // must be set to NULL
  2209. // pvSignReserved Reserved: The private data used by the signing process
  2210. // must be set to NULL
  2211. //-------------------------------------------------------------------------
  2212. typedef struct _CRYPTUI_WIZ_GET_SIGN_PAGE_INFO
  2213. {
  2214. DWORD dwSize;
  2215. DWORD dwPageChoice;
  2216. DWORD dwFlags;
  2217. HWND hwndParent;
  2218. LPWSTR pwszPageTitle;
  2219. PCCRYPTUI_WIZ_DIGITAL_SIGN_INFO pDigitalSignInfo;
  2220. PFNCPROPPAGECALLBACK pPropPageCallback;
  2221. void * pvCallbackData;
  2222. BOOL fResult;
  2223. DWORD dwError;
  2224. PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT pSignContext;
  2225. DWORD dwReserved;
  2226. void *pvSignReserved;
  2227. }CRYPTUI_WIZ_GET_SIGN_PAGE_INFO, *PCRYPTUI_WIZ_GET_SIGN_PAGE_INFO;
  2228. typedef const CRYPTUI_WIZ_GET_SIGN_PAGE_INFO *PCCRYPTUI_WIZ_GET_SIGN_PAGE_INFO;
  2229. //-----------------------------------------------------------------------
  2230. //
  2231. // CryptUIWizGetDigitalSignPages
  2232. //
  2233. // Get specific wizard pages from the CryptUIWizDigitalSign wizard.
  2234. // Application can include the pages to other wizards. The pages will
  2235. // gather user inputs throught the new "Parent" wizard.
  2236. // After user clicks the finish buttion, signing process will start the signing
  2237. // and return the result in fResult and dwError field of CRYPTUI_WIZ_SIGN_GET_PAGE_INFO
  2238. // struct. If not enough information can be gathered through the wizard pages,
  2239. // user should supply addtional information in pSignGetPageInfo.
  2240. //
  2241. //
  2242. // pSignGetPageInfo IN Required: The struct that user allocate. It can be used
  2243. // to supply additinal information which is not gathered
  2244. // from the selected wizard pages
  2245. // prghPropPages, OUT Required: The wizard pages returned. Please
  2246. // notice the pszTitle of the struct is set to NULL
  2247. // pcPropPages OUT Required: The number of wizard pages returned
  2248. //------------------------------------------------------------------------
  2249. BOOL
  2250. WINAPI
  2251. CryptUIWizGetDigitalSignPages(
  2252. IN PCRYPTUI_WIZ_GET_SIGN_PAGE_INFO pSignGetPageInfo,
  2253. OUT PROPSHEETPAGEW **prghPropPages,
  2254. OUT DWORD *pcPropPages);
  2255. BOOL
  2256. WINAPI
  2257. CryptUIWizFreeDigitalSignPages(
  2258. IN PROPSHEETPAGEW *rghPropPages,
  2259. IN DWORD cPropPages
  2260. );
  2261. DWORD
  2262. WINAPI
  2263. I_CryptUIProtect(
  2264. IN PVOID pvReserved1,
  2265. IN PVOID pvReserved2,
  2266. IN DWORD dwReserved3,
  2267. IN PVOID *pvReserved4,
  2268. IN BOOL fReserved5,
  2269. IN PVOID pvReserved6
  2270. );
  2271. DWORD
  2272. WINAPI
  2273. I_CryptUIProtectFailure(
  2274. IN PVOID pvReserved1,
  2275. IN DWORD dwReserved2,
  2276. IN PVOID *pvReserved3);
  2277. #include <poppack.h>
  2278. #ifdef __cplusplus
  2279. } // Balance extern "C" above
  2280. #endif
  2281. #endif // _CRYPTUI_H_