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.

299 lines
6.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: table.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include <pch.cpp>
  11. #pragma hdrstop
  12. #include "csprop.h"
  13. #include "encode.h"
  14. #define iso_member 0x2a // iso(1) memberbody(2)
  15. #define us 0x86, 0x48 // us(840)
  16. #define rsadsi 0x86, 0xf7, 0x0d // rsadsi(113549)
  17. #define pkcs 0x01 // pkcs(1)
  18. #define rsa_dsi iso_member, us, rsadsi
  19. #define rsa_dsi_len 6
  20. #define pkcs_1 iso_member, us, rsadsi, pkcs
  21. #define pkcs_len 7
  22. #define prefix311 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37
  23. #define prefix311Length 7
  24. #define prefix19200300 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c
  25. #define prefix19200300Length 7
  26. #define joint_iso_ccitt_ds 0x55
  27. #define attributetype 0x04
  28. #define attributeType joint_iso_ccitt_ds, attributetype
  29. #define attributeLength 3
  30. const ALGIDTRANSLATE g_aAlgIdTranslate[] =
  31. {
  32. {
  33. ALGTYPE_SIG_RSA_MD5,
  34. szOID_RSA_MD5RSA, // "1.2.840.113549.1.1.4"
  35. },
  36. {
  37. ALGTYPE_KEYEXCH_RSA_MD5,
  38. szOID_RSA_RSA, // "1.2.840.113549.1.1.1"
  39. },
  40. {
  41. ALGTYPE_CIPHER_RC4_MD5,
  42. szOID_RSA_RC4, // "1.2.840.113549.3.4"
  43. }
  44. };
  45. const DWORD g_cAlgIdTranslate = ARRAYSIZE(g_aAlgIdTranslate);
  46. const OIDTRANSLATE g_aOidTranslate[] =
  47. {
  48. // Subject RDN OIDs:
  49. {
  50. szOID_COUNTRY_NAME, // "2.5.4.6"
  51. { attributeType, 6 }, // 0x55, 0x04, 0x06
  52. attributeLength,
  53. },
  54. {
  55. szOID_ORGANIZATION_NAME, // "2.5.4.10"
  56. { attributeType, 10 }, // 0x55, 0x04, 0x0a
  57. attributeLength,
  58. },
  59. {
  60. szOID_ORGANIZATIONAL_UNIT_NAME, // "2.5.4.11"
  61. { attributeType, 11 }, // 0x55, 0x04, 0x0b
  62. attributeLength,
  63. },
  64. {
  65. szOID_COMMON_NAME, // "2.5.4.3"
  66. { attributeType, 3 }, // 0x55, 0x04, 0x03
  67. attributeLength,
  68. },
  69. {
  70. szOID_LOCALITY_NAME, // "2.5.4.7"
  71. { attributeType, 7 }, // 0x55, 0x04, 0x07
  72. attributeLength,
  73. },
  74. {
  75. szOID_STATE_OR_PROVINCE_NAME, // "2.5.4.8"
  76. { attributeType, 8 }, // 0x55, 0x04, 0x08
  77. attributeLength,
  78. },
  79. {
  80. szOID_TITLE, // "2.5.4.12"
  81. { attributeType, 12 }, // 0x55, 0x04, 0x0c
  82. attributeLength,
  83. },
  84. {
  85. szOID_GIVEN_NAME, // "2.5.4.42"
  86. { attributeType, 42 }, // 0x55, 0x04, 0x02a
  87. attributeLength,
  88. },
  89. {
  90. szOID_INITIALS, // "2.5.4.43"
  91. { attributeType, 43 }, // 0x55, 0x04, 0x2b
  92. attributeLength,
  93. },
  94. {
  95. szOID_SUR_NAME, // "2.5.4.4"
  96. { attributeType, 4 }, // 0x55, 0x04, 0x04
  97. attributeLength,
  98. },
  99. {
  100. szOID_DOMAIN_COMPONENT, // "0.9.2342.19200300.100.1.25"
  101. { prefix19200300, 100, 1, 25 },
  102. // 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19
  103. prefix19200300Length + 3,
  104. },
  105. {
  106. szOID_RSA_emailAddr, // "1.2.840.113549.1.9.1"
  107. { pkcs_1, 9, 1 },
  108. pkcs_len + 2,
  109. },
  110. {
  111. szOID_STREET_ADDRESS, // "2.5.4.9"
  112. { attributeType, 9 }, // 0x55, 0x04, 0x09
  113. attributeLength,
  114. },
  115. {
  116. szOID_RSA_unstructName, // "1.2.840.113549.1.9.2"
  117. { pkcs_1, 9, 2 },
  118. pkcs_len + 2,
  119. },
  120. {
  121. szOID_RSA_unstructAddr, // "1.2.840.113549.1.9.8"
  122. { pkcs_1, 9, 8 },
  123. pkcs_len + 2,
  124. },
  125. {
  126. szOID_DEVICE_SERIAL_NUMBER, // "2.5.4.5"
  127. { attributeType, 5 }, // 0x55, 0x04, 0x05
  128. attributeLength,
  129. },
  130. // Non-Subject RDN OIDs:
  131. {
  132. szOID_CERT_EXTENSIONS, // "1.3.6.1.4.1.311.2.1.14"
  133. { prefix311, 2, 1, 14 },
  134. prefix311Length + 3,
  135. },
  136. {
  137. szOID_ENROLL_CERTTYPE_EXTENSION, // "1.3.6.1.4.1.311.20.2"
  138. { prefix311, 20, 2 },
  139. prefix311Length + 2,
  140. },
  141. {
  142. szOID_RSA_MD5RSA, // "1.2.840.113549.1.1.4"
  143. { pkcs_1, 1, 4 },
  144. pkcs_len + 2
  145. },
  146. {
  147. szOID_RSA_RSA, // "1.2.840.113549.1.1.1"
  148. { pkcs_1, 1, 1 },
  149. pkcs_len + 2
  150. },
  151. {
  152. szOID_RSA_RC4, // "1.2.840.113549.3.4"
  153. { rsa_dsi, 3, 4 },
  154. rsa_dsi_len + 2
  155. },
  156. };
  157. const DWORD g_cOidTranslate = ARRAYSIZE(g_aOidTranslate);
  158. // Limit strings to cch???MAX chars, not including the trailing '\0'
  159. RDNENTRY g_ardnSubject[] =
  160. {
  161. {
  162. szOID_COUNTRY_NAME, // "2.5.4.6"
  163. "C",
  164. BER_PRINTABLE_STRING,
  165. cchCOUNTRYNAMEMAX,
  166. CCH_DBMAXTEXT_RDN,
  167. },
  168. {
  169. szOID_ORGANIZATION_NAME, // "2.5.4.10"
  170. "O",
  171. BER_PRINTABLE_STRING,
  172. cchORGANIZATIONNAMEMAX,
  173. CCH_DBMAXTEXT_RDN,
  174. },
  175. {
  176. szOID_ORGANIZATIONAL_UNIT_NAME, // "2.5.4.11"
  177. "OU",
  178. BER_PRINTABLE_STRING,
  179. cchORGANIZATIONALUNITNAMEMAX,
  180. CCH_DBMAXTEXT_RDN,
  181. },
  182. {
  183. szOID_COMMON_NAME, // "2.5.4.3"
  184. "CN",
  185. BER_TELETEX_STRING,
  186. cchCOMMONNAMEMAX,
  187. CCH_DBMAXTEXT_RDN,
  188. },
  189. {
  190. szOID_LOCALITY_NAME, // "2.5.4.7"
  191. "L",
  192. BER_PRINTABLE_STRING,
  193. cchLOCALITYMANAMEMAX,
  194. CCH_DBMAXTEXT_RDN,
  195. },
  196. {
  197. szOID_STATE_OR_PROVINCE_NAME, // "2.5.4.8"
  198. "S",
  199. BER_PRINTABLE_STRING,
  200. cchSTATEORPROVINCENAMEMAX,
  201. CCH_DBMAXTEXT_RDN,
  202. },
  203. {
  204. szOID_TITLE, // "2.5.4.12"
  205. "T",
  206. BER_PRINTABLE_STRING,
  207. cchTITLEMAX,
  208. CCH_DBMAXTEXT_RDN,
  209. },
  210. {
  211. szOID_GIVEN_NAME, // "2.5.4.42"
  212. "G",
  213. BER_PRINTABLE_STRING,
  214. cchGIVENNAMEMAX,
  215. CCH_DBMAXTEXT_RDN,
  216. },
  217. {
  218. szOID_INITIALS, // "2.5.4.43"
  219. "I",
  220. BER_PRINTABLE_STRING,
  221. cchINITIALSMAX,
  222. CCH_DBMAXTEXT_RDN,
  223. },
  224. {
  225. szOID_SUR_NAME, // "2.5.4.4"
  226. "SN",
  227. BER_PRINTABLE_STRING,
  228. cchSURNAMEMAX,
  229. CCH_DBMAXTEXT_RDN,
  230. },
  231. {
  232. szOID_DOMAIN_COMPONENT, // "0.9.2342.19200300.100.1.25"
  233. "DC",
  234. BER_PRINTABLE_STRING,
  235. cchDOMAINCOMPONENTMAX,
  236. CCH_DBMAXTEXT_RDN,
  237. },
  238. {
  239. szOID_RSA_emailAddr, // "1.2.840.113549.1.9.1"
  240. "E",
  241. BER_IA5_STRING,
  242. cchEMAILMAX,
  243. CCH_DBMAXTEXT_RDN,
  244. },
  245. {
  246. szOID_STREET_ADDRESS, // "2.5.4.9"
  247. "STREET",
  248. BER_PRINTABLE_STRING,
  249. cchSTREETADDRESSMAX,
  250. CCH_DBMAXTEXT_RDN,
  251. },
  252. {
  253. szOID_RSA_unstructName, // "1.2.840.113549.1.9.2"
  254. "UnstructuredName",
  255. BER_PRINTABLE_STRING,
  256. cchUNSTRUCTUREDNAMEMAX,
  257. CCH_DBMAXTEXT_RDN,
  258. },
  259. {
  260. szOID_RSA_unstructAddr, // "1.2.840.113549.1.9.8"
  261. "UnstructuredAddress",
  262. BER_PRINTABLE_STRING,
  263. cchUNSTRUCTUREDADDRESSMAX,
  264. CCH_DBMAXTEXT_RDN,
  265. },
  266. {
  267. szOID_DEVICE_SERIAL_NUMBER, // "2.5.4.5"
  268. "DeviceSerialNumber",
  269. BER_PRINTABLE_STRING,
  270. cchDEVICESERIALNUMBERMAX,
  271. CCH_DBMAXTEXT_RDN,
  272. },
  273. };
  274. const DWORD g_crdnSubject = ARRAYSIZE(g_ardnSubject);