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.

2294 lines
54 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: certlib.h
  7. //
  8. // Contents: Cert Server wrapper routines
  9. //
  10. //---------------------------------------------------------------------------
  11. #ifndef __CERTLIB_H__
  12. #define __CERTLIB_H__
  13. #include <wintrust.h> // for spc_xxxx
  14. #include <cryptui.h> // for CRYPTUI_CA_CONTEXT
  15. #include <setupapi.h> // for HINF
  16. #include <stdio.h> // for wprintf -- include before cs.h
  17. #include "cs.h" // for CSASSERT
  18. #include <xelib.h> // for CERTLIB_ALLOCATOR
  19. #include "csregstr.h" // for ENUM_CATYPES
  20. #include "csfile.h" // for __dwFILE__
  21. #include "csauto.h" // self cleaning pointers
  22. #ifndef CERTREQUEST_CLIENT_CERTREQ // moved to xelib.h
  23. #define SECURITY_WIN32
  24. #include <security.h> // for EXTENDED_NAME_FORMAT
  25. #define DWORDROUND(cb) (((cb) + (sizeof(DWORD) - 1)) & ~(sizeof(DWORD) - 1))
  26. #define POINTERROUND(cb) (((cb) + (sizeof(VOID *) - 1)) & ~(sizeof(VOID *) - 1))
  27. #endif
  28. #define myCASIGN_KEY_USAGE \
  29. (CERT_KEY_CERT_SIGN_KEY_USAGE | \
  30. CERT_CRL_SIGN_KEY_USAGE)
  31. // "flags" property values for DS CA object
  32. // CN=CAName,CN=Certification Authorities
  33. #define CA_SERVER_TYPE_UNKNOWN 0x0
  34. #define CA_SERVER_TYPE_SERVER 0x1
  35. #define CA_SERVER_TYPE_ADVANCEDSERVER 0x2
  36. #ifndef CSM_GLOBALDESTRUCTOR // if old xelib.h
  37. # define CSM_GLOBALDESTRUCTOR 0x200
  38. #endif
  39. #define _16BITMASK ((1 << 16) - 1)
  40. #define MAKECANAMEID(iCert, iKey) (((iKey) << 16) | (iCert))
  41. #define CANAMEIDTOIKEY(NameId) ((NameId) >> 16)
  42. #define CANAMEIDTOICERT(NameId) (_16BITMASK & (NameId))
  43. typedef struct _CAINFO
  44. {
  45. DWORD cbSize;
  46. ENUM_CATYPES CAType;
  47. DWORD cCASignatureCerts;
  48. DWORD cCAExchangeCerts;
  49. DWORD cExitModules;
  50. LONG lPropIdMax;
  51. LONG lRoleSeparationEnabled;
  52. DWORD cKRACertUsedCount;
  53. DWORD cKRACertCount;
  54. DWORD fAdvancedServer;
  55. } CAINFO;
  56. #define cwcHRESULTSTRING 40
  57. #define cwcDWORDSPRINTF (1 + 10 + 1) // DWORD "%d" w/sign & '\0'
  58. #define GETCERT_CAXCHGCERT TRUE
  59. #define GETCERT_CASIGCERT FALSE
  60. #define GETCERT_CHAIN 0x80000000 // internal use only
  61. #define GETCERT_CRLS 0x00800000 // internal use only
  62. #define GETCERT_FILEVERSION 0x66696c65 // "file"
  63. #define GETCERT_PRODUCTVERSION 0x70726f64 // "prod"
  64. #define GETCERT_POLICYVERSION 0x706f6c69 // "poli"
  65. #define GETCERT_CANAME 0x6e616d65 // "name"
  66. #define GETCERT_SANITIZEDCANAME 0x73616e69 // "sani"
  67. #define GETCERT_SHAREDFOLDER 0x73686172 // "shar"
  68. #define GETCERT_ERRORTEXT1 0x65727231 // "err1"
  69. #define GETCERT_ERRORTEXT2 0x65727232 // "err2"
  70. #define GETCERT_CATYPE 0x74797065 // "type"
  71. #define GETCERT_CAINFO 0x696e666f // "info"
  72. #define GETCERT_PARENTCONFIG 0x70617265 // "pare"
  73. #define GETCERT_CURRENTCRL 0x6363726c // "ccrl"
  74. #define GETCERT_CACERTBYINDEX 0x63740000 // "ct??" + 0 based index
  75. #define GETCERT_CACERTSTATEBYINDEX 0x73740000 // "st??" + 0 based index
  76. #define GETCERT_CRLBYINDEX 0x636c0000 // "cl??" + 0 based index
  77. #define GETCERT_CRLSTATEBYINDEX 0x736c0000 // "sl??" + 0 based index
  78. #define GETCERT_EXITVERSIONBYINDEX 0x65780000 // "ex??" + 0 based index
  79. #define GETCERT_BYINDEXMASK 0x7f7f0000 // mask for fetch by index
  80. #define GETCERT_INDEXVALUEMASK 0x0000ffff // mask for index extraction
  81. #define GETCERT_VERSIONMASK 0x7f7f7f7f // mask for above
  82. #define CSREG_UPGRADE 0x00000001
  83. #define CSREG_APPEND 0x00000002
  84. #define CSREG_REPLACE 0x00000004
  85. #define CSREG_MERGE 0x00000008
  86. #define wszCERTENROLLSHARENAME L"CertEnroll"
  87. #define wszCERTENROLLSHAREPATH L"CertSrv\\CertEnroll"
  88. #define wszCERTCONFIGSHARENAME L"CertConfig"
  89. // Constants chosen to avoid DWORD overflow:
  90. #define CVT_WEEKS (7 * CVT_DAYS)
  91. #define CVT_DAYS (24 * CVT_HOURS)
  92. #define CVT_HOURS (60 * CVT_MINUTES)
  93. #define CVT_MINUTES (60 * CVT_SECONDS)
  94. #define CVT_SECONDS (1)
  95. #define CVT_BASE (1000 * 1000 * 10)
  96. #define chLBRACKET '['
  97. #define chRBRACKET ']'
  98. #define szLBRACKET "["
  99. #define szRBRACKET "]"
  100. #define wcLBRACKET L'['
  101. #define wcRBRACKET L']'
  102. #define wszLBRACKET L"["
  103. #define wszRBRACKET L"]"
  104. #define chLBRACE '{'
  105. #define chRBRACE '}'
  106. #define szLBRACE "{"
  107. #define szRBRACE "}"
  108. #define wcLBRACE L'{'
  109. #define wcRBRACE L'}'
  110. #define wszLBRACE L"{"
  111. #define wszRBRACE L"}"
  112. #define chLPAREN '('
  113. #define chRPAREN ')'
  114. #define szLPAREN "("
  115. #define szRPAREN ")"
  116. #define wcLPAREN L'('
  117. #define wcRPAREN L')'
  118. #define wszLPAREN L"("
  119. #define wszRPAREN L")"
  120. typedef struct _CSURLTEMPLATE
  121. {
  122. DWORD Flags;
  123. WCHAR *pwszURL;
  124. } CSURLTEMPLATE;
  125. WCHAR const *
  126. myHResultToString(
  127. IN OUT WCHAR *awchr,
  128. IN HRESULT hr);
  129. WCHAR const *
  130. myHResultToStringRaw(
  131. IN OUT WCHAR *awchr,
  132. IN HRESULT hr);
  133. WCHAR const *
  134. myGetErrorMessageText(
  135. IN HRESULT hr,
  136. IN BOOL fHResultString);
  137. WCHAR const *
  138. myGetErrorMessageText1(
  139. IN HRESULT hr,
  140. IN BOOL fHResultString,
  141. IN OPTIONAL WCHAR const *pwszInsertionText);
  142. WCHAR const *
  143. myGetErrorMessageTextEx(
  144. IN HRESULT hr,
  145. IN BOOL fHResultString,
  146. IN OPTIONAL WCHAR const * const *papwszInsertionText);
  147. HRESULT
  148. myJetHResult(IN HRESULT hr);
  149. BOOL
  150. myIsDelayLoadHResult(IN HRESULT hr);
  151. #define CBMAX_CRYPT_HASH_LEN 20
  152. BOOL
  153. myCryptSignMessage(
  154. IN CRYPT_SIGN_MESSAGE_PARA const *pcsmp,
  155. IN BYTE const *pbToBeSigned,
  156. IN DWORD cbToBeSigned,
  157. IN CERTLIB_ALLOCATOR allocType,
  158. OUT BYTE **ppbSignedBlob, // CoTaskMem*
  159. OUT DWORD *pcbSignedBlob);
  160. HRESULT
  161. myCryptMsgGetParam(
  162. IN HCRYPTMSG hCryptMsg,
  163. IN DWORD dwParamType,
  164. IN DWORD dwIndex,
  165. OUT VOID **ppvData,
  166. OUT DWORD *pcbData);
  167. BOOL
  168. myEncodeCert(
  169. IN DWORD dwEncodingType,
  170. IN CERT_SIGNED_CONTENT_INFO const *pInfo,
  171. IN CERTLIB_ALLOCATOR allocType,
  172. OUT BYTE **ppbEncoded,
  173. OUT DWORD *pcbEncoded);
  174. BOOL
  175. myEncodeName(
  176. IN DWORD dwEncodingType,
  177. IN CERT_NAME_INFO const *pInfo,
  178. IN DWORD dwFlags,
  179. IN CERTLIB_ALLOCATOR allocType,
  180. OUT BYTE **ppbEncoded,
  181. OUT DWORD *pcbEncoded);
  182. BOOL
  183. myEncodeKeyAttributes(
  184. IN DWORD dwEncodingType,
  185. IN CERT_KEY_ATTRIBUTES_INFO const *pInfo,
  186. IN CERTLIB_ALLOCATOR allocType,
  187. OUT BYTE **ppbEncoded,
  188. OUT DWORD *pcbEncoded);
  189. BOOL
  190. myEncodeKeyUsage(
  191. IN DWORD dwEncodingType,
  192. IN CRYPT_BIT_BLOB const *pInfo,
  193. IN CERTLIB_ALLOCATOR allocType,
  194. OUT BYTE **ppbEncoded,
  195. OUT DWORD *pcbEncoded);
  196. BOOL
  197. myEncodeKeyAuthority(
  198. IN DWORD dwEncodingType,
  199. IN CERT_AUTHORITY_KEY_ID_INFO const *pInfo,
  200. IN CERTLIB_ALLOCATOR allocType,
  201. OUT BYTE **ppbEncoded,
  202. OUT DWORD *pcbEncoded);
  203. BOOL
  204. myEncodeKeyAuthority2(
  205. IN DWORD dwEncodingType,
  206. IN CERT_AUTHORITY_KEY_ID2_INFO const *pInfo,
  207. IN CERTLIB_ALLOCATOR allocType,
  208. OUT BYTE **ppbEncoded,
  209. OUT DWORD *pcbEncoded);
  210. BOOL
  211. myEncodeToBeSigned(
  212. DWORD dwEncodingType,
  213. CERT_INFO const *pInfo,
  214. IN CERTLIB_ALLOCATOR allocType,
  215. BYTE **ppbEncoded,
  216. DWORD *pcbEncoded);
  217. BOOL
  218. myDecodeName(
  219. IN DWORD dwEncodingType,
  220. IN LPCSTR lpszStructType,
  221. IN BYTE const *pbEncoded,
  222. IN DWORD cbEncoded,
  223. IN CERTLIB_ALLOCATOR allocType,
  224. OUT CERT_NAME_INFO **ppNameInfo,
  225. OUT DWORD *pcbNameInfo);
  226. HRESULT
  227. myDecodeCSPProviderAttribute(
  228. IN BYTE const *pbCSPEncoded,
  229. IN DWORD cbCSPEncoded,
  230. OUT CRYPT_CSP_PROVIDER **ppccp);
  231. BOOL
  232. myDecodeKeyGenRequest(
  233. IN BYTE const *pbRequest,
  234. IN DWORD cbRequest,
  235. IN CERTLIB_ALLOCATOR allocType,
  236. OUT CERT_KEYGEN_REQUEST_INFO **ppKeyGenRequest,
  237. OUT DWORD *pcbKeyGenRequest);
  238. BOOL
  239. myDecodeExtensions(
  240. IN DWORD dwEncodingType,
  241. IN BYTE const *pbEncoded,
  242. IN DWORD cbEncoded,
  243. IN CERTLIB_ALLOCATOR allocType,
  244. OUT CERT_EXTENSIONS **ppInfo,
  245. OUT DWORD *pcbInfo);
  246. BOOL
  247. myDecodeKeyAuthority(
  248. IN DWORD dwEncodingType,
  249. IN BYTE const *pbEncoded,
  250. IN DWORD cbEncoded,
  251. IN CERTLIB_ALLOCATOR allocType,
  252. OUT CERT_AUTHORITY_KEY_ID_INFO const **ppInfo,
  253. OUT DWORD *pcbInfo);
  254. BOOL
  255. myDecodeKeyAuthority2(
  256. IN DWORD dwEncodingType,
  257. IN BYTE const *pbEncoded,
  258. IN DWORD cbEncoded,
  259. IN CERTLIB_ALLOCATOR allocType,
  260. OUT CERT_AUTHORITY_KEY_ID2_INFO const **ppInfo,
  261. OUT DWORD *pcbInfo);
  262. BOOL
  263. myCertGetCertificateContextProperty(
  264. IN CERT_CONTEXT const *pCertContext,
  265. IN DWORD dwPropId,
  266. IN CERTLIB_ALLOCATOR allocType,
  267. OUT VOID **ppvData,
  268. OUT DWORD *pcbData);
  269. HRESULT
  270. myCryptEncrypt(
  271. IN HCRYPTKEY hKey,
  272. IN BYTE const *pbIn,
  273. IN DWORD cbIn,
  274. OUT BYTE **ppbEncrypted,
  275. OUT DWORD *pcbEncrypted);
  276. HRESULT
  277. myCryptDecrypt(
  278. IN HCRYPTKEY hKey,
  279. IN BYTE const *pbIn,
  280. IN DWORD cbIn,
  281. OUT BYTE **ppbDecrypted,
  282. OUT DWORD *pcbDecrypted);
  283. HRESULT
  284. myCryptEncryptMessage(
  285. IN ALG_ID algId,
  286. IN DWORD cCertRecipient,
  287. IN CERT_CONTEXT const **rgCertRecipient,
  288. IN BYTE const *pbIn,
  289. IN DWORD cbIn,
  290. IN OPTIONAL HCRYPTPROV hCryptProv,
  291. OUT BYTE **ppbEncrypted,
  292. OUT DWORD *pcbEncrypted);
  293. HRESULT
  294. myCryptDecryptMessage(
  295. IN HCERTSTORE hStoreCA,
  296. IN BYTE const *pbEncrypted,
  297. IN DWORD cbEncrypted,
  298. IN CERTLIB_ALLOCATOR allocType,
  299. OUT BYTE **ppbDecrypted,
  300. OUT DWORD *pcbDecrypted);
  301. HRESULT
  302. myGetInnerPKCS10(
  303. IN HCRYPTMSG hMsg,
  304. IN char const *pszInnerContentObjId,
  305. OUT CERT_REQUEST_INFO **ppRequest);
  306. BOOL
  307. myDecodeNameValuePair(
  308. IN DWORD dwEncodingType,
  309. IN BYTE const *pbEncoded,
  310. IN DWORD cbEncoded,
  311. IN CERTLIB_ALLOCATOR allocType,
  312. OUT CRYPT_ENROLLMENT_NAME_VALUE_PAIR **ppInfo,
  313. OUT DWORD *pcbInfo);
  314. HRESULT
  315. myEncodeExtension(
  316. IN DWORD Flags,
  317. IN BYTE const *pbIn,
  318. IN DWORD cbIn,
  319. OUT BYTE **ppbOut,
  320. OUT DWORD *pcbOut);
  321. HRESULT
  322. myDecodeExtension(
  323. IN DWORD Flags,
  324. IN BYTE const *pbIn,
  325. IN DWORD cbIn,
  326. OUT BYTE **ppbOut,
  327. OUT DWORD *pcbOut);
  328. HRESULT
  329. myGenerateKeys(
  330. IN WCHAR const *pwszContainer,
  331. OPTIONAL IN WCHAR const *pwszProvName,
  332. IN BOOL fMachineKeySet,
  333. IN DWORD dwKeySpec,
  334. IN DWORD dwProvType,
  335. IN DWORD dwKeySize,
  336. OUT HCRYPTPROV *phProv);
  337. HRESULT
  338. myCryptExportKey(
  339. IN HCRYPTKEY hKey,
  340. IN HCRYPTKEY hKeyExp,
  341. IN DWORD dwBlobType,
  342. IN DWORD dwFlags,
  343. OUT BYTE **ppbKey,
  344. OUT DWORD *pcbKey);
  345. HRESULT
  346. myCertGetNameString(
  347. IN CERT_CONTEXT const *pcc,
  348. IN DWORD dwType,
  349. OUT WCHAR **ppwszSimpleName);
  350. #define CA_VERIFY_FLAGS_ALLOW_UNTRUSTED_ROOT 0x00000001
  351. #define CA_VERIFY_FLAGS_IGNORE_OFFLINE 0x00000002
  352. #define CA_VERIFY_FLAGS_NO_REVOCATION 0x00000004
  353. #define CA_VERIFY_FLAGS_NT_AUTH 0x00000008
  354. #define CA_VERIFY_FLAGS_DUMP_CHAIN 0x40000000
  355. #define CA_VERIFY_FLAGS_SAVE_CHAIN 0x80000000
  356. HRESULT
  357. myVerifyCertContext(
  358. IN CERT_CONTEXT const *pCert,
  359. IN DWORD dwFlags,
  360. IN DWORD cUsageOids,
  361. OPTIONAL IN CHAR const * const *apszUsageOids,
  362. OPTIONAL IN HCERTCHAINENGINE hChainEngine,
  363. OPTIONAL IN HCERTSTORE hAdditionalStore,
  364. OPTIONAL OUT WCHAR **ppwszMissingIssuer);
  365. HRESULT
  366. myVerifyCertContextEx(
  367. IN CERT_CONTEXT const *pCert,
  368. IN DWORD dwFlags,
  369. IN DWORD cUsageOids,
  370. OPTIONAL IN CHAR const * const *apszUsageOids,
  371. OPTIONAL IN HCERTCHAINENGINE hChainEngine,
  372. OPTIONAL IN FILETIME const *pft,
  373. OPTIONAL IN HCERTSTORE hAdditionalStore,
  374. OPTIONAL OUT WCHAR **ppwszMissingIssuer,
  375. OPTIONAL OUT WCHAR **ppwszzIssuancePolicies,
  376. OPTIONAL OUT WCHAR **ppwszzApplicationPolicies);
  377. HRESULT
  378. myVerifyKRACertContext(
  379. IN CERT_CONTEXT const *pCert,
  380. IN DWORD dwFlags);
  381. HRESULT
  382. myCertStrToName(
  383. IN DWORD dwCertEncodingType,
  384. IN LPCWSTR pszX500,
  385. IN DWORD dwStrType,
  386. IN OPTIONAL void *pvReserved,
  387. OUT BYTE **ppbEncoded,
  388. OUT DWORD *pcbEncoded,
  389. OUT OPTIONAL LPCWSTR *ppszError);
  390. HRESULT
  391. myCertNameToStr(
  392. IN DWORD dwCertEncodingType,
  393. IN CERT_NAME_BLOB const *pName,
  394. IN DWORD dwStrType,
  395. OUT WCHAR **ppwszName);
  396. HRESULT
  397. myCryptStringToBinaryA(
  398. IN LPCSTR pszString,
  399. IN DWORD cchString,
  400. IN DWORD dwFlags,
  401. OUT BYTE **ppbBinary,
  402. OUT DWORD *pcbBinary,
  403. OUT DWORD *pdwSkip, // OPTIONAL
  404. OUT DWORD *pdwFlags); // OPTIONAL
  405. HRESULT
  406. myCryptStringToBinary(
  407. IN LPCWSTR pwszString,
  408. IN DWORD cwcString,
  409. IN DWORD dwFlags,
  410. OUT BYTE **ppbBinary,
  411. OUT DWORD *pcbBinary,
  412. OUT DWORD *pdwSkip, // OPTIONAL
  413. OUT DWORD *pdwFlags); // OPTIONAL
  414. HRESULT
  415. myCryptBinaryToStringA(
  416. IN CONST BYTE *pbBinary,
  417. IN DWORD cbBinary,
  418. IN DWORD dwFlags,
  419. OUT LPSTR *ppszString);
  420. HRESULT
  421. myCryptBinaryToString(
  422. IN CONST BYTE *pbBinary,
  423. IN DWORD cbBinary,
  424. IN DWORD dwFlags,
  425. OUT LPWSTR *ppwszString);
  426. HRESULT
  427. myIsFirstSigner(
  428. IN CERT_NAME_BLOB const *pNameBlob,
  429. OUT BOOL *pfDummy);
  430. HRESULT
  431. myCopyKeys(
  432. IN CRYPT_KEY_PROV_INFO const *pkpi,
  433. IN WCHAR const *pwszOldContainer,
  434. IN WCHAR const *pwszNewContainer,
  435. IN BOOL fOldUserKey,
  436. IN BOOL fNewUserKey,
  437. IN BOOL fForceOverWrite);
  438. HRESULT
  439. mySaveChainAndKeys(
  440. IN CERT_SIMPLE_CHAIN const *pSimpleChain,
  441. IN WCHAR const *pwszStore,
  442. IN DWORD dwStoreFlags,
  443. IN CRYPT_KEY_PROV_INFO const *pkpi,
  444. OPTIONAL OUT CERT_CONTEXT const **ppCert);
  445. HCERTSTORE
  446. myPFXImportCertStore(
  447. IN CRYPT_DATA_BLOB *ppfx,
  448. OPTIONAL IN WCHAR const *pwszPassword,
  449. IN DWORD dwFlags);
  450. HRESULT
  451. myPFXExportCertStore(
  452. IN HCERTSTORE hStore,
  453. OUT CRYPT_DATA_BLOB *ppfx,
  454. IN WCHAR const *pwszPassword,
  455. IN DWORD dwFlags);
  456. HRESULT
  457. myAddChainToMemoryStore(
  458. IN HCERTSTORE hMemoryStore,
  459. IN CERT_CONTEXT const *pCertContext);
  460. typedef struct _RESTORECHAIN
  461. {
  462. CERT_CHAIN_CONTEXT const *pChain;
  463. DWORD NameId;
  464. } RESTORECHAIN;
  465. HRESULT
  466. myGetChainArrayFromStore(
  467. IN HCERTSTORE hStore,
  468. IN BOOL fCAChain,
  469. IN BOOL fUserStore,
  470. OPTIONAL OUT WCHAR **ppwszCommonName,
  471. IN OUT DWORD *pcRestoreChain,
  472. OPTIONAL OUT RESTORECHAIN *paRestoreChain);
  473. #ifndef CERTREQUEST_CLIENT_CERTREQ // moved to xelib.h
  474. HRESULT
  475. myGetUserNameEx(
  476. IN EXTENDED_NAME_FORMAT NameFormat,
  477. OUT WCHAR **ppwszUserName);
  478. #endif
  479. HRESULT
  480. myGetComputerObjectName(
  481. IN EXTENDED_NAME_FORMAT NameFormat,
  482. OUT WCHAR **ppwszDnsName);
  483. HRESULT
  484. myGetComputerNames(
  485. OUT WCHAR **ppwszDnsName,
  486. OUT WCHAR **ppwszOldName);
  487. #ifndef CERTREQUEST_CLIENT_CERTREQ // moved to xelib.h
  488. HRESULT
  489. myGetMachineDnsName(
  490. OUT WCHAR **ppwszDnsName);
  491. #endif
  492. LANGID
  493. mySetThreadUILanguage(
  494. IN WORD wReserved);
  495. BOOL
  496. myConvertStringSecurityDescriptorToSecurityDescriptor(
  497. IN LPCWSTR StringSecurityDescriptor,
  498. IN DWORD StringSDRevision,
  499. OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
  500. OUT PULONG SecurityDescriptorSize OPTIONAL);
  501. BOOL
  502. myConvertSidToStringSid(
  503. IN PSID Sid,
  504. OUT LPWSTR *StringSid);
  505. BOOL
  506. myConvertStringSidToSid(
  507. IN LPCWSTR StringSid,
  508. OUT PSID *Sid);
  509. #define DH_INDENTMASK 0x000000ff
  510. #define DH_MULTIADDRESS 0x00000100 // add address to multi-line output only
  511. #define DH_NOADDRESS 0x00000200
  512. #define DH_NOASCIIHEX 0x00000400
  513. #define DH_NOTABPREFIX 0x00000800 // double space after addr if displayed
  514. VOID
  515. DumpHex(
  516. IN DWORD Flags,
  517. IN BYTE const *pb,
  518. IN ULONG cb);
  519. DWORD
  520. myGetDisplayLength(
  521. IN WCHAR const *pwsz);
  522. LONG
  523. myConsolePrintString(
  524. IN DWORD ccolMin,
  525. IN WCHAR const *pwszString);
  526. BOOL
  527. myConsolePrintfDisable(
  528. IN BOOL fDisable);
  529. int __cdecl
  530. myConsolePrintf(
  531. IN WCHAR const *pwszFmt,
  532. ...);
  533. //+==============================
  534. // Date/Time conversion routines:
  535. HRESULT
  536. myDateToFileTime(
  537. IN DATE const *pDate,
  538. OUT FILETIME *pft);
  539. HRESULT
  540. myFileTimeToDate(
  541. IN FILETIME const *pft,
  542. OUT DATE *pDate);
  543. HRESULT
  544. myFileTimePeriodToWszTimePeriod(
  545. IN FILETIME const *pftGMT,
  546. IN BOOL fExact,
  547. OUT WCHAR **ppwszTimePeriod);
  548. HRESULT
  549. myTranslateUnlocalizedPeriodString(
  550. IN enum ENUM_PERIOD enumPeriod,
  551. OUT WCHAR const **ppwszPeriodString);
  552. HRESULT
  553. myGMTFileTimeToWszLocalTime(
  554. IN FILETIME const *pftGMT,
  555. IN BOOL fSeconds,
  556. OUT WCHAR **ppwszLocalTime);
  557. HRESULT
  558. myFileTimeToWszTime(
  559. IN FILETIME const *pftGMT,
  560. IN BOOL fSeconds,
  561. OUT WCHAR **ppwszGMTTime);
  562. HRESULT
  563. myGMTDateToWszLocalTime(
  564. IN DATE const *pDateGMT,
  565. IN BOOL fSeconds,
  566. OUT WCHAR **ppwszLocalTime);
  567. HRESULT
  568. myWszLocalTimeToGMTDate(
  569. IN WCHAR const *pwszLocalTime,
  570. OUT DATE *pDateGMT);
  571. HRESULT
  572. myWszLocalTimeToGMTFileTime(
  573. IN WCHAR const *pwszLocalTime,
  574. OUT FILETIME *pftGMT);
  575. HRESULT
  576. mySystemTimeToGMTSystemTime(
  577. IN OUT SYSTEMTIME *pSys);
  578. enum ENUM_FORCETELETEX
  579. {
  580. ENUM_TELETEX_OFF = 0,
  581. ENUM_TELETEX_ON = 1,
  582. ENUM_TELETEX_AUTO = 2,
  583. ENUM_TELETEX_MASK = 0xf,
  584. ENUM_TELETEX_UTF8 = 0x10
  585. };
  586. typedef struct _LLFILETIME
  587. {
  588. union {
  589. LONGLONG ll;
  590. FILETIME ft;
  591. };
  592. } LLFILETIME;
  593. __inline VOID
  594. myAddToFileTime(
  595. IN OUT FILETIME *pft,
  596. IN LONGLONG ll)
  597. {
  598. LLFILETIME llft;
  599. llft.ft = *pft;
  600. llft.ll += ll;
  601. *pft = llft.ft;
  602. }
  603. __inline LONGLONG
  604. mySubtractFileTimes(
  605. IN FILETIME const *pft1,
  606. IN FILETIME const *pft2)
  607. {
  608. LLFILETIME llft1;
  609. LLFILETIME llft2;
  610. llft1.ft = *pft1;
  611. llft2.ft = *pft2;
  612. return(llft1.ll - llft2.ll);
  613. }
  614. HRESULT
  615. myMakeExprDate(
  616. IN OUT DATE *pDate,
  617. IN LONG lDelta,
  618. IN enum ENUM_PERIOD enumPeriod);
  619. HRESULT
  620. myTranslatePeriodUnits(
  621. IN WCHAR const *pwszPeriod,
  622. IN LONG lCount,
  623. OUT enum ENUM_PERIOD *penumPeriod,
  624. OUT LONG *plCount);
  625. HRESULT
  626. myDupString(
  627. IN WCHAR const *pwszIn,
  628. OUT WCHAR **ppwszOut);
  629. HRESULT
  630. myDupStringA(
  631. IN CHAR const *pszIn,
  632. OUT CHAR **ppszOut);
  633. HRESULT
  634. myUnmarshalVariant(
  635. IN DWORD PropType,
  636. IN DWORD cbValue,
  637. IN BYTE const *pbValue,
  638. OUT VARIANT *pvarValue);
  639. HRESULT
  640. myUnmarshalFormattedVariant(
  641. IN DWORD Flags,
  642. IN DWORD PropId,
  643. IN DWORD PropType,
  644. IN DWORD cbValue,
  645. IN BYTE const *pbValue,
  646. OUT VARIANT *pvarValue);
  647. HRESULT
  648. myMarshalVariant(
  649. IN VARIANT const *pvarPropertyValue,
  650. IN DWORD PropType,
  651. OUT DWORD *pcbprop,
  652. OUT BYTE **ppbprop);
  653. // Output values for myCheck7f's *pState parameter:
  654. #define CHECK7F_NONE 0x0000
  655. #define CHECK7F_OTHER 0x0001
  656. #define CHECK7F_ISSUER 0x0002
  657. #define CHECK7F_ISSUER_RDN 0x0003
  658. #define CHECK7F_ISSUER_RDN_ATTRIBUTE 0x0004
  659. #define CHECK7F_ISSUER_RDN_STRING 0x0005
  660. #define CHECK7F_SUBJECT 0x0006
  661. #define CHECK7F_SUBJECT_RDN 0x0007
  662. #define CHECK7F_SUBJECT_RDN_ATTRIBUTE 0x0008
  663. #define CHECK7F_SUBJECT_RDN_STRING 0x0009
  664. #define CHECK7F_EXTENSIONS 0x000a
  665. #define CHECK7F_EXTENSION_ARRAY 0x000b
  666. #define CHECK7F_EXTENSION 0x000c
  667. #define CHECK7F_EXTENSION_VALUE 0x000d
  668. #define CHECK7F_EXTENSION_VALUE_RAW 0x000e
  669. #define CHECK7F_COUNT 0x000f
  670. HRESULT
  671. myCheck7f(
  672. IN const BYTE *pbCert,
  673. IN DWORD cbCert,
  674. IN BOOL fVerbose,
  675. OUT DWORD *pState,
  676. OPTIONAL OUT DWORD *pIndex1,
  677. OPTIONAL OUT DWORD *pIndex2,
  678. OPTIONAL IN OUT DWORD *pcwcField,
  679. OPTIONAL OUT WCHAR *pwszField,
  680. OPTIONAL IN OUT DWORD *pcwcObjectId,
  681. OPTIONAL OUT WCHAR *pwszObjectId,
  682. OPTIONAL OUT WCHAR const **ppwszObjectIdDescription); // Static: don't free!
  683. HRESULT
  684. myVerifyObjIdA(
  685. IN char const *pszObjId);
  686. HRESULT
  687. myVerifyObjId(
  688. IN WCHAR const *pwszObjId);
  689. WCHAR const *
  690. myGetOIDNameA(
  691. IN char const *pszObjId);
  692. WCHAR const *
  693. myGetOIDName(
  694. IN WCHAR const *pwszObjId);
  695. BOOL
  696. myIsCharSanitized(
  697. IN WCHAR wc);
  698. HRESULT
  699. mySanitizeName(
  700. IN WCHAR const *pwszName,
  701. OUT WCHAR **ppwszNameOut);
  702. HRESULT
  703. myRevertSanitizeName(
  704. IN WCHAR const *pwszName,
  705. OUT WCHAR **ppwszNameOut);
  706. HRESULT
  707. mySanitizedNameToDSName(
  708. IN WCHAR const *pwszName,
  709. OUT WCHAR **ppwszNameOut);
  710. HRESULT
  711. myDecodeCMCRegInfo(
  712. IN BYTE const *pbOctet,
  713. IN DWORD cbOctet,
  714. OUT WCHAR **ppwszOut);
  715. HRESULT
  716. mySplitConfigString(
  717. IN WCHAR const *pwszConfig,
  718. OUT WCHAR **ppwszServer,
  719. OUT WCHAR **ppwszAuthority);
  720. HRESULT
  721. myCLSIDToWsz(
  722. IN CLSID const *pclsid,
  723. OUT WCHAR **ppwsz);
  724. interface ICertAdminD2;
  725. interface ICertRequestD2;
  726. HRESULT
  727. myOpenAdminDComConnection(
  728. IN WCHAR const *pwszConfig,
  729. OPTIONAL OUT WCHAR const **ppwszAuthority,
  730. OPTIONAL IN OUT WCHAR **ppwszServerName,
  731. IN OUT DWORD *pdwServerVersion,
  732. IN OUT ICertAdminD2 **ppICertAdminD);
  733. HRESULT
  734. myOpenRequestDComConnection(
  735. IN WCHAR const *pwszConfig,
  736. OPTIONAL OUT WCHAR const **ppwszAuthority,
  737. OPTIONAL IN OUT WCHAR **ppwszServerName,
  738. OPTIONAL OUT BOOL *pfNewConnection,
  739. IN OUT DWORD *pdwServerVersion,
  740. IN OUT ICertRequestD2 **ppICertRequestD);
  741. VOID
  742. myCloseDComConnection(
  743. OPTIONAL IN OUT IUnknown **ppUnknown,
  744. OPTIONAL IN OUT WCHAR **ppwszServerName);
  745. HRESULT
  746. myPingCertSrv(
  747. IN WCHAR const *pwszCAName,
  748. OPTIONAL IN WCHAR const *pwszMachineName,
  749. OPTIONAL OUT WCHAR **ppwszzCANames,
  750. OPTIONAL OUT WCHAR **ppwszSharedFolder,
  751. OPTIONAL OUT CAINFO **ppCAInfo,
  752. OPTIONAL OUT DWORD *pdwServerVersion,
  753. OPTIONAL OUT WCHAR **ppwszCADnsName);
  754. DWORD
  755. myGetCertNameProperty(
  756. IN CERT_NAME_INFO const *pNameInfo,
  757. IN char const *pszObjId,
  758. OUT WCHAR const **ppwszName);
  759. HRESULT
  760. mySetCARegFileNameTemplate(
  761. IN WCHAR const *pwszRegValueName,
  762. IN WCHAR const *pwszServerName,
  763. IN WCHAR const *pwszSanitizedName,
  764. IN WCHAR const *pwszFileName);
  765. HRESULT
  766. myGetCARegFileNameTemplate(
  767. IN WCHAR const *pwszRegValueName,
  768. IN WCHAR const *pwszServerName,
  769. IN WCHAR const *pwszSanitizedName,
  770. IN DWORD iCert,
  771. IN DWORD iCRL,
  772. OUT WCHAR **ppwszFileName);
  773. #define CSRH_CASIGCERT 0
  774. #define CSRH_CAXCHGCERT 1
  775. #define CSRH_CAKRACERT 2
  776. HRESULT
  777. mySetCARegHash(
  778. IN WCHAR const *pwszSanitizedCAName,
  779. IN DWORD dwRegHashChoice,
  780. IN DWORD Index,
  781. IN CERT_CONTEXT const *pCert);
  782. HRESULT
  783. myGetCARegHash(
  784. IN WCHAR const *pwszSanitizedCAName,
  785. IN DWORD dwRegHashChoice,
  786. IN DWORD Index,
  787. OUT BYTE **ppbHash,
  788. OUT DWORD *pcbHash);
  789. HRESULT
  790. myGetCARegHashCount(
  791. IN WCHAR const *pwszSanitizedCAName,
  792. IN DWORD dwRegHashChoice,
  793. OUT DWORD *pCount);
  794. HRESULT myShrinkCARegHash(
  795. IN WCHAR const *pwszSanitizedCAName,
  796. IN DWORD dwRegHashChoice,
  797. IN DWORD Index);
  798. HRESULT
  799. myGetNameId(
  800. IN CERT_CONTEXT const *pCACert,
  801. OUT DWORD *pdwNameId);
  802. HRESULT
  803. myFindCACertByHash(
  804. IN HCERTSTORE hStore,
  805. IN BYTE const *pbHash,
  806. IN DWORD cbHash,
  807. OUT OPTIONAL DWORD *pdwNameId,
  808. OUT CERT_CONTEXT const **ppCACert);
  809. HRESULT
  810. myFindCACertByHashIndex(
  811. IN HCERTSTORE hStore,
  812. IN WCHAR const *pwszSanitizedCAName,
  813. IN DWORD dwRegHashChoice,
  814. IN DWORD Index,
  815. OPTIONAL OUT DWORD *pdwNameId,
  816. OUT CERT_CONTEXT const **ppCACert);
  817. BOOL
  818. myAreBlobsSame(
  819. IN BYTE const *pbData1,
  820. IN DWORD cbData1,
  821. IN BYTE const *pbData2,
  822. IN DWORD cbData2);
  823. BOOL
  824. myAreSerialNumberBlobsSame(
  825. IN CRYPT_INTEGER_BLOB const *pBlob1,
  826. IN CRYPT_INTEGER_BLOB const *pBlob2);
  827. VOID
  828. myGenerateGuidSerialNumber(
  829. OUT GUID *pguidSerialNumber);
  830. #define CSRF_INSTALLCACERT 0x00000000
  831. #define CSRF_RENEWCACERT 0x00000001
  832. #define CSRF_NEWKEYS 0x00000002
  833. #define CSRF_UNATTENDED 0x40000000
  834. #define CSRF_OVERWRITE 0x80000000
  835. HRESULT
  836. CertServerRequestCACertificateAndComplete(
  837. IN HINSTANCE hInstance,
  838. IN HWND hwnd,
  839. IN DWORD Flags,
  840. IN WCHAR const *pwszCAName,
  841. OPTIONAL IN WCHAR const *pwszParentMachine,
  842. OPTIONAL IN WCHAR const *pwszParentCA,
  843. OPTIONAL IN WCHAR const *pwszCAChainFile,
  844. OPTIONAL OUT WCHAR **ppwszRequestFile);
  845. HRESULT
  846. myBuildPathAndExt(
  847. IN WCHAR const *pwszDir,
  848. IN WCHAR const *pwszFile,
  849. OPTIONAL IN WCHAR const *pwszExt,
  850. OUT WCHAR **ppwszPath);
  851. HRESULT
  852. myCreateBackupDir(
  853. IN WCHAR const *pwszDir,
  854. IN BOOL fForceOverWrite);
  855. typedef struct _DBBACKUPPROGRESS
  856. {
  857. DWORD dwDBPercentComplete;
  858. DWORD dwLogPercentComplete;
  859. DWORD dwTruncateLogPercentComplete;
  860. } DBBACKUPPROGRESS;
  861. #define CDBBACKUP_INCREMENTAL 0x00000001 // else full backup
  862. #define CDBBACKUP_KEEPOLDLOGS 0x00000002 // else truncate logs
  863. #define CDBBACKUP_OVERWRITE 0x00000100 // for myBackupDB only
  864. #define CDBBACKUP_VERIFYONLY 0x00000200 // for myBackupDB and myRestoreDB
  865. #define CDBBACKUP_BACKUPVALID (CDBBACKUP_INCREMENTAL | \
  866. CDBBACKUP_KEEPOLDLOGS | \
  867. CDBBACKUP_OVERWRITE | \
  868. CDBBACKUP_VERIFYONLY)
  869. #define CDBBACKUP_RESTOREVALID (CDBBACKUP_INCREMENTAL | \
  870. CDBBACKUP_KEEPOLDLOGS | \
  871. CDBBACKUP_VERIFYONLY)
  872. HRESULT
  873. myBackupDB(
  874. OPTIONAL IN WCHAR const *pwszConfig,
  875. IN DWORD Flags,
  876. IN WCHAR const *pwszBackupDir,
  877. OPTIONAL OUT DBBACKUPPROGRESS *pdbp);
  878. HRESULT
  879. myRestoreDB(
  880. IN WCHAR const *pwszConfig,
  881. IN DWORD Flags,
  882. OPTIONAL IN WCHAR const *pwszBackupDir,
  883. OPTIONAL IN WCHAR const *pwszCheckPointFilePath,
  884. OPTIONAL IN WCHAR const *pwszLogPath,
  885. OPTIONAL IN WCHAR const *pwszBackupLogPath,
  886. OPTIONAL OUT DBBACKUPPROGRESS *pdbp);
  887. HRESULT
  888. myDeleteDBFilesInDir(
  889. IN WCHAR const *pwszDir);
  890. HRESULT
  891. myDoDBFilesExist(
  892. IN WCHAR const *pwszSanitizedName,
  893. OUT BOOL *pfFilesExist,
  894. OPTIONAL OUT WCHAR **ppwszFileInUse);
  895. HRESULT
  896. myDoDBFilesExistInDir(
  897. IN WCHAR const *pwszDir,
  898. OUT BOOL *pfFilesExist,
  899. OPTIONAL OUT WCHAR **ppwszFileInUse);
  900. HRESULT
  901. myIsConfigLocal(
  902. IN WCHAR const *pwszConfig,
  903. OPTIONAL OUT WCHAR **ppwszMachine,
  904. OUT BOOL *pfLocal);
  905. HRESULT
  906. myIsConfigLocal2(
  907. IN WCHAR const *pwszConfig,
  908. IN WCHAR const *pwszDnsName,
  909. IN WCHAR const *pwszOldName,
  910. OUT BOOL *pfLocal);
  911. HRESULT
  912. myGetConfig(
  913. IN DWORD dwUIFlag,
  914. OUT WCHAR **ppwszConfig);
  915. HRESULT
  916. myConvertLocalPathToUNC(
  917. OPTIONAL IN WCHAR const *pwszServer,
  918. IN WCHAR const *pwszFile,
  919. OUT WCHAR **ppwszFileUNC);
  920. HRESULT
  921. myConvertUNCPathToLocal(
  922. IN WCHAR const *pwszUNCPath,
  923. OUT WCHAR **ppwszLocalPath);
  924. ULONG
  925. myLocalPathwcslen(
  926. IN WCHAR const *pwsz);
  927. VOID
  928. myLocalPathwcscpy(
  929. OUT WCHAR *pwszOut,
  930. IN WCHAR const *pwszIn);
  931. HRESULT
  932. myCertServerExportPFX(
  933. IN WCHAR const *pwszCAName,
  934. IN WCHAR const *pwszBackupDir,
  935. IN WCHAR const *pwszPassword,
  936. IN BOOL fForceOverWrite,
  937. IN BOOL fMustExportPrivateKeys,
  938. OPTIONAL OUT WCHAR **ppwszPFXFile);
  939. HRESULT
  940. myCertServerImportPFX(
  941. IN WCHAR const *pwszBackupDirOrPFXFile,
  942. IN WCHAR const *pwszPassword,
  943. IN BOOL fForceOverWrite,
  944. OPTIONAL OUT WCHAR **ppwszCommonName,
  945. OPTIONAL OUT WCHAR **ppwszPFXFile,
  946. OPTIONAL OUT CERT_CONTEXT const **ppSavedLeafCert);
  947. HRESULT
  948. myDeleteGuidKeys(
  949. IN HCERTSTORE hStorePFX,
  950. IN BOOL fMachineKeySet);
  951. #define IsHrSkipPrivateKey(hresult) \
  952. (NTE_BAD_KEY_STATE == (hresult) || \
  953. CRYPT_E_NO_KEY_PROPERTY == (hresult) || \
  954. E_HANDLE == (hresult))
  955. HRESULT
  956. myCryptExportPrivateKey(
  957. IN HCRYPTKEY hKey,
  958. OUT BYTE **ppbKey,
  959. OUT DWORD *pcbKey);
  960. HRESULT
  961. myCertGetKeyProviderInfo(
  962. IN CERT_CONTEXT const *pCert,
  963. OUT CRYPT_KEY_PROV_INFO **ppkpi);
  964. HRESULT
  965. myRepairCertKeyProviderInfo(
  966. IN CERT_CONTEXT const *pCert,
  967. IN BOOL fForceMachineKey,
  968. OPTIONAL OUT CRYPT_KEY_PROV_INFO **ppkpi);
  969. HRESULT
  970. myVerifyPublicKey(
  971. IN OPTIONAL CERT_CONTEXT const *pCert,
  972. IN BOOL fV1Cert,
  973. IN OPTIONAL CRYPT_KEY_PROV_INFO const *pKeyProvInfo,
  974. IN OPTIONAL CERT_PUBLIC_KEY_INFO const *pSubjectPublicKeyInfo,
  975. OPTIONAL OUT BOOL *pfMatchingKey);
  976. HRESULT
  977. myValidateKeyBlob(
  978. IN BYTE const *pbKey,
  979. IN DWORD cbKey,
  980. IN CERT_PUBLIC_KEY_INFO const *pPublicKeyInfo,
  981. IN BOOL fV1Cert,
  982. OPTIONAL OUT CRYPT_KEY_PROV_INFO *pkpi);
  983. BOOL
  984. myCertComparePublicKeyInfo(
  985. IN DWORD dwCertEncodingType,
  986. IN BOOL fV1Cert,
  987. IN CERT_PUBLIC_KEY_INFO const *pPublicKey1,
  988. IN CERT_PUBLIC_KEY_INFO const *pPublicKey2);
  989. BOOL
  990. myIsDirectory(
  991. IN WCHAR const *pwszDirectoryPath);
  992. BOOL
  993. myIsDirEmpty(
  994. IN WCHAR const *pwszDir);
  995. HRESULT
  996. myIsDirWriteable(
  997. IN WCHAR const *pwszPath,
  998. IN BOOL fFilePath);
  999. BOOL
  1000. myIsFileInUse(
  1001. IN WCHAR const *pwszFile);
  1002. __inline BOOL
  1003. myDoesFileExist(
  1004. IN WCHAR const *pwszFile)
  1005. {
  1006. // Allow Ansi subdirectory builds, use GetFileAttributesW
  1007. return(-1 != GetFileAttributesW(pwszFile));
  1008. }
  1009. WCHAR const *
  1010. myLoadResourceString(
  1011. IN DWORD ResourceId);
  1012. VOID
  1013. myFreeResourceStrings(
  1014. IN char const *pszModule);
  1015. HRESULT
  1016. myDoesDSExist(
  1017. IN BOOL fRetry);
  1018. HRESULT
  1019. myGetConfigFromPicker(
  1020. OPTIONAL IN HWND hwndParent,
  1021. OPTIONAL IN WCHAR const *pwszPrompt,
  1022. OPTIONAL IN WCHAR const *pwszTitle,
  1023. OPTIONAL IN WCHAR const *pwszSharedFolder,
  1024. IN BOOL fUseDS,
  1025. IN BOOL fCountOnly,
  1026. OUT DWORD *pdwCACount,
  1027. OUT CRYPTUI_CA_CONTEXT const **ppCAContext);
  1028. HRESULT
  1029. myGetConfigStringFromPicker(
  1030. OPTIONAL IN HWND hwndParent,
  1031. OPTIONAL IN WCHAR const *pwszPrompt,
  1032. OPTIONAL IN WCHAR const *pwszTitle,
  1033. OPTIONAL IN WCHAR const *pwszSharedFolder,
  1034. IN BOOL fUseDS,
  1035. OUT WCHAR **ppwszConfig);
  1036. HRESULT
  1037. myDeleteCertRegValueEx(
  1038. OPTIONAL IN WCHAR const *pwszName1,
  1039. OPTIONAL IN WCHAR const *pwszName2,
  1040. OPTIONAL IN WCHAR const *pwszName3,
  1041. OPTIONAL IN WCHAR const *pwszValueName,
  1042. IN BOOL fAbsolutePath);
  1043. HRESULT
  1044. myDeleteCertRegValue(
  1045. OPTIONAL IN WCHAR const *pwszName1,
  1046. OPTIONAL IN WCHAR const *pwszName2,
  1047. OPTIONAL IN WCHAR const *pwszName3,
  1048. OPTIONAL IN WCHAR const *pwszValueName);
  1049. HRESULT
  1050. myDeleteCertRegKeyEx(
  1051. OPTIONAL IN WCHAR const *pwszName1,
  1052. OPTIONAL IN WCHAR const *pwszName2,
  1053. OPTIONAL IN WCHAR const *pwszName3,
  1054. IN BOOL fConfigLevel);
  1055. HRESULT
  1056. myDeleteCertRegKey(
  1057. OPTIONAL IN WCHAR const *pwszName1,
  1058. OPTIONAL IN WCHAR const *pwszName2,
  1059. OPTIONAL IN WCHAR const *pwszName3);
  1060. HRESULT
  1061. myCreateCertRegKeyEx(
  1062. IN BOOL fUpgrade,
  1063. OPTIONAL IN WCHAR const *pwszName1,
  1064. OPTIONAL IN WCHAR const *pwszName2,
  1065. OPTIONAL IN WCHAR const *pwszName3);
  1066. HRESULT
  1067. myCreateCertRegKey(
  1068. OPTIONAL IN WCHAR const *pwszName1,
  1069. OPTIONAL IN WCHAR const *pwszName2,
  1070. OPTIONAL IN WCHAR const *pwszName3);
  1071. HRESULT
  1072. mySetCertRegValue(
  1073. OPTIONAL IN WCHAR const *pwszMachine,
  1074. OPTIONAL IN WCHAR const *pwszName1,
  1075. OPTIONAL IN WCHAR const *pwszName2,
  1076. OPTIONAL IN WCHAR const *pwszName3,
  1077. IN WCHAR const *pwszValueName,
  1078. IN DWORD const dwValueType,
  1079. IN BYTE const *pbData,
  1080. IN DWORD const cbData,
  1081. IN BOOL fAbsolutePath);
  1082. HRESULT
  1083. mySetCertRegValueEx(
  1084. OPTIONAL IN WCHAR const *pwszMachine,
  1085. OPTIONAL IN WCHAR const *pwszName1,
  1086. OPTIONAL IN WCHAR const *pwszName2,
  1087. OPTIONAL IN WCHAR const *pwszName3,
  1088. IN BOOL fConfigLevel,
  1089. OPTIONAL IN WCHAR const *pwszValueName,
  1090. IN DWORD const dwValueType,
  1091. IN BYTE const *pbData,
  1092. IN DWORD const cbData,
  1093. IN BOOL fAbsolutePath);
  1094. HRESULT
  1095. myGetCertRegValue(
  1096. OPTIONAL IN WCHAR const *pwszMachine,
  1097. OPTIONAL IN WCHAR const *pwszName1,
  1098. OPTIONAL IN WCHAR const *pwszName2,
  1099. OPTIONAL IN WCHAR const *pwszName3,
  1100. IN WCHAR const *pwszValueName,
  1101. OUT BYTE **ppbData, // free using LocalFree
  1102. OPTIONAL OUT DWORD *pcbData,
  1103. OPTIONAL OUT DWORD *pValueType);
  1104. HRESULT
  1105. myGetCertRegValueEx(
  1106. OPTIONAL IN WCHAR const *pwszMachine,
  1107. OPTIONAL IN WCHAR const *pwszName1,
  1108. OPTIONAL IN WCHAR const *pwszName2,
  1109. OPTIONAL IN WCHAR const *pwszName3,
  1110. IN BOOL fConfigLevel,
  1111. IN WCHAR const *pwszValueName,
  1112. OUT BYTE **ppbData,
  1113. OPTIONAL OUT DWORD *pcbData,
  1114. OPTIONAL OUT DWORD *pValueType);
  1115. HRESULT
  1116. mySetCertRegMultiStrValue(
  1117. OPTIONAL IN WCHAR const *pwszName1,
  1118. OPTIONAL IN WCHAR const *pwszName2,
  1119. OPTIONAL IN WCHAR const *pwszName3,
  1120. OPTIONAL IN WCHAR const *pwszValueName,
  1121. IN WCHAR const *pwszzValue);
  1122. HRESULT
  1123. myGetCertRegMultiStrValue(
  1124. OPTIONAL IN WCHAR const *pwszName1,
  1125. OPTIONAL IN WCHAR const *pwszName2,
  1126. OPTIONAL IN WCHAR const *pwszName3,
  1127. OPTIONAL IN WCHAR const *pwszValueName,
  1128. OUT WCHAR **ppwszzValue);
  1129. HRESULT
  1130. mySetCertRegStrValue(
  1131. OPTIONAL IN WCHAR const *pwszName1,
  1132. OPTIONAL IN WCHAR const *pwszName2,
  1133. OPTIONAL IN WCHAR const *pwszName3,
  1134. IN WCHAR const *pwszValueName,
  1135. IN WCHAR const *pwszValue);
  1136. HRESULT
  1137. mySetCertRegStrValueEx(
  1138. IN BOOL fUpgrade,
  1139. OPTIONAL IN WCHAR const *pwszName1,
  1140. OPTIONAL IN WCHAR const *pwszName2,
  1141. OPTIONAL IN WCHAR const *pwszName3,
  1142. OPTIONAL IN WCHAR const *pwszValueName,
  1143. IN WCHAR const *pwszValue);
  1144. HRESULT
  1145. mySetCertRegMultiStrValueEx(
  1146. IN DWORD dwFlags, //CSREG_UPGRADE | CSREG_APPEND
  1147. OPTIONAL IN WCHAR const *pwszName1,
  1148. OPTIONAL IN WCHAR const *pwszName2,
  1149. OPTIONAL IN WCHAR const *pwszName3,
  1150. OPTIONAL IN WCHAR const *pwszValueName,
  1151. IN WCHAR const *pwszzValue);
  1152. HRESULT
  1153. mySetAbsRegMultiStrValue(
  1154. IN WCHAR const *pwszName,
  1155. IN WCHAR const *pwszValueName,
  1156. IN WCHAR const *pwszzValue);
  1157. HRESULT
  1158. mySetAbsRegStrValue(
  1159. IN WCHAR const *pwszName,
  1160. IN WCHAR const *pwszValueName,
  1161. IN WCHAR const *pwszValue);
  1162. HRESULT
  1163. mySetCertRegDWValue(
  1164. OPTIONAL IN WCHAR const *pwszName1,
  1165. OPTIONAL IN WCHAR const *pwszName2,
  1166. OPTIONAL IN WCHAR const *pwszName3,
  1167. IN WCHAR const *pwszValueName,
  1168. IN DWORD const dwValue);
  1169. HRESULT
  1170. mySetCertRegDWValueEx(
  1171. IN BOOL fUpgrade,
  1172. OPTIONAL IN WCHAR const *pwszName1,
  1173. OPTIONAL IN WCHAR const *pwszName2,
  1174. OPTIONAL IN WCHAR const *pwszName3,
  1175. OPTIONAL IN WCHAR const *pwszValueName,
  1176. IN DWORD const dwValue);
  1177. HRESULT
  1178. myGetCertRegBinaryValue(
  1179. OPTIONAL IN WCHAR const *pwszName1,
  1180. OPTIONAL IN WCHAR const *pwszName2,
  1181. OPTIONAL IN WCHAR const *pwszName3,
  1182. IN WCHAR const *pwszValueName,
  1183. OUT BYTE **ppbValue);
  1184. HRESULT
  1185. myGetCertRegStrValue(
  1186. OPTIONAL IN WCHAR const *pwszName1,
  1187. OPTIONAL IN WCHAR const *pwszName2,
  1188. OPTIONAL IN WCHAR const *pwszName3,
  1189. IN WCHAR const *pwszValueName,
  1190. OUT WCHAR **ppwszValue); // free using LocalFree
  1191. HRESULT
  1192. myGetCertRegDWValue(
  1193. OPTIONAL IN WCHAR const *pwszName1,
  1194. OPTIONAL IN WCHAR const *pwszName2,
  1195. OPTIONAL IN WCHAR const *pwszName3,
  1196. IN WCHAR const *pwszValueName,
  1197. OUT DWORD *pdwValue);
  1198. HRESULT
  1199. myCopyCertRegStrValue(
  1200. OPTIONAL IN WCHAR const *pwszSrcName1,
  1201. OPTIONAL IN WCHAR const *pwszSrcName2,
  1202. OPTIONAL IN WCHAR const *pwszSrcName3,
  1203. IN WCHAR const *pwszSrcValueName,
  1204. OPTIONAL IN WCHAR const *pwszDesName1,
  1205. OPTIONAL IN WCHAR const *pwszDesName2,
  1206. OPTIONAL IN WCHAR const *pwszDesName3,
  1207. OPTIONAL IN WCHAR const *pwszDesValueName,
  1208. IN BOOL fMultiStr);
  1209. HRESULT
  1210. myMoveCertRegStrValue(
  1211. OPTIONAL IN WCHAR const *pwszSrcName1,
  1212. OPTIONAL IN WCHAR const *pwszSrcName2,
  1213. OPTIONAL IN WCHAR const *pwszSrcName3,
  1214. IN WCHAR const *pwszSrcValueName,
  1215. OPTIONAL IN WCHAR const *pwszDesName1,
  1216. OPTIONAL IN WCHAR const *pwszDesName2,
  1217. OPTIONAL IN WCHAR const *pwszDesName3,
  1218. OPTIONAL IN WCHAR const *pwszDesValueName,
  1219. IN BOOL fMultiStr);
  1220. HRESULT
  1221. myMoveOrCopyCertRegStrValue(
  1222. OPTIONAL IN WCHAR const *pwszSrcName1,
  1223. OPTIONAL IN WCHAR const *pwszSrcName2,
  1224. OPTIONAL IN WCHAR const *pwszSrcName3,
  1225. IN WCHAR const *pwszSrcValueName,
  1226. OPTIONAL IN WCHAR const *pwszDesName1,
  1227. OPTIONAL IN WCHAR const *pwszDesName2,
  1228. OPTIONAL IN WCHAR const *pwszDesName3,
  1229. OPTIONAL IN WCHAR const *pwszDesValueName,
  1230. IN BOOL fMultiStr,
  1231. IN BOOL fMove);
  1232. HRESULT
  1233. SetSetupStatus(
  1234. OPTIONAL IN WCHAR const *pwszSanitizedCAName,
  1235. IN const DWORD dwFlag,
  1236. IN const BOOL fComplete);
  1237. HRESULT
  1238. GetSetupStatus(
  1239. OPTIONAL IN WCHAR const *pwszSanitizedCAName,
  1240. OUT DWORD *pdwStatus);
  1241. HRESULT
  1242. myGetCASerialNumber(
  1243. IN WCHAR const *pwszSanitizedCAName,
  1244. OUT BYTE **ppbSerialNumber,
  1245. OUT DWORD *cbSerialNumber);
  1246. HRESULT
  1247. myGetColumnDisplayName(
  1248. IN WCHAR const *pwszColumnName,
  1249. OUT WCHAR const **ppwszDisplayName);
  1250. HRESULT
  1251. myGetColumnName(
  1252. IN DWORD Index,
  1253. IN BOOL fDisplayName,
  1254. OUT WCHAR const **ppwszName);
  1255. VOID
  1256. myFreeColumnDisplayNames(VOID);
  1257. typedef struct _CAPROP
  1258. {
  1259. LONG lPropId;
  1260. LONG lPropFlags;
  1261. WCHAR const *pwszDisplayName;
  1262. } CAPROP;
  1263. HRESULT
  1264. myCAPropGetDisplayName(
  1265. IN LONG lPropId,
  1266. OUT WCHAR const **ppwszDisplayName);
  1267. HRESULT
  1268. myCAPropInfoUnmarshal(
  1269. IN OUT CAPROP *pCAPropInfo,
  1270. IN LONG cCAPropInfo,
  1271. IN DWORD cbCAPropInfo);
  1272. HRESULT
  1273. myCAPropInfoLookup(
  1274. IN CAPROP const *pCAPropInfo,
  1275. IN LONG cCAPropInfo,
  1276. IN LONG lPropId,
  1277. OUT CAPROP const **ppcap);
  1278. // active modules
  1279. HRESULT
  1280. myGetActiveModule(
  1281. OPTIONAL IN WCHAR const *pwszMachine,
  1282. IN WCHAR const *pwszCAName,
  1283. IN BOOL fPolicyModule,
  1284. IN DWORD Index,
  1285. OUT LPOLESTR *ppwszProgIdModule, // CoTaskMem*
  1286. OUT CLSID *pclsidModule);
  1287. // active manage module
  1288. HRESULT
  1289. myGetActiveManageModule(
  1290. OPTIONAL IN WCHAR const *pwszMachine,
  1291. IN WCHAR const *pwszCAName,
  1292. IN BOOL fPolicyModule,
  1293. IN DWORD Index,
  1294. OUT LPOLESTR *ppwszProgIdManageModule, // CoTaskMem*
  1295. OUT CLSID *pclsidManageModule);
  1296. HRESULT
  1297. myFormConfigString(
  1298. IN WCHAR const *pwszServer,
  1299. IN WCHAR const *pwszCAName,
  1300. OUT WCHAR **ppwszConfig);
  1301. HRESULT
  1302. myLoadRCString(
  1303. IN HINSTANCE hInstance,
  1304. IN int iRCId,
  1305. OUT WCHAR **ppwsz);
  1306. #define RORKF_FULLPATH 0x00000001
  1307. #define RORKF_CREATESUBKEYS 0x00000002
  1308. #define RORKF_USERKEY 0x00000004
  1309. HRESULT
  1310. myRegOpenRelativeKey(
  1311. OPTIONAL IN WCHAR const *pwszConfig,
  1312. IN WCHAR const *pwszRegName,
  1313. IN DWORD Flags, // RORKF_*
  1314. OUT WCHAR **ppwszPath,
  1315. OUT OPTIONAL WCHAR **ppwszName,
  1316. OUT OPTIONAL HKEY *phkey);
  1317. HRESULT
  1318. myFixupRCFilterString(
  1319. IN WCHAR *pwszFilter);
  1320. // NOTE: disappears in release builds
  1321. #define ASSERTVALIDCATYPE(__CATYPE__) \
  1322. CSASSERT( (\
  1323. ENUM_ENTERPRISE_SUBCA == (__CATYPE__) || \
  1324. ENUM_ENTERPRISE_ROOTCA == (__CATYPE__) || \
  1325. ENUM_UNKNOWN_CA == (__CATYPE__) || \
  1326. ENUM_STANDALONE_SUBCA == (__CATYPE__) || \
  1327. ENUM_STANDALONE_ROOTCA == (__CATYPE__) ))
  1328. __inline BOOL
  1329. IsEnterpriseCA(
  1330. IN ENUM_CATYPES CAType)
  1331. {
  1332. // assert we're a valid type
  1333. ASSERTVALIDCATYPE(CAType);
  1334. return(ENUM_ENTERPRISE_SUBCA == CAType || ENUM_ENTERPRISE_ROOTCA == CAType);
  1335. }
  1336. __inline BOOL
  1337. IsStandaloneCA(
  1338. IN ENUM_CATYPES CAType)
  1339. {
  1340. // assert we're a valid type
  1341. ASSERTVALIDCATYPE(CAType);
  1342. return(ENUM_STANDALONE_SUBCA == CAType || ENUM_STANDALONE_ROOTCA == CAType);
  1343. }
  1344. __inline BOOL
  1345. IsRootCA(
  1346. IN ENUM_CATYPES CAType)
  1347. {
  1348. // assert we're a valid type
  1349. ASSERTVALIDCATYPE(CAType);
  1350. return(ENUM_STANDALONE_ROOTCA == CAType || ENUM_ENTERPRISE_ROOTCA == CAType);
  1351. }
  1352. __inline BOOL
  1353. IsSubordinateCA(
  1354. IN ENUM_CATYPES CAType)
  1355. {
  1356. // assert we're a valid type
  1357. ASSERTVALIDCATYPE(CAType);
  1358. return(ENUM_ENTERPRISE_SUBCA == CAType || ENUM_STANDALONE_SUBCA == CAType);
  1359. }
  1360. HRESULT
  1361. myEnablePrivilege(
  1362. IN LPCTSTR szPrivilege,
  1363. IN BOOL fEnable);
  1364. HRESULT
  1365. myDeleteFilePattern(
  1366. IN WCHAR const *pwszDir,
  1367. OPTIONAL IN WCHAR const *pwszPattern, // defaults to L"*.*"
  1368. IN BOOL fRecurse);
  1369. HRESULT
  1370. myRemoveFilesAndDirectory(
  1371. IN WCHAR const *pwszPath,
  1372. IN BOOL fRecurse);
  1373. HRESULT
  1374. myCreateNestedDirectories(
  1375. WCHAR const *pwszDirectory);
  1376. #define VFF_CREATEVROOTS 0x00000001
  1377. #define VFF_CREATEFILESHARES 0x00000002
  1378. #define VFF_DELETEVROOTS 0x00000004
  1379. #define VFF_DELETEFILESHARES 0x00000008
  1380. #define VFF_SETREGFLAGFIRST 0x00000010
  1381. #define VFF_CHECKREGFLAGFIRST 0x00000020
  1382. #define VFF_CLEARREGFLAGFIRST 0x00000040
  1383. #define VFF_CLEARREGFLAGIFOK 0x00000100
  1384. #define VFF_SETRUNONCEIFERROR 0x00000200
  1385. #define VFCSEC_TIMEOUT 5 // Recommended timeout in seconds
  1386. #define VFD_NOACTION 0
  1387. #define VFD_CREATED 1
  1388. #define VFD_DELETED 2
  1389. #define VFD_EXISTS 3
  1390. #define VFD_NOTFOUND 4
  1391. #define VFD_CREATEERROR 5
  1392. #define VFD_DELETEERROR 6
  1393. #define VFD_NOTSUPPORTED 7
  1394. HRESULT
  1395. myModifyVirtualRootsAndFileShares(
  1396. IN DWORD Flags, // VFF_*: Create/Delete VRoots and/or Shares
  1397. IN ENUM_CATYPES CAType, // CA Type
  1398. IN BOOL fAsynchronous, // block during call?
  1399. IN DWORD csecTimeOut, // 0 implies synchronous call
  1400. OPTIONAL OUT DWORD *pVRootDisposition, // VFD_*
  1401. OPTIONAL OUT DWORD *pShareDisposition); // VFD_*
  1402. HRESULT
  1403. myAddShare(
  1404. IN LPCWSTR szShareName,
  1405. IN LPCWSTR szShareDescr,
  1406. IN LPCWSTR szSharePath,
  1407. IN BOOL fOverwrite,
  1408. OPTIONAL OUT BOOL *pfCreated);
  1409. typedef struct {
  1410. HINSTANCE hInstance; // instance handle
  1411. HWND hDlg; // dialog handle
  1412. HWND hwndComputerEdit; // control handle of computer edit
  1413. HWND hwndCAList; // control handle of ca list control
  1414. WNDPROC pfnUICASelectionComputerWndProcs; // computer edit win procs
  1415. // info on selected CA
  1416. ENUM_CATYPES CAType;
  1417. bool fWebProxySetup;
  1418. } CERTSRVUICASELECTION;
  1419. LRESULT CALLBACK
  1420. myUICASelectionComputerEditFilterHook(
  1421. HWND hwndComputer,
  1422. UINT iMsg,
  1423. WPARAM wParam,
  1424. LPARAM lParam);
  1425. #define UNC_PATH 1
  1426. #define LOCAL_PATH 2
  1427. BOOL
  1428. myIsFullPath(
  1429. IN WCHAR const *pwszPath,
  1430. OUT DWORD *pdwFlag);
  1431. HRESULT
  1432. myUICAHandleCABrowseButton(
  1433. CERTSRVUICASELECTION *pData,
  1434. IN BOOL fUseDS,
  1435. OPTIONAL IN int idsPickerTitle,
  1436. OPTIONAL IN int idsPickerSubTitle,
  1437. OPTIONAL OUT WCHAR **ppwszSharedFolder);
  1438. HRESULT
  1439. myUICAHandleCAListDropdown(
  1440. IN int iNotification,
  1441. IN OUT CERTSRVUICASELECTION *pData,
  1442. IN OUT BOOL *pfComputerChange);
  1443. HRESULT
  1444. myUICASelectionValidation(
  1445. CERTSRVUICASELECTION *pData,
  1446. BOOL *pfValidate);
  1447. HRESULT
  1448. myInitUICASelectionControls(
  1449. IN OUT CERTSRVUICASELECTION *pUICASelection,
  1450. IN HINSTANCE hInstance,
  1451. IN HWND hDlg,
  1452. IN HWND hwndBrowseButton,
  1453. IN HWND hwndComputerEdit,
  1454. IN HWND hwndCAList,
  1455. IN BOOL fDSCA,
  1456. OUT BOOL *pfCAsExist);
  1457. char PrintableChar(char ch);
  1458. HRESULT
  1459. myGetMapiInfo(
  1460. OPTIONAL IN WCHAR const *pwszServerName,
  1461. OUT WCHAR **ppwszProfileName,
  1462. OUT WCHAR **ppwszLogonName,
  1463. OUT WCHAR **ppwszPassword);
  1464. HRESULT
  1465. mySaveMapiInfo(
  1466. OPTIONAL IN WCHAR const *pwszServerName,
  1467. OUT WCHAR const *pwszProfileName,
  1468. OUT WCHAR const *pwszLogonName,
  1469. OUT WCHAR const *pwszPassword);
  1470. #define cwcFILENAMESUFFIXMAX 20
  1471. #define cwcSUFFIXMAX (1 + 5 + 1) // five decimal digits plus parentheses
  1472. #define wszFCSAPARM_SERVERDNSNAME L"%1"
  1473. #define wszFCSAPARM_SERVERSHORTNAME L"%2"
  1474. #define wszFCSAPARM_SANITIZEDCANAME L"%3"
  1475. #define wszFCSAPARM_CERTFILENAMESUFFIX L"%4"
  1476. #define wszFCSAPARM_DOMAINDN L"%5"
  1477. #define wszFCSAPARM_CONFIGDN L"%6"
  1478. #define wszFCSAPARM_SANITIZEDCANAMEHASH L"%7"
  1479. #define wszFCSAPARM_CRLFILENAMESUFFIX L"%8"
  1480. #define wszFCSAPARM_CRLDELTAFILENAMESUFFIX L"%9"
  1481. #define wszFCSAPARM_DSCRLATTRIBUTE L"%10"
  1482. #define wszFCSAPARM_DSCACERTATTRIBUTE L"%11"
  1483. #define wszFCSAPARM_DSUSERCERTATTRIBUTE L"%12"
  1484. #define wszFCSAPARM_DSKRACERTATTRIBUTE L"%13"
  1485. #define wszFCSAPARM_DSCROSSCERTPAIRATTRIBUTE L"%14"
  1486. HRESULT
  1487. myFormatCertsrvStringArray(
  1488. IN BOOL fURL,
  1489. IN LPCWSTR pwszServerName_p1_2,
  1490. IN LPCWSTR pwszSanitizedName_p3_7,
  1491. IN DWORD iCert_p4,
  1492. IN LPCWSTR pwszDomainDN_p5,
  1493. IN LPCWSTR pwszConfigDN_p6,
  1494. IN DWORD iCRL_p8,
  1495. IN BOOL fDeltaCRL_p9,
  1496. IN BOOL fDSAttrib_p10_11,
  1497. IN DWORD cStrings,
  1498. IN LPCWSTR *apwszStringsIn,
  1499. OUT LPWSTR *apwszStringsOut);
  1500. HRESULT
  1501. myUncanonicalizeURLParm(
  1502. IN WCHAR const *pwszParmIn,
  1503. OUT WCHAR **ppwszParmOut);
  1504. HRESULT
  1505. myAllocIndexedName(
  1506. IN WCHAR const *pwszName,
  1507. IN DWORD Index,
  1508. OUT WCHAR **ppwszIndexedName);
  1509. HRESULT
  1510. myUIGetWindowText(
  1511. IN HWND hwndCtrl,
  1512. OUT WCHAR **ppwszText);
  1513. HRESULT
  1514. myGetSaveFileName(
  1515. IN HWND hwndOwner,
  1516. IN HINSTANCE hInstance,
  1517. OPTIONAL IN int iRCTitle,
  1518. OPTIONAL IN int iRCFilter,
  1519. OPTIONAL IN int iRCDefExt,
  1520. OPTIONAL IN DWORD Flags, //see OPENFILENAME Flags
  1521. OPTIONAL IN WCHAR const *pwszDefaultFile,
  1522. OUT WCHAR **ppwszFile);
  1523. HRESULT
  1524. myGetOpenFileName(
  1525. IN HWND hwndOwner,
  1526. IN HINSTANCE hInstance,
  1527. OPTIONAL IN int iRCTitle,
  1528. OPTIONAL IN int iRCFilter,
  1529. OPTIONAL IN int iRCDefExt,
  1530. OPTIONAL IN DWORD Flags, //see OPENFILENAME Flags
  1531. OPTIONAL IN WCHAR const *pwszDefaultFile,
  1532. OUT WCHAR **ppwszFile);
  1533. HRESULT
  1534. myGetSaveFileNameEx(
  1535. IN HWND hwndOwner,
  1536. IN HINSTANCE hInstance,
  1537. OPTIONAL IN int iRCTitle,
  1538. OPTIONAL IN WCHAR const *pwszTitleInsert,
  1539. OPTIONAL IN int iRCFilter,
  1540. OPTIONAL IN int iRCDefExt,
  1541. OPTIONAL IN DWORD Flags, //see OPENFILENAME Flags
  1542. OPTIONAL IN WCHAR const *pwszDefaultFile,
  1543. OUT WCHAR **ppwszFile);
  1544. HRESULT
  1545. myGetOpenFileNameEx(
  1546. IN HWND hwndOwner,
  1547. IN HINSTANCE hInstance,
  1548. OPTIONAL IN int iRCTitle,
  1549. OPTIONAL IN WCHAR const *pwszTitleInsert,
  1550. OPTIONAL IN int iRCFilter,
  1551. OPTIONAL IN int iRCDefExt,
  1552. OPTIONAL IN DWORD Flags, //see OPENFILENAME Flags
  1553. OPTIONAL IN WCHAR const *pwszDefaultFile,
  1554. OUT WCHAR **ppwszFile);
  1555. int
  1556. myWtoI(
  1557. IN WCHAR const *pwszDigitString,
  1558. OUT BOOL *pfValid);
  1559. HRESULT
  1560. myFormCertRegPath(
  1561. IN WCHAR const *pwszName1,
  1562. IN WCHAR const *pwszName2,
  1563. IN WCHAR const *pwszName3,
  1564. IN BOOL fConfigLevel, // from CertSrv if FALSE
  1565. OUT WCHAR **ppwszPath);
  1566. HRESULT
  1567. myGetEnvString(
  1568. OUT WCHAR **ppwszOut,
  1569. IN WCHAR const *pwszVariable);
  1570. typedef HRESULT (FNMYINFGETEXTENSION)(
  1571. IN HINF hInf,
  1572. OUT CERT_EXTENSION *pext);
  1573. FNMYINFGETEXTENSION myInfGetPolicyConstraintsExtension;
  1574. FNMYINFGETEXTENSION myInfGetPolicyMappingExtension;
  1575. FNMYINFGETEXTENSION myInfGetPolicyStatementExtension;
  1576. FNMYINFGETEXTENSION myInfGetApplicationPolicyConstraintsExtension;
  1577. FNMYINFGETEXTENSION myInfGetApplicationPolicyMappingExtension;
  1578. FNMYINFGETEXTENSION myInfGetApplicationPolicyStatementExtension;
  1579. FNMYINFGETEXTENSION myInfGetNameConstraintsExtension;
  1580. FNMYINFGETEXTENSION myInfGetEnhancedKeyUsageExtension;
  1581. FNMYINFGETEXTENSION myInfGetBasicConstraints2CAExtension;
  1582. FNMYINFGETEXTENSION myInfGetBasicConstraints2CAExtensionOrDefault;
  1583. FNMYINFGETEXTENSION myInfGetCrossCertDistributionPointsExtension;
  1584. WCHAR *
  1585. myInfGetError();
  1586. VOID
  1587. myInfClearError();
  1588. HRESULT
  1589. myInfOpenFile(
  1590. OPTIONAL IN WCHAR const *pwszfnPolicy,
  1591. OUT HINF *phInf,
  1592. OUT DWORD *pErrorLine);
  1593. VOID
  1594. myInfCloseFile(
  1595. IN HINF hInf);
  1596. HRESULT
  1597. myInfGetCRLDistributionPoints(
  1598. IN HINF hInf,
  1599. OUT BOOL *pfCritical,
  1600. OUT WCHAR **ppwszz);
  1601. HRESULT
  1602. myInfGetAuthorityInformationAccess(
  1603. IN HINF hInf,
  1604. OUT BOOL *pfCritical,
  1605. OUT WCHAR **ppwszz);
  1606. HRESULT
  1607. myInfGetEnhancedKeyUsage(
  1608. IN HINF hInf,
  1609. OUT BOOL *pfCritical,
  1610. OUT WCHAR **ppwszz);
  1611. HRESULT
  1612. myInfGetValidityPeriod(
  1613. IN HINF hInf,
  1614. OPTIONAL IN WCHAR const *pwszValidityPeriodCount,
  1615. OPTIONAL IN WCHAR const *pwszValidityPeriodString,
  1616. OUT DWORD *pdwValidityPeriodCount,
  1617. OUT ENUM_PERIOD *penumValidityPeriod,
  1618. OPTIONAL OUT BOOL *pfSwap);
  1619. HRESULT
  1620. myinfGetCRLPublicationParams(
  1621. IN HINF hInf,
  1622. IN LPCWSTR szInfSection_CRLPeriod,
  1623. IN LPCWSTR szInfSection_CRLCount,
  1624. OUT LPWSTR* ppwszCRLPeriod,
  1625. OUT DWORD* pdwCRLCount);
  1626. HRESULT
  1627. myInfGetKeyLength(
  1628. IN HINF hInf,
  1629. OUT DWORD *pdwKeyLength);
  1630. HRESULT
  1631. myInfParseBooleanValue(
  1632. IN WCHAR const *pwszValue,
  1633. OUT BOOL *pfValue);
  1634. HRESULT
  1635. myInfGetNumericKeyValue(
  1636. IN HINF hInf,
  1637. IN BOOL fLog,
  1638. IN WCHAR const *pwszSection,
  1639. IN WCHAR const *pwszKey,
  1640. OUT DWORD *pdwValue);
  1641. HRESULT
  1642. myInfGetBooleanValue(
  1643. IN HINF hInf,
  1644. IN WCHAR const *pwszSection,
  1645. IN WCHAR const *pwszKey,
  1646. IN BOOL fIgnoreMissingKey,
  1647. OUT BOOL *pfValue);
  1648. HRESULT
  1649. myInfGetKeyValue(
  1650. IN HINF hInf,
  1651. IN BOOL fLog,
  1652. IN WCHAR const *pwszSection,
  1653. IN WCHAR const *pwszKey,
  1654. OUT WCHAR **ppwszValue);
  1655. HRESULT
  1656. myInfGetKeyList(
  1657. IN HINF hInf,
  1658. IN WCHAR const *pwszSection,
  1659. IN WCHAR const *pwszKey,
  1660. OUT BOOL *pfCritical,
  1661. OUT WCHAR **ppwszz);
  1662. typedef struct _INFVALUES
  1663. {
  1664. WCHAR *pwszKey;
  1665. DWORD cValues;
  1666. WCHAR **rgpwszValues;
  1667. } INFVALUES;
  1668. HRESULT
  1669. myInfGetSectionValues(
  1670. IN HINF hInf,
  1671. IN WCHAR const *pwszSection,
  1672. OUT DWORD *pcInfValues,
  1673. OUT INFVALUES **prgInfValues);
  1674. VOID
  1675. myInfFreeSectionValues(
  1676. IN DWORD cInfValues,
  1677. IN OUT INFVALUES *rgInfValues);
  1678. HRESULT
  1679. myInfGetRequestAttributes(
  1680. IN HINF hInf,
  1681. OUT DWORD *pcAttribute,
  1682. OUT CRYPT_ATTR_BLOB **ppaAttribute,
  1683. OUT WCHAR **ppwszTemplateName);
  1684. VOID
  1685. myInfFreeRequestAttributes(
  1686. IN DWORD cAttribute,
  1687. IN OUT CRYPT_ATTR_BLOB *paAttribute);
  1688. HRESULT
  1689. myBuildOSVersionAttribute(
  1690. OUT BYTE **ppbVersion,
  1691. OUT DWORD *pcbVersion);
  1692. HRESULT
  1693. myBuildCertTypeExtension(
  1694. IN WCHAR const *pwszCertType,
  1695. OUT CERT_EXTENSION *pExt);
  1696. HRESULT
  1697. myParseNextAttribute(
  1698. IN OUT WCHAR **ppwszBuf,
  1699. IN BOOL fURL,
  1700. OUT WCHAR const **ppwszName,
  1701. OUT WCHAR const **ppwszValue);
  1702. #define CUCS_MYSTORE 0x00000001
  1703. #define CUCS_CASTORE 0x00000002
  1704. #define CUCS_KRASTORE 0x00000004
  1705. #define CUCS_ROOTSTORE 0x00000008
  1706. #define CUCS_MACHINESTORE 0x00010000
  1707. #define CUCS_USERSTORE 0x00020000
  1708. #define CUCS_DSSTORE 0x00040000
  1709. #define CUCS_ARCHIVED 0x10000000
  1710. #define CUCS_USAGEREQUIRED 0x20000000
  1711. #define CUCS_SILENT 0x40000000
  1712. #define CUCS_PRIVATEKEYREQUIRED 0x80000000
  1713. HRESULT
  1714. myGetCertificateFromPicker(
  1715. OPTIONAL IN HINSTANCE hInstance,
  1716. OPTIONAL IN HWND hwndParent,
  1717. OPTIONAL IN int idTitle,
  1718. OPTIONAL IN int idSubTitle,
  1719. IN DWORD dwFlags, // CUCS_*
  1720. OPTIONAL IN WCHAR const *pwszCommonName,
  1721. OPTIONAL IN DWORD cStore,
  1722. OPTIONAL IN HCERTSTORE *rghStore,
  1723. IN DWORD cpszObjId,
  1724. OPTIONAL IN CHAR const * const *apszObjId,
  1725. OUT CERT_CONTEXT const **ppCert);
  1726. HRESULT
  1727. myGetKRACertificateFromPicker(
  1728. OPTIONAL IN HINSTANCE hInstance,
  1729. OPTIONAL IN HWND hwndParent,
  1730. OPTIONAL IN int idTitle,
  1731. OPTIONAL IN int idSubTitle,
  1732. OPTIONAL IN WCHAR const *pwszCommonName,
  1733. IN BOOL fUseDS,
  1734. IN BOOL fSilent,
  1735. OUT CERT_CONTEXT const **ppCert);
  1736. HRESULT
  1737. myGetERACertificateFromPicker(
  1738. OPTIONAL IN HINSTANCE hInstance,
  1739. OPTIONAL IN HWND hwndParent,
  1740. OPTIONAL IN int idTitle,
  1741. OPTIONAL IN int idSubTitle,
  1742. OPTIONAL IN WCHAR const *pwszCommonName,
  1743. IN BOOL fSilent,
  1744. OUT CERT_CONTEXT const **ppCert);
  1745. HRESULT
  1746. myMakeSerialBstr(
  1747. IN WCHAR const *pwszSerialNumber,
  1748. OUT BSTR *pstrSerialNumber);
  1749. HRESULT
  1750. myNameBlobMatch(
  1751. IN CERT_NAME_BLOB const *pSubject,
  1752. IN WCHAR const *pwszCertName,
  1753. IN BOOL fAllowMissingCN,
  1754. OUT BOOL *pfMatch);
  1755. HRESULT
  1756. mySerialNumberMatch(
  1757. IN CRYPT_INTEGER_BLOB const *pSerialNumber,
  1758. IN WCHAR const *pwszSerialNumber,
  1759. OUT BOOL *pfMatch);
  1760. HRESULT
  1761. myCertHashMatch(
  1762. IN CERT_CONTEXT const *pCert,
  1763. IN DWORD cb,
  1764. IN BYTE const *pb,
  1765. OUT BOOL *pfMatch);
  1766. HRESULT
  1767. myCertMatch(
  1768. IN CERT_CONTEXT const *pCert,
  1769. IN WCHAR const *pwszCertName,
  1770. IN BOOL fAllowMissingCN,
  1771. OPTIONAL IN BYTE const *pbHash,
  1772. IN DWORD cbHash,
  1773. OPTIONAL IN WCHAR const *pwszSerialNumber,
  1774. OUT BOOL *pfMatch);
  1775. HRESULT
  1776. myCRLHashMatch(
  1777. IN CRL_CONTEXT const *pCRL,
  1778. IN DWORD cb,
  1779. IN BYTE const *pb,
  1780. OUT BOOL *pfMatch);
  1781. HRESULT
  1782. myCRLMatch(
  1783. IN CRL_CONTEXT const *pCRL,
  1784. IN WCHAR const *pwszCRLName,
  1785. IN BOOL fAllowMissingCN,
  1786. OPTIONAL IN BYTE const *pbHash,
  1787. IN DWORD cbHash,
  1788. OUT BOOL *pfMatch);
  1789. HRESULT
  1790. myCTLMatch(
  1791. IN CTL_CONTEXT const *pCTL,
  1792. OPTIONAL IN BYTE const *pbHash,
  1793. IN DWORD cbHash,
  1794. OUT BOOL *pfMatch);
  1795. HRESULT
  1796. myLoadPrivateKey(
  1797. IN CERT_PUBLIC_KEY_INFO const *pPubKeyInfo,
  1798. IN DWORD dwFlags, // CUCS_*
  1799. OUT HCRYPTPROV *phProv,
  1800. OUT DWORD *pdwKeySpec,
  1801. OUT BOOL *pfCallerFreeProv);
  1802. HRESULT
  1803. myLoadPrivateKeyFromCertStores(
  1804. IN CERT_PUBLIC_KEY_INFO const *pPubKeyInfo,
  1805. IN DWORD cStore,
  1806. IN HCERTSTORE *rghStore,
  1807. OUT HCRYPTPROV *phProv,
  1808. OUT DWORD *pdwKeySpec,
  1809. OUT BOOL *pfCallerFreeProv);
  1810. HRESULT
  1811. myOpenCertStores(
  1812. IN DWORD dwFlags, // CUCS_*
  1813. OUT DWORD *pcStore,
  1814. OUT HCERTSTORE **prghStore);
  1815. VOID
  1816. myCloseCertStores(
  1817. IN DWORD cStore,
  1818. IN HCERTSTORE *rghStore);
  1819. #define DECF_FORCEOVERWRITE 0x00000100
  1820. HRESULT
  1821. DecodeFileW(
  1822. IN WCHAR const *pwszfn,
  1823. OUT BYTE **ppbOut,
  1824. OUT DWORD *pcbOut,
  1825. IN DWORD Flags);
  1826. HRESULT
  1827. EncodeToFileW(
  1828. IN WCHAR const *pwszfn,
  1829. IN BYTE const *pbIn,
  1830. IN DWORD cbIn,
  1831. IN DWORD Flags);
  1832. HRESULT
  1833. DecodeCertString(
  1834. IN BSTR const bstrIn,
  1835. IN DWORD Flags,
  1836. OUT BYTE **ppbOut,
  1837. OUT DWORD *pcbOut);
  1838. HRESULT
  1839. EncodeCertString(
  1840. IN BYTE const *pbIn,
  1841. IN DWORD cbIn,
  1842. IN DWORD Flags,
  1843. OUT BSTR *pbstrOut);
  1844. HRESULT
  1845. WszToMultiByteIntegerBuf(
  1846. IN BOOL fOctetString,
  1847. IN WCHAR const *pwszIn,
  1848. IN OUT DWORD *pcbOut,
  1849. OPTIONAL OUT BYTE const *pbOut);
  1850. HRESULT
  1851. WszToMultiByteInteger(
  1852. IN BOOL fOctetString,
  1853. IN WCHAR const *pwszIn,
  1854. OUT DWORD *pcbOut,
  1855. OUT BYTE **ppbOut);
  1856. HRESULT
  1857. myGetSecurityDescriptorDacl(
  1858. IN PSECURITY_DESCRIPTOR pSD,
  1859. OUT PACL *ppDacl); // no free
  1860. HRESULT
  1861. myRegValueToVariant(
  1862. IN DWORD dwType,
  1863. IN DWORD cbValue,
  1864. IN BYTE const *pbValue,
  1865. OUT VARIANT *pVar);
  1866. HRESULT
  1867. myVariantToRegValue(
  1868. IN VARIANT const *pvarPropertyValue,
  1869. OUT DWORD *pdwType,
  1870. OUT DWORD *pcbprop,
  1871. OUT BYTE **ppbprop);
  1872. // are we the Whistler version?
  1873. BOOL IsWhistler(VOID);
  1874. // should we run advanced functionality?
  1875. BOOL FIsAdvancedServer(VOID);
  1876. // should we be running at all?
  1877. BOOL FIsServer(VOID);
  1878. HRESULT
  1879. myAddLogSourceToRegistry(
  1880. IN LPWSTR pwszMsgDLL,
  1881. IN LPWSTR pwszApp);
  1882. #define LOCAL_FREE(ptr) \
  1883. if(NULL != ptr) \
  1884. LocalFree(ptr)
  1885. inline bool EmptyString(LPCWSTR pwszString)
  1886. {
  1887. return((NULL == pwszString || L'\0' == *pwszString)? true : false);
  1888. }
  1889. HRESULT
  1890. myOIDHashOIDToString(
  1891. IN WCHAR const *pwszOID,
  1892. OUT WCHAR **ppwsz);
  1893. LPCWSTR
  1894. myCAGetDN(
  1895. IN HCAINFO hCAInfo);
  1896. HRESULT IsCurrentUserBuiltinAdmin(OUT bool* pfIsMember);
  1897. HRESULT
  1898. SetRegistryLocalPathString(
  1899. IN HKEY hkey,
  1900. IN WCHAR const *pwszRegValueName,
  1901. IN WCHAR const *pwszUNCPath);
  1902. HRESULT
  1903. LocalMachineIsDomainMember(OUT bool* fIsDomainMember);
  1904. HRESULT ComputeMAC(
  1905. LPCWSTR pcwsFileName,
  1906. LPWSTR* ppwszMAC);
  1907. HRESULT CertNameToHashString(
  1908. const CERT_NAME_BLOB *pCertName,
  1909. LPWSTR* ppwszHash);
  1910. using namespace CertSrv;
  1911. #endif // __CERTLIB_H__