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.

1058 lines
27 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: csext.h
  7. //
  8. // Contents: Cert Server globals
  9. //
  10. // History: 25-Jul-96 vich created
  11. //
  12. //---------------------------------------------------------------------------
  13. #ifndef __CSEXT_H__
  14. #define __CSEXT_H__
  15. #include "certacl.h"
  16. #ifndef SE_AUDITID_CERTSRV_ROLESEPARATIONSTATE
  17. // Temporary define audit events here
  18. #define SE_AUDITID_CERTSRV_ROLESEPARATIONSTATE ((ULONG)0x00000321L)
  19. #define SE_AUDITID_CERTSRV_PUBLISHCACERT ((ULONG)0x0000031fL)
  20. #endif // SE_AUDITID_CERTSRV_ROLESEPARATIONSTATE
  21. // privately used access bit to check for local administrator rights
  22. #define CA_ACCESS_LOCALADMIN 0x00008000
  23. // privately used access bit to trigger a denied audit event
  24. #define CA_ACCESS_DENIED 0x00004000
  25. // Each certificate handler must export the following functions.
  26. #define CMS_CRLPUB_PERIOD (60*1000) // 60 seconds (in milliseconds)
  27. //#define CMS_CRLPUB_PERIOD (60*60*1000) // 60 minutes (in milliseconds)
  28. #define CCCF_INREQUESTGROUPSET 0x00000001
  29. #define CCCF_INREQUESTGROUP 0x00000002
  30. #define CCCF_KEYARCHIVEDSET 0x00000004
  31. #define CCCF_KEYARCHIVED 0x00000008
  32. typedef struct _CERTSRV_COM_CONTEXT
  33. {
  34. DWORD dwFlags;
  35. HANDLE hAccessToken;
  36. DWORD RequestId;
  37. DWORD iExitModActive;
  38. WCHAR *pwszUserDN;
  39. } CERTSRV_COM_CONTEXT;
  40. #define CRCF_SIGNATUREERROR 0x00000001
  41. #define CRCF_KEYARCHIVALERROR 0x00000002
  42. #define CRCF_FAILDENIEDREQUEST 0x00000004
  43. #define CRCF_PREVIOUSLYDENIED 0x00000008
  44. #define CRCF_RENEWAL 0x00000010
  45. #define CRCF_ARCHIVESIGNINGKEYERROR 0x00000020
  46. typedef struct _CERTSRV_RESULT_CONTEXT
  47. {
  48. DWORD *pdwRequestId;
  49. DWORD dwResultFlags; // CRCF_*
  50. DWORD dwFlagsTop;
  51. BOOL fTransactionId;
  52. DWORD dwTransactionId;
  53. BYTE *pbSenderNonce;
  54. DWORD cbSenderNonce;
  55. BOOL fRequestSavedWithoutKey;
  56. BOOL fEnrollOnBehalfOf;
  57. BYTE *pbKeyHashIn;
  58. DWORD cbKeyHashIn;
  59. BYTE *pbKeyHashOut;
  60. DWORD cbKeyHashOut;
  61. BYTE *pbArchivedKey;
  62. DWORD cbArchivedKey;
  63. WCHAR *pwszKRAHashes;
  64. BSTR strRenewalCertHash;
  65. DWORD *pdwDisposition;
  66. WCHAR *pwszExtendedErrorInfo;
  67. CERTTRANSBLOB *pctbDispositionMessage;
  68. CERTTRANSBLOB *pctbCert;
  69. CERTTRANSBLOB *pctbCertChain;
  70. CERTTRANSBLOB *pctbFullResponse;
  71. } CERTSRV_RESULT_CONTEXT;
  72. VOID ReleaseResult(IN OUT CERTSRV_RESULT_CONTEXT *pResult);
  73. // Certification Authority Cert Context/Chain/Key information:
  74. #define CTXF_SKIPCRL 0x00000001
  75. #define CTXF_CERTMISSING 0x00000002
  76. #define CTXF_CRLZOMBIE 0x00000004
  77. #define CTXF_EXPIRED 0x00000010
  78. #define CTXF_REVOKED 0x00000020
  79. typedef struct _CACTX
  80. {
  81. DWORD Flags;
  82. DWORD iCert;
  83. DWORD iKey;
  84. DWORD NameId; // MAKECANAMEID(iCert, iKey)
  85. HRESULT hrVerifyStatus;
  86. CERT_CONTEXT const **apCACertChain;
  87. DWORD cCACertChain;
  88. CERT_CONTEXT const *pccCA;
  89. CRYPT_OBJID_BLOB IssuerKeyId;
  90. HCRYPTPROV hProvCA;
  91. CRYPT_OBJID_BLOB KeyAuthority2Cert;
  92. CRYPT_OBJID_BLOB KeyAuthority2CRL;
  93. CRYPT_OBJID_BLOB CDPCert;
  94. CRYPT_OBJID_BLOB CDPCRLFreshest;
  95. CRYPT_OBJID_BLOB CDPCRLBase;
  96. CRYPT_OBJID_BLOB CDPCRLDelta;
  97. CRYPT_OBJID_BLOB AIACert;
  98. char *pszObjIdSignatureAlgorithm;
  99. WCHAR *pwszKeyContainerName;
  100. WCHAR **papwszCRLFiles;
  101. WCHAR **papwszDeltaCRLFiles;
  102. } CACTX;
  103. typedef struct _CACROSSCTX
  104. {
  105. DWORD Flags;
  106. DWORD ReqId;
  107. CACTX *pCAContext;
  108. CACTX *pCAContextTarget;
  109. HRESULT hrVerifyStatus;
  110. CERT_CONTEXT const *pccCACross;
  111. } CACROSSCTX;
  112. typedef struct _CAXCHGCTX
  113. {
  114. DWORD Flags;
  115. DWORD ReqId;
  116. CERT_CONTEXT const *pccCAXchg;
  117. HCRYPTPROV hProvCA;
  118. WCHAR *pwszKeyContainerName;
  119. DWORD iCertSig;
  120. } CAXCHGCTX;
  121. //+****************************************************
  122. // Core Module:
  123. HRESULT
  124. CoreInit(
  125. IN BOOL fAuditEnabled);
  126. VOID
  127. CoreTerminate(VOID);
  128. HRESULT
  129. CoreValidateRequestId(
  130. IN ICertDBRow *prow,
  131. IN DWORD ExpectedDisposition);
  132. // Internal CoreProcessRequest Flags:
  133. #define CR_IN_NEW 0x00000000
  134. #define CR_IN_DENY 0x10000000
  135. #define CR_IN_RESUBMIT 0x20000000
  136. #define CR_IN_RETRIEVE 0x30000000
  137. #define CR_IN_COREMASK 0x30000000
  138. HRESULT
  139. CoreProcessRequest(
  140. IN DWORD dwType,
  141. OPTIONAL IN WCHAR const *pwszUserName,
  142. IN DWORD cbRequest,
  143. OPTIONAL IN BYTE const *pbRequest,
  144. OPTIONAL IN WCHAR const *pwszAttributes,
  145. OPTIONAL IN WCHAR const *pwszSerialNumber,
  146. IN DWORD dwComContextIndex,
  147. IN DWORD dwRequestId,
  148. OUT CERTSRV_RESULT_CONTEXT *pResult);
  149. HRESULT
  150. CoreDenyRequest(
  151. IN ICertDBRow *prow,
  152. IN DWORD Flags,
  153. IN DWORD ExpectedStatus);
  154. VOID
  155. CoreLogRequestStatus(
  156. IN ICertDBRow *prow,
  157. IN DWORD LogMsg,
  158. IN DWORD ErrCode,
  159. IN WCHAR const *pwszDisposition);
  160. WCHAR *
  161. CoreBuildDispositionString(
  162. OPTIONAL IN WCHAR const *pwszDispositionBase,
  163. OPTIONAL IN WCHAR const *pwszUserName,
  164. OPTIONAL IN WCHAR const *pwszDispositionDetail,
  165. OPTIONAL IN WCHAR const *pwszDispositionDetail2,
  166. OPTIONAL IN WCHAR const *pwszDispositionBy,
  167. IN HRESULT hrFail,
  168. IN BOOL fPublishError);
  169. HRESULT
  170. CoreSetDisposition(
  171. IN ICertDBRow *prow,
  172. IN DWORD Disposition);
  173. HRESULT
  174. CoreSetRequestDispositionFields(
  175. IN ICertDBRow *prow,
  176. IN DWORD ErrCode,
  177. IN DWORD Disposition,
  178. IN WCHAR const *pwszDisposition);
  179. HRESULT
  180. CoreSetComContextUserDN(
  181. IN DWORD dwRequestId,
  182. IN LONG Context,
  183. IN DWORD dwComContextIndex,
  184. OPTIONAL OUT WCHAR const **ppwszDN); // do NOT free!
  185. HRESULT
  186. CoreSetArchivedKey(
  187. IN OUT CERTSRV_COM_CONTEXT *pComContext);
  188. HRESULT
  189. CorePublishCrossCertificate(
  190. IN DWORD RequestId,
  191. IN CERT_CONTEXT const *pcc,
  192. IN BOOL fCreateDSObject,
  193. IN BOOL fDelete);
  194. #ifndef DBG_COMTEST
  195. # define DBG_COMTEST DBG_CERTSRV
  196. #endif
  197. #if DBG_COMTEST
  198. extern BOOL fComTest;
  199. BOOL ComTest(LONG Context);
  200. #endif
  201. #ifdef DBG_CERTSRV_DEBUG_PRINT
  202. # define CERTSRVDBGPRINTTIME(pszDesc, pftGMT) \
  203. CertSrvDbgPrintTime((pszDesc), (pftGMT))
  204. VOID
  205. CertSrvDbgPrintTime(
  206. IN char const *pszDesc,
  207. IN FILETIME const *pftGMT);
  208. #else // DBG_CERTSRV_DEBUG_PRINT
  209. # define CERTSRVDBGPRINTTIME(pszDesc, pftGMT)
  210. #endif // DBG_CERTSRV_DEBUG_PRINT
  211. HRESULT
  212. CertSrvBlockThreadUntilStop();
  213. /////////////////////////////////////
  214. // CRL Publication logic
  215. HRESULT
  216. CRLInit(
  217. IN WCHAR const *pwszSanitizedName);
  218. VOID
  219. CRLTerminate();
  220. HRESULT
  221. CRLPubWakeupEvent(
  222. OUT DWORD *pdwMSTimeOut);
  223. VOID
  224. CRLComputeTimeOut(
  225. IN FILETIME const *pftFirst,
  226. IN FILETIME const *pftLast,
  227. OUT DWORD *pdwMSTimeOut);
  228. HRESULT
  229. CRLPublishCRLs(
  230. IN BOOL fRebuildCRL,
  231. IN BOOL fForceRepublish,
  232. OPTIONAL IN WCHAR const *pwszUserName,
  233. IN BOOL fDelta,
  234. IN BOOL fShadowDelta,
  235. IN FILETIME ftNextUpdate,
  236. OUT BOOL *pfNeedRetry,
  237. OUT HRESULT *phrPublish);
  238. HRESULT
  239. CRLGetCRL(
  240. IN DWORD iCert,
  241. IN BOOL fDelta,
  242. OPTIONAL OUT CRL_CONTEXT const **ppCRL,
  243. OPTIONAL OUT DWORD *pdwCRLPublishFlags);
  244. HRESULT
  245. CRLWriteToLockedFile(
  246. IN BYTE const *pbEncoded,
  247. IN DWORD cbEncoded,
  248. IN BOOL fDelete,
  249. IN WCHAR const *pwszFile);
  250. DWORD
  251. CRLIsStringInList(
  252. IN WCHAR const *pwszSearch,
  253. OPTIONAL IN WCHAR const *pwszzList);
  254. /////////////////////////////////////
  255. HRESULT
  256. PKCSSetup(
  257. IN WCHAR const *pwszCommonName,
  258. IN WCHAR const *pwszSanitizedName);
  259. VOID
  260. PKCSTerminate();
  261. WCHAR const *
  262. PKCSMapAttributeName(
  263. OPTIONAL IN WCHAR const *pwszAttributeName,
  264. OPTIONAL IN CHAR const *pszObjId,
  265. OUT DWORD *pdwIndex,
  266. OUT DWORD *pcchMax);
  267. HRESULT
  268. PKCSGetProperty(
  269. IN ICertDBRow *prow,
  270. IN WCHAR const *pwszPropName,
  271. IN DWORD Flags,
  272. OPTIONAL OUT DWORD *pcbData,
  273. OUT BYTE **ppbData);
  274. HRESULT
  275. PKCSVerifyCAState(
  276. IN OUT CACTX *pCAContext);
  277. HRESULT
  278. PKCSMapCertIndex(
  279. IN DWORD iCert,
  280. OUT DWORD *piCert,
  281. OUT DWORD *pState);
  282. HRESULT
  283. PKCSMapCRLIndex(
  284. IN DWORD iCert,
  285. OUT DWORD *piCert, // returns newest iCert for passed iCert
  286. OUT DWORD *piCRL,
  287. OUT DWORD *pState);
  288. HRESULT
  289. PKCSGetCACertStatusCode(
  290. IN DWORD iCert,
  291. OUT HRESULT *phrCAStatusCode);
  292. HRESULT
  293. PKCSGetCAState(
  294. IN LONG PropId, // CR_PROP_*
  295. OUT BYTE *pb);
  296. HRESULT
  297. PKCSGetCAVersion(
  298. OUT DWORD *pb);
  299. HRESULT
  300. PKCSGetKRAState(
  301. IN DWORD cKRA,
  302. OUT BYTE *pb);
  303. HRESULT
  304. PKCSSetSubjectTemplate(
  305. IN WCHAR const *pwszTemplate);
  306. HRESULT
  307. PKCSGetCACert(
  308. IN LONG PropId, // CR_PROP_*
  309. IN DWORD iCert,
  310. OUT BYTE **ppbCACert,
  311. OUT DWORD *pcbCACert);
  312. HRESULT
  313. PKCSGetCAChain(
  314. IN DWORD iCert,
  315. IN BOOL fIncludeCRLs,
  316. OUT BYTE **ppbCAChain, // CoTaskMem*
  317. OUT DWORD *pcbCAChain);
  318. HRESULT
  319. PKCSGetCAXchgCert(
  320. IN DWORD iCert,
  321. IN WCHAR const *pwszUserName,
  322. OUT DWORD *piCertSig,
  323. OUT BYTE **ppbCACert,
  324. OUT DWORD *pcbCACert);
  325. HRESULT
  326. PKCSGetCAXchgChain(
  327. IN DWORD iCert,
  328. IN WCHAR const *pwszUserName,
  329. IN BOOL fIncludeCRLs,
  330. OUT BYTE **ppbCAChain, // CoTaskMem*
  331. OUT DWORD *pcbCAChain);
  332. HRESULT
  333. PKCSArchivePrivateKey(
  334. IN ICertDBRow *prow,
  335. IN BOOL fV1Cert,
  336. IN BOOL fOverwrite,
  337. IN CRYPT_ATTR_BLOB const *pBlobEncrypted,
  338. OPTIONAL IN OUT CERTSRV_RESULT_CONTEXT *pResult);
  339. HRESULT
  340. PKCSGetArchivedKey(
  341. IN DWORD dwRequestId,
  342. OUT BYTE **ppbArchivedKey,
  343. OUT DWORD *pcbArchivedKey);
  344. HRESULT
  345. PKCSUpdateXchgValidityPeriods(
  346. OPTIONAL IN HCERTTYPE hCertType);
  347. HRESULT
  348. PKCSGetCRLList(
  349. IN BOOL fDelta,
  350. IN DWORD iCert,
  351. OUT WCHAR const * const **ppapwszCRLList);
  352. HRESULT
  353. PKCSSetServerProperties(
  354. IN ICertDBRow *prow,
  355. OPTIONAL IN CACTX *pCAContext, // signing CACTX
  356. OPTIONAL IN FILETIME const *pftNotBefore,
  357. OPTIONAL IN FILETIME const *pftNotAfter,
  358. IN LONG lValidityPeriodCount,
  359. IN enum ENUM_PERIOD enumValidityPeriod);
  360. HRESULT
  361. PKCSSetRequestFlags(
  362. IN ICertDBRow *prow,
  363. IN BOOL fSet,
  364. IN DWORD dwChange);
  365. HRESULT
  366. PKCSCreateCertificate(
  367. IN ICertDBRow *prow,
  368. IN DWORD Disposition,
  369. IN BOOL fIncludeCRLs,
  370. IN BOOL fCrossCert,
  371. OPTIONAL IN CACTX *pCAContext, // signing CACTX
  372. OUT BOOL *pfErrorLogged,
  373. OPTIONAL OUT CACTX **ppCAContext,
  374. OPTIONAL OUT WCHAR **ppwszDispositionCreateCert,
  375. IN OUT CERTSRV_RESULT_CONTEXT *pResult); // CoTaskMem*
  376. HRESULT
  377. PKCSEncodeFullResponse(
  378. OPTIONAL IN ICertDBRow *prow,
  379. IN CERTSRV_RESULT_CONTEXT *pResult,
  380. IN HRESULT hrRequest,
  381. IN WCHAR *pwszDispositionString,
  382. OPTIONAL IN CACTX *pCAContext,
  383. OPTIONAL IN BYTE const *pbCertLeaf,
  384. IN DWORD cbCertLeaf,
  385. IN BOOL fIncludeCRLs,
  386. OUT BYTE **ppbResponse, // CoTaskMem*
  387. OUT DWORD *pcbResponse);
  388. HRESULT
  389. PKCSVerifyIssuedCertificate(
  390. IN CERT_CONTEXT const *pCert,
  391. OUT CACTX **ppCAContext);
  392. HRESULT
  393. PKCSIsRevoked(
  394. IN DWORD RequestId,
  395. OPTIONAL IN WCHAR const *pwszSerialNumber,
  396. OUT LONG *pRevocationReason,
  397. OUT LONG *pDisposition);
  398. HRESULT
  399. PKCSParseImportedCertificate(
  400. IN ICertDBRow *prow,
  401. IN BOOL fCrossCert, // else random imported cert
  402. IN DWORD Disposition,
  403. OPTIONAL IN CACTX const *pCAContext,
  404. IN CERT_CONTEXT const *pCert);
  405. HRESULT
  406. PKCSParseRequest(
  407. IN DWORD dwFlags,
  408. IN ICertDBRow *prow,
  409. IN DWORD cbRequest,
  410. IN BYTE const *pbRequest,
  411. IN CERT_CONTEXT const *pSigningAuthority,
  412. OUT BOOL *pfRenewal,
  413. IN OUT CERTSRV_RESULT_CONTEXT *pResult);
  414. HRESULT
  415. PKCSParseAttributes(
  416. IN ICertDBRow *prow,
  417. IN WCHAR const *pwszAttributes,
  418. IN BOOL fRegInfo,
  419. IN BOOL fPending,
  420. IN DWORD dwRDNTable,
  421. OPTIONAL OUT BOOL *pfEnrollOnBehalfOf);
  422. HRESULT
  423. PKCSVerifyChallengeString(
  424. IN ICertDBRow *prow);
  425. HRESULT
  426. PKCSVerifySubjectRDN(
  427. OPTIONAL IN ICertDBRow *prow,
  428. IN OUT WCHAR const **ppwszPropertyName,
  429. OPTIONAL IN WCHAR const *pwszPropertyValue,
  430. OUT BOOL *pfSubjectDot);
  431. HRESULT
  432. PKCSDeleteAllSubjectRDNs(
  433. IN ICertDBRow *prow,
  434. IN DWORD Flags);
  435. WCHAR *
  436. PKCSSplitToken(
  437. IN OUT WCHAR **ppwszIn,
  438. IN WCHAR *pwcSeparator,
  439. OUT BOOL *pfSplit);
  440. HRESULT
  441. PropAddSuffix(
  442. IN WCHAR const *pwszValue,
  443. IN WCHAR const *pwszSuffix,
  444. IN DWORD cwcNameMax,
  445. OUT WCHAR **ppwszOut);
  446. HRESULT
  447. PropParseRequest(
  448. IN ICertDBRow *prow,
  449. IN DWORD dwFlags,
  450. IN DWORD cbRequest,
  451. IN BYTE const *pbRequest,
  452. IN OUT CERTSRV_RESULT_CONTEXT *pResult);
  453. HRESULT
  454. PropSetRequestTimeProperty(
  455. IN ICertDBRow *prow,
  456. IN WCHAR const *pwszProp);
  457. HRESULT
  458. PropGetExtension(
  459. IN ICertDBRow *prow,
  460. IN DWORD Flags,
  461. IN WCHAR const *pwszExtensionName,
  462. OUT DWORD *pdwExtFlags,
  463. OUT DWORD *pcbValue,
  464. OUT BYTE **ppbValue);
  465. HRESULT
  466. PropSetExtension(
  467. IN ICertDBRow *prow,
  468. IN DWORD Flags,
  469. IN WCHAR const *pwszExtensionName,
  470. IN DWORD ExtFlags,
  471. IN DWORD cbValue,
  472. IN BYTE const *pbValue);
  473. HRESULT
  474. PropSetAttributeProperty(
  475. IN ICertDBRow *prow,
  476. IN BOOL fConcatenateRDNs,
  477. IN BOOL fPrependNewValue,
  478. IN DWORD dwTable,
  479. IN DWORD cchNameMax,
  480. OPTIONAL IN WCHAR const *pwszSuffix,
  481. IN WCHAR const *wszName,
  482. IN WCHAR const *wszValue);
  483. HRESULT
  484. RequestInitCAPropertyInfo(VOID);
  485. HRESULT
  486. RequestGetCAPropertyInfo(
  487. OUT LONG *pcProperty,
  488. OUT CERTTRANSBLOB *pctbPropInfo);
  489. HRESULT
  490. RequestGetCAProperty(
  491. IN LONG PropId, // CR_PROP_*
  492. IN LONG PropIndex,
  493. IN LONG PropType, // PROPTYPE_*
  494. OUT CERTTRANSBLOB *pctbPropertyValue);
  495. HRESULT
  496. RequestSetCAProperty(
  497. IN wchar_t const *pwszAuthority,
  498. IN LONG PropId, // CR_PROP_*
  499. IN LONG PropIndex,
  500. IN LONG PropType, // PROPTYPE_*
  501. OUT CERTTRANSBLOB *pctbPropertyValue);
  502. DWORD
  503. CertSrvStartServerThread(
  504. IN VOID *pvArg);
  505. HRESULT
  506. CertSrvEnterServer(
  507. OUT DWORD *pState);
  508. HRESULT
  509. CertSrvTestServerState();
  510. HRESULT
  511. CertSrvLockServer(
  512. IN OUT DWORD *pState);
  513. VOID
  514. CertSrvExitServer(
  515. IN DWORD State,
  516. IN HRESULT hrExit);
  517. struct IEnumCERTDBRESULTROW;
  518. typedef struct _CAVIEW
  519. {
  520. struct _CAVIEW *pCAViewNext;
  521. IEnumCERTDBRESULTROW *pView;
  522. VOID *pvSearch;
  523. FILETIME ftCreate;
  524. FILETIME ftLastAccess;
  525. } CAVIEW;
  526. HRESULT
  527. CertSrvDelinkCAView(
  528. IN VOID *pvSearch,
  529. OPTIONAL OUT CAVIEW **ppCAViewOut);
  530. HRESULT
  531. CertSrvLinkCAView(
  532. IN BOOL fNew,
  533. IN VOID *pvSearch,
  534. IN CAVIEW *pCAViewIn);
  535. HRESULT RPCInit(VOID);
  536. HRESULT RPCTeardown(VOID);
  537. VOID
  538. ServiceMain(
  539. IN DWORD dwArgc,
  540. IN LPWSTR *lpszArgv);
  541. HRESULT
  542. ServiceQueryInteractiveFlag(
  543. OUT BOOL *pfSilent);
  544. BOOL
  545. ServiceReportStatusToSCMgr(
  546. IN DWORD dwCurrentState,
  547. IN DWORD dwWin32ExitCode,
  548. IN DWORD dwCheckPoint,
  549. IN DWORD dwWaitHint);
  550. #define INCREMENT_EXTENSIONS 16
  551. HRESULT
  552. DBOpen( // initialize database
  553. WCHAR const *pwszSanitizedName);
  554. HRESULT
  555. DBShutDown( // terminate database access
  556. IN BOOL fPendingNotify);
  557. STDMETHODIMP
  558. CheckCertSrvAccess(
  559. IN LPCWSTR wszCA,
  560. IN handle_t hRpc,
  561. IN ACCESS_MASK Mask,
  562. OUT BOOL *pfAccessAllowed,
  563. OPTIONAL OUT HANDLE *phToken);
  564. HRESULT
  565. CertSrvSetRegistryFileTimeValue(
  566. IN BOOL fConfigLevel,
  567. IN WCHAR const *pwszRegValueName,
  568. IN DWORD cpwszDelete,
  569. OPTIONAL IN WCHAR const * const *papwszRegValueNameDelete);
  570. HRESULT
  571. GetClientUserName(
  572. OPTIONAL IN RPC_BINDING_HANDLE hRpc,
  573. OPTIONAL OUT WCHAR **ppwszUserSamName,
  574. OPTIONAL OUT WCHAR **ppwszUserDN);
  575. HRESULT CertStartClassFactories(VOID);
  576. VOID CertStopClassFactories(VOID);
  577. HRESULT
  578. SetCAObjectFlags(DWORD dwFlags);
  579. namespace CertSrv
  580. {
  581. HRESULT
  582. GetMembership(
  583. IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzRM,
  584. IN PSID pSid,
  585. PTOKEN_GROUPS *ppGroups);
  586. HRESULT
  587. CheckOfficerRights(
  588. DWORD dwRequestID,
  589. CertSrv::CAuditEvent &event);
  590. HRESULT
  591. CheckOfficerRights(
  592. LPCWSTR pwszRequesterName,
  593. CertSrv::CAuditEvent &event);
  594. HRESULT
  595. CheckOfficerRightsFromAuthzCC(
  596. IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzCCOfficer,
  597. IN WCHAR const *pwszRequesterName);
  598. HRESULT
  599. CheckOfficerRightsFromOfficerName(
  600. IN WCHAR const *pwszOfficerName,
  601. IN WCHAR const *pwszRequesterName);
  602. HRESULT
  603. GetCallerAuthzContext(
  604. OUT AUTHZ_CLIENT_CONTEXT_HANDLE *phAuthzCC);
  605. BOOL
  606. CallbackAccessCheck(
  607. IN AUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext,
  608. IN PACE_HEADER pAce,
  609. IN PVOID pArgs OPTIONAL,
  610. IN OUT PBOOL pbAceApplicable);
  611. }
  612. HRESULT
  613. PKCSGetKRACert(
  614. IN DWORD iCert,
  615. OUT BYTE **ppbCert,
  616. OUT DWORD *pcbCert);
  617. #define CSST_STARTSERVICECONTROLLER 0x00000001
  618. #define CSST_CONSOLE 0x00000002
  619. extern enum ENUM_PERIOD g_enumValidityPeriod;
  620. extern LONG g_lValidityPeriodCount;
  621. extern enum ENUM_PERIOD g_enumCAXchgValidityPeriod;
  622. extern LONG g_lCAXchgValidityPeriodCount;
  623. extern enum ENUM_PERIOD g_enumCAXchgOverlapPeriod;
  624. extern LONG g_lCAXchgOverlapPeriodCount;
  625. extern DWORD g_dwDelay2;
  626. extern DWORD g_dwClockSkewMinutes;
  627. extern DWORD g_dwViewAgeMinutes;
  628. extern DWORD g_dwViewIdleMinutes;
  629. extern DWORD g_dwLogLevel;
  630. extern DWORD g_dwSessionCount;
  631. extern DWORD g_dwCRLFlags;
  632. extern DWORD g_dwHighSerial;
  633. extern BYTE *g_pbHighSerial;
  634. extern DWORD g_cbHighSerial;
  635. extern DWORD g_cbMaxIncomingAllocSize;
  636. extern ICertDB *g_pCertDB;
  637. extern BOOL g_fDBRecovered;
  638. extern HCERTSTORE g_hStoreCA;
  639. extern HCRYPTPROV g_hProvCA;
  640. extern BSTR g_strPolicyDescription;
  641. extern BSTR g_strExitDescription;
  642. extern BOOL g_fCertEnrollCompatible;
  643. extern BOOL g_fEnforceRDNNameLengths;
  644. extern BOOL g_fCreateDB;
  645. extern BOOL g_fStartAsService;
  646. extern DWORD g_CRLEditFlags;
  647. extern DWORD g_KRAFlags;
  648. extern DWORD g_cKRACertsRoundRobin;
  649. extern DWORD g_cKRACerts;
  650. extern ENUM_FORCETELETEX g_fForceTeletex;
  651. extern ENUM_CATYPES g_CAType;
  652. extern BOOL g_fUseDS;
  653. extern BOOL g_fServerUpgraded;
  654. extern long g_cTemplateUpdateSequenceNum;
  655. extern DWORD g_InterfaceFlags;
  656. extern HRESULT g_hrJetVersionStoreOutOfMemory;
  657. extern DWORD g_CryptSilent;
  658. extern DWORD g_dwVerifyCertFlags;
  659. extern WCHAR g_wszCAStore[];
  660. extern WCHAR const g_wszCertSrvServiceName[];
  661. extern WCHAR const g_wszRegKeyConfigPath[];
  662. extern WCHAR const g_wszRegDBA[];
  663. extern WCHAR g_wszSanitizedName[];
  664. extern WCHAR *g_pwszSanitizedDSName;
  665. extern WCHAR g_wszCommonName[];
  666. extern WCHAR g_wszPolicyDCName[];
  667. extern DWORD g_cwcPolicyDCName;
  668. extern WCHAR g_wszParentConfig[];
  669. extern WCHAR g_wszDatabase[];
  670. extern WCHAR g_wszLogDir[];
  671. extern WCHAR g_wszSystemDir[];
  672. extern WCHAR *g_pwszServerName;
  673. extern BSTR g_strDomainDN;
  674. extern BSTR g_strConfigDN;
  675. extern WCHAR *g_pwszKRAPublishURL;
  676. extern WCHAR *g_pwszAIACrossCertPublishURL;
  677. extern WCHAR *g_pwszRootTrustCrossCertPublishURL;
  678. extern WCHAR const g_wszRegValidityPeriodString[];
  679. extern WCHAR const g_wszRegValidityPeriodCount[];
  680. extern WCHAR const g_wszRegCAXchgValidityPeriodString[];
  681. extern WCHAR const g_wszRegCAXchgValidityPeriodCount[];
  682. extern WCHAR const g_wszRegCAXchgOverlapPeriodString[];
  683. extern WCHAR const g_wszRegCAXchgOverlapPeriodCount[];
  684. extern WCHAR const g_wszRegCAXchgCertHash[];
  685. extern WCHAR const g_wszRegHighSerial[];
  686. // renewal-friendly properties
  687. extern DWORD g_cCAKeys; // Total number of CA keys managed by this CA
  688. extern DWORD g_cCACerts; // Total number of CA certs managed by this CA
  689. extern DWORD g_cExitMod; // Total number of exit modules loaded by this CA
  690. extern CertSrv::CCertificateAuthoritySD g_CASD;
  691. extern AUTHZ_RESOURCE_MANAGER_HANDLE g_AuthzCertSrvRM;
  692. extern DWORD g_dwAuditFilter;
  693. extern CertSrv::COfficerRightsSD g_OfficerRightsSD;
  694. extern CertSrv::CConfigStorage g_ConfigStorage;
  695. extern CertSrv::CAutoLPWSTR g_pwszDBFileHash;
  696. //+--------------------------------------------------------------------------
  697. // Name properties:
  698. extern WCHAR const g_wszPropDistinguishedName[];
  699. extern WCHAR const g_wszPropRawName[];
  700. extern WCHAR const g_wszPropCountry[];
  701. extern WCHAR const g_wszPropOrganization[];
  702. extern WCHAR const g_wszPropOrgUnit[];
  703. extern WCHAR const g_wszPropCommonName[];
  704. extern WCHAR const g_wszPropLocality[];
  705. extern WCHAR const g_wszPropState[];
  706. extern WCHAR const g_wszPropTitle[];
  707. extern WCHAR const g_wszPropGivenName[];
  708. extern WCHAR const g_wszPropInitials[];
  709. extern WCHAR const g_wszPropSurName[];
  710. extern WCHAR const g_wszPropDomainComponent[];
  711. extern WCHAR const g_wszPropEMail[];
  712. extern WCHAR const g_wszPropStreetAddress[];
  713. extern WCHAR const g_wszPropUnstructuredAddress[];
  714. extern WCHAR const g_wszPropUnstructuredName[];
  715. extern WCHAR const g_wszPropDeviceSerialNumber[];
  716. extern WCHAR const g_wszPropCertificateIssuerNameID[];
  717. //+--------------------------------------------------------------------------
  718. // Subject Name properties:
  719. extern WCHAR const g_wszPropSubjectDot[];
  720. extern WCHAR const g_wszPropSubjectDistinguishedName[];
  721. extern WCHAR const g_wszPropSubjectRawName[];
  722. extern WCHAR const g_wszPropSubjectCountry[];
  723. extern WCHAR const g_wszPropSubjectOrganization[];
  724. extern WCHAR const g_wszPropSubjectOrgUnit[];
  725. extern WCHAR const g_wszPropSubjectCommonName[];
  726. extern WCHAR const g_wszPropSubjectLocality[];
  727. extern WCHAR const g_wszPropSubjectState[];
  728. extern WCHAR const g_wszPropSubjectTitle[];
  729. extern WCHAR const g_wszPropSubjectGivenName[];
  730. extern WCHAR const g_wszPropSubjectInitials[];
  731. extern WCHAR const g_wszPropSubjectSurName[];
  732. extern WCHAR const g_wszPropSubjectDomainComponent[];
  733. extern WCHAR const g_wszPropSubjectEMail[];
  734. extern WCHAR const g_wszPropSubjectStreetAddress[];
  735. extern WCHAR const g_wszPropSubjectUnstructuredAddress[];
  736. extern WCHAR const g_wszPropSubjectUnstructuredName[];
  737. extern WCHAR const g_wszPropSubjectDeviceSerialNumber[];
  738. //+--------------------------------------------------------------------------
  739. // Issuer Name properties:
  740. extern WCHAR const g_wszPropIssuerDot[];
  741. extern WCHAR const g_wszPropIssuerDistinguishedName[];
  742. extern WCHAR const g_wszPropIssuerRawName[];
  743. extern WCHAR const g_wszPropIssuerCountry[];
  744. extern WCHAR const g_wszPropIssuerOrganization[];
  745. extern WCHAR const g_wszPropIssuerOrgUnit[];
  746. extern WCHAR const g_wszPropIssuerCommonName[];
  747. extern WCHAR const g_wszPropIssuerLocality[];
  748. extern WCHAR const g_wszPropIssuerState[];
  749. extern WCHAR const g_wszPropIssuerTitle[];
  750. extern WCHAR const g_wszPropIssuerGivenName[];
  751. extern WCHAR const g_wszPropIssuerInitials[];
  752. extern WCHAR const g_wszPropIssuerSurName[];
  753. extern WCHAR const g_wszPropIssuerDomainComponent[];
  754. extern WCHAR const g_wszPropIssuerEMail[];
  755. extern WCHAR const g_wszPropIssuerStreetAddress[];
  756. extern WCHAR const g_wszPropIssuerUnstructuredAddress[];
  757. extern WCHAR const g_wszPropIssuerUnstructuredName[];
  758. extern WCHAR const g_wszPropIssuerDeviceSerialNumber[];
  759. //+--------------------------------------------------------------------------
  760. // Request properties:
  761. extern WCHAR const g_wszPropRequestRequestID[];
  762. extern WCHAR const g_wszPropRequestRawRequest[];
  763. extern WCHAR const g_wszPropRequestRawArchivedKey[];
  764. extern WCHAR const g_wszPropRequestKeyRecoveryHashes[];
  765. extern WCHAR const g_wszPropRequestRawOldCertificate[];
  766. extern WCHAR const g_wszPropRequestAttributes[];
  767. extern WCHAR const g_wszPropRequestType[];
  768. extern WCHAR const g_wszPropRequestFlags[];
  769. extern WCHAR const g_wszPropRequestStatusCode[];
  770. extern WCHAR const g_wszPropRequestDisposition[];
  771. extern WCHAR const g_wszPropRequestDispositionMessage[];
  772. extern WCHAR const g_wszPropRequestSubmittedWhen[];
  773. extern WCHAR const g_wszPropRequestResolvedWhen[];
  774. extern WCHAR const g_wszPropRequestRevokedWhen[];
  775. extern WCHAR const g_wszPropRequestRevokedEffectiveWhen[];
  776. extern WCHAR const g_wszPropRequestRevokedReason[];
  777. extern WCHAR const g_wszPropRequesterName[];
  778. extern WCHAR const g_wszPropCallerName[];
  779. extern WCHAR const g_wszPropRequestOSVersion[];
  780. extern WCHAR const g_wszPropRequestCSPProvider[];
  781. //+--------------------------------------------------------------------------
  782. // Request attribute properties:
  783. extern WCHAR const g_wszPropChallenge[];
  784. extern WCHAR const g_wszPropExpectedChallenge[];
  785. //+--------------------------------------------------------------------------
  786. // Certificate properties:
  787. extern WCHAR const g_wszPropCertificateRequestID[];
  788. extern WCHAR const g_wszPropRawCertificate[];
  789. extern WCHAR const g_wszPropCertificateHash[];
  790. extern WCHAR const g_wszPropCertificateSerialNumber[];
  791. extern WCHAR const g_wszPropCertificateNotBeforeDate[];
  792. extern WCHAR const g_wszPropCertificateNotAfterDate[];
  793. extern WCHAR const g_wszPropCertificateSubjectKeyIdentifier[];
  794. extern WCHAR const g_wszPropCertificateRawPublicKey[];
  795. extern WCHAR const g_wszPropCertificatePublicKeyLength[];
  796. extern WCHAR const g_wszPropCertificatePublicKeyAlgorithm[];
  797. extern WCHAR const g_wszPropCertificateRawPublicKeyAlgorithmParameters[];
  798. //+--------------------------------------------------------------------------
  799. // Disposition messages:
  800. extern WCHAR const *g_pwszRequestedBy;
  801. extern WCHAR const *g_pwszRevokedBy;
  802. extern WCHAR const *g_pwszUnrevokedBy;
  803. extern WCHAR const *g_pwszPublishedBy;
  804. extern WCHAR const *g_pwszUnknownSubject;
  805. extern WCHAR const *g_pwszInvalidIssuancePolicies;
  806. extern WCHAR const *g_pwszInvalidApplicationPolicies;
  807. extern WCHAR const *g_pwszIntermediateCAStore;
  808. //+--------------------------------------------------------------------------
  809. // Localizable audit strings
  810. extern WCHAR const *g_pwszYes;
  811. extern WCHAR const *g_pwszNo;
  812. extern LPCWSTR g_pwszAuditResources[];
  813. //+--------------------------------------------------------------------------
  814. // Secured attributes:
  815. extern LPWSTR g_wszzSecuredAttributes;
  816. extern HANDLE g_hServiceStoppingEvent;
  817. extern HANDLE g_hServiceStoppedEvent;
  818. extern HANDLE g_hCRLManualPublishEvent;
  819. extern BOOL g_fCRLPublishDisabled;
  820. extern BOOL g_fDeltaCRLPublishDisabled;
  821. extern HKEY g_hkeyCABase;
  822. extern HWND g_hwndMain;
  823. extern BOOL g_fAdvancedServer;
  824. __inline DWORD GetCertsrvComThreadingModel() { return(COINIT_MULTITHREADED); }
  825. extern CACTX *g_aCAContext;
  826. extern CACTX *g_pCAContextCurrent;
  827. inline HRESULT CheckAuthorityName(PCWSTR pwszAuthority, bool fAllowEmptyName = false)
  828. {
  829. HRESULT hr;
  830. if (NULL != pwszAuthority && L'\0' != *pwszAuthority)
  831. {
  832. if (0 != mylstrcmpiL(pwszAuthority, g_wszCommonName))
  833. {
  834. if (0 != mylstrcmpiL(pwszAuthority, g_wszSanitizedName) &&
  835. 0 != mylstrcmpiL(pwszAuthority, g_pwszSanitizedDSName))
  836. {
  837. hr = E_INVALIDARG;
  838. goto error;
  839. }
  840. #ifdef DBG_CERTSRV_DEBUG_PRINT
  841. if (0 == mylstrcmpiL(pwszAuthority, g_wszSanitizedName))
  842. {
  843. DBGPRINT((
  844. DBG_SS_CERTSRV,
  845. "'%ws' called with Sanitized Name: '%ws'\n",
  846. g_wszCommonName,
  847. pwszAuthority));
  848. }
  849. else if (0 == mylstrcmpiL(pwszAuthority, g_pwszSanitizedDSName))
  850. {
  851. DBGPRINT((
  852. DBG_SS_CERTSRV,
  853. "'%ws' called with Sanitized DS Name: '%ws'\n",
  854. g_wszCommonName,
  855. pwszAuthority));
  856. }
  857. #endif
  858. }
  859. }
  860. else if(!fAllowEmptyName)
  861. {
  862. return hr = E_INVALIDARG;
  863. }
  864. hr = S_OK;
  865. error:
  866. return hr;
  867. }
  868. #endif // __CSEXT_H__