Source code of Windows XP (NT5)
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.

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