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.

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