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.

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