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.

436 lines
15 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: dbtable.h
  7. //
  8. // Contents: Cert Server Database interface implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #ifndef __DBTABLE_H__
  12. #define __DBTABLE_H__ 1
  13. #define DTR_REQUESTID 0
  14. #define DTR_REQUESTRAWREQUEST 1
  15. #define DTR_REQUESTRAWARCHIVEDKEY 2
  16. #define DTR_REQUESTKEYRECOVERYHASHES 3
  17. #define DTR_REQUESTRAWOLDCERTIFICATE 4
  18. #define DTR_REQUESTATTRIBUTES 5
  19. #define DTR_REQUESTTYPE 6
  20. #define DTR_REQUESTFLAGS 7
  21. #define DTR_REQUESTSTATUSCODE 8
  22. #define DTR_REQUESTDISPOSITION 9
  23. #define DTR_REQUESTDISPOSITIONMESSAGE 10
  24. #define DTR_REQUESTSUBMITTEDWHEN 11
  25. #define DTR_REQUESTRESOLVEDWHEN 12
  26. #define DTR_REQUESTREVOKEDWHEN 13
  27. #define DTR_REQUESTREVOKEDEFFECTIVEWHEN 14
  28. #define DTR_REQUESTREVOKEDREASON 15
  29. #define DTR_REQUESTERNAME 16
  30. #define DTR_CALLERNAME 17
  31. #define DTR_SIGNERPOLICIES 18
  32. #define DTR_SIGNERAPPLICATIONPOLICIES 19
  33. #define DTR_OFFICER 20
  34. #define DTR_DISTINGUISHEDNAME 21
  35. #define DTR_RAWNAME 22
  36. #define DTR_COUNTRY 23
  37. #define DTR_ORGANIZATION 24
  38. #define DTR_ORGUNIT 25
  39. #define DTR_COMMONNAME 26
  40. #define DTR_LOCALITY 27
  41. #define DTR_STATE 28
  42. #define DTR_TITLE 29
  43. #define DTR_GIVENNAME 30
  44. #define DTR_INITIALS 31
  45. #define DTR_SURNAME 32
  46. #define DTR_DOMAINCOMPONENT 33
  47. #define DTR_EMAIL 34
  48. #define DTR_STREETADDRESS 35
  49. #define DTR_UNSTRUCTUREDNAME 36
  50. #define DTR_UNSTRUCTUREDADDRESS 37
  51. #define DTR_DEVICESERIALNUMBER 38
  52. #define DTR_MAX 39
  53. #define DTC_REQUESTID 0
  54. #define DTC_RAWCERTIFICATE 1
  55. #define DTC_CERTIFICATEHASH 2
  56. #define DTC_CERTIFICATETEMPLATE 3
  57. #define DTC_CERTIFICATEENROLLMENTFLAGS 4
  58. #define DTC_CERTIFICATEGENERALFLAGS 5
  59. #define DTC_CERTIFICATESERIALNUMBER 6
  60. #define DTC_CERTIFICATEISSUERNAMEID 7
  61. #define DTC_CERTIFICATENOTBEFOREDATE 8
  62. #define DTC_CERTIFICATENOTAFTERDATE 9
  63. #define DTC_CERTIFICATESUBJECTKEYIDENTIFIER 10
  64. #define DTC_CERTIFICATERAWPUBLICKEY 11
  65. #define DTC_CERTIFICATEPUBLICKEYLENGTH 12
  66. #define DTC_CERTIFICATEPUBLICKEYALGORITHM 13
  67. #define DTC_CERTIFICATERAWPUBLICKEYALGORITHMPARAMETERS 14
  68. #define DTC_CERTIFICATEUPN 15
  69. #define DTC_DISTINGUISHEDNAME 16
  70. #define DTC_RAWNAME 17
  71. #define DTC_COUNTRY 18
  72. #define DTC_ORGANIZATION 19
  73. #define DTC_ORGUNIT 20
  74. #define DTC_COMMONNAME 21
  75. #define DTC_LOCALITY 22
  76. #define DTC_STATE 23
  77. #define DTC_TITLE 24
  78. #define DTC_GIVENNAME 25
  79. #define DTC_INITIALS 26
  80. #define DTC_SURNAME 27
  81. #define DTC_DOMAINCOMPONENT 28
  82. #define DTC_EMAIL 29
  83. #define DTC_STREETADDRESS 30
  84. #define DTC_UNSTRUCTUREDNAME 31
  85. #define DTC_UNSTRUCTUREDADDRESS 32
  86. #define DTC_DEVICESERIALNUMBER 33
  87. #define DTC_MAX 34
  88. #define DTA_REQUESTID 0
  89. #define DTA_ATTRIBUTENAME 1
  90. #define DTA_ATTRIBUTEVALUE 2
  91. #define DTA_MAX 3
  92. #define DTE_REQUESTID 0
  93. #define DTE_EXTENSIONNAME 1
  94. #define DTE_EXTENSIONFLAGS 2
  95. #define DTE_EXTENSIONRAWVALUE 3
  96. #define DTE_MAX 4
  97. #define DTL_ROWID 0
  98. #define DTL_NUMBER 1
  99. #define DTL_MINBASE 2
  100. #define DTL_NAMEID 3
  101. #define DTL_COUNT 4
  102. #define DTL_THISUPDATEDATE 5
  103. #define DTL_NEXTUPDATEDATE 6
  104. #define DTL_THISPUBLISHDATE 7
  105. #define DTL_NEXTPUBLISHDATE 8
  106. #define DTL_EFFECTIVEDATE 9
  107. #define DTL_PROPAGATIONCOMPLETEDATE 10
  108. #define DTL_LASTPUBLISHEDDATE 11
  109. #define DTL_PUBLISHATTEMPTS 12
  110. #define DTL_PUBLISHFLAGS 13
  111. #define DTL_PUBLISHSTATUSCODE 14
  112. #define DTL_PUBLISHERROR 15
  113. #define DTL_RAWCRL 16
  114. #define DTL_MAX 17
  115. #define DTI_REQUESTTABLE 0x00001000
  116. #define DTI_CERTIFICATETABLE 0x00002000
  117. #define DTI_ATTRIBUTETABLE 0x00003000
  118. #define DTI_EXTENSIONTABLE 0x00004000
  119. #define DTI_CRLTABLE 0x00005000
  120. #define DTI_TABLEMASK 0x0000f000
  121. #define DTI_TABLESHIFT 12
  122. #define DTI_COLUMNMASK ((1 << DTI_TABLESHIFT) - 1)
  123. #define ISTEXTCOLTYP(coltyp) \
  124. (JET_coltypText == (coltyp) || JET_coltypLongText == (coltyp))
  125. #define IsValidJetTableId(tableid) (0 != (tableid) && 0xffffffff != (tableid))
  126. const DWORD DBTF_POLICYWRITEABLE = 0x00000001;
  127. const DWORD DBTF_INDEXPRIMARY = 0x00000002; // Primary DB Index
  128. const DWORD DBTF_INDEXREQUESTID = 0x00000004; // Combine Index with RequestID
  129. const DWORD DBTF_SUBJECT = 0x00000008; // Is a "Subject." property
  130. const DWORD DBTF_INDEXUNIQUE = 0x00000010; // Force uniqueness constraint
  131. const DWORD DBTF_INDEXIGNORENULL = 0x00000020; // don't index NULLs
  132. const DWORD DBTF_SOFTFAIL = 0x00000040; // optional column (it's new)
  133. const DWORD DBTF_MISSING = 0x00000080; // optional column is missing
  134. const DWORD DBTF_OLDCOLUMNID = 0x00000100; // old column id still exists
  135. const DWORD DBTF_COLUMNRENAMED = 0x00000200; // renamed, old name appended
  136. const DWORD DBTF_INDEXRENAMED = 0x00000400; // renamed, old name appended
  137. const DWORD DBTF_COMPUTED = 0x00000800; // computed column
  138. typedef struct _DBTABLE
  139. {
  140. WCHAR const *pwszPropName;
  141. WCHAR const *pwszPropNameObjId;
  142. DWORD dwFlags;
  143. DWORD dwcbMax; // maximum allowed strlen/wcslen(value string)
  144. DWORD dwTable;
  145. CHAR const *pszFieldName;
  146. CHAR const *pszIndexName;
  147. DWORD dbcolumnMax;
  148. JET_GRBIT dbgrbit;
  149. JET_COLTYP dbcoltyp;
  150. JET_COLUMNID dbcolumnid;
  151. JET_COLUMNID dbcolumnidOld; // Old column Id if DBTF_OLDCOLUMNID
  152. } DBTABLE;
  153. #define DBTABLE_NULL \
  154. { NULL, NULL, 0, 0, 0, NULL, NULL, 0, 0, 0, 0 } // Termination marker
  155. typedef struct _DUPTABLE
  156. {
  157. CHAR const *pszFieldName;
  158. WCHAR const *pwszPropName;
  159. } DUPTABLE;
  160. typedef struct _DBAUXDATA
  161. {
  162. char const *pszTable;
  163. char const *pszRowIdIndex;
  164. char const *pszRowIdNameIndex;
  165. char const *pszNameIndex;
  166. DBTABLE const *pdtRowId;
  167. DBTABLE const *pdtName;
  168. DBTABLE const *pdtFlags;
  169. DBTABLE const *pdtValue;
  170. DBTABLE const *pdtIssuerNameId;
  171. } DBAUXDATA;
  172. typedef struct _DBCREATETABLE {
  173. char const *pszTableName;
  174. DBAUXDATA *pdbaux;
  175. DBTABLE *pdt;
  176. } DBCREATETABLE;
  177. const DWORD TABLE_REQCERTS = 0;
  178. const DWORD TABLE_REQUESTS = 1;
  179. const DWORD TABLE_CERTIFICATES = 2;
  180. const DWORD TABLE_ATTRIBUTES = 3;
  181. const DWORD TABLE_EXTENSIONS = 4;
  182. const DWORD TABLE_CRLS = 5;
  183. const DWORD CSF_TABLEMASK = 0x0000000f;
  184. const DWORD CSF_TABLESET = 0x00000010;
  185. const DWORD CSF_INUSE = 0x00000020;
  186. const DWORD CSF_READONLY = 0x00000040;
  187. const DWORD CSF_CREATE = 0x00000080;
  188. const DWORD CSF_DELETE = 0x00000100;
  189. const DWORD CSF_VIEW = 0x00000200;
  190. const DWORD CSF_VIEWRESET = 0x00000400;
  191. const DWORD CST_SEEKINDEXRANGE = 0x00000001;
  192. const DWORD CST_SEEKNOTMOVE = 0x00000002;
  193. const DWORD CST_SEEKUSECURRENT = 0x00000004;
  194. const DWORD CST_SEEKASCEND = 0x00000008;
  195. const DWORD CVF_NOMOREDATA = 0x00010000;
  196. const DWORD CVF_COLUMNVALUE = 0x00020000;
  197. char const szCERTIFICATE_REQUESTIDINDEX[] = "CertificateReqIdIndex";
  198. char const szCERTIFICATE_COMMONNAMEINDEX[] = "$CertificateCommonNameIndex";
  199. #define szCERTIFICATE_SERIALNUMBERINDEX "$CertificateSerialNumberIndex2"
  200. #define szCERTIFICATE_SERIALNUMBERINDEX_OLD "$CertificateSerialNumberIndex"
  201. char const szCERTIFICATE_HASHINDEX[] = "$CertificateHashIndex";
  202. char const szCERTIFICATE_TEMPLATEINDEX[] = "$CertificateTemplateIndex";
  203. #define szCERTIFICATE_NOTAFTERINDEX "CertificateNotAfterIndex"
  204. #define szCERTIFICATE_NOTAFTERINDEX_OLD "$CertificateNotAfterIndex"
  205. char const szCERTIFICATE_UPNINDEX[] = "$CertificateUPNIndex";
  206. char const szREQUEST_REQUESTIDINDEX[] = "RequestReqIdIndex";
  207. char const szREQUEST_DISPOSITIONINDEX[] = "RequestDispositionIndex";
  208. char const szREQUEST_REQUESTERNAMEINDEX[] = "$RequestRequesterNameIndex";
  209. char const szREQUEST_CALLERNAMEINDEX[] = "$RequestCallerNameIndex";
  210. #define szREQUEST_RESOLVEDWHENINDEX "RequestResolvedWhenIndex"
  211. #define szREQUEST_RESOLVEDWHENINDEX_OLD "$RequestResolvedWhenIndex"
  212. #define szREQUEST_REVOKEDEFFECTIVEWHENINDEX "RequestRevokedEffectiveWhenIndex"
  213. #define szREQUEST_REVOKEDEFFECTIVEWHENINDEX_OLD "$RequestRevokedEffectiveWhenIndex"
  214. char const szEXTENSION_REQUESTIDINDEX[] = "ExtensionReqIdIndex";
  215. char const szEXTENSION_REQUESTIDNAMEINDEX[] = "$ExtensionReqIdNameIndex";
  216. char const szATTRIBUTE_REQUESTIDINDEX[] = "AttributeReqIdIndex";
  217. char const szATTRIBUTE_REQUESTIDNAMEINDEX[] = "$AttributeReqIdNameIndex";
  218. char const szCRL_ROWIDINDEX[] = "CRLRowIdIndex";
  219. char const szCRL_CRLNUMBERINDEX[] = "CRLCRLNumberIndex";
  220. char const szCRL_CRLNEXTUPDATEINDEX[] = "CRLCRLNextUpdateIndex";
  221. char const szCRL_CRLNEXTPUBLISHINDEX[] = "CRLCRLNextPublishIndex";
  222. char const szCRL_CRLPROPAGATIONCOMPLETEINDEX[] = "CRLCRLPropagationCompleteIndex";
  223. char const szCRL_CRLLASTPUBLISHEDINDEX[] = "CRLLastPublishedIndex";
  224. char const szCRL_CRLPUBLISHATTEMPTSINDEX[] = "CRLPublishAttemptsIndex";
  225. char const szCRL_CRLPUBLSTATUSCODEISHINDEX[] = "CRLPublishStatusCodeIndex";
  226. char const szCERTIFICATETABLE[] = "Certificates";
  227. char const szREQUESTTABLE[] = "Requests";
  228. char const szCERTIFICATEEXTENSIONTABLE[] = "CertificateExtensions";
  229. char const szREQUESTATTRIBUTETABLE[] = "RequestAttributes";
  230. char const szCRLTABLE[] = "CRLs";
  231. #define wszCERTIFICATETABLE L"Certificates"
  232. #define wszREQUESTTABLE L"Requests"
  233. #define wszCERTIFICATEEXTENSIONTABLE L"CertificateExtensions"
  234. #define wszREQUESTATTRIBUTETABLE L"RequestAttributes"
  235. #define wszCRLTABLE L"CRLs"
  236. #define chTEXTPREFIX '$'
  237. #define szREQUESTID "RequestID"
  238. #define szRAWREQUEST "RawRequest"
  239. #define szRAWARCHIVEDKEY "RawArchivedKey"
  240. #define szKEYRECOVERYHASHES "$KeyRecoveryHashes"
  241. #define szRAWOLDCERTIFICATE "RawOldCertificate"
  242. #define szREQUESTATTRIBUTES "$RequestAttributes"
  243. #define szREQUESTTYPE "RequestType"
  244. #define szREQUESTFLAGS "RequestFlags"
  245. #define szSTATUSCODE "StatusCode"
  246. #define szDISPOSITION "Disposition"
  247. #define szDISPOSITIONMESSAGE "$DispositionMessage"
  248. #define szSUBMITTEDWHEN "SubmittedWhen"
  249. #define szRESOLVEDWHEN "ResolvedWhen"
  250. #define szREVOKEDWHEN "RevokedWhen"
  251. #define szREVOKEDEFFECTIVEWHEN "RevokedEffectiveWhen"
  252. #define szREVOKEDREASON "RevokedReason"
  253. #define szREQUESTERNAME "$RequesterName"
  254. #define szCALLERNAME "$CallerName"
  255. #define szSIGNERPOLICIES "$SignerPolicies"
  256. #define szSIGNERAPPLICATIONPOLICIES "$SignerApplicationPolicies"
  257. #define szOFFICER "?Officer"
  258. #define szDISTINGUISHEDNAME "$DistinguishedName"
  259. #define szRAWNAME "RawName"
  260. #define szCOUNTRY "$Country"
  261. #define szORGANIZATION "$Organization"
  262. #define szORGANIZATIONALUNIT "$OrganizationalUnit"
  263. #define szCOMMONNAME "$CommonName"
  264. #define szLOCALITY "$Locality"
  265. #define szSTATEORPROVINCE "$StateOrProvince"
  266. #define szTITLE "$Title"
  267. #define szGIVENNAME "$GivenName"
  268. #define szINITIALS "$Initials"
  269. #define szSURNAME "$SurName"
  270. #define szDOMAINCOMPONENT "$DomainComponent"
  271. #define szEMAIL "$EMail"
  272. #define szSTREETADDRESS "$StreetAddress"
  273. #define szUNSTRUCTUREDNAME "$UnstructuredName"
  274. #define szUNSTRUCTUREDADDRESS "$UnstructuredAddress"
  275. #define szDEVICESERIALNUMBER "$DeviceSerialNumber"
  276. //#define szREQUESTID "RequestID"
  277. #define szRAWCERTIFICATE "RawCertificate"
  278. #define szCERTIFICATETEMPLATE "$CertificateTemplate"
  279. #define szCERTIFICATEENROLLMENTFLAGS "EnrollmentFlags"
  280. #define szCERTIFICATEGENERALFLAGS "GeneralFlags"
  281. #define szCERTIFICATEHASH "$CertificateHash2" // 2nd revision
  282. #define szSERIALNUMBER "$SerialNumber"
  283. #define szISSUERNAMEID "IssuerNameID"
  284. #define szNOTBEFORE "NotBefore"
  285. #define szNOTAFTER "NotAfter"
  286. #define szUPN "$UPN"
  287. #define szSUBJECTKEYIDENTIFIER "$SubjectKeyIdentifier"
  288. #define szSUBJECTKEYIDENTIFIER_OLD "$CertificateHash" // 2nd revision
  289. #define szPUBLICKEY "PublicKey"
  290. #define szPUBLICKEYLENGTH "PublicKeyLength"
  291. #define szPUBLICKEYALGORITHM "$PublicKeyAlgorithm"
  292. #define szPUBLICKEYPARAMS "PublicKeyParams"
  293. //#define szDISTINGUISHEDNAME "$DistinguishedName"
  294. //#define szRAWNAME "RawName"
  295. //#define szCOUNTRY "Country"
  296. //#define ...
  297. //#define szREQUESTID "RequestID"
  298. #define szATTRIBUTENAME "$AttributeName"
  299. #define szATTRIBUTEVALUE "$AttributeValue"
  300. //#define szREQUESTID "RequestID"
  301. #define szEXTENSIONNAME "$ExtensionName"
  302. #define szEXTENSIONFLAGS "ExtensionFlags"
  303. #define szEXTENSIONRAWVALUE "ExtensionRawValue"
  304. #define szCRLROWID "RowId"
  305. #define szCRLNUMBER "Number"
  306. #define szCRLMINBASE "MinBase"
  307. #define szCRLNAMEID "NameId"
  308. #define szCRLCOUNT "Count"
  309. #define szCRLTHISUPDATE "ThisUpdate"
  310. #define szCRLNEXTUPDATE "NextUpdate"
  311. #define szCRLTHISPUBLISH "ThisPublish"
  312. #define szCRLNEXTPUBLISH "NextPublish"
  313. #define szCRLEFFECTIVE "Effective"
  314. #define szCRLPROPAGATIONCOMPLETE "PropgationComplete"
  315. #define szCRLLASTPUBLISHED "CRLLastPublished"
  316. #define szCRLPUBLISHATTEMPTS "CRLPublishAttempts"
  317. #define szCRLPUBLISHFLAGS "CRLPublishFlags"
  318. #define szCRLPUBLISHSTATUSCODE "CRLPublishStatusCode"
  319. #define szCRLPUBLISHERROR "$CRLPublishError"
  320. #define szCRLPUBLISHERROR_OLD "CRLPublishError"
  321. #define szRAWCRL "RawCRL"
  322. #define CSTI_PRIMARY 0
  323. #define CSTI_CERTIFICATE 1
  324. #define CSTI_ATTRIBUTE 2
  325. #define CSTI_EXTENSION 3
  326. #define CSTI_MAX 4
  327. #define CSTI_MAXDIRECT (CSTI_CERTIFICATE + 1)
  328. typedef struct _CERTSESSIONTABLE
  329. {
  330. JET_TABLEID TableId;
  331. DWORD TableFlags;
  332. } CERTSESSIONTABLE;
  333. typedef struct _CERTSESSION
  334. {
  335. JET_SESID SesId;
  336. JET_DBID DBId;
  337. DWORD RowId;
  338. DWORD SesFlags;
  339. CERTSESSIONTABLE aTable[CSTI_MAX];
  340. DWORD cTransact;
  341. ICertDBRow *prow;
  342. IEnumCERTDBRESULTROW *pview;
  343. DWORD dwThreadId;
  344. } CERTSESSION;
  345. extern DBTABLE g_adtRequests[];
  346. extern DBTABLE g_adtCertificates[];
  347. extern DBTABLE g_adtRequestAttributes[];
  348. //extern DBTABLE g_adtNameExtensions[];
  349. extern DBTABLE g_adtCertExtensions[];
  350. extern DBTABLE g_adtCRLs[];
  351. extern DBAUXDATA g_dbauxRequests;
  352. extern DBAUXDATA g_dbauxCertificates;
  353. extern DBAUXDATA g_dbauxAttributes;
  354. extern DBAUXDATA g_dbauxExtensions;
  355. extern DBAUXDATA g_dbauxCRLs;
  356. extern DBCREATETABLE const g_actDataBase[];
  357. extern DUPTABLE const g_dntr[];
  358. extern DWORD g_aColumnViewQueue[];
  359. extern DWORD g_cColumnViewQueue;
  360. extern DWORD g_aColumnViewLog[];
  361. extern DWORD g_cColumnViewLog;
  362. extern DWORD g_aColumnViewRevoked[];
  363. extern DWORD g_cColumnViewRevoked;
  364. extern DWORD g_aColumnViewExtension[];
  365. extern DWORD g_cColumnViewExtension;
  366. extern DWORD g_aColumnViewAttribute[];
  367. extern DWORD g_cColumnViewAttribute;
  368. extern DWORD g_aColumnViewCRL[];
  369. extern DWORD g_cColumnViewCRL;
  370. #endif // #ifndef __DBTABLE_H__