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

1334 lines
46 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: cenroll.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // CEnroll.h : Declaration of the CCEnroll
  11. #ifndef __CENROLL_H_
  12. #define __CENROLL_H_
  13. #include <objsafe.h>
  14. #include "resource.h" // main symbols
  15. extern HINSTANCE hInstanceXEnroll;
  16. #define MAX_SAFE_FOR_SCRIPTING_REQUEST_STORE_COUNT 500
  17. typedef enum _StoreType {
  18. StoreNONE,
  19. StoreMY,
  20. StoreCA,
  21. StoreROOT,
  22. StoreREQUEST
  23. } StoreType;
  24. typedef struct _StoreInfo {
  25. LPWSTR wszName;
  26. LPSTR szType;
  27. DWORD dwFlags;
  28. HCERTSTORE hStore;
  29. } STOREINFO, *PSTOREINFO;
  30. typedef struct _EXT_STACK {
  31. CERT_EXTENSION ext;
  32. struct _EXT_STACK * pNext;
  33. } EXT_STACK, * PEXT_STACK;
  34. typedef struct _ATTR_STACK {
  35. CRYPT_ATTRIBUTE attr;
  36. struct _ATTR_STACK * pNext;
  37. } ATTR_STACK, * PATTR_STACK;
  38. typedef struct _PROP_STACK {
  39. LONG lPropId;
  40. LONG lFlags;
  41. CRYPT_DATA_BLOB prop;
  42. struct _PROP_STACK * pNext;
  43. } PROP_STACK, * PPROP_STACK;
  44. // Interface for a generic certificate context filter, currently used
  45. // filter enumerations of the certificate store.
  46. class CertContextFilter {
  47. public:
  48. // Returns S_OK on success, and assigns the out parameter.
  49. // The out parameter is TRUE if the cert context should be present in its enumeration,
  50. // FALSE if it should be filtered out. On error, the value of the out parameter is
  51. // undefined.
  52. virtual HRESULT accept(IN PCCERT_CONTEXT pCertContext, OUT BOOL * fResult) = 0;
  53. };
  54. class CompositeCertContextFilter : public CertContextFilter {
  55. CertContextFilter * filter1, * filter2;
  56. public:
  57. CompositeCertContextFilter(CertContextFilter * _filter1, CertContextFilter * _filter2) {
  58. filter1 = _filter1;
  59. filter2 = _filter2;
  60. }
  61. virtual HRESULT accept(IN PCCERT_CONTEXT pCertContext, OUT BOOL * fResult)
  62. {
  63. HRESULT hr = S_OK;
  64. *fResult = TRUE;
  65. // Note: do not do input validation, as that could lead to a change in the behavior
  66. // of the filters composed.
  67. if (filter1 == NULL || S_OK == (hr = filter1->accept(pCertContext, fResult)))
  68. {
  69. if (*fResult && (filter2 != NULL) )
  70. { hr = filter2->accept(pCertContext, fResult); }
  71. }
  72. return hr;
  73. }
  74. };
  75. // Extension of the base certificate context filter. Filters out all certificate contexts
  76. // with different hash values.
  77. class EquivalentHashCertContextFilter : public CertContextFilter {
  78. public:
  79. EquivalentHashCertContextFilter(CRYPT_DATA_BLOB hashBlob) : m_hashBlob(hashBlob) { }
  80. virtual HRESULT accept(IN PCCERT_CONTEXT pCertContext, OUT BOOL * fResult)
  81. {
  82. BOOL fFreeBuffer = FALSE, fDone = FALSE;
  83. BYTE buffer[30];
  84. CRYPT_DATA_BLOB hashBlob;
  85. HRESULT hr = S_OK;
  86. // Input validation:
  87. if (pCertContext == NULL) { return E_INVALIDARG; }
  88. hashBlob.cbData = 30;
  89. hashBlob.pbData = buffer;
  90. do {
  91. if (!CertGetCertificateContextProperty
  92. (pCertContext,
  93. CERT_HASH_PROP_ID,
  94. (LPVOID)(hashBlob.pbData),
  95. &(hashBlob.cbData)))
  96. {
  97. // We need to allocate a bigger buffer for our OUT param:
  98. if (ERROR_MORE_DATA == GetLastError())
  99. {
  100. hashBlob.pbData = (LPBYTE)LocalAlloc(LPTR, hashBlob.cbData);
  101. if (NULL == hashBlob.pbData)
  102. {
  103. hr = E_OUTOFMEMORY;
  104. goto ErrorReturn;
  105. }
  106. fFreeBuffer = TRUE;
  107. }
  108. else
  109. {
  110. hr = HRESULT_FROM_WIN32(GetLastError());
  111. goto ErrorReturn;
  112. }
  113. }
  114. else
  115. {
  116. fDone = TRUE;
  117. }
  118. } while (!fDone);
  119. // We have the same hashes if they are the same size and contain the same data.
  120. *fResult = (hashBlob.cbData == m_hashBlob.cbData &&
  121. 0 == memcmp(hashBlob.pbData, m_hashBlob.pbData, hashBlob.cbData));
  122. CommonReturn:
  123. if (fFreeBuffer) { LocalFree(hashBlob.pbData); }
  124. return hr;
  125. ErrorReturn:
  126. goto CommonReturn;
  127. }
  128. private:
  129. CRYPT_DATA_BLOB m_hashBlob;
  130. };
  131. // Extension of the base certificate context filter. Filters out all certificate contexts
  132. // which are not pending.
  133. class PendingCertContextFilter : public CertContextFilter {
  134. public:
  135. virtual HRESULT accept(IN PCCERT_CONTEXT pCertContext, OUT BOOL * fResult)
  136. {
  137. BOOL fFreeBuffer = FALSE, fDone = FALSE;
  138. BYTE buffer[100];
  139. CRYPT_DATA_BLOB pendingInfoBlob;
  140. HRESULT hr = S_OK;
  141. // Input validation:
  142. if (pCertContext == NULL) { return E_INVALIDARG; }
  143. pendingInfoBlob.cbData = 100;
  144. pendingInfoBlob.pbData = buffer;
  145. do {
  146. if (!CertGetCertificateContextProperty
  147. (pCertContext,
  148. CERT_ENROLLMENT_PROP_ID,
  149. (LPVOID)(pendingInfoBlob.pbData),
  150. &(pendingInfoBlob.cbData)))
  151. {
  152. switch (GetLastError()) {
  153. case CRYPT_E_NOT_FOUND:
  154. // The cert doesn't have this property, it can't be pending.
  155. *fResult = FALSE;
  156. fDone = TRUE;
  157. break;
  158. case ERROR_MORE_DATA:
  159. // Our output buffer wasn't big enough. Reallocate and try again...
  160. pendingInfoBlob.pbData = (LPBYTE)LocalAlloc(LPTR, pendingInfoBlob.cbData);
  161. if (NULL == pendingInfoBlob.pbData)
  162. {
  163. hr = E_OUTOFMEMORY;
  164. goto ErrorReturn;
  165. }
  166. fFreeBuffer = TRUE;
  167. break;
  168. default:
  169. // Oops, an error
  170. hr = HRESULT_FROM_WIN32(GetLastError());
  171. goto ErrorReturn;
  172. }
  173. }
  174. else
  175. {
  176. // No error, cert must have this property.
  177. *fResult = TRUE;
  178. fDone = TRUE;
  179. }
  180. } while (!fDone);
  181. CommonReturn:
  182. if (fFreeBuffer) { LocalFree(pendingInfoBlob.pbData); }
  183. return hr;
  184. ErrorReturn:
  185. goto CommonReturn;
  186. }
  187. };
  188. class PendingRequestTable {
  189. private:
  190. //
  191. // Auxiliary class definitions:
  192. //
  193. typedef struct _TableElem {
  194. PCCERT_CONTEXT pCertContext;
  195. } TableElem;
  196. public:
  197. //
  198. // Public interface:
  199. //
  200. PendingRequestTable();
  201. ~PendingRequestTable();
  202. HRESULT construct(HCERTSTORE hStore);
  203. DWORD size() { return this->dwElemCount; }
  204. PCCERT_CONTEXT & operator[] (DWORD dwElem) { return this->table[dwElem].pCertContext; }
  205. private:
  206. HRESULT add (TableElem tePendingRequest);
  207. HRESULT resize (DWORD dwNewSize);
  208. DWORD dwElemCount;
  209. DWORD dwElemSize;
  210. TableElem *table;
  211. };
  212. // General procedure for providing a filtered iteration of certificates in a store.
  213. // Excepting its ability to filter, behaves in the same manner as
  214. // CertEnumCertificatesInStore().
  215. HRESULT FilteredCertEnumCertificatesInStore(HCERTSTORE hStore,
  216. PCCERT_CONTEXT pCertContext,
  217. CertContextFilter *pFilter,
  218. PCCERT_CONTEXT *pCertContextNext);
  219. #define XENROLL_PASS_THRU_PROP_ID (CERT_FIRST_USER_PROP_ID + 0x100)
  220. #define XENROLL_RENEWAL_CERTIFICATE_PROP_ID (CERT_FIRST_USER_PROP_ID + 0x101)
  221. #define XENROLL_REQUEST_INFO ((LPCSTR) 400)
  222. /////////////////////////////////////////////////////////////////////////////
  223. // CCEnroll
  224. class ATL_NO_VTABLE CCEnroll : IEnroll4,
  225. public CComObjectRootEx<CComSingleThreadModel>,
  226. public CComCoClass<CCEnroll, &CLSID_CEnroll2>,
  227. public IDispatchImpl<ICEnroll4, &IID_ICEnroll4, &LIBID_XENROLLLib>,
  228. public IObjectSafety
  229. {
  230. public:
  231. DECLARE_REGISTRY_RESOURCEID(IDR_CENROLL)
  232. BEGIN_COM_MAP(CCEnroll)
  233. COM_INTERFACE_ENTRY(IEnroll)
  234. COM_INTERFACE_ENTRY(IEnroll2)
  235. COM_INTERFACE_ENTRY(IEnroll4)
  236. COM_INTERFACE_ENTRY(ICEnroll)
  237. COM_INTERFACE_ENTRY(ICEnroll2)
  238. COM_INTERFACE_ENTRY(ICEnroll3)
  239. COM_INTERFACE_ENTRY(ICEnroll4)
  240. COM_INTERFACE_ENTRY(IDispatch)
  241. COM_INTERFACE_ENTRY(IObjectSafety)
  242. END_COM_MAP()
  243. // ICEnroll
  244. public:
  245. CCEnroll();
  246. virtual ~CCEnroll();
  247. virtual HRESULT __stdcall GetInterfaceSafetyOptions(
  248. /* [in] */ REFIID riid,
  249. /* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
  250. /* [out] */ DWORD __RPC_FAR *pdwEnabledOptions);
  251. virtual HRESULT __stdcall SetInterfaceSafetyOptions(
  252. /* [in] */ REFIID riid,
  253. /* [in] */ DWORD dwOptionSetMask,
  254. /* [in] */ DWORD dwEnabledOptions);
  255. virtual HRESULT STDMETHODCALLTYPE createFilePKCS10(
  256. /* [in] */ BSTR DNName,
  257. /* [in] */ BSTR Usage,
  258. /* [in] */ BSTR wszPKCS10FileName);
  259. virtual HRESULT STDMETHODCALLTYPE acceptFilePKCS7(
  260. /* [in] */ BSTR wszPKCS7FileName);
  261. virtual HRESULT STDMETHODCALLTYPE getCertFromPKCS7(
  262. /* [in] */ BSTR wszPKCS7,
  263. /* [retval][out] */ BSTR __RPC_FAR *pbstrCert);
  264. virtual HRESULT STDMETHODCALLTYPE createPKCS10(
  265. /* [in] */ BSTR DNName,
  266. /* [in] */ BSTR Usage,
  267. /* [retval][out] */ BSTR __RPC_FAR *pPKCS10);
  268. virtual HRESULT STDMETHODCALLTYPE acceptPKCS7(
  269. /* [in] */ BSTR PKCS7);
  270. virtual HRESULT STDMETHODCALLTYPE enumProviders(
  271. /* [in] */ LONG dwIndex,
  272. /* [in] */ LONG dwFlags,
  273. /* [out][retval] */ BSTR __RPC_FAR *pbstrProvName);
  274. virtual HRESULT STDMETHODCALLTYPE enumContainers(
  275. /* [in] */ LONG dwIndex,
  276. /* [out][retval] */ BSTR __RPC_FAR *pbstr);
  277. virtual HRESULT STDMETHODCALLTYPE addCertTypeToRequest(
  278. /* [in] */ BSTR CertType);
  279. virtual HRESULT STDMETHODCALLTYPE addNameValuePairToSignature(
  280. /* [in] */ BSTR Name,
  281. /* [in] */ BSTR Value);
  282. virtual HRESULT STDMETHODCALLTYPE freeRequestInfo(
  283. /* [in] */ BSTR PKCS7OrPKCS10);
  284. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MyStoreName(
  285. /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
  286. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MyStoreName(
  287. /* [in] */ BSTR bstrName);
  288. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MyStoreType(
  289. /* [retval][out] */ BSTR __RPC_FAR *pbstrType);
  290. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MyStoreType(
  291. /* [in] */ BSTR bstrType);
  292. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MyStoreFlags(
  293. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  294. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MyStoreFlags(
  295. /* [in] */ LONG dwFlags);
  296. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CAStoreName(
  297. /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
  298. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CAStoreName(
  299. /* [in] */ BSTR bstrName);
  300. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CAStoreType(
  301. /* [retval][out] */ BSTR __RPC_FAR *pbstrType);
  302. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CAStoreType(
  303. /* [in] */ BSTR bstrType);
  304. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CAStoreFlags(
  305. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  306. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CAStoreFlags(
  307. /* [in] */ LONG dwFlags);
  308. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootStoreName(
  309. /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
  310. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootStoreName(
  311. /* [in] */ BSTR bstrName);
  312. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootStoreType(
  313. /* [retval][out] */ BSTR __RPC_FAR *pbstrType);
  314. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootStoreType(
  315. /* [in] */ BSTR bstrType);
  316. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootStoreFlags(
  317. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  318. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootStoreFlags(
  319. /* [in] */ LONG dwFlags);
  320. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RequestStoreName(
  321. /* [retval][out] */ BSTR __RPC_FAR *pbstrName);
  322. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RequestStoreName(
  323. /* [in] */ BSTR bstrName);
  324. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RequestStoreType(
  325. /* [retval][out] */ BSTR __RPC_FAR *pbstrType);
  326. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RequestStoreType(
  327. /* [in] */ BSTR bstrType);
  328. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RequestStoreFlags(
  329. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  330. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RequestStoreFlags(
  331. /* [in] */ LONG dwFlags);
  332. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ContainerName(
  333. /* [retval][out] */ BSTR __RPC_FAR *pbstrContainer);
  334. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ContainerName(
  335. /* [in] */ BSTR bstrContainer);
  336. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProviderName(
  337. /* [retval][out] */ BSTR __RPC_FAR *pbstrProvider);
  338. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ProviderName(
  339. /* [in] */ BSTR bstrProvider);
  340. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProviderType(
  341. /* [retval][out] */ LONG __RPC_FAR *pdwType);
  342. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ProviderType(
  343. /* [in] */ LONG dwType);
  344. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_KeySpec(
  345. /* [retval][out] */ LONG __RPC_FAR *pdw);
  346. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_KeySpec(
  347. /* [in] */ LONG dw);
  348. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProviderFlags(
  349. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  350. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ProviderFlags(
  351. /* [in] */ LONG dwFlags);
  352. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_UseExistingKeySet(
  353. /* [retval][out] */ BOOL __RPC_FAR *fUseExistingKeys);
  354. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_UseExistingKeySet(
  355. /* [in] */ BOOL fUseExistingKeys);
  356. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_GenKeyFlags(
  357. /* [retval][out] */ LONG __RPC_FAR *pdwFlags);
  358. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_GenKeyFlags(
  359. /* [in] */ LONG dwFlags);
  360. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DeleteRequestCert(
  361. /* [retval][out] */ BOOL __RPC_FAR *fBool);
  362. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DeleteRequestCert(
  363. /* [in] */ BOOL fBool);
  364. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_WriteCertToCSP(
  365. /* [retval][out] */ BOOL __RPC_FAR *fBool);
  366. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_WriteCertToCSP(
  367. /* [in] */ BOOL fBool);
  368. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_WriteCertToUserDS(
  369. /* [retval][out] */ BOOL __RPC_FAR *fBool);
  370. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_WriteCertToUserDS(
  371. /* [in] */ BOOL fBool);
  372. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_EnableT61DNEncoding(
  373. /* [retval][out] */ BOOL __RPC_FAR *fBool);
  374. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_EnableT61DNEncoding(
  375. /* [in] */ BOOL fBool);
  376. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_SPCFileName(
  377. /* [retval][out] */ BSTR __RPC_FAR *pbstr);
  378. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_SPCFileName(
  379. /* [in] */ BSTR bstr);
  380. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_PVKFileName(
  381. /* [retval][out] */ BSTR __RPC_FAR *pbstr);
  382. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_PVKFileName(
  383. /* [in] */ BSTR bstr);
  384. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HashAlgorithm(
  385. /* [retval][out] */ BSTR __RPC_FAR *pbstr);
  386. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HashAlgorithm(
  387. /* [in] */ BSTR bstr);
  388. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ThumbPrint(
  389. /* [in] */ BSTR bstrThumbPrint);
  390. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ThumbPrint(
  391. /* [out, retval] */ BSTR *pbstrThumbPrint);
  392. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ThumbPrintWStr(
  393. /* [in] */ CRYPT_DATA_BLOB thumbPrintBlob);
  394. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ThumbPrintWStr(
  395. /* [out, retval] */ PCRYPT_DATA_BLOB thumbPrintBlob);
  396. virtual HRESULT STDMETHODCALLTYPE InstallPKCS7(
  397. /* [in] */ BSTR PKCS7);
  398. virtual HRESULT STDMETHODCALLTYPE createFilePKCS10WStr(
  399. /* [in] */ LPCWSTR DNName,
  400. /* [in] */ LPCWSTR Usage,
  401. /* [in] */ LPCWSTR wszPKCS10FileName);
  402. virtual HRESULT STDMETHODCALLTYPE acceptFilePKCS7WStr(
  403. /* [in] */ LPCWSTR wszPKCS7FileName);
  404. virtual HRESULT STDMETHODCALLTYPE createPKCS10WStr(
  405. /* [in] */ LPCWSTR DNName,
  406. /* [in] */ LPCWSTR Usage,
  407. /* [out] */ PCRYPT_DATA_BLOB pPkcs10Blob);
  408. virtual HRESULT STDMETHODCALLTYPE acceptPKCS7Blob(
  409. /* [in] */ PCRYPT_DATA_BLOB pBlobPKCS7);
  410. virtual PCCERT_CONTEXT STDMETHODCALLTYPE getCertContextFromPKCS7(
  411. /* [in] */ PCRYPT_DATA_BLOB pBlobPKCS7);
  412. virtual HCERTSTORE STDMETHODCALLTYPE getMyStore( void);
  413. virtual HCERTSTORE STDMETHODCALLTYPE getCAStore( void);
  414. virtual HCERTSTORE STDMETHODCALLTYPE getROOTHStore( void);
  415. virtual HRESULT STDMETHODCALLTYPE enumProvidersWStr(
  416. /* [in] */ LONG dwIndex,
  417. /* [in] */ LONG dwFlags,
  418. /* [out] */ LPWSTR __RPC_FAR *pbstrProvName);
  419. virtual HRESULT STDMETHODCALLTYPE enumContainersWStr(
  420. /* [in] */ LONG dwIndex,
  421. /* [out] */ LPWSTR __RPC_FAR *pbstr);
  422. virtual HRESULT STDMETHODCALLTYPE freeRequestInfoBlob(
  423. /* [in] */ CRYPT_DATA_BLOB pkcs7OrPkcs10);
  424. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MyStoreNameWStr(
  425. /* [out] */ LPWSTR __RPC_FAR *szwName);
  426. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MyStoreNameWStr(
  427. /* [in] */ LPWSTR szwName);
  428. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_MyStoreTypeWStr(
  429. /* [out] */ LPWSTR __RPC_FAR *szwType);
  430. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MyStoreTypeWStr(
  431. /* [in] */ LPWSTR szwType);
  432. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CAStoreNameWStr(
  433. /* [out] */ LPWSTR __RPC_FAR *szwName);
  434. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CAStoreNameWStr(
  435. /* [in] */ LPWSTR szwName);
  436. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CAStoreTypeWStr(
  437. /* [out] */ LPWSTR __RPC_FAR *szwType);
  438. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_CAStoreTypeWStr(
  439. /* [in] */ LPWSTR szwType);
  440. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootStoreNameWStr(
  441. /* [out] */ LPWSTR __RPC_FAR *szwName);
  442. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootStoreNameWStr(
  443. /* [in] */ LPWSTR szwName);
  444. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootStoreTypeWStr(
  445. /* [out] */ LPWSTR __RPC_FAR *szwType);
  446. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootStoreTypeWStr(
  447. /* [in] */ LPWSTR szwType);
  448. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RequestStoreNameWStr(
  449. /* [out] */ LPWSTR __RPC_FAR *szwName);
  450. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RequestStoreNameWStr(
  451. /* [in] */ LPWSTR szwName);
  452. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RequestStoreTypeWStr(
  453. /* [out] */ LPWSTR __RPC_FAR *szwType);
  454. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RequestStoreTypeWStr(
  455. /* [in] */ LPWSTR szwType);
  456. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ContainerNameWStr(
  457. /* [out] */ LPWSTR __RPC_FAR *szwContainer);
  458. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ContainerNameWStr(
  459. /* [in] */ LPWSTR szwContainer);
  460. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProviderNameWStr(
  461. /* [out] */ LPWSTR __RPC_FAR *szwProvider);
  462. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ProviderNameWStr(
  463. /* [in] */ LPWSTR szwProvider);
  464. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_SPCFileNameWStr(
  465. /* [out] */ LPWSTR __RPC_FAR *szw);
  466. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_SPCFileNameWStr(
  467. /* [in] */ LPWSTR szw);
  468. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_PVKFileNameWStr(
  469. /* [out] */ LPWSTR __RPC_FAR *szw);
  470. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_PVKFileNameWStr(
  471. /* [in] */ LPWSTR szw);
  472. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HashAlgorithmWStr(
  473. /* [out] */ LPWSTR __RPC_FAR *szw);
  474. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HashAlgorithmWStr(
  475. /* [in] */ LPWSTR szw);
  476. virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RenewalCertificate(
  477. /* [out] */ PCCERT_CONTEXT __RPC_FAR *ppCertContext);
  478. virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RenewalCertificate(
  479. /* [in] */ PCCERT_CONTEXT pCertContext);
  480. virtual HRESULT STDMETHODCALLTYPE AddCertTypeToRequestWStr(
  481. LPWSTR szw);
  482. virtual HRESULT STDMETHODCALLTYPE AddNameValuePairToSignatureWStr(
  483. /* [in] */ LPWSTR Name,
  484. /* [in] */ LPWSTR Value);
  485. virtual HRESULT STDMETHODCALLTYPE AddExtensionsToRequest(
  486. PCERT_EXTENSIONS pCertExtensions);
  487. virtual HRESULT STDMETHODCALLTYPE AddAuthenticatedAttributesToPKCS7Request(
  488. PCRYPT_ATTRIBUTES pAttributes);
  489. virtual HRESULT STDMETHODCALLTYPE CreatePKCS7RequestFromRequest(
  490. PCRYPT_DATA_BLOB pRequest,
  491. PCCERT_CONTEXT pSigningCertContext,
  492. PCRYPT_DATA_BLOB pPkcs7Blob);
  493. virtual HRESULT STDMETHODCALLTYPE Reset(void);
  494. virtual HRESULT STDMETHODCALLTYPE GetSupportedKeySpec(
  495. LONG __RPC_FAR *pdwKeySpec);
  496. virtual HRESULT STDMETHODCALLTYPE InstallPKCS7Blob(
  497. PCRYPT_DATA_BLOB pBlobPKCS7);
  498. virtual HRESULT STDMETHODCALLTYPE GetKeyLen(
  499. BOOL fMin,
  500. BOOL fExchange,
  501. LONG __RPC_FAR *pdwKeySize);
  502. virtual HRESULT STDMETHODCALLTYPE EnumAlgs(
  503. LONG dwIndex,
  504. LONG algMask,
  505. LONG __RPC_FAR *pdwAlgID);
  506. virtual HRESULT STDMETHODCALLTYPE GetAlgNameWStr(
  507. LONG algID,
  508. LPWSTR __RPC_FAR *ppwsz);
  509. virtual HRESULT STDMETHODCALLTYPE GetAlgName(
  510. LONG algID,
  511. BSTR __RPC_FAR *pbstr);
  512. virtual HRESULT STDMETHODCALLTYPE put_ReuseHardwareKeyIfUnableToGenNew(
  513. BOOL fReuseHardwareKeyIfUnableToGenNew);
  514. virtual HRESULT STDMETHODCALLTYPE get_ReuseHardwareKeyIfUnableToGenNew(
  515. BOOL __RPC_FAR *fReuseHardwareKeyIfUnableToGenNew);
  516. virtual HRESULT STDMETHODCALLTYPE put_HashAlgID(
  517. LONG hashAlgID);
  518. virtual HRESULT STDMETHODCALLTYPE get_HashAlgID(
  519. LONG * hashAlgID);
  520. virtual HRESULT STDMETHODCALLTYPE SetHStoreMy(
  521. HCERTSTORE hStore
  522. );
  523. virtual HRESULT STDMETHODCALLTYPE SetHStoreCA(
  524. HCERTSTORE hStore
  525. );
  526. virtual HRESULT STDMETHODCALLTYPE SetHStoreROOT(
  527. HCERTSTORE hStore
  528. );
  529. virtual HRESULT STDMETHODCALLTYPE SetHStoreRequest(
  530. HCERTSTORE hStore
  531. );
  532. virtual HRESULT STDMETHODCALLTYPE put_LimitExchangeKeyToEncipherment(
  533. BOOL fLimitExchangeKeyToEncipherment
  534. );
  535. virtual HRESULT STDMETHODCALLTYPE get_LimitExchangeKeyToEncipherment(
  536. BOOL * fLimitExchangeKeyToEncipherment
  537. );
  538. virtual HRESULT STDMETHODCALLTYPE put_EnableSMIMECapabilities(
  539. BOOL fEnableSMIMECapabilities
  540. );
  541. virtual HRESULT STDMETHODCALLTYPE get_EnableSMIMECapabilities(
  542. BOOL * fEnableSMIMECapabilities
  543. );
  544. //ICEnroll4
  545. virtual HRESULT STDMETHODCALLTYPE put_PrivateKeyArchiveCertificate(
  546. IN BSTR bstrCert
  547. );
  548. virtual HRESULT STDMETHODCALLTYPE get_PrivateKeyArchiveCertificate(
  549. OUT BSTR __RPC_FAR *pbstrCert
  550. );
  551. virtual HRESULT STDMETHODCALLTYPE binaryToString(
  552. IN LONG Flags,
  553. IN BSTR strBinary,
  554. OUT BSTR *pstrEncoded
  555. );
  556. virtual HRESULT STDMETHODCALLTYPE stringToBinary(
  557. IN LONG Flags,
  558. IN BSTR strEncoded,
  559. OUT BSTR *pstrBinary
  560. );
  561. virtual HRESULT STDMETHODCALLTYPE addExtensionToRequest(
  562. IN LONG Flags,
  563. IN BSTR strName,
  564. IN BSTR strValue
  565. );
  566. virtual HRESULT STDMETHODCALLTYPE addAttributeToRequest(
  567. IN LONG Flags,
  568. IN BSTR strName,
  569. IN BSTR strValue
  570. );
  571. virtual HRESULT STDMETHODCALLTYPE addNameValuePairToRequest(
  572. IN LONG Flags,
  573. IN BSTR strName,
  574. IN BSTR strValue
  575. );
  576. virtual HRESULT STDMETHODCALLTYPE createRequest(
  577. IN LONG Flags,
  578. IN BSTR strDNName,
  579. IN BSTR strUsage,
  580. OUT BSTR *pstrRequest
  581. );
  582. virtual HRESULT STDMETHODCALLTYPE createFileRequest(
  583. IN LONG Flags,
  584. IN BSTR strDNName,
  585. IN BSTR strUsage,
  586. IN BSTR strRequestFileName
  587. );
  588. virtual HRESULT STDMETHODCALLTYPE acceptResponse(
  589. IN BSTR strResponse
  590. );
  591. virtual HRESULT STDMETHODCALLTYPE acceptFileResponse(
  592. IN BSTR strResponseFileName
  593. );
  594. virtual HRESULT STDMETHODCALLTYPE getCertFromResponse(
  595. IN BSTR strResponse,
  596. OUT BSTR *pstrCert
  597. );
  598. virtual HRESULT STDMETHODCALLTYPE getCertFromFileResponse(
  599. IN BSTR strResponseFileName,
  600. OUT BSTR *pstrCert
  601. );
  602. virtual HRESULT STDMETHODCALLTYPE createPFX(
  603. IN BSTR strPassword,
  604. OUT BSTR *pstrPFX
  605. );
  606. virtual HRESULT STDMETHODCALLTYPE createFilePFX(
  607. IN BSTR strPassword,
  608. IN BSTR strPFXFileName
  609. );
  610. virtual HRESULT STDMETHODCALLTYPE setPendingRequestInfo(
  611. IN LONG lRequestID,
  612. IN BSTR strCADNS,
  613. IN BSTR strCAName,
  614. IN BSTR strFriendlyName
  615. );
  616. virtual HRESULT STDMETHODCALLTYPE enumPendingRequest(
  617. IN LONG lIndex,
  618. IN LONG lDesiredProperty,
  619. OUT VARIANT *pvarProperty
  620. );
  621. virtual HRESULT STDMETHODCALLTYPE removePendingRequest(
  622. IN BSTR strThumbprint
  623. );
  624. virtual HRESULT STDMETHODCALLTYPE InstallPKCS7Ex(
  625. IN BSTR PKCS7,
  626. OUT LONG __RPC_FAR *plCertInstalled
  627. );
  628. virtual HRESULT STDMETHODCALLTYPE addBlobPropertyToCertificate(
  629. IN LONG lPropertyId,
  630. IN LONG lFlags,
  631. IN BSTR strProperty
  632. );
  633. virtual HRESULT STDMETHODCALLTYPE put_SignerCertificate(
  634. IN BSTR bstrCert
  635. );
  636. //IEnroll4
  637. virtual HRESULT STDMETHODCALLTYPE SetPrivateKeyArchiveCertificate(
  638. IN PCCERT_CONTEXT pPrivateKeyArchiveCert
  639. );
  640. virtual PCCERT_CONTEXT STDMETHODCALLTYPE GetPrivateKeyArchiveCertificate(
  641. void
  642. );
  643. virtual HRESULT STDMETHODCALLTYPE binaryBlobToString(
  644. IN LONG Flags,
  645. IN PCRYPT_DATA_BLOB pblobBinary,
  646. OUT LPWSTR *ppwszString
  647. );
  648. virtual HRESULT STDMETHODCALLTYPE stringToBinaryBlob(
  649. IN LONG Flags,
  650. IN LPCWSTR pwszString,
  651. OUT PCRYPT_DATA_BLOB pblobBinary,
  652. OUT LONG *pdwSkip,
  653. OUT LONG *pdwFlags
  654. );
  655. virtual HRESULT STDMETHODCALLTYPE addExtensionToRequestWStr(
  656. IN LONG Flags,
  657. IN LPCWSTR pwszName,
  658. IN PCRYPT_DATA_BLOB pblobValue
  659. );
  660. virtual HRESULT STDMETHODCALLTYPE addAttributeToRequestWStr(
  661. IN LONG Flags,
  662. IN LPCWSTR pwszName,
  663. IN PCRYPT_DATA_BLOB pblobValue
  664. );
  665. virtual HRESULT STDMETHODCALLTYPE addNameValuePairToRequestWStr(
  666. IN LONG Flags,
  667. IN LPCWSTR pwszName,
  668. IN LPCWSTR pwszValue
  669. );
  670. virtual HRESULT STDMETHODCALLTYPE createRequestWStr(
  671. IN LONG Flags,
  672. IN LPCWSTR pwszDNName,
  673. IN LPCWSTR pwszUsage,
  674. OUT PCRYPT_DATA_BLOB pblobRequest
  675. );
  676. virtual HRESULT STDMETHODCALLTYPE createFileRequestWStr(
  677. IN LONG Flags,
  678. IN LPCWSTR pwszDNName,
  679. IN LPCWSTR pwszUsage,
  680. IN LPCWSTR pwszRequestFileName
  681. );
  682. virtual HRESULT STDMETHODCALLTYPE acceptResponseBlob(
  683. IN PCRYPT_DATA_BLOB pblobResponse
  684. );
  685. virtual HRESULT STDMETHODCALLTYPE acceptFileResponseWStr(
  686. IN LPCWSTR pwszResponseFileName
  687. );
  688. virtual HRESULT STDMETHODCALLTYPE getCertContextFromResponseBlob(
  689. IN PCRYPT_DATA_BLOB pblobResponse,
  690. OUT PCCERT_CONTEXT *ppCertContext
  691. );
  692. virtual HRESULT STDMETHODCALLTYPE getCertContextFromFileResponseWStr(
  693. IN LPCWSTR pwszResponseFileName,
  694. OUT PCCERT_CONTEXT *ppCertContext
  695. );
  696. virtual HRESULT STDMETHODCALLTYPE createPFXWStr(
  697. IN LPCWSTR pwszPassword,
  698. OUT PCRYPT_DATA_BLOB pblobPFX
  699. );
  700. virtual HRESULT STDMETHODCALLTYPE createFilePFXWStr(
  701. IN LPCWSTR pwszPassword,
  702. IN LPCWSTR pwszPFXFileName
  703. );
  704. virtual HRESULT STDMETHODCALLTYPE setPendingRequestInfoWStr(
  705. IN LONG lRequestID,
  706. IN LPCWSTR pwszCADNS,
  707. IN LPCWSTR pwszCAName,
  708. IN LPCWSTR pwszFriendlyName
  709. );
  710. virtual HRESULT STDMETHODCALLTYPE removePendingRequestWStr(
  711. IN CRYPT_DATA_BLOB thumbPrintBlob
  712. );
  713. virtual HRESULT STDMETHODCALLTYPE enumPendingRequestWStr(
  714. IN LONG lIndex,
  715. IN LONG lDesiredProperty,
  716. OUT LPVOID ppProperty
  717. );
  718. virtual HRESULT STDMETHODCALLTYPE InstallPKCS7BlobEx(
  719. IN PCRYPT_DATA_BLOB pBlobPKCS7,
  720. OPTIONAL OUT LONG *plCertInstalled);
  721. virtual HRESULT STDMETHODCALLTYPE addCertTypeToRequestEx(
  722. IN LONG lType,
  723. IN BSTR bstrOIDOrName,
  724. IN LONG lMajorVersion,
  725. IN BOOL fMinorVersion,
  726. IN LONG lMinorVersion
  727. );
  728. virtual HRESULT STDMETHODCALLTYPE AddCertTypeToRequestWStrEx(
  729. IN LONG lType,
  730. IN LPCWSTR pwszOIDOrName,
  731. IN LONG lMajorVersion,
  732. IN BOOL fMinorVersion,
  733. IN LONG lMinorVersion
  734. );
  735. virtual HRESULT STDMETHODCALLTYPE getProviderType(
  736. IN BSTR strProvName,
  737. OUT LONG *lpProvType
  738. );
  739. virtual HRESULT STDMETHODCALLTYPE getProviderTypeWStr(
  740. IN LPCWSTR pwszProvName,
  741. OUT LONG *lpProvType
  742. );
  743. virtual HRESULT STDMETHODCALLTYPE addBlobPropertyToCertificateWStr(
  744. IN LONG lPropertyId,
  745. IN LONG lFlags,
  746. IN PCRYPT_DATA_BLOB pBlobProperty
  747. );
  748. virtual HRESULT STDMETHODCALLTYPE SetSignerCertificate(
  749. IN PCCERT_CONTEXT pSignerCert
  750. );
  751. //both ICEnroll4 and IEnroll4
  752. virtual HRESULT STDMETHODCALLTYPE resetExtensions(
  753. void
  754. );
  755. virtual HRESULT STDMETHODCALLTYPE resetAttributes(
  756. void
  757. );
  758. virtual HRESULT STDMETHODCALLTYPE resetBlobProperties(
  759. void
  760. );
  761. virtual HRESULT STDMETHODCALLTYPE GetKeyLenEx(
  762. IN LONG lSizeSpec,
  763. IN LONG lKeySpec,
  764. OUT LONG __RPC_FAR *plKeySize
  765. );
  766. virtual HRESULT STDMETHODCALLTYPE get_ClientId(
  767. OUT LONG __RPC_FAR *plClientId);
  768. virtual HRESULT STDMETHODCALLTYPE put_ClientId(
  769. IN LONG lClientId);
  770. virtual HRESULT STDMETHODCALLTYPE get_IncludeSubjectKeyID(
  771. OUT BOOL __RPC_FAR *pfInclude);
  772. virtual HRESULT STDMETHODCALLTYPE put_IncludeSubjectKeyID(
  773. IN BOOL lfInclude);
  774. private:
  775. HRESULT Init(void);
  776. void Destruct(void);
  777. HCERTSTORE GetStore(
  778. StoreType storeType
  779. );
  780. void FlushStore(
  781. StoreType storeType
  782. );
  783. HCRYPTPROV GetProv(
  784. DWORD dwFlags
  785. );
  786. BOOL SetKeyParams(
  787. PCRYPT_KEY_PROV_INFO pKeyProvInfo
  788. );
  789. HRESULT AddCertsToStores(
  790. HCERTSTORE hStoreMsg,
  791. LONG *plCertInstalled
  792. );
  793. HRESULT GetEndEntityCert(
  794. PCRYPT_DATA_BLOB pBlobPKCS7,
  795. BOOL fSaveToStores,
  796. PCCERT_CONTEXT *ppCert
  797. );
  798. HRESULT BStringToFile(
  799. IN BSTR bString,
  800. IN LPCWSTR pwszFileName);
  801. HRESULT BlobToBstring(
  802. IN CRYPT_DATA_BLOB *pBlob,
  803. IN DWORD dwFlag,
  804. OUT BSTR *pBString);
  805. HRESULT BstringToBlob(
  806. IN BSTR bString,
  807. OUT CRYPT_DATA_BLOB *pBlob);
  808. HRESULT GetCertFromResponseBlobToBStr(
  809. IN CRYPT_DATA_BLOB *pBlobResponse,
  810. OUT BSTR *pstrCert);
  811. HRESULT createPKCS10WStrBStr(
  812. LPCWSTR DNName,
  813. LPCWSTR wszPurpose,
  814. BSTR __RPC_FAR *pPKCS10);
  815. HRESULT createPFXWStrBStr(
  816. IN LPCWSTR pwszPassword,
  817. OUT BSTR __RPC_FAR *pbstrPFX);
  818. HRESULT createRequestWStrBStr(
  819. IN LONG Flags,
  820. IN LPCWSTR pwszDNName,
  821. IN LPCWSTR pwszUsage,
  822. IN DWORD dwFlag,
  823. OUT BSTR __RPC_FAR *pbstrRequest);
  824. BOOL GetCapiHashAndSigAlgId(ALG_ID rgAlg[2]);
  825. DWORD GetKeySizeInfo(
  826. LONG lKeySizeSpec,
  827. DWORD algClass
  828. );
  829. HRESULT GetKeyArchivePKCS7(CRYPT_ATTR_BLOB *pBlobKeyArchivePKCS7);
  830. BOOL CopyAndPushStackExtension(PCERT_EXTENSION pExt, BOOL fNewRequestMethod);
  831. PCERT_EXTENSION PopStackExtension(BOOL fNewRequestMethod);
  832. DWORD CountStackExtension(BOOL fNewRequestMethod);
  833. void FreeStackExtension(PCERT_EXTENSION pExt);
  834. PCERT_EXTENSION EnumStackExtension(PCERT_EXTENSION pExtLast, BOOL fNewRequestMethod);
  835. void FreeAllStackExtension(void);
  836. BOOL CopyAndPushStackAttribute(PCRYPT_ATTRIBUTE pAttr, BOOL fNewRequestMethod);
  837. PCRYPT_ATTRIBUTE PopStackAttribute(BOOL fNewRequestMethod);
  838. DWORD CountStackAttribute(BOOL fNewRequestMethod);
  839. void FreeStackAttribute(PCRYPT_ATTRIBUTE pAttr);
  840. PCRYPT_ATTRIBUTE EnumStackAttribute(PCRYPT_ATTRIBUTE pAttrLast, BOOL fNewRequestMethod);
  841. void FreeAllStackAttribute(void);
  842. HANDLE CreateOpenFileSafely(
  843. LPCWSTR wsz,
  844. BOOL fCreate);
  845. HANDLE CreateFileSafely(
  846. LPCWSTR wsz);
  847. HANDLE OpenFileSafely(
  848. LPCWSTR wsz);
  849. HANDLE CreateOpenFileSafely2(
  850. LPCWSTR wsz,
  851. DWORD idsCreate,
  852. DWORD idsOverwrite);
  853. BOOL fIsRequestStoreSafeForScripting(void);
  854. HRESULT
  855. xeStringToBinaryFromFile(
  856. IN WCHAR const *pwszfn,
  857. OUT BYTE **ppbOut,
  858. OUT DWORD *pcbOut,
  859. IN DWORD Flags);
  860. HRESULT PKCS7ToCert(IN HCERTSTORE hCertStore,
  861. IN CRYPT_DATA_BLOB pkcs10Blob,
  862. OUT PCCERT_CONTEXT *ppCertContext);
  863. HRESULT PKCS10ToCert(IN HCERTSTORE hCertStore,
  864. IN CRYPT_DATA_BLOB pkcs10Blob,
  865. OUT PCCERT_CONTEXT *ppCertContext);
  866. PPROP_STACK EnumStackProperty(PPROP_STACK pProp);
  867. HRESULT GetGoodCertContext(
  868. IN PCCERT_CONTEXT pCertContext,
  869. OUT PCCERT_CONTEXT *ppGoodCertContext);
  870. HRESULT GetVerifyProv();
  871. private:
  872. PCCERT_CONTEXT m_PrivateKeyArchiveCertificate;
  873. PCCERT_CONTEXT m_pCertContextRenewal;
  874. PCCERT_CONTEXT m_pCertContextSigner;
  875. PCCERT_CONTEXT m_pCertContextStatic;
  876. PendingRequestTable *m_pPendingRequestTable;
  877. // The cert last created through createPKCS10(). This is used as the target
  878. // of setPendingRequestInfo() if no other target is specified by the client.
  879. PCCERT_CONTEXT m_pCertContextPendingRequest;
  880. // The HASH of the current request created with the xenroll instance.
  881. // This value is set through the put_ThumbPrint() method, and is used to
  882. // determine the target cert of the setPendingRequestInfo() operation.
  883. // If this value is not set through the put_ThumbPrint() method, it will be
  884. // NULL, and m_pCertContextPendingRequest will contain the target cert.
  885. CRYPT_DATA_BLOB m_hashBlobPendingRequest;
  886. // Used to keep track of last enumerated element in enumPendingRequestWStr
  887. PCCERT_CONTEXT m_pCertContextLastEnumerated;
  888. DWORD m_dwCurrentPendingRequestIndex;
  889. BYTE m_arHashBytesNewCert[20];
  890. BYTE m_arHashBytesOldCert[20];
  891. BOOL m_fArchiveOldCert;
  892. CRYPT_KEY_PROV_INFO m_keyProvInfo;
  893. HCRYPTPROV m_hProv;
  894. HCRYPTPROV m_hVerifyProv;
  895. CRITICAL_SECTION m_csXEnroll;
  896. BOOL m_fWriteCertToUserDS;
  897. BOOL m_fWriteCertToUserDSModified;
  898. BOOL m_fWriteCertToCSP;
  899. BOOL m_fWriteCertToCSPModified;
  900. BOOL m_fDeleteRequestCert;
  901. BOOL m_fUseExistingKey;
  902. BOOL m_fMyStoreOpenFlagsModified;
  903. BOOL m_fCAStoreOpenFlagsModified;
  904. BOOL m_fRootStoreOpenFlagsModified;
  905. BOOL m_fRequestStoreOpenFlagsModified;
  906. BOOL m_fReuseHardwareKeyIfUnableToGenNew;
  907. BOOL m_fLimitExchangeKeyToEncipherment;
  908. BOOL m_fEnableSMIMECapabilities;
  909. BOOL m_fSMIMESetByClient;
  910. BOOL m_fKeySpecSetByClient;
  911. DWORD m_dwT61DNEncoding;
  912. DWORD const m_dwEnabledSafteyOptions;
  913. DWORD m_dwGenKeyFlags;
  914. STOREINFO m_MyStore;
  915. STOREINFO m_CAStore;
  916. STOREINFO m_RootStore;
  917. STOREINFO m_RequestStore;
  918. LPWSTR m_wszSPCFileName;
  919. LPWSTR m_wszPVKFileName;
  920. DWORD m_HashAlgId;
  921. PEXT_STACK m_pExtStack;
  922. DWORD m_cExtStack;
  923. PATTR_STACK m_pAttrStack;
  924. DWORD m_cAttrStack;
  925. PEXT_STACK m_pExtStackNew;
  926. DWORD m_cExtStackNew;
  927. PATTR_STACK m_pAttrStackNew;
  928. DWORD m_cAttrStackNew;
  929. BOOL m_fNewRequestMethod;
  930. BOOL m_fHonorRenew;
  931. BOOL m_fOID_V2;
  932. HCRYPTKEY m_hCachedKey;
  933. BOOL m_fUseClientKeyUsage;
  934. BOOL m_fCMCFormat;
  935. PPROP_STACK m_pPropStack;
  936. DWORD m_cPropStack;
  937. LONG m_lClientId;
  938. DWORD m_dwLastAlgIndex;
  939. BOOL m_fIncludeSubjectKeyID;
  940. BOOL m_fHonorIncludeSubjectKeyID;
  941. PCERT_PUBLIC_KEY_INFO m_pPublicKeyInfo;
  942. CRYPT_HASH_BLOB m_blobResponseKAHash;
  943. DWORD m_dwSigKeyLenMax;
  944. DWORD m_dwSigKeyLenMin;
  945. DWORD m_dwSigKeyLenDef;
  946. DWORD m_dwSigKeyLenInc;
  947. DWORD m_dwXhgKeyLenMax;
  948. DWORD m_dwXhgKeyLenMin;
  949. DWORD m_dwXhgKeyLenDef;
  950. DWORD m_dwXhgKeyLenInc;
  951. };
  952. BOOL GetSignatureFromHPROV(
  953. IN HCRYPTPROV hProv,
  954. OUT BYTE **ppbSignature,
  955. DWORD *pcbSignature
  956. );
  957. PCCERT_CONTEXT
  958. WINAPI
  959. MyCertCreateSelfSignCertificate(
  960. IN HCRYPTPROV hProv,
  961. IN PCERT_NAME_BLOB pSubjectIssuerBlob,
  962. IN DWORD dwFlags,
  963. OPTIONAL PCRYPT_KEY_PROV_INFO pKeyProvInfo,
  964. OPTIONAL PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
  965. OPTIONAL PSYSTEMTIME pStartTime,
  966. OPTIONAL PSYSTEMTIME pEndTime,
  967. OPTIONAL PCERT_EXTENSIONS pExtensions
  968. ) ;
  969. BOOL
  970. WINAPI
  971. MyCryptQueryObject(DWORD dwObjectType,
  972. const void *pvObject,
  973. DWORD dwExpectedContentTypeFlags,
  974. DWORD dwExpectedFormatTypeFlags,
  975. DWORD dwFlags,
  976. DWORD *pdwMsgAndCertEncodingType,
  977. DWORD *pdwContentType,
  978. DWORD *pdwFormatType,
  979. HCERTSTORE *phCertStore,
  980. HCRYPTMSG *phMsg,
  981. const void **ppvContext);
  982. BOOL
  983. WINAPI
  984. MyCertStrToNameW(
  985. IN DWORD dwCertEncodingType,
  986. IN LPCWSTR pwszX500,
  987. IN DWORD dwStrType,
  988. IN OPTIONAL void * pvReserved,
  989. OUT BYTE * pbEncoded,
  990. IN OUT DWORD * pcbEncoded,
  991. OUT OPTIONAL LPCWSTR * ppwszError
  992. );
  993. BOOL
  994. WINAPI
  995. MyCryptVerifyMessageSignature
  996. (IN PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
  997. IN DWORD dwSignerIndex,
  998. IN BYTE const *pbSignedBlob,
  999. IN DWORD cbSignedBlob,
  1000. OUT BYTE *pbDecoded,
  1001. IN OUT DWORD *pcbDecoded,
  1002. OUT OPTIONAL PCCERT_CONTEXT *ppSignerCert);
  1003. extern "C" BOOL WINAPI InitIE302UpdThunks(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
  1004. BOOL
  1005. MyCryptStringToBinaryA(
  1006. IN LPCSTR pszString,
  1007. IN DWORD cchString,
  1008. IN DWORD dwFlags,
  1009. IN BYTE *pbBinary,
  1010. IN OUT DWORD *pcbBinary,
  1011. OUT DWORD *pdwSkip, //OPTIONAL
  1012. OUT DWORD *pdwFlags //OPTIONAL
  1013. );
  1014. BOOL
  1015. MyCryptStringToBinaryW(
  1016. IN LPCWSTR pszString,
  1017. IN DWORD cchString,
  1018. IN DWORD dwFlags,
  1019. IN BYTE *pbBinary,
  1020. IN OUT DWORD *pcbBinary,
  1021. OUT DWORD *pdwSkip, //OPTIONAL
  1022. OUT DWORD *pdwFlags //OPTIONAL
  1023. );
  1024. BOOL
  1025. MyCryptBinaryToStringA(
  1026. IN CONST BYTE *pbBinary,
  1027. IN DWORD cbBinary,
  1028. IN DWORD dwFlags,
  1029. IN LPSTR pszString,
  1030. IN OUT DWORD *pcchString
  1031. );
  1032. BOOL
  1033. MyCryptBinaryToStringW(
  1034. IN CONST BYTE *pbBinary,
  1035. IN DWORD cbBinary,
  1036. IN DWORD dwFlags,
  1037. IN LPWSTR pszString,
  1038. IN OUT DWORD *pcchString
  1039. );
  1040. HRESULT
  1041. xeLoadRCString(
  1042. HINSTANCE hInstance,
  1043. IN int iRCId,
  1044. OUT WCHAR **ppwsz);
  1045. #endif //__CENROLL_H_