home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / security / certsvr / policyvb / const.bas next >
Encoding:
BASIC Source File  |  1997-05-29  |  218.8 KB  |  4,548 lines

  1. Attribute VB_Name = "Const"
  2. Option Explicit
  3. '+---------------------------------------------------------------------------
  4. '
  5. ' Microsoft Windows
  6. '
  7. ' File: wincrypt.h
  8. '
  9. ' Contents: Cryptographic API Prototypes and Definitions
  10. '
  11. '----------------------------------------------------------------------------
  12. '
  13. ' Algorithm IDs and Flags
  14. '
  15. ' ALG_ID crackers
  16. ' Algorithm classes
  17. Public Const ALG_CLASS_ANY As Long = 0
  18. ' Algorithm types
  19. Public Const ALG_TYPE_ANY As Long = 0
  20. ' Generic sub-ids
  21. Public Const ALG_SID_ANY As Long = 0
  22. ' Some RSA sub-ids
  23. Public Const ALG_SID_RSA_ANY As Long = 0
  24. Public Const ALG_SID_RSA_PKCS As Long = 1
  25. Public Const ALG_SID_RSA_MSATWORK As Long = 2
  26. Public Const ALG_SID_RSA_ENTRUST As Long = 3
  27. Public Const ALG_SID_RSA_PGP As Long = 4
  28. ' Some DSS sub-ids
  29. '
  30. Public Const ALG_SID_DSS_ANY As Long = 0
  31. Public Const ALG_SID_DSS_PKCS As Long = 1
  32. Public Const ALG_SID_DSS_DMS As Long = 2
  33. ' Block cipher sub ids
  34. ' DES sub_ids
  35. Public Const ALG_SID_DES As Long = 1
  36. Public Const ALG_SID_3DES As Long = 3
  37. Public Const ALG_SID_DESX As Long = 4
  38. Public Const ALG_SID_IDEA As Long = 5
  39. Public Const ALG_SID_CAST As Long = 6
  40. Public Const ALG_SID_SAFERSK64 As Long = 7
  41. Public Const ALD_SID_SAFERSK128 As Long = 8
  42. Public Const ALG_SID_3DES_112 As Long = 9
  43. Public Const ALG_SID_CYLINK_MEK As Long = 12
  44. Public Const ALG_SID_RC5 As Long = 13
  45. ' Fortezza sub-ids
  46. Public Const ALG_SID_SKIPJACK As Long = 10
  47. Public Const ALG_SID_TEK As Long = 11
  48. ' KP_MODE
  49. Public Const CRYPT_MODE_CBCI As Long = 6
  50. Public Const CRYPT_MODE_CFBP As Long = 7
  51. Public Const CRYPT_MODE_OFBP As Long = 8
  52. Public Const CRYPT_MODE_CBCOFM As Long = 9
  53. Public Const CRYPT_MODE_CBCOFMI As Long = 10
  54. ' RC2 sub-ids
  55. Public Const ALG_SID_RC2 As Long = 2
  56. ' Stream cipher sub-ids
  57. Public Const ALG_SID_RC4 As Long = 1
  58. Public Const ALG_SID_SEAL As Long = 2
  59. ' Diffie-Hellman sub-ids
  60. Public Const ALG_SID_DH_SANDF As Long = 1
  61. Public Const ALG_SID_DH_EPHEM As Long = 2
  62. Public Const ALG_SID_AGREED_KEY_ANY As Long = 3
  63. Public Const ALG_SID_KEA As Long = 4
  64. ' Hash sub ids
  65. Public Const ALG_SID_MD2 As Long = 1
  66. Public Const ALG_SID_MD4 As Long = 2
  67. Public Const ALG_SID_MD5 As Long = 3
  68. Public Const ALG_SID_SHA As Long = 4
  69. Public Const ALG_SID_SHA1 As Long = 4
  70. Public Const ALG_SID_MAC As Long = 5
  71. Public Const ALG_SID_RIPEMD As Long = 6
  72. Public Const ALG_SID_RIPEMD160 As Long = 7
  73. Public Const ALG_SID_SSL3SHAMD5 As Long = 8
  74. Public Const ALG_SID_HMAC As Long = 9
  75. ' secure channel sub ids
  76. Public Const ALG_SID_SSL3_MASTER As Long = 1
  77. Public Const ALG_SID_SCHANNEL_MASTER_HASH As Long = 2
  78. Public Const ALG_SID_SCHANNEL_MAC_KEY As Long = 3
  79. Public Const ALG_SID_PCT1_MASTER As Long = 4
  80. Public Const ALG_SID_SSL2_MASTER As Long = 5
  81. Public Const ALG_SID_TLS1_MASTER As Long = 6
  82. Public Const ALG_SID_SCHANNEL_ENC_KEY As Long = 7
  83. ' Our silly example sub-id
  84. Public Const ALG_SID_EXAMPLE As Long = 80
  85. ' algorithm identifier definitions
  86. ' dwFlags definitions for CryptAcquireContext
  87. Public Const CRYPT_VERIFYCONTEXT As Long = &HF0000000
  88. Public Const CRYPT_NEWKEYSET As Long = &H00000008
  89. Public Const CRYPT_DELETEKEYSET As Long = &H00000010
  90. Public Const CRYPT_MACHINE_KEYSET As Long = &H00000020
  91. ' dwFlag definitions for CryptGenKey
  92. Public Const CRYPT_EXPORTABLE As Long = &H00000001
  93. Public Const CRYPT_USER_PROTECTED As Long = &H00000002
  94. Public Const CRYPT_CREATE_SALT As Long = &H00000004
  95. Public Const CRYPT_UPDATE_KEY As Long = &H00000008
  96. Public Const CRYPT_NO_SALT As Long = &H00000010
  97. Public Const CRYPT_PREGEN As Long = &H00000040
  98. Public Const CRYPT_RECIPIENT As Long = &H00000010
  99. Public Const CRYPT_INITIATOR As Long = &H00000040
  100. Public Const CRYPT_ONLINE As Long = &H00000080
  101. Public Const CRYPT_SF As Long = &H00000100
  102. Public Const CRYPT_CREATE_IV As Long = &H00000200
  103. Public Const CRYPT_KEK As Long = &H00000400
  104. Public Const CRYPT_DATA_KEY As Long = &H00000800
  105. ' dwFlags definitions for CryptDeriveKey
  106. Public Const CRYPT_SERVER As Long = &H00000400
  107. Public Const KEY_LENGTH_MASK As Long = &HFFFF0000
  108. ' dwFlag definitions for CryptExportKey
  109. Public Const CRYPT_Y_ONLY As Long = &H00000001
  110. Public Const CRYPT_SSL2_SLUMMING As Long = &H00000002
  111. ' dwFlags definitions for CryptHashSessionKey
  112. Public Const CRYPT_LITTLE_ENDIAN As Long = &H00000001
  113. ' dwFlag definitions for CryptSetProviderEx and CryptGetDefaultProvider
  114. Public Const CRYPT_MACHINE_DEFAULT As Long = &H00000001
  115. Public Const CRYPT_USER_DEFAULT As Long = &H00000002
  116. Public Const CRYPT_DELETE_DEFAULT As Long = &H00000004
  117. ' exported key blob definitions
  118. Public Const SIMPLEBLOB As Long = &H1
  119. Public Const PUBLICKEYBLOB As Long = &H6
  120. Public Const PRIVATEKEYBLOB As Long = &H7
  121. Public Const PLAINTEXTKEYBLOB As Long = &H8
  122. Public Const AT_KEYEXCHANGE As Long = 1
  123. Public Const AT_SIGNATURE As Long = 2
  124. Public Const CRYPT_USERDATA As Long = 1
  125. ' dwParam
  126. Public Const KP_IV As Long = 1
  127. Public Const KP_SALT As Long = 2
  128. Public Const KP_PADDING As Long = 3
  129. Public Const KP_MODE As Long = 4
  130. Public Const KP_MODE_BITS As Long = 5
  131. Public Const KP_PERMISSIONS As Long = 6
  132. Public Const KP_ALGID As Long = 7
  133. Public Const KP_BLOCKLEN As Long = 8
  134. Public Const KP_KEYLEN As Long = 9
  135. Public Const KP_SALT_EX As Long = 10
  136. Public Const KP_P As Long = 11
  137. Public Const KP_G As Long = 12
  138. Public Const KP_Q As Long = 13
  139. Public Const KP_X As Long = 14
  140. Public Const KP_Y As Long = 15
  141. Public Const KP_RA As Long = 16
  142. Public Const KP_RB As Long = 17
  143. Public Const KP_INFO As Long = 18
  144. Public Const KP_EFFECTIVE_KEYLEN As Long = 19
  145. Public Const KP_SCHANNEL_ALG As Long = 20
  146. Public Const KP_CLIENT_RANDOM As Long = 21
  147. Public Const KP_SERVER_RANDOM As Long = 22
  148. Public Const KP_RP As Long = 23
  149. Public Const KP_PRECOMP_MD5 As Long = 24
  150. Public Const KP_PRECOMP_SHA As Long = 25
  151. Public Const KP_CERTIFICATE As Long = 26
  152. Public Const KP_CLEAR_KEY As Long = 27
  153. Public Const KP_PUB_EX_LEN As Long = 28
  154. Public Const KP_PUB_EX_VAL As Long = 29
  155. ' KP_PADDING
  156. Public Const PKCS5_PADDING As Long = 1
  157. Public Const RANDOM_PADDING As Long = 2
  158. Public Const ZERO_PADDING As Long = 3
  159. ' KP_MODE
  160. Public Const CRYPT_MODE_CBC As Long = 1
  161. Public Const CRYPT_MODE_ECB As Long = 2
  162. Public Const CRYPT_MODE_OFB As Long = 3
  163. Public Const CRYPT_MODE_CFB As Long = 4
  164. Public Const CRYPT_MODE_CTS As Long = 5
  165. ' KP_PERMISSIONS
  166. Public Const CRYPT_ENCRYPT As Long = &H0001
  167. Public Const CRYPT_DECRYPT As Long = &H0002
  168. Public Const CRYPT_EXPORT As Long = &H0004
  169. Public Const CRYPT_READ As Long = &H0008
  170. Public Const CRYPT_WRITE As Long = &H0010
  171. Public Const CRYPT_MAC As Long = &H0020
  172. Public Const CRYPT_EXPORT_KEY As Long = &H0040
  173. Public Const CRYPT_IMPORT_KEY As Long = &H0080
  174. Public Const HP_ALGID As Long = &H0001
  175. Public Const HP_HASHVAL As Long = &H0002
  176. Public Const HP_HASHSIZE As Long = &H0004
  177. Public Const HP_HMAC_INFO As Long = &H0005
  178. '
  179. ' CryptGetProvParam
  180. '
  181. Public Const PP_ENUMALGS As Long = 1
  182. Public Const PP_ENUMCONTAINERS As Long = 2
  183. Public Const PP_IMPTYPE As Long = 3
  184. Public Const PP_NAME As Long = 4
  185. Public Const PP_VERSION As Long = 5
  186. Public Const PP_CONTAINER As Long = 6
  187. Public Const PP_CHANGE_PASSWORD As Long = 7
  188. Public Const PP_KEYSET_SEC_DESCR As Long = 8
  189. Public Const PP_CERTCHAIN As Long = 9
  190. Public Const PP_KEY_TYPE_SUBTYPE As Long = 10
  191. Public Const PP_PROVTYPE As Long = 16
  192. Public Const PP_KEYSTORAGE As Long = 17
  193. Public Const PP_APPLI_CERT As Long = 18
  194. Public Const PP_SYM_KEYSIZE As Long = 19
  195. Public Const PP_SESSION_KEYSIZE As Long = 20
  196. Public Const PP_UI_PROMPT As Long = 21
  197. Public Const PP_ENUMALGS_EX As Long = 22
  198. Public Const CRYPT_FIRST As Long = 1
  199. Public Const CRYPT_NEXT As Long = 2
  200. Public Const CRYPT_IMPL_HARDWARE As Long = 1
  201. Public Const CRYPT_IMPL_SOFTWARE As Long = 2
  202. Public Const CRYPT_IMPL_MIXED As Long = 3
  203. Public Const CRYPT_IMPL_UNKNOWN As Long = 4
  204. ' key storage flags
  205. Public Const CRYPT_SEC_DESCR As Long = &H00000001
  206. Public Const CRYPT_PSTORE As Long = &H00000002
  207. Public Const CRYPT_UI_PROMPT As Long = &H00000004
  208. ' protocol flags
  209. Public Const CRYPT_FLAG_PCT1 As Long = &H0001
  210. Public Const CRYPT_FLAG_SSL2 As Long = &H0002
  211. Public Const CRYPT_FLAG_SSL3 As Long = &H0004
  212. Public Const CRYPT_FLAG_TLS1 As Long = &H0008
  213. '
  214. ' CryptSetProvParam
  215. '
  216. Public Const PP_CLIENT_HWND As Long = 1
  217. Public Const PP_CONTEXT_INFO As Long = 11
  218. Public Const PP_KEYEXCHANGE_KEYSIZE As Long = 12
  219. Public Const PP_SIGNATURE_KEYSIZE As Long = 13
  220. Public Const PP_KEYEXCHANGE_ALG As Long = 14
  221. Public Const PP_SIGNATURE_ALG As Long = 15
  222. Public Const PROV_RSA_FULL As Long = 1
  223. Public Const PROV_RSA_SIG As Long = 2
  224. Public Const PROV_DSS As Long = 3
  225. Public Const PROV_FORTEZZA As Long = 4
  226. Public Const PROV_MS_EXCHANGE As Long = 5
  227. Public Const PROV_SSL As Long = 6
  228. Public Const PROV_RSA_SCHANNEL As Long = 12
  229. Public Const PROV_DSS_DH As Long = 13
  230. Public Const PROV_EC_ECDSA As Long = 14
  231. Public Const PROV_EC_ECNR As Long = 15
  232. Public Const PROV_EC_ECDSA_FULL As Long = 16
  233. Public Const PROV_EC_ECNR_FULL As Long = 17
  234. Public Const PROV_SPYRUS_LYNKS As Long = 20
  235. '
  236. ' STT defined Providers
  237. '
  238. Public Const PROV_STT_MER As Long = 7
  239. Public Const PROV_STT_ACQ As Long = 8
  240. Public Const PROV_STT_BRND As Long = 9
  241. Public Const PROV_STT_ROOT As Long = 10
  242. Public Const PROV_STT_ISS As Long = 11
  243. '
  244. ' Provider friendly names
  245. '
  246. Public Const MS_DEF_PROV_A As String = "Microsoft Base Cryptographic Provider v1.0"
  247. Public Const MS_DEF_PROV_W As String = "Microsoft Base Cryptographic Provider v1.0"
  248. Public Const MS_ENHANCED_PROV_A As String = "Microsoft Enhanced Cryptographic Provider v1.0"
  249. Public Const MS_ENHANCED_PROV_W As String = "Microsoft Enhanced Cryptographic Provider v1.0"
  250. Public Const MS_DEF_DSS_PROV_A As String = "Microsoft Base DSS Cryptographic Provider"
  251. Public Const MS_DEF_DSS_PROV_W As String = "Microsoft Base DSS Cryptographic Provider"
  252. Public Const MAXUIDLEN As Long = 64
  253. Public Const CUR_BLOB_VERSION As Long = 2
  254. ' structure for use with CryptSetHashParam with CALG_HMAC
  255. ' structure for use with CryptSetKeyParam with KP_SCHANNEL_ALG
  256. ' uses of algortihms for SCHANNEL_ALG structure
  257. Public Const SCHANNEL_MAC_KEY As Long = &H00000000
  258. Public Const SCHANNEL_ENC_KEY As Long = &H00000001
  259. '+-------------------------------------------------------------------------
  260. ' CRYPTOAPI BLOB definitions
  261. '--------------------------------------------------------------------------
  262. '+-------------------------------------------------------------------------
  263. ' In a CRYPT_BIT_BLOB the last byte may contain 0-7 unused bits. Therefore, the
  264. ' overall bit length is cbData * 8 - cUnusedBits.
  265. '--------------------------------------------------------------------------
  266. '+-------------------------------------------------------------------------
  267. ' Type used for any algorithm
  268. '
  269. ' Where the Parameters CRYPT_OBJID_BLOB is in its encoded representation. For most
  270. '--------------------------------------------------------------------------
  271. ' Following are the definitions of various algorithm object identifiers
  272. ' RSA
  273. Public Const szOID_RSA As String = "1.2.840.113549"
  274. Public Const szOID_PKCS As String = "1.2.840.113549.1"
  275. Public Const szOID_RSA_HASH As String = "1.2.840.113549.2"
  276. Public Const szOID_RSA_ENCRYPT As String = "1.2.840.113549.3"
  277. Public Const szOID_PKCS_1 As String = "1.2.840.113549.1.1"
  278. Public Const szOID_PKCS_2 As String = "1.2.840.113549.1.2"
  279. Public Const szOID_PKCS_3 As String = "1.2.840.113549.1.3"
  280. Public Const szOID_PKCS_4 As String = "1.2.840.113549.1.4"
  281. Public Const szOID_PKCS_5 As String = "1.2.840.113549.1.5"
  282. Public Const szOID_PKCS_6 As String = "1.2.840.113549.1.6"
  283. Public Const szOID_PKCS_7 As String = "1.2.840.113549.1.7"
  284. Public Const szOID_PKCS_8 As String = "1.2.840.113549.1.8"
  285. Public Const szOID_PKCS_9 As String = "1.2.840.113549.1.9"
  286. Public Const szOID_PKCS_10 As String = "1.2.840.113549.1.10"
  287. Public Const szOID_RSA_RSA As String = "1.2.840.113549.1.1.1"
  288. Public Const szOID_RSA_MD2RSA As String = "1.2.840.113549.1.1.2"
  289. Public Const szOID_RSA_MD4RSA As String = "1.2.840.113549.1.1.3"
  290. Public Const szOID_RSA_MD5RSA As String = "1.2.840.113549.1.1.4"
  291. Public Const szOID_RSA_SHA1RSA As String = "1.2.840.113549.1.1.5"
  292. Public Const szOID_RSA_SETOAEP_RSA As String = "1.2.840.113549.1.1.6"
  293. Public Const szOID_RSA_data As String = "1.2.840.113549.1.7.1"
  294. Public Const szOID_RSA_signedData As String = "1.2.840.113549.1.7.2"
  295. Public Const szOID_RSA_envelopedData As String = "1.2.840.113549.1.7.3"
  296. Public Const szOID_RSA_signEnvData As String = "1.2.840.113549.1.7.4"
  297. Public Const szOID_RSA_digestedData As String = "1.2.840.113549.1.7.5"
  298. Public Const szOID_RSA_hashedData As String = "1.2.840.113549.1.7.5"
  299. Public Const szOID_RSA_encryptedData As String = "1.2.840.113549.1.7.6"
  300. Public Const szOID_RSA_emailAddr As String = "1.2.840.113549.1.9.1"
  301. Public Const szOID_RSA_unstructName As String = "1.2.840.113549.1.9.2"
  302. Public Const szOID_RSA_contentType As String = "1.2.840.113549.1.9.3"
  303. Public Const szOID_RSA_messageDigest As String = "1.2.840.113549.1.9.4"
  304. Public Const szOID_RSA_signingTime As String = "1.2.840.113549.1.9.5"
  305. Public Const szOID_RSA_counterSign As String = "1.2.840.113549.1.9.6"
  306. Public Const szOID_RSA_challengePwd As String = "1.2.840.113549.1.9.7"
  307. Public Const szOID_RSA_unstructAddr As String = "1.2.840.113549.1.9.8"
  308. Public Const szOID_RSA_extCertAttrs As String = "1.2.840.113549.1.9.9"
  309. Public Const szOID_RSA_MD2 As String = "1.2.840.113549.2.2"
  310. Public Const szOID_RSA_MD4 As String = "1.2.840.113549.2.4"
  311. Public Const szOID_RSA_MD5 As String = "1.2.840.113549.2.5"
  312. Public Const szOID_RSA_RC2CBC As String = "1.2.840.113549.3.2"
  313. Public Const szOID_RSA_RC4 As String = "1.2.840.113549.3.4"
  314. ' ITU-T UsefulDefinitions
  315. Public Const szOID_DS As String = "2.5"
  316. Public Const szOID_DSALG As String = "2.5.8"
  317. Public Const szOID_DSALG_CRPT As String = "2.5.8.1"
  318. Public Const szOID_DSALG_HASH As String = "2.5.8.2"
  319. Public Const szOID_DSALG_SIGN As String = "2.5.8.3"
  320. Public Const szOID_DSALG_RSA As String = "2.5.8.1.1"
  321. ' http:
  322. ' http:
  323. Public Const szOID_OIW As String = "1.3.14"
  324. Public Const szOID_OIWSEC As String = "1.3.14.3.2"
  325. Public Const szOID_OIWSEC_md4RSA As String = "1.3.14.3.2.2"
  326. Public Const szOID_OIWSEC_md5RSA As String = "1.3.14.3.2.3"
  327. Public Const szOID_OIWSEC_md4RSA2 As String = "1.3.14.3.2.4"
  328. Public Const szOID_OIWSEC_desECB As String = "1.3.14.3.2.6"
  329. Public Const szOID_OIWSEC_desCBC As String = "1.3.14.3.2.7"
  330. Public Const szOID_OIWSEC_desOFB As String = "1.3.14.3.2.8"
  331. Public Const szOID_OIWSEC_desCFB As String = "1.3.14.3.2.9"
  332. Public Const szOID_OIWSEC_desMAC As String = "1.3.14.3.2.10"
  333. Public Const szOID_OIWSEC_rsaSign As String = "1.3.14.3.2.11"
  334. Public Const szOID_OIWSEC_dsa As String = "1.3.14.3.2.12"
  335. Public Const szOID_OIWSEC_shaDSA As String = "1.3.14.3.2.13"
  336. Public Const szOID_OIWSEC_mdc2RSA As String = "1.3.14.3.2.14"
  337. Public Const szOID_OIWSEC_shaRSA As String = "1.3.14.3.2.15"
  338. Public Const szOID_OIWSEC_dhCommMod As String = "1.3.14.3.2.16"
  339. Public Const szOID_OIWSEC_desEDE As String = "1.3.14.3.2.17"
  340. Public Const szOID_OIWSEC_sha As String = "1.3.14.3.2.18"
  341. Public Const szOID_OIWSEC_mdc2 As String = "1.3.14.3.2.19"
  342. Public Const szOID_OIWSEC_dsaComm As String = "1.3.14.3.2.20"
  343. Public Const szOID_OIWSEC_dsaCommSHA As String = "1.3.14.3.2.21"
  344. Public Const szOID_OIWSEC_rsaXchg As String = "1.3.14.3.2.22"
  345. Public Const szOID_OIWSEC_keyHashSeal As String = "1.3.14.3.2.23"
  346. Public Const szOID_OIWSEC_md2RSASign As String = "1.3.14.3.2.24"
  347. Public Const szOID_OIWSEC_md5RSASign As String = "1.3.14.3.2.25"
  348. Public Const szOID_OIWSEC_sha1 As String = "1.3.14.3.2.26"
  349. Public Const szOID_OIWSEC_dsaSHA1 As String = "1.3.14.3.2.27"
  350. Public Const szOID_OIWSEC_dsaCommSHA1 As String = "1.3.14.3.2.28"
  351. Public Const szOID_OIWSEC_sha1RSASign As String = "1.3.14.3.2.29"
  352. Public Const szOID_OIWDIR As String = "1.3.14.7.2"
  353. Public Const szOID_OIWDIR_CRPT As String = "1.3.14.7.2.1"
  354. Public Const szOID_OIWDIR_HASH As String = "1.3.14.7.2.2"
  355. Public Const szOID_OIWDIR_SIGN As String = "1.3.14.7.2.3"
  356. Public Const szOID_OIWDIR_md2 As String = "1.3.14.7.2.2.1"
  357. Public Const szOID_OIWDIR_md2RSA As String = "1.3.14.7.2.3.1"
  358. ' INFOSEC Algorithms
  359. Public Const szOID_INFOSEC As String = "2.16.840.1.101.2.1"
  360. Public Const szOID_INFOSEC_sdnsSignature As String = "2.16.840.1.101.2.1.1.1"
  361. Public Const szOID_INFOSEC_mosaicSignature As String = "2.16.840.1.101.2.1.1.2"
  362. Public Const szOID_INFOSEC_sdnsConfidentiality As String = "2.16.840.1.101.2.1.1.3"
  363. Public Const szOID_INFOSEC_mosaicConfidentiality As String = "2.16.840.1.101.2.1.1.4"
  364. Public Const szOID_INFOSEC_sdnsIntegrity As String = "2.16.840.1.101.2.1.1.5"
  365. Public Const szOID_INFOSEC_mosaicIntegrity As String = "2.16.840.1.101.2.1.1.6"
  366. Public Const szOID_INFOSEC_sdnsTokenProtection As String = "2.16.840.1.101.2.1.1.7"
  367. Public Const szOID_INFOSEC_mosaicTokenProtection As String = "2.16.840.1.101.2.1.1.8"
  368. Public Const szOID_INFOSEC_sdnsKeyManagement As String = "2.16.840.1.101.2.1.1.9"
  369. Public Const szOID_INFOSEC_mosaicKeyManagement As String = "2.16.840.1.101.2.1.1.10"
  370. Public Const szOID_INFOSEC_sdnsKMandSig As String = "2.16.840.1.101.2.1.1.11"
  371. Public Const szOID_INFOSEC_mosaicKMandSig As String = "2.16.840.1.101.2.1.1.12"
  372. Public Const szOID_INFOSEC_SuiteASignature As String = "2.16.840.1.101.2.1.1.13"
  373. Public Const szOID_INFOSEC_SuiteAConfidentiality As String = "2.16.840.1.101.2.1.1.14"
  374. Public Const szOID_INFOSEC_SuiteAIntegrity As String = "2.16.840.1.101.2.1.1.15"
  375. Public Const szOID_INFOSEC_SuiteATokenProtection As String = "2.16.840.1.101.2.1.1.16"
  376. Public Const szOID_INFOSEC_SuiteAKeyManagement As String = "2.16.840.1.101.2.1.1.17"
  377. Public Const szOID_INFOSEC_SuiteAKMandSig As String = "2.16.840.1.101.2.1.1.18"
  378. Public Const szOID_INFOSEC_mosaicUpdatedSig As String = "2.16.840.1.101.2.1.1.19"
  379. Public Const szOID_INFOSEC_mosaicKMandUpdSig As String = "2.16.840.1.101.2.1.1.20"
  380. Public Const szOID_INFOSEC_mosaicUpdatedInteg As String = "2.16.840.1.101.2.1.1.21"
  381. '+-------------------------------------------------------------------------
  382. '--------------------------------------------------------------------------
  383. '+-------------------------------------------------------------------------
  384. ' Type used for an extension to an encoded content
  385. '
  386. ' Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  387. '--------------------------------------------------------------------------
  388. '+-------------------------------------------------------------------------
  389. ' AttributeTypeValue
  390. '
  391. ' Where the Value's CRYPT_OBJID_BLOB is in its encoded representation.
  392. '--------------------------------------------------------------------------
  393. '+-------------------------------------------------------------------------
  394. ' Attributes
  395. '
  396. ' Where the Value's PATTR_BLOBs are in their encoded representation.
  397. '--------------------------------------------------------------------------
  398. '+-------------------------------------------------------------------------
  399. '
  400. ' The interpretation of the Value depends on the dwValueType.
  401. ' See below for a list of the types.
  402. '--------------------------------------------------------------------------
  403. '+-------------------------------------------------------------------------
  404. ' CERT_RDN attribute Object Identifiers
  405. '--------------------------------------------------------------------------
  406. ' Labeling attribute types:
  407. Public Const szOID_COMMON_NAME As String = "2.5.4.3"
  408. Public Const szOID_SUR_NAME As String = "2.5.4.4"
  409. Public Const szOID_DEVICE_SERIAL_NUMBER As String = "2.5.4.5"
  410. ' Geographic attribute types:
  411. Public Const szOID_COUNTRY_NAME As String = "2.5.4.6"
  412. Public Const szOID_LOCALITY_NAME As String = "2.5.4.7"
  413. Public Const szOID_STATE_OR_PROVINCE_NAME As String = "2.5.4.8"
  414. Public Const szOID_STREET_ADDRESS As String = "2.5.4.9"
  415. ' Organizational attribute types:
  416. Public Const szOID_ORGANIZATION_NAME As String = "2.5.4.10"
  417. Public Const szOID_ORGANIZATIONAL_UNIT_NAME As String = "2.5.4.11"
  418. Public Const szOID_TITLE As String = "2.5.4.12"
  419. ' Explanatory attribute types:
  420. Public Const szOID_DESCRIPTION As String = "2.5.4.13"
  421. Public Const szOID_SEARCH_GUIDE As String = "2.5.4.14"
  422. Public Const szOID_BUSINESS_CATEGORY As String = "2.5.4.15"
  423. ' Postal addressing attribute types:
  424. Public Const szOID_POSTAL_ADDRESS As String = "2.5.4.16"
  425. Public Const szOID_POSTAL_CODE As String = "2.5.4.17"
  426. Public Const szOID_POST_OFFICE_BOX As String = "2.5.4.18"
  427. Public Const szOID_PHYSICAL_DELIVERY_OFFICE_NAME As String = "2.5.4.19"
  428. ' Telecommunications addressing attribute types:
  429. Public Const szOID_TELEPHONE_NUMBER As String = "2.5.4.20"
  430. Public Const szOID_TELEX_NUMBER As String = "2.5.4.21"
  431. Public Const szOID_TELETEXT_TERMINAL_IDENTIFIER As String = "2.5.4.22"
  432. Public Const szOID_FACSIMILE_TELEPHONE_NUMBER As String = "2.5.4.23"
  433. Public Const szOID_X21_ADDRESS As String = "2.5.4.24"
  434. Public Const szOID_INTERNATIONAL_ISDN_NUMBER As String = "2.5.4.25"
  435. Public Const szOID_REGISTERED_ADDRESS As String = "2.5.4.26"
  436. Public Const szOID_DESTINATION_INDICATOR As String = "2.5.4.27"
  437. ' Preference attribute types:
  438. Public Const szOID_PREFERRED_DELIVERY_METHOD As String = "2.5.4.28"
  439. ' OSI application attribute types:
  440. Public Const szOID_PRESENTATION_ADDRESS As String = "2.5.4.29"
  441. Public Const szOID_SUPPORTED_APPLICATION_CONTEXT As String = "2.5.4.30"
  442. ' Relational application attribute types:
  443. Public Const szOID_MEMBER As String = "2.5.4.31"
  444. Public Const szOID_OWNER As String = "2.5.4.32"
  445. Public Const szOID_ROLE_OCCUPANT As String = "2.5.4.33"
  446. Public Const szOID_SEE_ALSO As String = "2.5.4.34"
  447. ' Security attribute types:
  448. Public Const szOID_USER_PASSWORD As String = "2.5.4.35"
  449. Public Const szOID_USER_CERTIFICATE As String = "2.5.4.36"
  450. Public Const szOID_CA_CERTIFICATE As String = "2.5.4.37"
  451. Public Const szOID_AUTHORITY_REVOCATION_LIST As String = "2.5.4.38"
  452. Public Const szOID_CERTIFICATE_REVOCATION_LIST As String = "2.5.4.39"
  453. Public Const szOID_CROSS_CERTIFICATE_PAIR As String = "2.5.4.40"
  454. ' Undocumented attribute types???
  455. '#define szOID_??? "2.5.4.41"
  456. Public Const szOID_GIVEN_NAME As String = "2.5.4.42"
  457. Public Const szOID_INITIALS As String = "2.5.4.43"
  458. ' Pilot user attribute types:
  459. Public Const szOID_DOMAIN_COMPONENT As String = "0.9.2342.19200300.100.1.25"
  460. '+-------------------------------------------------------------------------
  461. ' CERT_RDN Attribute Value Types
  462. '
  463. ' For RDN_ENCODED_BLOB, the Value's CERT_RDN_VALUE_BLOB is in its encoded
  464. ' representation. Otherwise, its an array of bytes.
  465. '
  466. ' For all CERT_RDN types, Value.cbData is always the number of bytes, not
  467. ' necessarily the number of elements in the string. For instance,
  468. '
  469. ' For CertDecodeName, two 0 bytes are always appended to the end of the
  470. ' These added 0 bytes are't included in the BLOB.cbData.
  471. '--------------------------------------------------------------------------
  472. Public Const CERT_RDN_ANY_TYPE As Long = 0
  473. Public Const CERT_RDN_ENCODED_BLOB As Long = 1
  474. Public Const CERT_RDN_OCTET_STRING As Long = 2
  475. Public Const CERT_RDN_NUMERIC_STRING As Long = 3
  476. Public Const CERT_RDN_PRINTABLE_STRING As Long = 4
  477. Public Const CERT_RDN_TELETEX_STRING As Long = 5
  478. Public Const CERT_RDN_T61_STRING As Long = 5
  479. Public Const CERT_RDN_VIDEOTEX_STRING As Long = 6
  480. Public Const CERT_RDN_IA5_STRING As Long = 7
  481. Public Const CERT_RDN_GRAPHIC_STRING As Long = 8
  482. Public Const CERT_RDN_VISIBLE_STRING As Long = 9
  483. Public Const CERT_RDN_ISO646_STRING As Long = 9
  484. Public Const CERT_RDN_GENERAL_STRING As Long = 10
  485. Public Const CERT_RDN_UNIVERSAL_STRING As Long = 11
  486. Public Const CERT_RDN_INT4_STRING As Long = 11
  487. Public Const CERT_RDN_BMP_STRING As Long = 12
  488. Public Const CERT_RDN_UNICODE_STRING As Long = 12
  489. ' Macro to check that the dwValueType is a character string and not an
  490. ' encoded blob or octet string
  491. '+-------------------------------------------------------------------------
  492. ' A CERT_RDN consists of an array of the above attributes
  493. '--------------------------------------------------------------------------
  494. '+-------------------------------------------------------------------------
  495. ' Information stored in a subject's or issuer's name. The information
  496. ' is represented as an array of the above RDNs.
  497. '--------------------------------------------------------------------------
  498. '+-------------------------------------------------------------------------
  499. ' Name attribute value without the Object Identifier
  500. '
  501. ' The interpretation of the Value depends on the dwValueType.
  502. ' See above for a list of the types.
  503. '--------------------------------------------------------------------------
  504. '+-------------------------------------------------------------------------
  505. ' Public Key Info
  506. '
  507. ' The PublicKey is the encoded representation of the information as it is
  508. ' stored in the bit string
  509. '--------------------------------------------------------------------------
  510. '+-------------------------------------------------------------------------
  511. ' Information stored in a certificate
  512. '
  513. ' The Issuer, Subject, Algorithm, PublicKey and Extension BLOBs are the
  514. ' encoded representation of the information.
  515. '--------------------------------------------------------------------------
  516. '+-------------------------------------------------------------------------
  517. ' Certificate versions
  518. '--------------------------------------------------------------------------
  519. Public Const CERT_V1 As Long = 0
  520. Public Const CERT_V2 As Long = 1
  521. Public Const CERT_V3 As Long = 2
  522. '+-------------------------------------------------------------------------
  523. ' Certificate Information Flags
  524. '--------------------------------------------------------------------------
  525. Public Const CERT_INFO_VERSION_FLAG As Long = 1
  526. Public Const CERT_INFO_SERIAL_NUMBER_FLAG As Long = 2
  527. Public Const CERT_INFO_SIGNATURE_ALGORITHM_FLAG As Long = 3
  528. Public Const CERT_INFO_ISSUER_FLAG As Long = 4
  529. Public Const CERT_INFO_NOT_BEFORE_FLAG As Long = 5
  530. Public Const CERT_INFO_NOT_AFTER_FLAG As Long = 6
  531. Public Const CERT_INFO_SUBJECT_FLAG As Long = 7
  532. Public Const CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG As Long = 8
  533. Public Const CERT_INFO_ISSUER_UNIQUE_ID_FLAG As Long = 9
  534. Public Const CERT_INFO_SUBJECT_UNIQUE_ID_FLAG As Long = 10
  535. Public Const CERT_INFO_EXTENSION_FLAG As Long = 11
  536. '+-------------------------------------------------------------------------
  537. ' An entry in a CRL
  538. '
  539. ' The Extension BLOBs are the encoded representation of the information.
  540. '--------------------------------------------------------------------------
  541. '+-------------------------------------------------------------------------
  542. ' Information stored in a CRL
  543. '
  544. ' The Issuer, Algorithm and Extension BLOBs are the encoded
  545. ' representation of the information.
  546. '--------------------------------------------------------------------------
  547. '+-------------------------------------------------------------------------
  548. ' CRL versions
  549. '--------------------------------------------------------------------------
  550. Public Const CRL_V1 As Long = 0
  551. Public Const CRL_V2 As Long = 1
  552. '+-------------------------------------------------------------------------
  553. ' Information stored in a certificate request
  554. '
  555. ' The Subject, Algorithm, PublicKey and Attribute BLOBs are the encoded
  556. ' representation of the information.
  557. '--------------------------------------------------------------------------
  558. '+-------------------------------------------------------------------------
  559. ' Certificate Request versions
  560. '--------------------------------------------------------------------------
  561. Public Const CERT_REQUEST_V1 As Long = 0
  562. '+-------------------------------------------------------------------------
  563. ' Information stored in Netscape's Keygen request
  564. '--------------------------------------------------------------------------
  565. Public Const CERT_KEYGEN_REQUEST_V1 As Long = 0
  566. '+-------------------------------------------------------------------------
  567. ' Certificate, CRL, Certificate Request or Keygen Request Signed Content
  568. '
  569. ' The "to be signed" encoded content plus its signature. The ToBeSigned
  570. ' is the encoded CERT_INFO, CRL_INFO, CERT_REQUEST_INFO or
  571. ' CERT_KEYGEN_REQUEST_INFO.
  572. '--------------------------------------------------------------------------
  573. '+-------------------------------------------------------------------------
  574. '--------------------------------------------------------------------------
  575. '+-------------------------------------------------------------------------
  576. ' CTL Usage. Also used for EnhancedKeyUsage extension.
  577. '--------------------------------------------------------------------------
  578. '+-------------------------------------------------------------------------
  579. ' An entry in a CTL
  580. '--------------------------------------------------------------------------
  581. '+-------------------------------------------------------------------------
  582. ' Information stored in a CTL
  583. '--------------------------------------------------------------------------
  584. '+-------------------------------------------------------------------------
  585. ' CTL versions
  586. '--------------------------------------------------------------------------
  587. Public Const CTL_V1 As Long = 0
  588. '+-------------------------------------------------------------------------
  589. ' TimeStamp Request
  590. '
  591. ' The pszTimeStamp is the OID for the Time type requested
  592. ' The pszContentType is the Content Type OID for the content, usually DATA
  593. ' The Content is a un-decoded blob
  594. '--------------------------------------------------------------------------
  595. '+-------------------------------------------------------------------------
  596. ' Certificate and Message encoding types
  597. '
  598. ' The encoding type is a DWORD containing both the certificate and message
  599. ' encoding types. The certificate encoding type is stored in the LOWORD.
  600. ' The message encoding type is stored in the HIWORD. Some functions or
  601. ' structure fields require only one of the encoding types. The following
  602. ' required:
  603. '
  604. ' Its always acceptable to specify both.
  605. '--------------------------------------------------------------------------
  606. Public Const CERT_ENCODING_TYPE_MASK As Long = &H0000FFFF
  607. Public Const CMSG_ENCODING_TYPE_MASK As Long = &HFFFF0000
  608. Public Const CRYPT_ASN_ENCODING As Long = &H00000001
  609. Public Const CRYPT_NDR_ENCODING As Long = &H00000002
  610. Public Const X509_ASN_ENCODING As Long = &H00000001
  611. Public Const X509_NDR_ENCODING As Long = &H00000002
  612. Public Const PKCS_7_ASN_ENCODING As Long = &H00010000
  613. Public Const PKCS_7_NDR_ENCODING As Long = &H00020000
  614. '+-------------------------------------------------------------------------
  615. ' format the specified data structure according to the certificate
  616. ' encoding type.
  617. '
  618. '--------------------------------------------------------------------------
  619. '+-------------------------------------------------------------------------
  620. ' Encode / decode the specified data structure according to the certificate
  621. ' encoding type.
  622. '
  623. ' See below for a list of the predefined data structures.
  624. '--------------------------------------------------------------------------
  625. ' When the following flag is set the nocopy optimization is enabled.
  626. ' This optimization where appropriate, updates the pvStructInfo fields
  627. ' to point to content residing within pbEncoded instead of making a copy
  628. ' of and appending to pvStructInfo.
  629. '
  630. ' Note, when set, pbEncoded can't be freed until pvStructInfo is freed.
  631. Public Const CRYPT_DECODE_NOCOPY_FLAG As Long = &H1
  632. '+-------------------------------------------------------------------------
  633. ' Predefined X509 certificate data structures that can be encoded / decoded.
  634. '--------------------------------------------------------------------------
  635. Public Const CRYPT_ENCODE_DECODE_NONE As Long = 0
  636. '+-------------------------------------------------------------------------
  637. ' Predefined X509 certificate extension data structures that can be
  638. ' encoded / decoded.
  639. '--------------------------------------------------------------------------
  640. '+-------------------------------------------------------------------------
  641. ' Additional predefined data structures that can be encoded / decoded.
  642. '--------------------------------------------------------------------------
  643. '+-------------------------------------------------------------------------
  644. ' Predefined primitive data structures that can be encoded / decoded.
  645. '--------------------------------------------------------------------------
  646. '+-------------------------------------------------------------------------
  647. ' More predefined X509 certificate extension data structures that can be
  648. ' encoded / decoded.
  649. '--------------------------------------------------------------------------
  650. '+-------------------------------------------------------------------------
  651. ' Predefined PKCS #7 data structures that can be encoded / decoded.
  652. '--------------------------------------------------------------------------
  653. '+-------------------------------------------------------------------------
  654. ' can be encoded / decoded.
  655. '
  656. ' Predefined values: 2000 .. 2999
  657. '
  658. ' See spc.h for value and data structure definitions.
  659. '--------------------------------------------------------------------------
  660. '+-------------------------------------------------------------------------
  661. ' Extension Object Identifiers
  662. '--------------------------------------------------------------------------
  663. Public Const szOID_AUTHORITY_KEY_IDENTIFIER As String = "2.5.29.1"
  664. Public Const szOID_KEY_ATTRIBUTES As String = "2.5.29.2"
  665. Public Const szOID_KEY_USAGE_RESTRICTION As String = "2.5.29.4"
  666. Public Const szOID_SUBJECT_ALT_NAME As String = "2.5.29.7"
  667. Public Const szOID_ISSUER_ALT_NAME As String = "2.5.29.8"
  668. Public Const szOID_BASIC_CONSTRAINTS As String = "2.5.29.10"
  669. Public Const szOID_KEY_USAGE As String = "2.5.29.15"
  670. Public Const szOID_BASIC_CONSTRAINTS2 As String = "2.5.29.19"
  671. Public Const szOID_CERT_POLICIES As String = "2.5.29.32"
  672. Public Const szOID_AUTHORITY_KEY_IDENTIFIER2 As String = "2.5.29.35"
  673. Public Const szOID_SUBJECT_KEY_IDENTIFIER As String = "2.5.29.14"
  674. Public Const szOID_SUBJECT_ALT_NAME2 As String = "2.5.29.17"
  675. Public Const szOID_ISSUER_ALT_NAME2 As String = "2.5.29.18"
  676. Public Const szOID_CRL_REASON_CODE As String = "2.5.29.21"
  677. Public Const szOID_CRL_DIST_POINTS As String = "2.5.29.31"
  678. Public Const szOID_ENHANCED_KEY_USAGE As String = "2.5.29.37"
  679. ' Internet Public Key Infrastructure
  680. Public Const szOID_PKIX As String = "1.3.6.1.5.5.7"
  681. Public Const szOID_AUTHORITY_INFO_ACCESS As String = "1.3.6.1.5.5.7.2"
  682. ' Microsoft extensions or attributes
  683. Public Const szOID_CERT_EXTENSIONS As String = "1.3.6.1.4.1.311.2.1.14"
  684. Public Const szOID_NEXT_UPDATE_LOCATION As String = "1.3.6.1.4.1.311.10.2"
  685. ' Microsoft PKCS #7 ContentType Object Identifiers
  686. Public Const szOID_CTL As String = "1.3.6.1.4.1.311.10.1"
  687. '+-------------------------------------------------------------------------
  688. '--------------------------------------------------------------------------
  689. Public Const szOID_POLICY_MAPPINGS As String = "2.5.29.5"
  690. Public Const szOID_SUBJECT_DIR_ATTRS As String = "2.5.29.9"
  691. '+-------------------------------------------------------------------------
  692. '--------------------------------------------------------------------------
  693. Public Const szOID_PKIX_KP As String = "1.3.6.1.5.5.7.3"
  694. ' Consistent key usage bits: DIGITAL_SIGNATURE, KEY_ENCIPHERMENT
  695. ' or KEY_AGREEMENT
  696. Public Const szOID_PKIX_KP_SERVER_AUTH As String = "1.3.6.1.5.5.7.3.1"
  697. ' Consistent key usage bits: DIGITAL_SIGNATURE
  698. Public Const szOID_PKIX_KP_CLIENT_AUTH As String = "1.3.6.1.5.5.7.3.2"
  699. ' Consistent key usage bits: DIGITAL_SIGNATURE
  700. Public Const szOID_PKIX_KP_CODE_SIGNING As String = "1.3.6.1.5.5.7.3.3"
  701. ' Consistent key usage bits: DIGITAL_SIGNATURE, NON_REPUDIATION and/or
  702. Public Const szOID_PKIX_KP_EMAIL_PROTECTION As String = "1.3.6.1.5.5.7.3.4"
  703. '+-------------------------------------------------------------------------
  704. '+-------------------------------------------------------------------------
  705. ' Signer of CTLs
  706. Public Const szOID_KP_CTL_USAGE_SIGNING As String = "1.3.6.1.4.1.311.10.3.1"
  707. '+-------------------------------------------------------------------------
  708. ' Microsoft Attribute Object Identifiers
  709. '+-------------------------------------------------------------------------
  710. Public Const szOID_YESNO_TRUST_ATTR As String = "1.3.6.1.4.1.311.10.4.1"
  711. '+-------------------------------------------------------------------------
  712. ' X509_CERT
  713. '
  714. ' The "to be signed" encoded content plus its signature. The ToBeSigned
  715. ' X509_CERT_TO_BE_SIGNED, X509_CERT_CRL_TO_BE_SIGNED or
  716. ' X509_CERT_REQUEST_TO_BE_SIGNED.
  717. '
  718. ' pvStructInfo points to CERT_SIGNED_CONTENT_INFO.
  719. '--------------------------------------------------------------------------
  720. '+-------------------------------------------------------------------------
  721. ' X509_CERT_TO_BE_SIGNED
  722. '
  723. ' pvStructInfo points to CERT_INFO.
  724. '
  725. '
  726. '--------------------------------------------------------------------------
  727. '+-------------------------------------------------------------------------
  728. ' X509_CERT_CRL_TO_BE_SIGNED
  729. '
  730. ' pvStructInfo points to CRL_INFO.
  731. '
  732. '
  733. '--------------------------------------------------------------------------
  734. '+-------------------------------------------------------------------------
  735. ' X509_CERT_REQUEST_TO_BE_SIGNED
  736. '
  737. ' pvStructInfo points to CERT_REQUEST_INFO.
  738. '
  739. '
  740. '--------------------------------------------------------------------------
  741. '+-------------------------------------------------------------------------
  742. ' X509_EXTENSIONS
  743. ' szOID_CERT_EXTENSIONS
  744. '
  745. ' pvStructInfo points to following CERT_EXTENSIONS.
  746. '--------------------------------------------------------------------------
  747. '+-------------------------------------------------------------------------
  748. ' X509_NAME_VALUE
  749. ' X509_ANY_STRING
  750. '
  751. ' pvStructInfo points to CERT_NAME_VALUE.
  752. '--------------------------------------------------------------------------
  753. '+-------------------------------------------------------------------------
  754. ' X509_UNICODE_NAME_VALUE
  755. ' X509_UNICODE_ANY_STRING
  756. '
  757. ' pvStructInfo points to CERT_NAME_VALUE.
  758. '
  759. ' The name values are unicode strings.
  760. '
  761. ' For CryptEncodeObject:
  762. ' Value.pbData points to the unicode string.
  763. ' If Value.cbData = 0, then, the unicode string is NULL terminated.
  764. ' Otherwise, Value.cbData is the unicode string byte count. The byte count
  765. ' is twice the character count.
  766. '
  767. ' If the unicode string contains an invalid character for the specified
  768. ' dwValueType, then, *pcbEncoded is updated with the unicode character
  769. ' index of the first invalid character. LastError is set to:
  770. ' CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  771. ' CRYPT_E_INVALID_IA5_STRING.
  772. '
  773. ' The unicode string is converted before being encoded according to
  774. ' the specified dwValueType. If dwValueType is set to 0, LastError
  775. ' is set to E_INVALIDARG.
  776. '
  777. ' CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING), then, CryptEncodeObject
  778. ' will return FALSE with LastError set to CRYPT_E_NOT_CHAR_STRING.
  779. '
  780. ' For CryptDecodeObject:
  781. ' Value.pbData points to a NULL terminated unicode string. Value.cbData
  782. ' contains the byte count of the unicode string excluding the NULL
  783. ' terminator. dwValueType contains the type used in the encoded object.
  784. ' Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  785. ' converted to the unicode string according to the dwValueType.
  786. '
  787. ' If the encoded object isn't one of the character string types, then,
  788. ' CryptDecodeObject will return FALSE with LastError set to
  789. ' CRYPT_E_NOT_CHAR_STRING. For a non character string, decode using
  790. ' X509_NAME_VALUE or X509_ANY_STRING.
  791. '--------------------------------------------------------------------------
  792. '+-------------------------------------------------------------------------
  793. ' X509_NAME
  794. '
  795. ' pvStructInfo points to CERT_NAME_INFO.
  796. '--------------------------------------------------------------------------
  797. '+-------------------------------------------------------------------------
  798. ' X509_UNICODE_NAME
  799. '
  800. ' pvStructInfo points to CERT_NAME_INFO.
  801. '
  802. ' The RDN attribute values are unicode strings except for the dwValueTypes of
  803. ' CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING. These dwValueTypes are
  804. ' the same as for a X509_NAME. Their values aren't converted to/from unicode.
  805. '
  806. ' For CryptEncodeObject:
  807. ' Value.pbData points to the unicode string.
  808. ' If Value.cbData = 0, then, the unicode string is NULL terminated.
  809. ' Otherwise, Value.cbData is the unicode string byte count. The byte count
  810. ' is twice the character count.
  811. '
  812. ' an acceptable dwValueType. If the unicode string contains an
  813. ' invalid character for the found or specified dwValueType, then,
  814. ' *pcbEncoded is updated with the error location of the invalid character.
  815. ' See below for details. LastError is set to:
  816. ' CRYPT_E_INVALID_NUMERIC_STRING, CRYPT_E_INVALID_PRINTABLE_STRING or
  817. ' CRYPT_E_INVALID_IA5_STRING.
  818. '
  819. ' The unicode string is converted before being encoded according to
  820. ' the specified or ObjId matching dwValueType.
  821. '
  822. ' For CryptDecodeObject:
  823. ' Value.pbData points to a NULL terminated unicode string. Value.cbData
  824. ' contains the byte count of the unicode string excluding the NULL
  825. ' terminator. dwValueType contains the type used in the encoded object.
  826. ' Its not forced to CERT_RDN_UNICODE_STRING. The encoded value is
  827. ' converted to the unicode string according to the dwValueType.
  828. '
  829. ' If the dwValueType of the encoded value isn't a character string
  830. ' type, then, it isn't converted to UNICODE. Use the
  831. ' that Value.pbData points to a converted unicode string.
  832. '--------------------------------------------------------------------------
  833. '+-------------------------------------------------------------------------
  834. ' Unicode Name Value Error Location Definitions
  835. '
  836. ' Error location is returned in *pcbEncoded by
  837. '
  838. ' Error location consists of:
  839. ' RDN_INDEX - 10 bits << 22
  840. ' ATTR_INDEX - 6 bits << 16
  841. '--------------------------------------------------------------------------
  842. Public Const CERT_UNICODE_RDN_ERR_INDEX_MASK As Long = &H3FF
  843. Public Const CERT_UNICODE_RDN_ERR_INDEX_SHIFT As Long = 22
  844. Public Const CERT_UNICODE_ATTR_ERR_INDEX_MASK As Long = &H003F
  845. Public Const CERT_UNICODE_ATTR_ERR_INDEX_SHIFT As Long = 16
  846. Public Const CERT_UNICODE_VALUE_ERR_INDEX_MASK As Long = &H0000FFFF
  847. Public Const CERT_UNICODE_VALUE_ERR_INDEX_SHIFT As Long = 0
  848. '+-------------------------------------------------------------------------
  849. ' X509_PUBLIC_KEY_INFO
  850. '
  851. ' pvStructInfo points to CERT_PUBLIC_KEY_INFO.
  852. '--------------------------------------------------------------------------
  853. '+-------------------------------------------------------------------------
  854. ' X509_AUTHORITY_KEY_ID
  855. ' szOID_AUTHORITY_KEY_IDENTIFIER
  856. '
  857. ' pvStructInfo points to following CERT_AUTHORITY_KEY_ID_INFO.
  858. '--------------------------------------------------------------------------
  859. '+-------------------------------------------------------------------------
  860. ' X509_KEY_ATTRIBUTES
  861. ' szOID_KEY_ATTRIBUTES
  862. '
  863. ' pvStructInfo points to following CERT_KEY_ATTRIBUTES_INFO.
  864. '--------------------------------------------------------------------------
  865. Public Const CERT_DIGITAL_SIGNATURE_KEY_USAGE As Long = &H80
  866. Public Const CERT_NON_REPUDIATION_KEY_USAGE As Long = &H40
  867. Public Const CERT_KEY_ENCIPHERMENT_KEY_USAGE As Long = &H20
  868. Public Const CERT_DATA_ENCIPHERMENT_KEY_USAGE As Long = &H10
  869. Public Const CERT_KEY_AGREEMENT_KEY_USAGE As Long = &H08
  870. Public Const CERT_KEY_CERT_SIGN_KEY_USAGE As Long = &H04
  871. Public Const CERT_OFFLINE_CRL_SIGN_KEY_USAGE As Long = &H02
  872. Public Const CERT_CRL_SIGN_KEY_USAGE As Long = &H02
  873. '+-------------------------------------------------------------------------
  874. ' X509_KEY_USAGE_RESTRICTION
  875. ' szOID_KEY_USAGE_RESTRICTION
  876. '
  877. ' pvStructInfo points to following CERT_KEY_USAGE_RESTRICTION_INFO.
  878. '--------------------------------------------------------------------------
  879. ' See CERT_KEY_ATTRIBUTES_INFO for definition of the RestrictedKeyUsage bits
  880. '+-------------------------------------------------------------------------
  881. ' X509_ALTERNATE_NAME
  882. ' szOID_SUBJECT_ALT_NAME
  883. ' szOID_ISSUER_ALT_NAME
  884. ' szOID_SUBJECT_ALT_NAME2
  885. ' szOID_ISSUER_ALT_NAME2
  886. '
  887. ' pvStructInfo points to following CERT_ALT_NAME_INFO.
  888. '--------------------------------------------------------------------------
  889. Public Const CERT_ALT_NAME_OTHER_NAME As Long = 1
  890. Public Const CERT_ALT_NAME_RFC822_NAME As Long = 2
  891. Public Const CERT_ALT_NAME_DNS_NAME As Long = 3
  892. Public Const CERT_ALT_NAME_X400_ADDRESS As Long = 4
  893. Public Const CERT_ALT_NAME_DIRECTORY_NAME As Long = 5
  894. Public Const CERT_ALT_NAME_EDI_PARTY_NAME As Long = 6
  895. Public Const CERT_ALT_NAME_URL As Long = 7
  896. Public Const CERT_ALT_NAME_IP_ADDRESS As Long = 8
  897. Public Const CERT_ALT_NAME_REGISTERED_ID As Long = 9
  898. '+-------------------------------------------------------------------------
  899. ' Alternate name IA5 Error Location Definitions for
  900. ' CRYPT_E_INVALID_IA5_STRING.
  901. '
  902. ' Error location is returned in *pcbEncoded by
  903. '
  904. ' Error location consists of:
  905. ' ENTRY_INDEX - 8 bits << 16
  906. '--------------------------------------------------------------------------
  907. Public Const CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK As Long = &HFF
  908. Public Const CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT As Long = 16
  909. Public Const CERT_ALT_NAME_VALUE_ERR_INDEX_MASK As Long = &H0000FFFF
  910. Public Const CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT As Long = 0
  911. '+-------------------------------------------------------------------------
  912. ' X509_BASIC_CONSTRAINTS
  913. ' szOID_BASIC_CONSTRAINTS
  914. '
  915. ' pvStructInfo points to following CERT_BASIC_CONSTRAINTS_INFO.
  916. '--------------------------------------------------------------------------
  917. Public Const CERT_CA_SUBJECT_FLAG As Long = &H80
  918. Public Const CERT_END_ENTITY_SUBJECT_FLAG As Long = &H40
  919. '+-------------------------------------------------------------------------
  920. ' X509_BASIC_CONSTRAINTS2
  921. ' szOID_BASIC_CONSTRAINTS2
  922. '
  923. ' pvStructInfo points to following CERT_BASIC_CONSTRAINTS2_INFO.
  924. '--------------------------------------------------------------------------
  925. '+-------------------------------------------------------------------------
  926. ' X509_KEY_USAGE
  927. ' szOID_KEY_USAGE
  928. '
  929. ' pvStructInfo points to a CRYPT_BIT_BLOB. Has same bit definitions as
  930. ' CERT_KEY_ATTRIBUTES_INFO's IntendedKeyUsage.
  931. '--------------------------------------------------------------------------
  932. '+-------------------------------------------------------------------------
  933. ' X509_CERT_POLICIES
  934. ' szOID_CERT_POLICIES
  935. '
  936. ' pvStructInfo points to following CERT_POLICIES_INFO.
  937. '--------------------------------------------------------------------------
  938. '+-------------------------------------------------------------------------
  939. ' RSA_CSP_PUBLICKEYBLOB
  940. '
  941. ' pvStructInfo points to a PUBLICKEYSTRUC immediately followed by a
  942. ' RSAPUBKEY and the modulus bytes.
  943. '
  944. ' CryptExportKey outputs the above StructInfo for a dwBlobType of
  945. ' PUBLICKEYBLOB. CryptImportKey expects the above StructInfo when
  946. ' importing a public key.
  947. '
  948. ' For dwCertEncodingType = X509_ASN_ENCODING, the RSA_CSP_PUBLICKEYBLOB is
  949. ' encoded as a PKCS #1 RSAPublicKey consisting of a SEQUENCE of a
  950. ' modulus INTEGER and a publicExponent INTEGER. The modulus is encoded
  951. ' as being a unsigned integer. When decoded, if the modulus was encoded
  952. ' as unsigned integer with a leading 0 byte, the 0 byte is removed before
  953. ' converting to the CSP modulus bytes.
  954. '
  955. ' For decode, the aiKeyAlg field of PUBLICKEYSTRUC is always set to
  956. ' CALG_RSA_KEYX.
  957. '--------------------------------------------------------------------------
  958. '+-------------------------------------------------------------------------
  959. ' X509_KEYGEN_REQUEST_TO_BE_SIGNED
  960. '
  961. ' pvStructInfo points to CERT_KEYGEN_REQUEST_INFO.
  962. '
  963. '
  964. '--------------------------------------------------------------------------
  965. '+-------------------------------------------------------------------------
  966. ' PKCS_ATTRIBUTE data structure
  967. '
  968. ' pvStructInfo points to a CRYPT_ATTRIBUTE.
  969. '--------------------------------------------------------------------------
  970. '+-------------------------------------------------------------------------
  971. ' PKCS_CONTENT_INFO_SEQUENCE_OF_ANY data structure
  972. '
  973. ' pvStructInfo points to following CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY.
  974. '
  975. ' For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure wrapping
  976. ' a sequence of ANY. The value of the contentType field is pszObjId,
  977. ' while the content field is the following structure:
  978. ' SequenceOfAny ::= SEQUENCE OF ANY
  979. '
  980. ' The CRYPT_DER_BLOBs point to the already encoded ANY content.
  981. '--------------------------------------------------------------------------
  982. '+-------------------------------------------------------------------------
  983. ' PKCS_CONTENT_INFO data structure
  984. '
  985. ' pvStructInfo points to following CRYPT_CONTENT_INFO.
  986. '
  987. ' For X509_ASN_ENCODING: encoded as a PKCS#7 ContentInfo structure.
  988. ' The CRYPT_DER_BLOB points to the already encoded ANY content.
  989. '--------------------------------------------------------------------------
  990. '+-------------------------------------------------------------------------
  991. ' X509_OCTET_STRING data structure
  992. '
  993. ' pvStructInfo points to a CRYPT_DATA_BLOB.
  994. '--------------------------------------------------------------------------
  995. '+-------------------------------------------------------------------------
  996. ' X509_BITS data structure
  997. '
  998. ' pvStructInfo points to a CRYPT_BIT_BLOB.
  999. '--------------------------------------------------------------------------
  1000. '+-------------------------------------------------------------------------
  1001. ' X509_INTEGER data structure
  1002. '
  1003. ' pvStructInfo points to an int.
  1004. '--------------------------------------------------------------------------
  1005. '+-------------------------------------------------------------------------
  1006. ' X509_MULTI_BYTE_INTEGER data structure
  1007. '
  1008. ' pvStructInfo points to a CRYPT_INTEGER_BLOB.
  1009. '--------------------------------------------------------------------------
  1010. '+-------------------------------------------------------------------------
  1011. ' X509_ENUMERATED data structure
  1012. '
  1013. ' pvStructInfo points to an int containing the enumerated value
  1014. '--------------------------------------------------------------------------
  1015. '+-------------------------------------------------------------------------
  1016. ' X509_CHOICE_OF_TIME data structure
  1017. '
  1018. ' pvStructInfo points to a FILETIME.
  1019. '--------------------------------------------------------------------------
  1020. '+-------------------------------------------------------------------------
  1021. ' X509_SEQUENCE_OF_ANY data structure
  1022. '
  1023. ' pvStructInfo points to following CRYPT_SEQUENCE_OF_ANY.
  1024. '
  1025. ' The CRYPT_DER_BLOBs point to the already encoded ANY content.
  1026. '--------------------------------------------------------------------------
  1027. '+-------------------------------------------------------------------------
  1028. ' X509_AUTHORITY_KEY_ID2
  1029. ' szOID_AUTHORITY_KEY_IDENTIFIER2
  1030. '
  1031. ' pvStructInfo points to following CERT_AUTHORITY_KEY_ID2_INFO.
  1032. '
  1033. ' For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  1034. '
  1035. ' See X509_ALTERNATE_NAME for error location defines.
  1036. '--------------------------------------------------------------------------
  1037. '+-------------------------------------------------------------------------
  1038. ' szOID_SUBJECT_KEY_IDENTIFIER
  1039. '
  1040. ' pvStructInfo points to a CRYPT_DATA_BLOB.
  1041. '--------------------------------------------------------------------------
  1042. '+-------------------------------------------------------------------------
  1043. ' X509_CRL_REASON_CODE
  1044. ' szOID_CRL_REASON_CODE
  1045. '
  1046. ' pvStructInfo points to an int which can be set to one of the following
  1047. ' enumerated values:
  1048. '--------------------------------------------------------------------------
  1049. Public Const CRL_REASON_UNSPECIFIED As Long = 0
  1050. Public Const CRL_REASON_KEY_COMPROMISE As Long = 1
  1051. Public Const CRL_REASON_CA_COMPROMISE As Long = 2
  1052. Public Const CRL_REASON_AFFILIATION_CHANGED As Long = 3
  1053. Public Const CRL_REASON_SUPERSEDED As Long = 4
  1054. Public Const CRL_REASON_CESSATION_OF_OPERATION As Long = 5
  1055. Public Const CRL_REASON_CERTIFICATE_HOLD As Long = 6
  1056. Public Const CRL_REASON_REMOVE_FROM_CRL As Long = 8
  1057. '+-------------------------------------------------------------------------
  1058. ' X509_CRL_DIST_POINTS
  1059. ' szOID_CRL_DIST_POINTS
  1060. '
  1061. ' pvStructInfo points to following CRL_DIST_POINTS_INFO.
  1062. '
  1063. ' For CRYPT_E_INVALID_IA5_STRING, the error location is returned in
  1064. '
  1065. ' Error location consists of:
  1066. ' POINT_INDEX - 7 bits << 24
  1067. ' ENTRY_INDEX - 8 bits << 16
  1068. '
  1069. ' See X509_ALTERNATE_NAME for ENTRY_INDEX and VALUE_INDEX error location
  1070. ' defines.
  1071. '--------------------------------------------------------------------------
  1072. Public Const CRL_DIST_POINT_NO_NAME As Long = 0
  1073. Public Const CRL_DIST_POINT_FULL_NAME As Long = 1
  1074. Public Const CRL_DIST_POINT_ISSUER_RDN_NAME As Long = 2
  1075. Public Const CRL_REASON_UNUSED_FLAG As Long = &H80
  1076. Public Const CRL_REASON_KEY_COMPROMISE_FLAG As Long = &H40
  1077. Public Const CRL_REASON_CA_COMPROMISE_FLAG As Long = &H20
  1078. Public Const CRL_REASON_AFFILIATION_CHANGED_FLAG As Long = &H10
  1079. Public Const CRL_REASON_SUPERSEDED_FLAG As Long = &H08
  1080. Public Const CRL_REASON_CESSATION_OF_OPERATION_FLAG As Long = &H04
  1081. Public Const CRL_REASON_CERTIFICATE_HOLD_FLAG As Long = &H02
  1082. Public Const CRL_DIST_POINT_ERR_INDEX_MASK As Long = &H7F
  1083. Public Const CRL_DIST_POINT_ERR_INDEX_SHIFT As Long = 24
  1084. '+-------------------------------------------------------------------------
  1085. ' X509_ENHANCED_KEY_USAGE
  1086. ' szOID_ENHANCED_KEY_USAGE
  1087. '
  1088. ' pvStructInfo points to a CERT_ENHKEY_USAGE, CTL_USAGE.
  1089. '--------------------------------------------------------------------------
  1090. '+-------------------------------------------------------------------------
  1091. ' szOID_NEXT_UPDATE_LOCATION
  1092. '
  1093. ' pvStructInfo points to a CERT_ALT_NAME_INFO.
  1094. '--------------------------------------------------------------------------
  1095. '+-------------------------------------------------------------------------
  1096. ' PKCS_CTL
  1097. ' szOID_CTL
  1098. '
  1099. ' pvStructInfo points to a CTL_INFO.
  1100. '--------------------------------------------------------------------------
  1101. '+-------------------------------------------------------------------------
  1102. ' PKCS7_SIGNER_INFO
  1103. '
  1104. ' pvStructInfo points to CMSG_SIGNER_INFO.
  1105. '--------------------------------------------------------------------------
  1106. '+-------------------------------------------------------------------------
  1107. ' Netscape Certificate Extension Object Identifiers
  1108. '--------------------------------------------------------------------------
  1109. Public Const szOID_NETSCAPE As String = "2.16.840.1.113730"
  1110. Public Const szOID_NETSCAPE_CERT_EXTENSION As String = "2.16.840.1.113730.1"
  1111. Public Const szOID_NETSCAPE_CERT_TYPE As String = "2.16.840.1.113730.1.1"
  1112. Public Const szOID_NETSCAPE_BASE_URL As String = "2.16.840.1.113730.1.2"
  1113. Public Const szOID_NETSCAPE_REVOCATION_URL As String = "2.16.840.1.113730.1.3"
  1114. Public Const szOID_NETSCAPE_CA_REVOCATION_URL As String = "2.16.840.1.113730.1.4"
  1115. Public Const szOID_NETSCAPE_CERT_RENEWAL_URL As String = "2.16.840.1.113730.1.7"
  1116. Public Const szOID_NETSCAPE_CA_POLICY_URL As String = "2.16.840.1.113730.1.8"
  1117. Public Const szOID_NETSCAPE_SSL_SERVER_NAME As String = "2.16.840.1.113730.1.12"
  1118. Public Const szOID_NETSCAPE_COMMENT As String = "2.16.840.1.113730.1.13"
  1119. '+-------------------------------------------------------------------------
  1120. ' Netscape Certificate Data Type Object Identifiers
  1121. '--------------------------------------------------------------------------
  1122. Public Const szOID_NETSCAPE_DATA_TYPE As String = "2.16.840.1.113730.2"
  1123. Public Const szOID_NETSCAPE_CERT_SEQUENCE As String = "2.16.840.1.113730.2.5"
  1124. '+-------------------------------------------------------------------------
  1125. ' szOID_NETSCAPE_CERT_TYPE extension
  1126. '
  1127. ' Its value is a bit string. CryptDecodeObject/CryptEncodeObject using
  1128. ' X509_BITS.
  1129. '
  1130. ' The following bits are defined:
  1131. '--------------------------------------------------------------------------
  1132. Public Const NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE As Long = &H80
  1133. Public Const NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE As Long = &H40
  1134. Public Const NETSCAPE_SSL_CA_CERT_TYPE As Long = &H04
  1135. '+-------------------------------------------------------------------------
  1136. ' szOID_NETSCAPE_BASE_URL extension
  1137. '
  1138. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1139. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1140. ' dwValueType = CERT_RDN_IA5_STRING.
  1141. '
  1142. ' When present this string is added to the beginning of all relative URLs
  1143. ' in the certificate. This extension can be considered an optimization
  1144. ' to reduce the size of the URL extensions.
  1145. '--------------------------------------------------------------------------
  1146. '+-------------------------------------------------------------------------
  1147. ' szOID_NETSCAPE_REVOCATION_URL extension
  1148. '
  1149. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1150. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1151. ' dwValueType = CERT_RDN_IA5_STRING.
  1152. '
  1153. ' It is a relative or absolute URL that can be used to check the
  1154. ' revocation status of a certificate. The revocation check will be
  1155. ' performed as an HTTP GET method using a url that is the concatenation of
  1156. ' revocation-url and certificate-serial-number.
  1157. ' Where the certificate-serial-number is encoded as a string of
  1158. ' ascii hexadecimal digits. For example, if the netscape-base-url is
  1159. ' https:
  1160. ' cgi-bin/check-rev.cgi?, and the certificate serial number is 173420,
  1161. ' the resulting URL would be:
  1162. ' https:
  1163. '
  1164. ' The server should return a document with a Content-Type of
  1165. ' application/x-netscape-revocation. The document should contain
  1166. ' a single ascii digit, '1' if the certificate is not curently valid,
  1167. ' and '0' if it is curently valid.
  1168. '
  1169. ' Note: for all of the URLs that include the certificate serial number,
  1170. ' the serial number will be encoded as a string which consists of an even
  1171. ' number of hexadecimal digits. If the number of significant digits is odd,
  1172. ' the string will have a single leading zero to ensure an even number of
  1173. ' digits is generated.
  1174. '--------------------------------------------------------------------------
  1175. '+-------------------------------------------------------------------------
  1176. ' szOID_NETSCAPE_CA_REVOCATION_URL extension
  1177. '
  1178. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1179. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1180. ' dwValueType = CERT_RDN_IA5_STRING.
  1181. '
  1182. ' It is a relative or absolute URL that can be used to check the
  1183. ' revocation status of any certificates that are signed by the CA that
  1184. ' this certificate belongs to. This extension is only valid in CA
  1185. ' certificates. The use of this extension is the same as the above
  1186. ' szOID_NETSCAPE_REVOCATION_URL extension.
  1187. '--------------------------------------------------------------------------
  1188. '+-------------------------------------------------------------------------
  1189. ' szOID_NETSCAPE_CERT_RENEWAL_URL extension
  1190. '
  1191. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1192. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1193. ' dwValueType = CERT_RDN_IA5_STRING.
  1194. '
  1195. ' It is a relative or absolute URL that points to a certificate renewal
  1196. ' form. The renewal form will be accessed with an HTTP GET method using a
  1197. ' url that is the concatenation of renewal-url and
  1198. ' certificate-serial-number. Where the certificate-serial-number is
  1199. ' encoded as a string of ascii hexadecimal digits. For example, if the
  1200. ' netscape-base-url is https:
  1201. ' netscape-cert-renewal-url is cgi-bin/check-renew.cgi?, and the
  1202. ' certificate serial number is 173420, the resulting URL would be:
  1203. ' https:
  1204. ' The document returned should be an HTML form that will allow the user
  1205. ' to request a renewal of their certificate.
  1206. '--------------------------------------------------------------------------
  1207. '+-------------------------------------------------------------------------
  1208. ' szOID_NETSCAPE_CA_POLICY_URL extension
  1209. '
  1210. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1211. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1212. ' dwValueType = CERT_RDN_IA5_STRING.
  1213. '
  1214. ' It is a relative or absolute URL that points to a web page that
  1215. ' describes the policies under which the certificate was issued.
  1216. '--------------------------------------------------------------------------
  1217. '+-------------------------------------------------------------------------
  1218. ' szOID_NETSCAPE_SSL_SERVER_NAME extension
  1219. '
  1220. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1221. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1222. ' dwValueType = CERT_RDN_IA5_STRING.
  1223. '
  1224. ' It is a "shell expression" that can be used to match the hostname of the
  1225. ' SSL server that is using this certificate. It is recommended that if
  1226. ' the server's hostname does not match this pattern the user be notified
  1227. ' and given the option to terminate the SSL connection. If this extension
  1228. ' is not present then the CommonName in the certificate subject's
  1229. ' distinguished name is used for the same purpose.
  1230. '--------------------------------------------------------------------------
  1231. '+-------------------------------------------------------------------------
  1232. ' szOID_NETSCAPE_COMMENT extension
  1233. '
  1234. ' Its value is an IA5_STRING. CryptDecodeObject/CryptEncodeObject using
  1235. ' X509_ANY_STRING or X509_UNICODE_ANY_STRING, where,
  1236. ' dwValueType = CERT_RDN_IA5_STRING.
  1237. '
  1238. ' It is a comment that may be displayed to the user when the certificate
  1239. ' is viewed.
  1240. '--------------------------------------------------------------------------
  1241. '+-------------------------------------------------------------------------
  1242. ' szOID_NETSCAPE_CERT_SEQUENCE
  1243. '
  1244. ' Its value is a PKCS#7 ContentInfo structure wrapping a sequence of
  1245. ' certificates. The value of the contentType field is
  1246. ' szOID_NETSCAPE_CERT_SEQUENCE, while the content field is the following
  1247. ' structure:
  1248. ' CertificateSequence ::= SEQUENCE OF Certificate.
  1249. '
  1250. ' CryptDecodeObject/CryptEncodeObject using
  1251. ' PKCS_CONTENT_INFO_SEQUENCE_OF_ANY, where,
  1252. ' pszObjId = szOID_NETSCAPE_CERT_SEQUENCE and the CRYPT_DER_BLOBs point
  1253. ' to encoded X509 certificates.
  1254. '--------------------------------------------------------------------------
  1255. '+=========================================================================
  1256. '==========================================================================
  1257. ' Predefined OID Function Names
  1258. Public Const CRYPT_OID_ENCODE_OBJECT_FUNC As String = "CryptDllEncodeObject"
  1259. Public Const CRYPT_OID_DECODE_OBJECT_FUNC As String = "CryptDllDecodeObject"
  1260. Public Const CRYPT_OID_CREATE_COM_OBJECT_FUNC As String = "CryptDllCreateCOMObject"
  1261. Public Const CRYPT_OID_VERIFY_REVOCATION_FUNC As String = "CertDllVerifyRevocation"
  1262. Public Const CRYPT_OID_VERIFY_CTL_USAGE_FUNC As String = "CertDllVerifyCTLUsage"
  1263. Public Const CRYPT_OID_FORMAT_OBJECT_FUNC As String = "CryptDllFormatObject"
  1264. ' CryptDllEncodeObject has same function signature as CryptEncodeObject.
  1265. ' CryptDllDecodeObject has same function signature as CryptDecodeObject.
  1266. ' CryptDllCreateCOMObject has the following signature:
  1267. ' IN DWORD dwEncodingType,
  1268. ' IN LPCSTR pszOID,
  1269. ' IN PCRYPT_DATA_BLOB pEncodedContent,
  1270. ' IN DWORD dwFlags,
  1271. ' IN REFIID riid,
  1272. ' OUT void **ppvObj);
  1273. ' CertDllVerifyRevocation has the same signature as CertVerifyRevocation
  1274. ' CertDllVerifyCTLUsage has the same signature as CertVerifyCTLUsage
  1275. ' Example of a complete OID Function Registry Name:
  1276. ' HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\OID
  1277. ' Encoding Type 1\CryptDllEncodeObject\1.2.3
  1278. '
  1279. ' The key's "Dll" value contains the name of the Dll.
  1280. ' The key's "FuncName" value overrides the default function name
  1281. Public Const CRYPT_OID_REGPATH As String = "Software\\Microsoft\\Cryptography\\OID"
  1282. Public Const CRYPT_OID_REG_ENCODING_TYPE_PREFIX As String = "EncodingType "
  1283. Public Const CRYPT_OID_REG_DLL_VALUE_NAME As String = "Dll"
  1284. Public Const CRYPT_OID_REG_FUNC_NAME_VALUE_NAME As String = "FuncName"
  1285. Public Const CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A As String = "FuncName"
  1286. ' OID used for Default OID functions
  1287. Public Const CRYPT_DEFAULT_OID As String = "DEFAULT"
  1288. Public Const CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG As Long = 1
  1289. '+-------------------------------------------------------------------------
  1290. ' Install a set of callable OID function addresses.
  1291. '
  1292. ' By default the functions are installed at end of the list.
  1293. ' Set CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG to install at beginning of list.
  1294. '
  1295. ' hModule should be updated with the hModule passed to DllMain to prevent
  1296. ' the Dll containing the function addresses from being unloaded by
  1297. ' CryptGetOIDFuncAddress/CryptFreeOIDFunctionAddress. This would be the
  1298. ' case when the Dll has also regsvr32'ed OID functions via
  1299. ' CryptRegisterOIDFunction.
  1300. '
  1301. ' DEFAULT functions are installed by setting rgFuncEntry[].pszOID =
  1302. ' CRYPT_DEFAULT_OID.
  1303. '--------------------------------------------------------------------------
  1304. '+-------------------------------------------------------------------------
  1305. ' Initialize and return handle to the OID function set identified by its
  1306. ' function name.
  1307. '
  1308. ' If the set already exists, a handle to the existing set is returned.
  1309. '--------------------------------------------------------------------------
  1310. '+-------------------------------------------------------------------------
  1311. ' Search the list of installed functions for an encoding type and OID match.
  1312. ' If not found, search the registry.
  1313. '
  1314. ' For success, returns TRUE with *ppvFuncAddr updated with the function's
  1315. ' address and *phFuncAddr updated with the function address's handle.
  1316. ' The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  1317. ' be called to release it.
  1318. '
  1319. ' For a registry match, the Dll containing the function is loaded.
  1320. '--------------------------------------------------------------------------
  1321. '+-------------------------------------------------------------------------
  1322. ' Get the list of registered default Dll entries for the specified
  1323. ' function set and encoding type.
  1324. '
  1325. ' The returned list consists of none, one or more null terminated Dll file
  1326. ' For example: "first.dll" L"\0" L"second.dll" L"\0" L"\0"
  1327. '--------------------------------------------------------------------------
  1328. '+-------------------------------------------------------------------------
  1329. ' Either: get the first or next installed DEFAULT function OR
  1330. ' load the Dll containing the DEFAULT function.
  1331. '
  1332. ' If pwszDll is NULL, search the list of installed DEFAULT functions.
  1333. ' *phFuncAddr must be set to NULL to get the first installed function.
  1334. ' Successive installed functions are returned by setting *phFuncAddr
  1335. ' to the hFuncAddr returned by the previous call.
  1336. '
  1337. ' If pwszDll is NULL, the input *phFuncAddr
  1338. ' is always CryptFreeOIDFunctionAddress'ed by this function, even for
  1339. ' an error.
  1340. '
  1341. ' If pwszDll isn't NULL, then, attempts to load the Dll and the DEFAULT
  1342. ' function. *phFuncAddr is ignored upon entry and isn't
  1343. ' CryptFreeOIDFunctionAddress'ed.
  1344. '
  1345. ' For success, returns TRUE with *ppvFuncAddr updated with the function's
  1346. ' address and *phFuncAddr updated with the function address's handle.
  1347. ' The function's handle is AddRef'ed. CryptFreeOIDFunctionAddress needs to
  1348. ' be called to release it or CryptGetDefaultOIDFunctionAddress can also
  1349. ' be called for a NULL pwszDll.
  1350. '--------------------------------------------------------------------------
  1351. '+-------------------------------------------------------------------------
  1352. ' Releases the handle AddRef'ed and returned by CryptGetOIDFunctionAddress
  1353. ' or CryptGetDefaultOIDFunctionAddress.
  1354. '
  1355. ' If a Dll was loaded for the function its unloaded. However, before doing
  1356. ' the unload, the DllCanUnloadNow function exported by the loaded Dll is
  1357. ' called. It should return S_FALSE to inhibit the unload or S_TRUE to enable
  1358. ' the unload. If the Dll doesn't export DllCanUnloadNow, the Dll is unloaded.
  1359. '
  1360. ' DllCanUnloadNow has the following signature:
  1361. '--------------------------------------------------------------------------
  1362. '+-------------------------------------------------------------------------
  1363. ' Register the Dll containing the function to be called for the specified
  1364. ' encoding type, function name and OID.
  1365. '
  1366. ' pwszDll may contain environment-variable strings
  1367. '
  1368. ' In addition to registering the DLL, you may override the
  1369. ' name of the function to be called. For example,
  1370. ' pszFuncName = "CryptDllEncodeObject",
  1371. ' pszOverrideFuncName = "MyEncodeXyz".
  1372. ' This allows a Dll to export multiple OID functions for the same
  1373. ' function name without needing to interpose its own OID dispatcher function.
  1374. '--------------------------------------------------------------------------
  1375. '+-------------------------------------------------------------------------
  1376. ' Unregister the Dll containing the function to be called for the specified
  1377. ' encoding type, function name and OID.
  1378. '--------------------------------------------------------------------------
  1379. '+-------------------------------------------------------------------------
  1380. ' Register the Dll containing the default function to be called for the
  1381. ' specified encoding type and function name.
  1382. '
  1383. ' Unlike CryptRegisterOIDFunction, you can't override the function name
  1384. ' needing to be exported by the Dll.
  1385. '
  1386. ' The Dll is inserted before the entry specified by dwIndex.
  1387. ' dwIndex == 0, inserts at the beginning.
  1388. ' dwIndex == CRYPT_REGISTER_LAST_INDEX, appends at the end.
  1389. '
  1390. ' pwszDll may contain environment-variable strings
  1391. '--------------------------------------------------------------------------
  1392. Public Const CRYPT_REGISTER_FIRST_INDEX As Long = 0
  1393. Public Const CRYPT_REGISTER_LAST_INDEX As Long = &HFFFFFFFF
  1394. '+-------------------------------------------------------------------------
  1395. ' Unregister the Dll containing the default function to be called for
  1396. ' the specified encoding type and function name.
  1397. '--------------------------------------------------------------------------
  1398. '+-------------------------------------------------------------------------
  1399. ' Set the value for the specified encoding type, function name, OID and
  1400. ' value name.
  1401. '
  1402. ' See RegSetValueEx for the possible value types.
  1403. '
  1404. ' String types are UNICODE.
  1405. '--------------------------------------------------------------------------
  1406. '+-------------------------------------------------------------------------
  1407. ' Get the value for the specified encoding type, function name, OID and
  1408. ' value name.
  1409. '
  1410. ' See RegEnumValue for the possible value types.
  1411. '
  1412. ' String types are UNICODE.
  1413. '--------------------------------------------------------------------------
  1414. '+-------------------------------------------------------------------------
  1415. ' Enumerate the OID functions identified by their encoding type,
  1416. ' function name and OID.
  1417. '
  1418. ' pfnEnumOIDFunc is called for each registry key matching the input
  1419. ' parameters. Setting dwEncodingType to CRYPT_MATCH_ANY_ENCODING_TYPE matches
  1420. ' any. Setting pszFuncName or pszOID to NULL matches any.
  1421. '
  1422. ' Set pszOID == CRYPT_DEFAULT_OID to restrict the enumeration to only the
  1423. ' DEFAULT functions
  1424. '
  1425. ' String types are UNICODE.
  1426. '--------------------------------------------------------------------------
  1427. Public Const CRYPT_MATCH_ANY_ENCODING_TYPE As Long = &HFFFFFFFF
  1428. '+=========================================================================
  1429. ' Low Level Cryptographic Message Data Structures and APIs
  1430. '==========================================================================
  1431. Public Const szOID_PKCS_7_DATA As String = "1.2.840.113549.1.7.1"
  1432. Public Const szOID_PKCS_7_SIGNED As String = "1.2.840.113549.1.7.2"
  1433. Public Const szOID_PKCS_7_ENVELOPED As String = "1.2.840.113549.1.7.3"
  1434. Public Const szOID_PKCS_7_SIGNEDANDENVELOPED As String = "1.2.840.113549.1.7.4"
  1435. Public Const szOID_PKCS_7_DIGESTED As String = "1.2.840.113549.1.7.5"
  1436. Public Const szOID_PKCS_7_ENCRYPTED As String = "1.2.840.113549.1.7.6"
  1437. Public Const szOID_PKCS_9_CONTENT_TYPE As String = "1.2.840.113549.1.9.3"
  1438. Public Const szOID_PKCS_9_MESSAGE_DIGEST As String = "1.2.840.113549.1.9.4"
  1439. '+-------------------------------------------------------------------------
  1440. ' Message types
  1441. '--------------------------------------------------------------------------
  1442. Public Const CMSG_DATA As Long = 1
  1443. Public Const CMSG_SIGNED As Long = 2
  1444. Public Const CMSG_ENVELOPED As Long = 3
  1445. Public Const CMSG_SIGNED_AND_ENVELOPED As Long = 4
  1446. Public Const CMSG_HASHED As Long = 5
  1447. Public Const CMSG_ENCRYPTED As Long = 6
  1448. '+-------------------------------------------------------------------------
  1449. ' Message Type Bit Flags
  1450. '--------------------------------------------------------------------------
  1451. '+-------------------------------------------------------------------------
  1452. '--------------------------------------------------------------------------
  1453. '+-------------------------------------------------------------------------
  1454. ' CMSG_DATA: pvMsgEncodeInfo = NULL
  1455. '--------------------------------------------------------------------------
  1456. '+-------------------------------------------------------------------------
  1457. ' CMSG_SIGNED
  1458. '
  1459. ' The pCertInfo in the CMSG_SIGNER_ENCODE_INFO provides the Issuer, SerialNumber
  1460. ' and PublicKeyInfo.Algorithm. The PublicKeyInfo.Algorithm implicitly
  1461. ' specifies the HashEncryptionAlgorithm to be used.
  1462. '
  1463. ' The hCryptProv and dwKeySpec specify the private key to use. If dwKeySpec
  1464. ' == 0, then, defaults to AT_SIGNATURE.
  1465. '
  1466. ' pvHashAuxInfo currently isn't used and must be set to NULL.
  1467. '--------------------------------------------------------------------------
  1468. '+-------------------------------------------------------------------------
  1469. ' CMSG_ENVELOPED
  1470. '
  1471. ' The PCERT_INFO for the rgRecipients provides the Issuer, SerialNumber
  1472. ' and PublicKeyInfo. The PublicKeyInfo.Algorithm implicitly
  1473. ' specifies the KeyEncryptionAlgorithm to be used.
  1474. '
  1475. ' The PublicKeyInfo.PublicKey in PCERT_INFO is used to encrypt the content
  1476. ' encryption key for the recipient.
  1477. '
  1478. ' hCryptProv is used to do the content encryption, recipient key encryption
  1479. ' and export. The hCryptProv's private keys aren't used.
  1480. '
  1481. ' Note: CAPI currently doesn't support more than one KeyEncryptionAlgorithm
  1482. ' per provider. This will need to be fixed.
  1483. '
  1484. ' pvEncryptionAuxInfo currently isn't used and must be set to NULL.
  1485. '--------------------------------------------------------------------------
  1486. '+-------------------------------------------------------------------------
  1487. ' CMSG_SIGNED_AND_ENVELOPED
  1488. '
  1489. ' For PKCS #7, a signed and enveloped message doesn't have the
  1490. ' signer's authenticated or unauthenticated attributes. Otherwise, a
  1491. ' combination of the CMSG_SIGNED_ENCODE_INFO and CMSG_ENVELOPED_ENCODE_INFO.
  1492. '--------------------------------------------------------------------------
  1493. '+-------------------------------------------------------------------------
  1494. ' CMSG_HASHED
  1495. '
  1496. ' hCryptProv is used to do the hash. Doesn't need to use a private key.
  1497. '
  1498. ' If fDetachedHash is set, then, the encoded message doesn't contain
  1499. '
  1500. ' pvHashAuxInfo currently isn't used and must be set to NULL.
  1501. '--------------------------------------------------------------------------
  1502. '+-------------------------------------------------------------------------
  1503. ' CMSG_ENCRYPTED
  1504. '
  1505. ' The key used to encrypt the message is identified outside of the message
  1506. '
  1507. ' The content input to CryptMsgUpdate has already been encrypted.
  1508. '
  1509. ' pvEncryptionAuxInfo currently isn't used and must be set to NULL.
  1510. '--------------------------------------------------------------------------
  1511. '+-------------------------------------------------------------------------
  1512. ' This parameter allows messages to be of variable length with streamed
  1513. ' output.
  1514. '
  1515. ' By default, messages are of a definite length and
  1516. ' called to get the cryptographically processed content. Until closed,
  1517. ' the handle keeps a copy of the processed content.
  1518. '
  1519. ' With streamed output, the processed content can be freed as its streamed.
  1520. '
  1521. ' If the length of the content to be updated is known at the time of the
  1522. ' open, then, ContentLength should be set to that length. Otherwise, it
  1523. ' should be set to CMSG_INDEFINITE_LENGTH.
  1524. '--------------------------------------------------------------------------
  1525. Public Const CMSG_INDEFINITE_LENGTH As Long = &HFFFFFFFF
  1526. '+-------------------------------------------------------------------------
  1527. ' Open dwFlags
  1528. '--------------------------------------------------------------------------
  1529. Public Const CMSG_BARE_CONTENT_FLAG As Long = &H00000001
  1530. Public Const CMSG_LENGTH_ONLY_FLAG As Long = &H00000002
  1531. Public Const CMSG_DETACHED_FLAG As Long = &H00000004
  1532. Public Const CMSG_AUTHENTICATED_ATTRIBUTES_FLAG As Long = &H00000008
  1533. Public Const CMSG_CONTENTS_OCTETS_FLAG As Long = &H00000010
  1534. '+-------------------------------------------------------------------------
  1535. ' Open a cryptographic message for encoding
  1536. '
  1537. ' For PKCS #7:
  1538. ' If the content to be passed to CryptMsgUpdate has already
  1539. ' from another message encode), then, the CMSG_ENCODED_CONTENT_INFO_FLAG should
  1540. ' be set in dwFlags. If not set, then, the inner ContentType is Data and
  1541. ' the input to CryptMsgUpdate is treated as the inner Data type's Content,
  1542. ' a string of bytes.
  1543. ' If CMSG_BARE_CONTENT_FLAG is specified for a streamed message,
  1544. ' the streamed output will not have an outer ContentInfo wrapper. This
  1545. ' makes it suitable to be streamed into an enclosing message.
  1546. '
  1547. ' The pStreamInfo parameter needs to be set to stream the encoded message
  1548. ' output.
  1549. '--------------------------------------------------------------------------
  1550. '+-------------------------------------------------------------------------
  1551. ' Calculate the length of an encoded cryptographic message.
  1552. '
  1553. ' Calculates the length of the encoded message given the
  1554. ' message type, encoding parameters and total length of
  1555. ' the data to be updated. Note, this might not be the exact length. However,
  1556. ' it will always be greater than or equal to the actual length.
  1557. '--------------------------------------------------------------------------
  1558. '+-------------------------------------------------------------------------
  1559. ' Open a cryptographic message for decoding
  1560. '
  1561. ' BUGBUG! These comments need to be changed
  1562. ' For PKCS #7: if the inner ContentType isn't Data, then, the inner
  1563. ' ContentInfo consisting of both ContentType and Content is output.
  1564. ' To also enable ContentInfo output for the Data ContentType, then,
  1565. ' the CMSG_ENCODED_CONTENT_INFO_FLAG should be set
  1566. ' in dwFlags. If not set, then, only the content portion of the inner
  1567. ' ContentInfo is output for the Data ContentType.
  1568. '
  1569. ' To only calculate the length of the decoded message, set the
  1570. ' CMSG_LENGTH_ONLY_FLAG in dwFlags. After the final CryptMsgUpdate get the
  1571. ' MSG_CONTENT_PARAM. Note, this might not be the exact length. However,
  1572. ' it will always be greater than or equal to the actual length.
  1573. '
  1574. ' hCryptProv specifies the crypto provider to use for hashing and/or
  1575. ' decrypting the message. For enveloped messages, hCryptProv also specifies
  1576. ' the private exchange key to use. For signed messages, hCryptProv is used
  1577. ' when CryptMsgVerifySigner is called.
  1578. '
  1579. ' For enveloped messages, the pRecipientInfo contains the Issuer and
  1580. ' SerialNumber identifying the RecipientInfo in the message.
  1581. '
  1582. ' Note, the pRecipientInfo should correspond to the provider's private
  1583. ' exchange key.
  1584. '
  1585. ' If pRecipientInfo is NULL, then, the message isn't decrypted. To decrypt
  1586. ' CryptMsgUpdate.
  1587. '
  1588. ' The pStreamInfo parameter needs to be set to stream the decoded content
  1589. ' output. Note, if pRecipientInfo is NULL, then, the streamed output isn't
  1590. ' decrypted.
  1591. '--------------------------------------------------------------------------
  1592. '+-------------------------------------------------------------------------
  1593. ' Close a cryptographic message handle
  1594. '
  1595. ' LastError is preserved unless FALSE is returned.
  1596. '--------------------------------------------------------------------------
  1597. '+-------------------------------------------------------------------------
  1598. ' Update the content of a cryptographic message. Depending on how the
  1599. ' message was opened, the content is either encoded or decoded.
  1600. '
  1601. ' This function is repetitively called to append to the message content.
  1602. ' fFinal is set to identify the last update. On fFinal, the encode/decode
  1603. ' is completed. The encoded/decoded content and the decoded parameters
  1604. ' are valid until the open and all duplicated handles are closed.
  1605. '--------------------------------------------------------------------------
  1606. '+-------------------------------------------------------------------------
  1607. ' Perform a special "control" function after the final CryptMsgUpdate of a
  1608. ' encoded/decoded cryptographic message.
  1609. '
  1610. ' The dwCtrlType parameter specifies the type of operation to be performed.
  1611. '
  1612. ' The pvCtrlPara definition depends on the dwCtrlType value.
  1613. '
  1614. ' See below for a list of the control operations and their pvCtrlPara
  1615. ' type definition.
  1616. '--------------------------------------------------------------------------
  1617. '+-------------------------------------------------------------------------
  1618. ' Message control types
  1619. '--------------------------------------------------------------------------
  1620. Public Const CMSG_CTRL_VERIFY_SIGNATURE As Long = 1
  1621. Public Const CMSG_CTRL_DECRYPT As Long = 2
  1622. Public Const CMSG_CTRL_VERIFY_HASH As Long = 5
  1623. Public Const CMSG_CTRL_ADD_SIGNER As Long = 6
  1624. Public Const CMSG_CTRL_DEL_SIGNER As Long = 7
  1625. Public Const CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR As Long = 8
  1626. Public Const CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR As Long = 9
  1627. Public Const CMSG_CTRL_ADD_CERT As Long = 10
  1628. Public Const CMSG_CTRL_DEL_CERT As Long = 11
  1629. Public Const CMSG_CTRL_ADD_CRL As Long = 12
  1630. Public Const CMSG_CTRL_DEL_CRL As Long = 13
  1631. '+-------------------------------------------------------------------------
  1632. ' CMSG_CTRL_VERIFY_SIGNATURE
  1633. '
  1634. ' Verify the signature of a SIGNED or SIGNED_AND_ENVELOPED
  1635. ' message after it has been decoded.
  1636. '
  1637. ' For a SIGNED_AND_ENVELOPED message, called after
  1638. ' with a NULL pRecipientInfo.
  1639. '
  1640. ' pvCtrlPara points to a CERT_INFO struct.
  1641. '
  1642. ' The CERT_INFO contains the Issuer and SerialNumber identifying
  1643. ' the Signer of the message. The CERT_INFO also contains the
  1644. ' PublicKeyInfo
  1645. ' used to verify the signature. The cryptographic provider specified
  1646. ' in CryptMsgOpenToDecode is used.
  1647. '--------------------------------------------------------------------------
  1648. '+-------------------------------------------------------------------------
  1649. ' CMSG_CTRL_DECRYPT
  1650. '
  1651. ' Decrypt an ENVELOPED or SIGNED_AND_ENVELOPED message after it has been
  1652. ' decoded.
  1653. '
  1654. ' hCryptProv and dwKeySpec specify the private key to use. For dwKeySpec ==
  1655. ' 0, defaults to AT_KEYEXCHANGE.
  1656. '
  1657. ' dwRecipientIndex is the index of the recipient in the message associated
  1658. ' with the hCryptProv's private key.
  1659. '
  1660. ' This control function needs to be called, if you don't know the appropriate
  1661. ' recipient before calling CryptMsgOpenToDecode. After the final
  1662. ' CryptMsgUpdate, the list of recipients is obtained by iterating through
  1663. ' CMSG_RECIPIENT_INFO_PARAM. The recipient corresponding to a private
  1664. ' key owned by the caller is selected and passed to this function to decrypt
  1665. ' the message.
  1666. '
  1667. ' Note, the message can only be decrypted once.
  1668. '--------------------------------------------------------------------------
  1669. '+-------------------------------------------------------------------------
  1670. ' CMSG_CTRL_VERIFY_HASH
  1671. '
  1672. ' Verify the hash of a HASHED message after it has been decoded.
  1673. '
  1674. ' Only the hCryptMsg parameter is used, to specify the message whose
  1675. ' hash is being verified.
  1676. '--------------------------------------------------------------------------
  1677. '+-------------------------------------------------------------------------
  1678. ' CMSG_CTRL_ADD_SIGNER
  1679. '
  1680. ' Add a signer to a signed-data or signed-and-enveloped-data message.
  1681. '
  1682. ' pvCtrlPara points to a CMSG_SIGNER_ENCODE_INFO.
  1683. '--------------------------------------------------------------------------
  1684. '+-------------------------------------------------------------------------
  1685. ' CMSG_CTRL_DEL_SIGNER
  1686. '
  1687. ' Remove a signer from a signed-data or signed-and-enveloped-data message.
  1688. '
  1689. ' pvCtrlPara points to a DWORD containing the 0-based index of the
  1690. ' signer to be removed.
  1691. '--------------------------------------------------------------------------
  1692. '+-------------------------------------------------------------------------
  1693. ' CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR
  1694. '
  1695. ' Add an unauthenticated attribute to the SignerInfo of a signed-data or
  1696. ' signed-and-enveloped-data message.
  1697. '
  1698. ' The unauthenticated attribute is input in the form of an encoded blob.
  1699. '--------------------------------------------------------------------------
  1700. '+-------------------------------------------------------------------------
  1701. ' CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR
  1702. '
  1703. ' Delete an unauthenticated attribute from the SignerInfo of a signed-data
  1704. ' or signed-and-enveloped-data message.
  1705. '
  1706. ' The unauthenticated attribute to be removed is specified by
  1707. ' a 0-based index.
  1708. '--------------------------------------------------------------------------
  1709. '+-------------------------------------------------------------------------
  1710. ' CMSG_CTRL_ADD_CERT
  1711. '
  1712. ' Add a certificate to a signed-data or signed-and-enveloped-data message.
  1713. '
  1714. ' pvCtrlPara points to a CRYPT_DATA_BLOB containing the certificate's
  1715. ' encoded bytes.
  1716. '--------------------------------------------------------------------------
  1717. '+-------------------------------------------------------------------------
  1718. ' CMSG_CTRL_DEL_CERT
  1719. '
  1720. ' Delete a certificate from a signed-data or signed-and-enveloped-data
  1721. ' message.
  1722. '
  1723. ' pvCtrlPara points to a DWORD containing the 0-based index of the
  1724. ' certificate to be removed.
  1725. '--------------------------------------------------------------------------
  1726. '+-------------------------------------------------------------------------
  1727. ' CMSG_CTRL_ADD_CRL
  1728. '
  1729. ' Add a CRL to a signed-data or signed-and-enveloped-data message.
  1730. '
  1731. ' pvCtrlPara points to a CRYPT_DATA_BLOB containing the CRL's
  1732. ' encoded bytes.
  1733. '--------------------------------------------------------------------------
  1734. '+-------------------------------------------------------------------------
  1735. ' CMSG_CTRL_DEL_CRL
  1736. '
  1737. ' Delete a CRL from a signed-data or signed-and-enveloped-data message.
  1738. '
  1739. ' pvCtrlPara points to a DWORD containing the 0-based index of the CRL
  1740. ' to be removed.
  1741. '--------------------------------------------------------------------------
  1742. '+-------------------------------------------------------------------------
  1743. ' Verify a countersignature, at the SignerInfo level.
  1744. ' ie. verify that pbSignerInfoCountersignature contains the encrypted
  1745. ' hash of the encryptedDigest field of pbSignerInfo.
  1746. '
  1747. ' hCryptProv is used to hash the encryptedDigest field of pbSignerInfo.
  1748. ' The only fields referenced from pciCountersigner are SerialNumber, Issuer,
  1749. ' and SubjectPublicKeyInfo.
  1750. '--------------------------------------------------------------------------
  1751. '+-------------------------------------------------------------------------
  1752. ' Countersign an already-existing signature in a message
  1753. '
  1754. ' dwIndex is a zero-based index of the SignerInfo to be countersigned.
  1755. '--------------------------------------------------------------------------
  1756. '+-------------------------------------------------------------------------
  1757. ' Output an encoded SignerInfo blob, suitable for use as a countersignature
  1758. ' attribute in the unauthenticated attributes of a signed-data or
  1759. ' signed-and-enveloped-data message.
  1760. '--------------------------------------------------------------------------
  1761. '+-------------------------------------------------------------------------
  1762. ' Get a parameter after encoding/decoding a cryptographic message. Called
  1763. ' after the final CryptMsgUpdate. Only the CMSG_CONTENT_PARAM and
  1764. ' CMSG_COMPUTED_HASH_PARAM are valid for an encoded message.
  1765. '
  1766. ' For an encoded HASHED message, the CMSG_COMPUTED_HASH_PARAM can be got
  1767. ' before any CryptMsgUpdates to get its length.
  1768. '
  1769. ' The pvData type definition depends on the dwParamType value.
  1770. '
  1771. ' Elements pointed to by fields in the pvData structure follow the
  1772. ' structure. Therefore, *pcbData may exceed the size of the structure.
  1773. '
  1774. ' Upon input, if *pcbData == 0, then, *pcbData is updated with the length
  1775. ' of the data and the pvData parameter is ignored.
  1776. '
  1777. ' Upon return, *pcbData is updated with the length of the data.
  1778. '
  1779. ' The OBJID BLOBs returned in the pvData structures point to
  1780. ' their still encoded representation. The appropriate functions
  1781. ' must be called to decode the information.
  1782. '
  1783. ' See below for a list of the parameters to get.
  1784. '--------------------------------------------------------------------------
  1785. '+-------------------------------------------------------------------------
  1786. ' Get parameter types and their corresponding data structure definitions.
  1787. '--------------------------------------------------------------------------
  1788. Public Const CMSG_TYPE_PARAM As Long = 1
  1789. Public Const CMSG_CONTENT_PARAM As Long = 2
  1790. Public Const CMSG_BARE_CONTENT_PARAM As Long = 3
  1791. Public Const CMSG_INNER_CONTENT_TYPE_PARAM As Long = 4
  1792. Public Const CMSG_SIGNER_COUNT_PARAM As Long = 5
  1793. Public Const CMSG_SIGNER_INFO_PARAM As Long = 6
  1794. Public Const CMSG_SIGNER_CERT_INFO_PARAM As Long = 7
  1795. Public Const CMSG_SIGNER_HASH_ALGORITHM_PARAM As Long = 8
  1796. Public Const CMSG_SIGNER_AUTH_ATTR_PARAM As Long = 9
  1797. Public Const CMSG_SIGNER_UNAUTH_ATTR_PARAM As Long = 10
  1798. Public Const CMSG_CERT_COUNT_PARAM As Long = 11
  1799. Public Const CMSG_CERT_PARAM As Long = 12
  1800. Public Const CMSG_CRL_COUNT_PARAM As Long = 13
  1801. Public Const CMSG_CRL_PARAM As Long = 14
  1802. Public Const CMSG_ENVELOPE_ALGORITHM_PARAM As Long = 15
  1803. Public Const CMSG_RECIPIENT_COUNT_PARAM As Long = 17
  1804. Public Const CMSG_RECIPIENT_INDEX_PARAM As Long = 18
  1805. Public Const CMSG_RECIPIENT_INFO_PARAM As Long = 19
  1806. Public Const CMSG_HASH_ALGORITHM_PARAM As Long = 20
  1807. Public Const CMSG_HASH_DATA_PARAM As Long = 21
  1808. Public Const CMSG_COMPUTED_HASH_PARAM As Long = 22
  1809. Public Const CMSG_ENCRYPT_PARAM As Long = 26
  1810. Public Const CMSG_ENCRYPTED_DIGEST As Long = 27
  1811. Public Const CMSG_ENCODED_SIGNER As Long = 28
  1812. Public Const CMSG_ENCODED_MESSAGE As Long = 29
  1813. '+-------------------------------------------------------------------------
  1814. ' CMSG_TYPE_PARAM
  1815. '
  1816. ' The type of the decoded message.
  1817. '
  1818. ' pvData points to a DWORD
  1819. '--------------------------------------------------------------------------
  1820. '+-------------------------------------------------------------------------
  1821. ' CMSG_CONTENT_PARAM
  1822. '
  1823. ' The encoded content of a cryptographic message. Depending on how the
  1824. ' message was opened, the content is either the whole PKCS#7
  1825. ' In the decode case, the decrypted content is returned, if enveloped.
  1826. ' If not enveloped, and if the inner content is of type DATA, the returned
  1827. ' data is the contents octets of the inner content.
  1828. '
  1829. ' pvData points to the buffer receiving the content bytes
  1830. '--------------------------------------------------------------------------
  1831. '+-------------------------------------------------------------------------
  1832. ' CMSG_BARE_CONTENT_PARAM
  1833. '
  1834. ' The encoded content of an encoded cryptographic message, without the
  1835. ' outer layer of ContentInfo. That is, only the encoding of the
  1836. ' ContentInfo.content field is returned.
  1837. '
  1838. ' pvData points to the buffer receiving the content bytes
  1839. '--------------------------------------------------------------------------
  1840. '+-------------------------------------------------------------------------
  1841. ' CMSG_INNER_CONTENT_TYPE_PARAM
  1842. '
  1843. ' The type of the inner content of a decoded cryptographic message,
  1844. ' in the form of a NULL-terminated object identifier string
  1845. '
  1846. ' pvData points to the buffer receiving the object identifier string
  1847. '--------------------------------------------------------------------------
  1848. '+-------------------------------------------------------------------------
  1849. ' CMSG_SIGNER_COUNT_PARAM
  1850. '
  1851. ' Count of signers in a SIGNED or SIGNED_AND_ENVELOPED message
  1852. '
  1853. ' pvData points to a DWORD
  1854. '--------------------------------------------------------------------------
  1855. '+-------------------------------------------------------------------------
  1856. ' CMSG_SIGNER_CERT_INFO_PARAM
  1857. '
  1858. ' To get all the signers, repetitively call CryptMsgGetParam, with
  1859. ' dwIndex set to 0 .. SignerCount - 1.
  1860. '
  1861. ' pvData points to a CERT_INFO struct.
  1862. '
  1863. ' Only the following fields have been updated in the CERT_INFO struct:
  1864. ' Issuer and SerialNumber.
  1865. '--------------------------------------------------------------------------
  1866. '+-------------------------------------------------------------------------
  1867. ' CMSG_SIGNER_INFO_PARAM
  1868. '
  1869. ' To get all the signers, repetitively call CryptMsgGetParam, with
  1870. ' dwIndex set to 0 .. SignerCount - 1.
  1871. '
  1872. ' pvData points to a CMSG_SIGNER_INFO struct.
  1873. '--------------------------------------------------------------------------
  1874. '+-------------------------------------------------------------------------
  1875. ' CMSG_SIGNER_HASH_ALGORITHM_PARAM
  1876. '
  1877. ' This parameter specifies the HashAlgorithm that was used for the signer.
  1878. '
  1879. ' Set dwIndex to iterate through all the signers.
  1880. '
  1881. ' pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  1882. '--------------------------------------------------------------------------
  1883. '+-------------------------------------------------------------------------
  1884. ' CMSG_SIGNER_AUTH_ATTR_PARAM
  1885. '
  1886. ' The authenticated attributes for the signer.
  1887. '
  1888. ' Set dwIndex to iterate through all the signers.
  1889. '
  1890. ' pvData points to a CMSG_ATTR struct.
  1891. '--------------------------------------------------------------------------
  1892. '+-------------------------------------------------------------------------
  1893. ' CMSG_SIGNER_UNAUTH_ATTR_PARAM
  1894. '
  1895. ' The unauthenticated attributes for the signer.
  1896. '
  1897. ' Set dwIndex to iterate through all the signers.
  1898. '
  1899. ' pvData points to a CMSG_ATTR struct.
  1900. '--------------------------------------------------------------------------
  1901. '+-------------------------------------------------------------------------
  1902. ' CMSG_CERT_COUNT_PARAM
  1903. '
  1904. ' Count of certificates in a SIGNED or SIGNED_AND_ENVELOPED message.
  1905. '
  1906. ' pvData points to a DWORD
  1907. '--------------------------------------------------------------------------
  1908. '+-------------------------------------------------------------------------
  1909. ' CMSG_CERT_PARAM
  1910. '
  1911. ' To get all the certificates, repetitively call CryptMsgGetParam, with
  1912. ' dwIndex set to 0 .. CertCount - 1.
  1913. '
  1914. ' pvData points to an array of the certificate's encoded bytes.
  1915. '--------------------------------------------------------------------------
  1916. '+-------------------------------------------------------------------------
  1917. ' CMSG_CRL_COUNT_PARAM
  1918. '
  1919. ' Count of CRLs in a SIGNED or SIGNED_AND_ENVELOPED message.
  1920. '
  1921. ' pvData points to a DWORD
  1922. '--------------------------------------------------------------------------
  1923. '+-------------------------------------------------------------------------
  1924. ' CMSG_CRL_PARAM
  1925. '
  1926. ' To get all the CRLs, repetitively call CryptMsgGetParam, with
  1927. ' dwIndex set to 0 .. CrlCount - 1.
  1928. '
  1929. ' pvData points to an array of the CRL's encoded bytes.
  1930. '--------------------------------------------------------------------------
  1931. '+-------------------------------------------------------------------------
  1932. ' CMSG_ENVELOPE_ALGORITHM_PARAM
  1933. '
  1934. ' The ContentEncryptionAlgorithm that was used in
  1935. ' an ENVELOPED or SIGNED_AND_ENVELOPED message.
  1936. '
  1937. ' pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  1938. '--------------------------------------------------------------------------
  1939. '+-------------------------------------------------------------------------
  1940. ' CMSG_RECIPIENT_COUNT_PARAM
  1941. '
  1942. ' Count of recipients in an ENVELOPED or SIGNED_AND_ENVELOPED message.
  1943. '
  1944. ' pvData points to a DWORD
  1945. '--------------------------------------------------------------------------
  1946. '+-------------------------------------------------------------------------
  1947. ' CMSG_RECIPIENT_INDEX_PARAM
  1948. '
  1949. ' Index of the recipient used to decrypt an ENVELOPED or SIGNED_AND_ENVELOPED
  1950. ' message.
  1951. '
  1952. ' pvData points to a DWORD
  1953. '--------------------------------------------------------------------------
  1954. '+-------------------------------------------------------------------------
  1955. ' CMSG_RECIPIENT_INFO_PARAM
  1956. '
  1957. ' To get all the recipients, repetitively call CryptMsgGetParam, with
  1958. ' dwIndex set to 0 .. RecipientCount - 1.
  1959. '
  1960. ' pvData points to a CERT_INFO struct.
  1961. '
  1962. ' Only the following fields have been updated in the CERT_INFO struct:
  1963. ' Issuer, SerialNumber and PublicKeyAlgorithm. The PublicKeyAlgorithm
  1964. ' specifies the KeyEncryptionAlgorithm that was used.
  1965. '--------------------------------------------------------------------------
  1966. '+-------------------------------------------------------------------------
  1967. ' CMSG_HASH_ALGORITHM_PARAM
  1968. '
  1969. ' The HashAlgorithm in a HASHED message.
  1970. '
  1971. ' pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  1972. '--------------------------------------------------------------------------
  1973. '+-------------------------------------------------------------------------
  1974. ' CMSG_HASH_DATA_PARAM
  1975. '
  1976. ' The hash in a HASHED message.
  1977. '
  1978. ' pvData points to an array of bytes.
  1979. '--------------------------------------------------------------------------
  1980. '+-------------------------------------------------------------------------
  1981. ' CMSG_COMPUTED_HASH_PARAM
  1982. '
  1983. ' The computed hash for a HASHED message.
  1984. '
  1985. ' This may be called for either an encoded or decoded message.
  1986. ' It also may be called before any encoded CryptMsgUpdates to get its length.
  1987. '
  1988. ' pvData points to an array of bytes.
  1989. '--------------------------------------------------------------------------
  1990. '+-------------------------------------------------------------------------
  1991. ' CMSG_ENCRYPT_PARAM
  1992. '
  1993. ' The ContentEncryptionAlgorithm that was used in an ENCRYPTED message.
  1994. '
  1995. ' pvData points to an CRYPT_ALGORITHM_IDENTIFIER struct.
  1996. '--------------------------------------------------------------------------
  1997. '+-------------------------------------------------------------------------
  1998. ' CMSG_ENCODED_MESSAGE
  1999. '
  2000. ' The full encoded message. This is useful in the case of a decoded
  2001. ' signed-and-enveloped-data message which has been countersigned).
  2002. '
  2003. ' pvData points to an array of the message's encoded bytes.
  2004. '--------------------------------------------------------------------------
  2005. '+=========================================================================
  2006. ' Certificate Store Data Structures and APIs
  2007. '==========================================================================
  2008. '+-------------------------------------------------------------------------
  2009. ' In its most basic implementation, a cert store is simply a
  2010. ' collection of certificates and/or CRLs. This is the case when
  2011. ' a cert store is opened with all of its certificates and CRLs
  2012. ' coming from a PKCS #7 encoded cryptographic message.
  2013. '
  2014. ' Nonetheless, all cert stores have the following properties:
  2015. ' - A public key may have more than one certificate in the store.
  2016. ' For example, a private/public key used for signing may have a
  2017. ' certificate issued for VISA and another issued for
  2018. ' Mastercard. Also, when a certificate is renewed there might
  2019. ' be more than one certificate with the same subject and
  2020. ' issuer.
  2021. ' - However, each certificate in the store is uniquely
  2022. ' identified by its Issuer and SerialNumber.
  2023. ' - There's an issuer of subject certificate relationship. A
  2024. ' certificate's issuer is found by doing a match of
  2025. ' pSubjectCert->Issuer with pIssuerCert->Subject.
  2026. ' The relationship is verified by using
  2027. ' the issuer's public key to verify the subject certificate's
  2028. ' signature. Note, there might be X.509 v3 extensions
  2029. ' to assist in finding the issuer certificate.
  2030. ' - Since issuer certificates might be renewed, a subject
  2031. ' certificate might have more than one issuer certificate.
  2032. ' - There's an issuer of CRL relationship. An
  2033. ' issuer's CRL is found by doing a match of
  2034. ' pIssuerCert->Subject with pCrl->Issuer.
  2035. ' The relationship is verified by using
  2036. ' the issuer's public key to verify the CRL's
  2037. ' signature. Note, there might be X.509 v3 extensions
  2038. ' to assist in finding the CRL.
  2039. ' - Since some issuers might support the X.509 v3 delta CRL
  2040. ' extensions, an issuer might have more than one CRL.
  2041. ' - The store shouldn't have any redundant certificates or
  2042. ' CRLs. There shouldn't be two certificates with the same
  2043. ' Issuer and SerialNumber. There shouldn't be two CRLs with
  2044. ' the same Issuer, ThisUpdate and NextUpdate.
  2045. ' - The store has NO policy or trust information. No
  2046. ' certificates are tagged as being "root". Its up to
  2047. ' SerialNumber) for certificates it trusts.
  2048. ' - The store might contain bad certificates and/or CRLs.
  2049. ' The issuer's signature of a subject certificate or CRL may
  2050. ' not verify. Certificates or CRLs may not satisfy their
  2051. ' time validity requirements. Certificates may be
  2052. ' revoked.
  2053. '
  2054. ' In addition to the certificates and CRLs, properties can be
  2055. ' stored. There are two predefined property IDs for a user
  2056. ' certificate: CERT_KEY_PROV_HANDLE_PROP_ID and
  2057. ' CERT_KEY_PROV_INFO_PROP_ID. The CERT_KEY_PROV_HANDLE_PROP_ID
  2058. ' is a HCRYPTPROV handle to the private key assoicated
  2059. ' with the certificate. The CERT_KEY_PROV_INFO_PROP_ID contains
  2060. ' information to be used to call
  2061. ' CryptAcquireContext and CryptProvSetParam to get a handle
  2062. ' to the private key associated with the certificate.
  2063. '
  2064. ' There exists two more predefined property IDs for certificates
  2065. ' and CRLs, CERT_SHA1_HASH_PROP_ID and CERT_MD5_HASH_PROP_ID.
  2066. ' If these properties don't already exist, then, a hash of the
  2067. ' hash algorithm, currently, CERT_SHA1_HASH_PROP_ID).
  2068. '
  2069. ' There are additional APIs for creating certificate and CRL
  2070. ' CertCreateCRLContext).
  2071. '
  2072. '--------------------------------------------------------------------------
  2073. '+-------------------------------------------------------------------------
  2074. ' Certificate context.
  2075. '
  2076. ' A certificate context contains both the encoded and decoded representation
  2077. ' of a certificate. A certificate context returned by a cert store function
  2078. ' must be freed by calling the CertFreeCertificateContext function. The
  2079. ' CertDuplicateCertificateContext function can be called to make a duplicate
  2080. '--------------------------------------------------------------------------
  2081. '+-------------------------------------------------------------------------
  2082. ' CRL context.
  2083. '
  2084. ' A CRL context contains both the encoded and decoded representation
  2085. ' of a CRL. A CRL context returned by a cert store function
  2086. ' must be freed by calling the CertFreeCRLContext function. The
  2087. ' CertDuplicateCRLContext function can be called to make a duplicate
  2088. '--------------------------------------------------------------------------
  2089. '+-------------------------------------------------------------------------
  2090. '
  2091. ' A CTL context contains both the encoded and decoded representation
  2092. ' of a CTL. Also contains an opened HCRYPTMSG handle to the decoded
  2093. ' cryptographic signed message containing the CTL_INFO as its inner content.
  2094. ' pbCtlContent is the encoded inner content of the signed message.
  2095. '
  2096. ' The CryptMsg APIs can be used to extract additional signer information.
  2097. '--------------------------------------------------------------------------
  2098. '+-------------------------------------------------------------------------
  2099. ' Certificate, CRL and CTL property IDs
  2100. '
  2101. ' See CertSetCertificateContextProperty or CertGetCertificateContextProperty
  2102. ' for usage information.
  2103. '--------------------------------------------------------------------------
  2104. Public Const CERT_KEY_PROV_HANDLE_PROP_ID As Long = 1
  2105. Public Const CERT_KEY_PROV_INFO_PROP_ID As Long = 2
  2106. Public Const CERT_SHA1_HASH_PROP_ID As Long = 3
  2107. Public Const CERT_MD5_HASH_PROP_ID As Long = 4
  2108. Public Const CERT_KEY_CONTEXT_PROP_ID As Long = 5
  2109. Public Const CERT_KEY_SPEC_PROP_ID As Long = 6
  2110. Public Const CERT_IE30_RESERVED_PROP_ID As Long = 7
  2111. Public Const CERT_PUBKEY_HASH_RESERVED_PROP_ID As Long = 8
  2112. Public Const CERT_ENHKEY_USAGE_PROP_ID As Long = 9
  2113. Public Const CERT_NEXT_UPDATE_LOCATION_PROP_ID As Long = 10
  2114. Public Const CERT_FRIENDLY_NAME_PROP_ID As Long = 11
  2115. ' Note, 32 - 34 are reserved for the CERT, CRL and CTL file element IDs.
  2116. Public Const CERT_FIRST_RESERVED_PROP_ID As Long = 12
  2117. Public Const CERT_LAST_RESERVED_PROP_ID As Long = &H00007FFF
  2118. Public Const CERT_FIRST_USER_PROP_ID As Long = &H00008000
  2119. Public Const CERT_LAST_USER_PROP_ID As Long = &H0000FFFF
  2120. '+-------------------------------------------------------------------------
  2121. ' Cryptographic Key Provider Information
  2122. '
  2123. ' CRYPT_KEY_PROV_INFO defines the CERT_KEY_PROV_INFO_PROP_ID's pvData.
  2124. '
  2125. ' The CRYPT_KEY_PROV_INFO fields are passed to CryptAcquireContext
  2126. ' to get a HCRYPTPROV handle. The optional CRYPT_KEY_PROV_PARAM fields are
  2127. ' passed to CryptProvSetParam to further initialize the provider.
  2128. '
  2129. ' The dwKeySpec field identifies the private key to use from the container
  2130. ' For example, AT_KEYEXCHANGE or AT_SIGNATURE.
  2131. '--------------------------------------------------------------------------
  2132. '+-------------------------------------------------------------------------
  2133. ' The following flag should be set in the above dwFlags to enable
  2134. ' CryptAcquireContext is done in the Sign or Decrypt Message functions.
  2135. '
  2136. ' The following define must not collide with any of the
  2137. ' CryptAcquireContext dwFlag defines.
  2138. '--------------------------------------------------------------------------
  2139. Public Const CERT_SET_KEY_PROV_HANDLE_PROP_ID As Long = &H00000001
  2140. Public Const CERT_SET_KEY_CONTEXT_PROP_ID As Long = &H00000001
  2141. '+-------------------------------------------------------------------------
  2142. ' Certificate Key Context
  2143. '
  2144. ' CERT_KEY_CONTEXT defines the CERT_KEY_CONTEXT_PROP_ID's pvData.
  2145. '--------------------------------------------------------------------------
  2146. '+-------------------------------------------------------------------------
  2147. ' Certificate Store Provider Types
  2148. '--------------------------------------------------------------------------
  2149. Public Const sz_CERT_STORE_PROV_MEMORY As String = "Memory"
  2150. Public Const sz_CERT_STORE_PROV_FILENAME_W As String = "File"
  2151. Public Const sz_CERT_STORE_PROV_SYSTEM_W As String = "System"
  2152. Public Const sz_CERT_STORE_PROV_PKCS7 As String = "PKCS7"
  2153. Public Const sz_CERT_STORE_PROV_SERIALIZED As String = "Serialized"
  2154. '+-------------------------------------------------------------------------
  2155. ' Certificate Store verify/results flags
  2156. '--------------------------------------------------------------------------
  2157. Public Const CERT_STORE_SIGNATURE_FLAG As Long = &H00000001
  2158. Public Const CERT_STORE_TIME_VALIDITY_FLAG As Long = &H00000002
  2159. Public Const CERT_STORE_REVOCATION_FLAG As Long = &H00000004
  2160. Public Const CERT_STORE_NO_CRL_FLAG As Long = &H00010000
  2161. Public Const CERT_STORE_NO_ISSUER_FLAG As Long = &H00020000
  2162. '+-------------------------------------------------------------------------
  2163. ' Certificate Store open/property flags
  2164. '--------------------------------------------------------------------------
  2165. Public Const CERT_STORE_NO_CRYPT_RELEASE_FLAG As Long = &H00000001
  2166. Public Const CERT_STORE_READONLY_FLAG As Long = &H00008000
  2167. '+-------------------------------------------------------------------------
  2168. ' Certificate Store Provider flags are in the HiWord 0xFFFF0000
  2169. '--------------------------------------------------------------------------
  2170. '+-------------------------------------------------------------------------
  2171. ' Certificate System Store Flag Values
  2172. '--------------------------------------------------------------------------
  2173. ' Location of the system store in the registry:
  2174. ' HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
  2175. Public Const CERT_SYSTEM_STORE_LOCATION_MASK As Long = &H00030000
  2176. Public Const CERT_SYSTEM_STORE_CURRENT_USER As Long = &H00010000
  2177. Public Const CERT_SYSTEM_STORE_LOCAL_MACHINE As Long = &H00020000
  2178. '+-------------------------------------------------------------------------
  2179. ' Open the cert store using the specified store provider.
  2180. '
  2181. ' hCryptProv specifies the crypto provider to use to create the hash
  2182. ' properties or verify the signature of a subject certificate or CRL.
  2183. ' The store doesn't need to use a private
  2184. ' key. If the CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, hCryptProv is
  2185. ' CryptReleaseContext'ed on the final CertCloseStore.
  2186. '
  2187. ' Note, if the open fails, hCryptProv is released if it would have been
  2188. ' released when the store was closed.
  2189. '
  2190. ' If hCryptProv is zero, then, the default provider and container for the
  2191. ' PROV_RSA_FULL provider type is CryptAcquireContext'ed with
  2192. ' CRYPT_VERIFYCONTEXT access. The CryptAcquireContext is deferred until
  2193. ' the first create hash or verify signature. In addition, once acquired,
  2194. ' the default provider isn't released until process exit when crypt32.dll
  2195. ' is unloaded. The acquired default provider is shared across all stores
  2196. ' and threads.
  2197. '
  2198. ' After initializing the store's data structures and optionally acquiring a
  2199. ' default crypt provider, CertOpenStore calls CryptGetOIDFunctionAddress to
  2200. ' get the address of the CRYPT_OID_OPEN_STORE_PROV_FUNC specified by
  2201. ' lpszStoreProvider. Since a store can contain certificates with different
  2202. ' encoding types, CryptGetOIDFunctionAddress is called with dwEncodingType
  2203. ' set to 0 and not the dwEncodingType passed to CertOpenStore.
  2204. ' PFN_CERT_DLL_OPEN_STORE_FUNC specifies the signature of the provider's
  2205. ' open function. This provider open function is called to load the
  2206. ' store's certificates and CRLs. Optionally, the provider may return an
  2207. ' array of functions called before a certificate or CRL is added or deleted
  2208. ' or has a property that is set.
  2209. '
  2210. ' Use of the dwEncodingType parameter is provider dependent. The type
  2211. ' definition for pvPara also depends on the provider.
  2212. '
  2213. ' Store providers are installed or registered via
  2214. ' CryptInstallOIDFunctionAddress or CryptRegisterOIDFunction, where,
  2215. ' dwEncodingType is 0 and pszFuncName is CRYPT_OID_OPEN_STORE_PROV_FUNC.
  2216. '
  2217. '
  2218. ' CERT_STORE_PROV_MSG:
  2219. ' Gets the certificates and CRLs from the specified cryptographic message.
  2220. ' dwEncodingType contains the message and certificate encoding types.
  2221. ' The message's handle is passed in pvPara. Given,
  2222. '
  2223. ' CERT_STORE_PROV_MEMORY
  2224. ' sz_CERT_STORE_PROV_MEMORY:
  2225. ' Opens a store without any initial certificates or CRLs. pvPara
  2226. ' isn't used.
  2227. '
  2228. ' CERT_STORE_PROV_FILE:
  2229. ' Reads the certificates and CRLs from the specified file. The file's
  2230. ' handle is passed in pvPara. Given,
  2231. '
  2232. ' For a successful open, the file pointer is advanced past
  2233. ' the certificates and CRLs and their properties read from the file.
  2234. ' Note, only expects a serialized store and not a file containing
  2235. ' either a PKCS #7 signed message or a single encoded certificate.
  2236. '
  2237. ' The hFile isn't closed.
  2238. '
  2239. ' CERT_STORE_PROV_REG:
  2240. ' Reads the certificates and CRLs from the registry. The registry's
  2241. ' key handle is passed in pvPara. Given,
  2242. '
  2243. ' The input hKey isn't closed by the provider. Before returning, the
  2244. ' provider opens/creates "Certificates" and "CRLs" subkeys. These
  2245. ' subkeys remain open until the store is closed.
  2246. '
  2247. ' If CERT_STORE_READONLY_FLAG is set, then, the registry subkeys are
  2248. ' RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry subkeys
  2249. ' are RegCreateKey'ed with KEY_ALL_ACCESS.
  2250. '
  2251. ' This provider returns the array of functions for reading, writing,
  2252. ' deleting and property setting certificates and CRLs.
  2253. ' Any changes to the opened store are immediately pushed through to
  2254. ' the registry. However, if CERT_STORE_READONLY_FLAG is set, then,
  2255. ' writing, deleting or property setting results in a
  2256. '
  2257. ' Note, all the certificates and CRLs are read from the registry
  2258. ' when the store is opened. The opened store serves as a write through
  2259. ' cache. However, the opened store isn't notified of other changes
  2260. ' made to the registry. Note, RegNotifyChangeKeyValue is supported
  2261. ' on NT but not supported on Windows95.
  2262. '
  2263. ' CERT_STORE_PROV_PKCS7:
  2264. ' sz_CERT_STORE_PROV_PKCS7:
  2265. ' Gets the certificates and CRLs from the encoded PKCS #7 signed message.
  2266. ' dwEncodingType specifies the message and certificate encoding types.
  2267. ' The pointer to the encoded message's blob is passed in pvPara. Given,
  2268. '
  2269. ' Note, also supports the IE3.0 special version of a
  2270. ' PKCS #7 signed message referred to as a "SPC" formatted message.
  2271. '
  2272. ' CERT_STORE_PROV_SERIALIZED:
  2273. ' sz_CERT_STORE_PROV_SERIALIZED:
  2274. ' Gets the certificates and CRLs from memory containing a serialized
  2275. ' store. The pointer to the serialized memory blob is passed in pvPara.
  2276. ' Given,
  2277. '
  2278. ' CERT_STORE_PROV_FILENAME_A:
  2279. ' CERT_STORE_PROV_FILENAME_W:
  2280. ' CERT_STORE_PROV_FILENAME:
  2281. ' sz_CERT_STORE_PROV_FILENAME_W:
  2282. ' sz_CERT_STORE_PROV_FILENAME:
  2283. ' Opens the file and first attempts to read as a serialized store. Then,
  2284. ' as a PKCS #7 signed message. Finally, as a single encoded certificate.
  2285. ' The filename is passed in pvPara. The filename is UNICODE for the
  2286. ' "_W" provider and ASCII for the "_A" provider. For "_W": given,
  2287. ' For "_A": given,
  2288. '
  2289. '
  2290. ' Note, also supports the reading of the IE3.0 special version of a
  2291. ' PKCS #7 signed message file referred to as a "SPC" formatted file.
  2292. '
  2293. ' CERT_STORE_PROV_SYSTEM_A:
  2294. ' CERT_STORE_PROV_SYSTEM_W:
  2295. ' CERT_STORE_PROV_SYSTEM:
  2296. ' sz_CERT_STORE_PROV_SYSTEM_W:
  2297. ' sz_CERT_STORE_PROV_SYSTEM:
  2298. ' Opens the specified "system" store. Currently, all the system
  2299. ' stores are stored in the registry. The upper word of the dwFlags
  2300. ' parameter is used to specify the location of the system store. It
  2301. ' should be set to either CERT_SYSTEM_STORE_CURRENT_USER for
  2302. ' HKEY_CURRENT_USER or CERT_SYSTEM_STORE_LOCAL_MACHINE for
  2303. ' HKEY_LOCAL_MACHINE.
  2304. '
  2305. ' After opening the registry key associated with the system name,
  2306. ' the CERT_STORE_PROV_REG provider is called to complete the open.
  2307. '
  2308. ' The system store name is passed in pvPara. The name is UNICODE for the
  2309. ' "_W" provider and ASCII for the "_A" provider. For "_W": given,
  2310. ' For "_A": given,
  2311. '
  2312. '
  2313. ' If CERT_STORE_READONLY_FLAG is set, then, the registry is
  2314. ' RegOpenKey'ed with KEY_READ_ACCESS. Otherwise, the registry is
  2315. ' RegCreateKey'ed with KEY_ALL_ACCESS.
  2316. '
  2317. ' The "root" store is treated differently from the other system
  2318. ' stores. Before a certificate is added to or deleted from the "root"
  2319. ' store, a pop up message box is displayed. The certificate's subject,
  2320. ' issuer, serial number, time validity, sha1 and md5 thumbprints are
  2321. ' displayed. The user is given the option to do the add or delete.
  2322. ' If they don't allow the operation, LastError is set to E_ACCESSDENIED.
  2323. '--------------------------------------------------------------------------
  2324. '+-------------------------------------------------------------------------
  2325. ' OID Installable Certificate Store Provider Data Structures
  2326. '--------------------------------------------------------------------------
  2327. ' Handle returned by the store provider when opened.
  2328. ' Store Provider OID function's pszFuncName.
  2329. Public Const CRYPT_OID_OPEN_STORE_PROV_FUNC As String = "CertDllOpenStoreProv"
  2330. ' Note, the Store Provider OID function's dwEncodingType is always 0.
  2331. ' The following information is returned by the provider when opened. Its
  2332. ' zeroed with cbSize set before the provider is called. If the provider
  2333. ' doesn't need to be called again after the open it doesn't need to
  2334. ' make any updates to the CERT_STORE_PROV_INFO.
  2335. ' Definition of the store provider's open function.
  2336. '
  2337. ' *pStoreProvInfo has been zeroed before the call.
  2338. '
  2339. ' Note, pStoreProvInfo->cStoreProvFunc should be set last. Once set,
  2340. ' all subsequent store calls, such as CertAddSerializedElementToStore will
  2341. ' call the appropriate provider callback function.
  2342. ' Indices into the store provider's array of callback functions.
  2343. '
  2344. ' The provider can implement any subset of the following functions. It
  2345. ' sets pStoreProvInfo->cStoreProvFunc to the last index + 1 and any
  2346. ' preceding not implemented functions to NULL.
  2347. Public Const CERT_STORE_PROV_CLOSE_FUNC As Long = 0
  2348. Public Const CERT_STORE_PROV_READ_CERT_FUNC As Long = 1
  2349. Public Const CERT_STORE_PROV_WRITE_CERT_FUNC As Long = 2
  2350. Public Const CERT_STORE_PROV_DELETE_CERT_FUNC As Long = 3
  2351. Public Const CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC As Long = 4
  2352. Public Const CERT_STORE_PROV_READ_CRL_FUNC As Long = 5
  2353. Public Const CERT_STORE_PROV_WRITE_CRL_FUNC As Long = 6
  2354. Public Const CERT_STORE_PROV_DELETE_CRL_FUNC As Long = 7
  2355. Public Const CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC As Long = 8
  2356. Public Const CERT_STORE_PROV_READ_CTL_FUNC As Long = 9
  2357. Public Const CERT_STORE_PROV_WRITE_CTL_FUNC As Long = 10
  2358. Public Const CERT_STORE_PROV_DELETE_CTL_FUNC As Long = 11
  2359. Public Const CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC As Long = 12
  2360. ' Called by CertCloseStore when the store's reference count is
  2361. ' decremented to 0.
  2362. ' Currently not called directly by the store APIs. However, may be exported
  2363. ' to support other providers based on it.
  2364. '
  2365. ' Reads the provider's copy of the certificate context. If it exists,
  2366. ' creates a new certificate context.
  2367. Public Const CERT_STORE_PROV_WRITE_ADD_FLAG As Long = &H1
  2368. ' Called by CertAddEncodedCertificateToStore,
  2369. ' CertAddCertificateContextToStore or CertAddSerializedElementToStore before
  2370. ' adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  2371. ' addition to the encoded certificate, the added pCertContext might also
  2372. ' have properties.
  2373. '
  2374. ' Returns TRUE if its OK to update the the store.
  2375. ' Called by CertDeleteCertificateFromStore before deleting from the
  2376. ' store.
  2377. '
  2378. ' Returns TRUE if its OK to delete from the store.
  2379. ' Called by CertSetCertificateContextProperty before setting the
  2380. ' certificate's property. Also called by CertGetCertificateContextProperty,
  2381. ' when getting a hash property that needs to be created and then persisted
  2382. ' via the set.
  2383. '
  2384. ' Upon input, the property hasn't been set for the pCertContext parameter.
  2385. '
  2386. ' Returns TRUE if its OK to set the property.
  2387. ' Currently not called directly by the store APIs. However, may be exported
  2388. ' to support other providers based on it.
  2389. '
  2390. ' Reads the provider's copy of the CRL context. If it exists,
  2391. ' creates a new CRL context.
  2392. ' Called by CertAddEncodedCRLToStore,
  2393. ' CertAddCRLContextToStore or CertAddSerializedElementToStore before
  2394. ' adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  2395. ' addition to the encoded CRL, the added pCertContext might also
  2396. ' have properties.
  2397. '
  2398. ' Returns TRUE if its OK to update the the store.
  2399. ' Called by CertDeleteCRLFromStore before deleting from the store.
  2400. '
  2401. ' Returns TRUE if its OK to delete from the store.
  2402. ' Called by CertSetCRLContextProperty before setting the
  2403. ' CRL's property. Also called by CertGetCRLContextProperty,
  2404. ' when getting a hash property that needs to be created and then persisted
  2405. ' via the set.
  2406. '
  2407. ' Upon input, the property hasn't been set for the pCrlContext parameter.
  2408. '
  2409. ' Returns TRUE if its OK to set the property.
  2410. ' Currently not called directly by the store APIs. However, may be exported
  2411. ' to support other providers based on it.
  2412. '
  2413. ' Reads the provider's copy of the CTL context. If it exists,
  2414. ' creates a new CTL context.
  2415. ' Called by CertAddEncodedCTLToStore,
  2416. ' CertAddCTLContextToStore or CertAddSerializedElementToStore before
  2417. ' adding to the store. The CERT_STORE_PROV_WRITE_ADD_FLAG is set. In
  2418. ' addition to the encoded CTL, the added pCertContext might also
  2419. ' have properties.
  2420. '
  2421. ' Returns TRUE if its OK to update the the store.
  2422. ' Called by CertDeleteCTLFromStore before deleting from the store.
  2423. '
  2424. ' Returns TRUE if its OK to delete from the store.
  2425. ' Called by CertSetCTLContextProperty before setting the
  2426. ' CTL's property. Also called by CertGetCTLContextProperty,
  2427. ' when getting a hash property that needs to be created and then persisted
  2428. ' via the set.
  2429. '
  2430. ' Upon input, the property hasn't been set for the pCtlContext parameter.
  2431. '
  2432. ' Returns TRUE if its OK to set the property.
  2433. '+-------------------------------------------------------------------------
  2434. ' Duplicate a cert store handle
  2435. '--------------------------------------------------------------------------
  2436. Public Const CERT_STORE_SAVE_AS_STORE As Long = 1
  2437. Public Const CERT_STORE_SAVE_AS_PKCS7 As Long = 2
  2438. Public Const CERT_STORE_SAVE_TO_FILE As Long = 1
  2439. Public Const CERT_STORE_SAVE_TO_MEMORY As Long = 2
  2440. Public Const CERT_STORE_SAVE_TO_FILENAME_A As Long = 3
  2441. Public Const CERT_STORE_SAVE_TO_FILENAME_W As Long = 4
  2442. '+-------------------------------------------------------------------------
  2443. ' Save the cert store. Extended version with lots of options.
  2444. '
  2445. ' According to the dwSaveAs parameter, the store can be saved as a
  2446. ' addition to encoded certificates, CRLs and CTLs or the store can be saved
  2447. ' include the properties or CTLs.
  2448. '
  2449. ' CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't saved into
  2450. ' a serialized store.
  2451. '
  2452. ' For CERT_STORE_SAVE_AS_PKCS7, the dwEncodingType specifies the message
  2453. ' encoding type. The dwEncodingType parameter isn't used for
  2454. ' CERT_STORE_SAVE_AS_STORE.
  2455. '
  2456. ' The dwFlags parameter currently isn't used and should be set to 0.
  2457. '
  2458. ' The dwSaveTo and pvSaveToPara parameters specify where to save the
  2459. ' store as follows:
  2460. ' CERT_STORE_SAVE_TO_FILE:
  2461. ' Saves to the specified file. The file's handle is passed in
  2462. ' pvSaveToPara. Given,
  2463. '
  2464. ' For a successful save, the file pointer is positioned after the
  2465. ' last write.
  2466. '
  2467. ' CERT_STORE_SAVE_TO_MEMORY:
  2468. ' Saves to the specified memory blob. The pointer to
  2469. ' the memory blob is passed in pvSaveToPara. Given,
  2470. ' Upon entry, the SaveBlob's pbData and cbData need to be initialized.
  2471. ' Upon return, cbData is updated with the actual length.
  2472. ' For a length only calculation, pbData should be set to NULL. If
  2473. ' pbData is non-NULL and cbData isn't large enough, FALSE is returned
  2474. ' with a last error of ERRROR_MORE_DATA.
  2475. '
  2476. ' CERT_STORE_SAVE_TO_FILENAME_A:
  2477. ' CERT_STORE_SAVE_TO_FILENAME_W:
  2478. ' CERT_STORE_SAVE_TO_FILENAME:
  2479. ' Opens the file and saves to it. The filename is passed in pvSaveToPara.
  2480. ' The filename is UNICODE for the "_W" option and ASCII for the "_A"
  2481. ' option. For "_W": given,
  2482. ' For "_A": given,
  2483. '
  2484. '
  2485. '--------------------------------------------------------------------------
  2486. '+-------------------------------------------------------------------------
  2487. ' Certificate Store close flags
  2488. '--------------------------------------------------------------------------
  2489. Public Const CERT_CLOSE_STORE_FORCE_FLAG As Long = &H00000001
  2490. Public Const CERT_CLOSE_STORE_CHECK_FLAG As Long = &H00000002
  2491. '+-------------------------------------------------------------------------
  2492. ' Close a cert store handle.
  2493. '
  2494. ' There needs to be a corresponding close for each open and duplicate.
  2495. '
  2496. ' Even on the final close, the cert store isn't freed until all of its
  2497. ' certificate and CRL contexts have also been freed.
  2498. '
  2499. ' On the final close, the hCryptProv passed to CertStoreOpen is
  2500. ' CryptReleaseContext'ed.
  2501. '
  2502. ' To force the closure of the store with all of its memory freed, set the
  2503. ' CERT_STORE_CLOSE_FORCE_FLAG. This flag should be set when the caller does
  2504. ' its own reference counting and wants everything to vanish.
  2505. '
  2506. ' To check if all the store's certificates and CRLs have been freed and that
  2507. ' this is the last CertCloseStore, set the CERT_CLOSE_STORE_CHECK_FLAG. If
  2508. ' set and certs, CRLs or stores still need to be freed/closed, FALSE is
  2509. ' returned with LastError set to CRYPT_E_PENDING_CLOSE. Note, for FALSE,
  2510. ' the store is still closed. This is a diagnostic flag.
  2511. '
  2512. ' LastError is preserved unless CERT_CLOSE_STORE_CHECK_FLAG is set and FALSE
  2513. ' is returned.
  2514. '--------------------------------------------------------------------------
  2515. '+-------------------------------------------------------------------------
  2516. ' Get the subject certificate context uniquely identified by its Issuer and
  2517. ' SerialNumber from the store.
  2518. '
  2519. ' If the certificate isn't found, NULL is returned. Otherwise, a pointer to
  2520. ' a read only CERT_CONTEXT is returned. CERT_CONTEXT must be freed by calling
  2521. ' CertFreeCertificateContext. CertDuplicateCertificateContext can be called to make a
  2522. ' duplicate.
  2523. '
  2524. ' The returned certificate might not be valid. Normally, it would be
  2525. '--------------------------------------------------------------------------
  2526. '+-------------------------------------------------------------------------
  2527. ' Enumerate the certificate contexts in the store.
  2528. '
  2529. ' If a certificate isn't found, NULL is returned.
  2530. ' Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  2531. ' must be freed by calling CertFreeCertificateContext or is freed when passed as the
  2532. ' pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  2533. ' can be called to make a duplicate.
  2534. '
  2535. ' pPrevCertContext MUST BE NULL to enumerate the first
  2536. ' certificate in the store. Successive certificates are enumerated by setting
  2537. ' pPrevCertContext to the CERT_CONTEXT returned by a previous call.
  2538. '
  2539. ' NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  2540. ' this function, even for an error.
  2541. '--------------------------------------------------------------------------
  2542. '+-------------------------------------------------------------------------
  2543. ' Find the first or next certificate context in the store.
  2544. '
  2545. ' The certificate is found according to the dwFindType and its pvFindPara.
  2546. ' See below for a list of the find types and its parameters.
  2547. '
  2548. ' Currently dwFindFlags is only used for CERT_FIND_SUBJECT_ATTR,
  2549. ' CERT_FIND_ISSUER_ATTR or CERT_FIND_CTL_USAGE. Otherwise, must be set to 0.
  2550. '
  2551. ' Usage of dwCertEncodingType depends on the dwFindType.
  2552. '
  2553. ' If the first or next certificate isn't found, NULL is returned.
  2554. ' Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  2555. ' must be freed by calling CertFreeCertificateContext or is freed when passed as the
  2556. ' pPrevCertContext on a subsequent call. CertDuplicateCertificateContext
  2557. ' can be called to make a duplicate.
  2558. '
  2559. ' pPrevCertContext MUST BE NULL on the first
  2560. ' call to find the certificate. To find the next certificate, the
  2561. ' pPrevCertContext is set to the CERT_CONTEXT returned by a previous call.
  2562. '
  2563. ' NOTE: a NON-NULL pPrevCertContext is always CertFreeCertificateContext'ed by
  2564. ' this function, even for an error.
  2565. '--------------------------------------------------------------------------
  2566. '+-------------------------------------------------------------------------
  2567. ' Certificate comparison functions
  2568. '--------------------------------------------------------------------------
  2569. Public Const CERT_COMPARE_MASK As Long = &HFFFF
  2570. Public Const CERT_COMPARE_SHIFT As Long = 16
  2571. Public Const CERT_COMPARE_ANY As Long = 0
  2572. Public Const CERT_COMPARE_SHA1_HASH As Long = 1
  2573. Public Const CERT_COMPARE_NAME As Long = 2
  2574. Public Const CERT_COMPARE_ATTR As Long = 3
  2575. Public Const CERT_COMPARE_MD5_HASH As Long = 4
  2576. Public Const CERT_COMPARE_PROPERTY As Long = 5
  2577. Public Const CERT_COMPARE_PUBLIC_KEY As Long = 6
  2578. Public Const CERT_COMPARE_NAME_STR_A As Long = 7
  2579. Public Const CERT_COMPARE_NAME_STR_W As Long = 8
  2580. Public Const CERT_COMPARE_KEY_SPEC As Long = 9
  2581. Public Const CERT_COMPARE_ENHKEY_USAGE As Long = 10
  2582. '+-------------------------------------------------------------------------
  2583. ' dwFindType
  2584. '
  2585. ' The dwFindType definition consists of two components:
  2586. ' - comparison function
  2587. ' - certificate information flag
  2588. '--------------------------------------------------------------------------
  2589. '+-------------------------------------------------------------------------
  2590. ' CERT_FIND_ANY
  2591. '
  2592. ' Find any certificate.
  2593. '
  2594. ' pvFindPara isn't used.
  2595. '--------------------------------------------------------------------------
  2596. '+-------------------------------------------------------------------------
  2597. ' CERT_FIND_HASH
  2598. '
  2599. ' Find a certificate with the specified hash.
  2600. '
  2601. ' pvFindPara points to a CRYPT_HASH_BLOB.
  2602. '--------------------------------------------------------------------------
  2603. '+-------------------------------------------------------------------------
  2604. ' CERT_FIND_PROPERTY
  2605. '
  2606. ' Find a certificate having the specified property.
  2607. '
  2608. ' pvFindPara points to a DWORD containing the PROP_ID
  2609. '--------------------------------------------------------------------------
  2610. '+-------------------------------------------------------------------------
  2611. ' CERT_FIND_PUBLIC_KEY
  2612. '
  2613. ' Find a certificate matching the specified public key.
  2614. '
  2615. ' pvFindPara points to a CERT_PUBLIC_KEY_INFO containing the public key
  2616. '--------------------------------------------------------------------------
  2617. '+-------------------------------------------------------------------------
  2618. ' CERT_FIND_SUBJECT_NAME
  2619. ' CERT_FIND_ISSUER_NAME
  2620. '
  2621. ' Find a certificate with the specified subject/issuer name. Does an exact
  2622. ' match of the entire name.
  2623. '
  2624. ' Restricts search to certificates matching the dwCertEncodingType.
  2625. '
  2626. ' pvFindPara points to a CERT_NAME_BLOB.
  2627. '--------------------------------------------------------------------------
  2628. '+-------------------------------------------------------------------------
  2629. ' CERT_FIND_SUBJECT_ATTR
  2630. ' CERT_FIND_ISSUER_ATTR
  2631. '
  2632. ' Find a certificate with the specified subject/issuer attributes.
  2633. '
  2634. ' Compares the attributes in the subject/issuer name with the
  2635. ' pvFindPara. The comparison iterates through the CERT_RDN attributes and looks
  2636. ' for an attribute match in any of the subject/issuer's RDNs.
  2637. '
  2638. ' The CERT_RDN_ATTR fields can have the following special values:
  2639. ' pszObjId == NULL - ignore the attribute object identifier
  2640. ' dwValueType == RDN_ANY_TYPE - ignore the value type
  2641. ' Value.pbData == NULL - match any value
  2642. '
  2643. ' Currently only an exact, case sensitive match is supported.
  2644. '
  2645. ' CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set in dwFindFlags if the RDN was
  2646. ' initialized with unicode strings as for
  2647. '
  2648. ' Restricts search to certificates matching the dwCertEncodingType.
  2649. '
  2650. '--------------------------------------------------------------------------
  2651. '+-------------------------------------------------------------------------
  2652. ' CERT_FIND_SUBJECT_STR_A
  2653. ' CERT_FIND_SUBJECT_STR_W | CERT_FIND_SUBJECT_STR
  2654. ' CERT_FIND_ISSUER_STR_A
  2655. ' CERT_FIND_ISSUER_STR_W | CERT_FIND_ISSUER_STR
  2656. '
  2657. ' Find a certificate containing the specified subject/issuer name string.
  2658. '
  2659. ' First, the certificate's subject/issuer is converted to a name string
  2660. ' case insensitive substring within string match is performed.
  2661. '
  2662. ' Restricts search to certificates matching the dwCertEncodingType.
  2663. '
  2664. ' For *_STR_A, pvFindPara points to a null terminated character string.
  2665. ' For *_STR_W, pvFindPara points to a null terminated wide character string.
  2666. '--------------------------------------------------------------------------
  2667. '+-------------------------------------------------------------------------
  2668. ' CERT_FIND_KEY_SPEC
  2669. '
  2670. ' Find a certificate having a CERT_KEY_SPEC_PROP_ID property matching
  2671. ' the specified KeySpec.
  2672. '
  2673. ' pvFindPara points to a DWORD containing the KeySpec.
  2674. '--------------------------------------------------------------------------
  2675. '+-------------------------------------------------------------------------
  2676. ' CERT_FIND_ENHKEY_USAGE
  2677. '
  2678. ' Find a certificate having the szOID_ENHANCED_KEY_USAGE extension or
  2679. ' the CERT_ENHKEY_USAGE_PROP_ID and matching the specified pszUsageIdentifers.
  2680. '
  2681. ' pvFindPara points to a CERT_ENHKEY_USAGE data structure. If pvFindPara
  2682. ' is NULL or CERT_ENHKEY_USAGE's cUsageIdentifier is 0, then, matches any
  2683. ' certificate having enhanced key usage.
  2684. '
  2685. ' The CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG can be set in dwFindFlags to
  2686. ' also match a certificate without either the extension or property.
  2687. '
  2688. ' If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set in dwFindFlags, finds
  2689. ' certificates without the key usage extension or property. Setting this
  2690. ' flag takes precedence over pvFindPara being NULL.
  2691. '
  2692. ' If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only does a match
  2693. ' using the extension. If pvFindPara is NULL or cUsageIdentifier is set to
  2694. ' 0, finds certificates having the extension. If
  2695. ' CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  2696. ' without the extension. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  2697. ' certificates without the extension.
  2698. '
  2699. ' If the CERT_FIND_EXT_PROP_ENHKEY_USAGE_FLAG is set, then, only does a match
  2700. ' using the property. If pvFindPara is NULL or cUsageIdentifier is set to
  2701. ' 0, finds certificates having the property. If
  2702. ' CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG is set, also matches a certificate
  2703. ' without the property. If CERT_FIND_NO_ENHKEY_USAGE_FLAG is set, finds
  2704. ' certificates without the property.
  2705. '--------------------------------------------------------------------------
  2706. Public Const CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG As Long = &H1
  2707. Public Const CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG As Long = &H2
  2708. Public Const CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG As Long = &H4
  2709. Public Const CERT_FIND_NO_ENHKEY_USAGE_FLAG As Long = &H8
  2710. '+-------------------------------------------------------------------------
  2711. ' Get the certificate context from the store for the first or next issuer
  2712. ' of the specified subject certificate. Perform the enabled
  2713. ' using the returned issuer certificate.)
  2714. '
  2715. ' If the first or next issuer certificate isn't found, NULL is returned.
  2716. ' Otherwise, a pointer to a read only CERT_CONTEXT is returned. CERT_CONTEXT
  2717. ' must be freed by calling CertFreeCertificateContext or is freed when passed as the
  2718. ' pPrevIssuerContext on a subsequent call. CertDuplicateCertificateContext
  2719. ' can be called to make a duplicate.
  2720. '
  2721. ' For a self signed subject certificate, NULL is returned with LastError set
  2722. ' to CERT_STORE_SELF_SIGNED. The enabled verification checks are still done.
  2723. '
  2724. ' The pSubjectContext may have been obtained from this store, another store
  2725. ' or created by the caller application. When created by the caller, the
  2726. ' CertCreateCertificateContext function must have been called.
  2727. '
  2728. ' An issuer may have multiple certificates. This may occur when the validity
  2729. ' period is about to change. pPrevIssuerContext MUST BE NULL on the first
  2730. ' call to get the issuer. To get the next certificate for the issuer, the
  2731. ' pPrevIssuerContext is set to the CERT_CONTEXT returned by a previous call.
  2732. '
  2733. ' NOTE: a NON-NULL pPrevIssuerContext is always CertFreeCertificateContext'ed by
  2734. ' this function, even for an error.
  2735. '
  2736. ' The following flags can be set in *pdwFlags to enable verification checks
  2737. ' on the subject certificate context:
  2738. ' CERT_STORE_SIGNATURE_FLAG - use the public key in the returned
  2739. ' issuer certificate to verify the
  2740. ' signature on the subject certificate.
  2741. ' Note, if pSubjectContext->hCertStore ==
  2742. ' hCertStore, the store provider might
  2743. ' be able to eliminate a redo of
  2744. ' the signature verify.
  2745. ' CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  2746. ' its within the subject certificate's
  2747. ' validity period
  2748. ' CERT_STORE_REVOCATION_FLAG - check if the subject certificate is on
  2749. ' the issuer's revocation list
  2750. '
  2751. ' If an enabled verification check fails, then, its flag is set upon return.
  2752. ' If CERT_STORE_REVOCATION_FLAG was enabled and the issuer doesn't have a
  2753. ' CRL in the store, then, CERT_STORE_NO_CRL_FLAG is set in addition to
  2754. ' the CERT_STORE_REVOCATION_FLAG.
  2755. '
  2756. ' If CERT_STORE_SIGNATURE_FLAG or CERT_STORE_REVOCATION_FLAG is set, then,
  2757. ' CERT_STORE_NO_ISSUER_FLAG is set if it doesn't have an issuer certificate
  2758. ' in the store.
  2759. '
  2760. ' For a verification check failure, a pointer to the issuer's CERT_CONTEXT
  2761. ' is still returned and SetLastError isn't updated.
  2762. '--------------------------------------------------------------------------
  2763. '+-------------------------------------------------------------------------
  2764. ' Perform the enabled verification checks on the subject certificate
  2765. ' using the issuer. Same checks and flags definitions as for the above
  2766. ' CertGetIssuerCertificateFromStore.
  2767. '
  2768. ' If you are only checking CERT_STORE_TIME_VALIDITY_FLAG, then, the
  2769. ' issuer can be NULL.
  2770. '
  2771. ' For a verification check failure, SUCCESS is still returned.
  2772. '--------------------------------------------------------------------------
  2773. '+-------------------------------------------------------------------------
  2774. ' Duplicate a certificate context
  2775. '--------------------------------------------------------------------------
  2776. '+-------------------------------------------------------------------------
  2777. ' Create a certificate context from the encoded certificate. The created
  2778. ' context isn't put in a store.
  2779. '
  2780. ' Makes a copy of the encoded certificate in the created context.
  2781. '
  2782. ' If unable to decode and create the certificate context, NULL is returned.
  2783. ' Otherwise, a pointer to a read only CERT_CONTEXT is returned.
  2784. ' CERT_CONTEXT must be freed by calling CertFreeCertificateContext.
  2785. ' CertDuplicateCertificateContext can be called to make a duplicate.
  2786. '
  2787. ' CertSetCertificateContextProperty and CertGetCertificateContextProperty can be called
  2788. ' to store properties for the certificate.
  2789. '--------------------------------------------------------------------------
  2790. '+-------------------------------------------------------------------------
  2791. ' Free a certificate context
  2792. '
  2793. ' There needs to be a corresponding free for each context obtained by a
  2794. ' get, find, duplicate or create.
  2795. '--------------------------------------------------------------------------
  2796. '+-------------------------------------------------------------------------
  2797. ' Set the property for the specified certificate context.
  2798. '
  2799. ' The type definition for pvData depends on the dwPropId value. There are
  2800. ' five predefined types:
  2801. ' CERT_KEY_PROV_HANDLE_PROP_ID - a HCRYPTPROV for the certificate's
  2802. ' private key is passed in pvData. Updates the hCryptProv field
  2803. ' of the CERT_KEY_CONTEXT_PROP_ID. If the CERT_KEY_CONTEXT_PROP_ID
  2804. ' doesn't exist, its created with all the other fields zeroed out. If
  2805. ' CERT_STORE_NO_CRYPT_RELEASE_FLAG isn't set, HCRYPTPROV is implicitly
  2806. ' released when either the property is set to NULL or on the final
  2807. ' free of the CertContext.
  2808. '
  2809. ' CERT_KEY_PROV_INFO_PROP_ID - a PCRYPT_KEY_PROV_INFO for the certificate's
  2810. ' private key is passed in pvData.
  2811. '
  2812. ' CERT_SHA1_HASH_PROP_ID -
  2813. ' CERT_MD5_HASH_PROP_ID - normally, either property is implicitly
  2814. ' set by doing a CertGetCertificateContextProperty. pvData points to a
  2815. ' CRYPT_HASH_BLOB.
  2816. '
  2817. ' CERT_KEY_CONTEXT_PROP_ID - a PCERT_KEY_CONTEXT for the certificate's
  2818. ' private key is passed in pvData. The CERT_KEY_CONTEXT contains both the
  2819. ' hCryptProv and dwKeySpec for the private key.
  2820. ' See the CERT_KEY_PROV_HANDLE_PROP_ID for more information about
  2821. ' the hCryptProv field and dwFlags settings. Note, more fields may
  2822. ' be added for this property. The cbSize field value will be adjusted
  2823. ' accordingly.
  2824. '
  2825. ' CERT_KEY_SPEC_PROP_ID - the dwKeySpec for the private key. pvData
  2826. ' points to a DWORD containing the KeySpec
  2827. '
  2828. ' CERT_ENHKEY_USAGE_PROP_ID - enhanced key usage definition for the
  2829. ' certificate. pvData points to a CRYPT_DATA_BLOB containing an
  2830. '
  2831. ' CERT_NEXT_UPDATE_LOCATION_PROP_ID - location of the next update.
  2832. ' Currently only applicable to CTLs. pvData points to a CRYPT_DATA_BLOB
  2833. '
  2834. ' CERT_FRIENDLY_NAME_PROP_ID - friendly name for the cert, CRL or CTL.
  2835. ' pvData points to a CRYPT_DATA_BLOB. pbData is a pointer to a NULL
  2836. ' terminated unicode, wide character string.
  2837. '
  2838. ' For all the other PROP_IDs: an encoded PCRYPT_DATA_BLOB is passed in pvData.
  2839. '
  2840. ' If the property already exists, then, the old value is deleted and silently
  2841. ' replaced. Setting, pvData to NULL, deletes the property.
  2842. '--------------------------------------------------------------------------
  2843. '+-------------------------------------------------------------------------
  2844. ' Get the property for the specified certificate context.
  2845. '
  2846. ' For CERT_KEY_PROV_HANDLE_PROP_ID, pvData points to a HCRYPTPROV.
  2847. '
  2848. ' For CERT_KEY_PROV_INFO_PROP_ID, pvData points to a CRYPT_KEY_PROV_INFO structure.
  2849. ' Elements pointed to by fields in the pvData structure follow the
  2850. ' structure. Therefore, *pcbData may exceed the size of the structure.
  2851. '
  2852. ' For CERT_KEY_CONTEXT_PROP_ID, pvData points to a CERT_KEY_CONTEXT structure.
  2853. '
  2854. ' For CERT_KEY_SPEC_PROP_ID, pvData points to a DWORD containing the KeySpec.
  2855. ' If the CERT_KEY_CONTEXT_PROP_ID exists, the KeySpec is obtained from there.
  2856. ' Otherwise, if the CERT_KEY_PROV_INFO_PROP_ID exists, its the source
  2857. ' of the KeySpec.
  2858. '
  2859. ' For CERT_SHA1_HASH_PROP_ID or CERT_MD5_HASH_PROP_ID, if the hash
  2860. ' and then set. pvData points to the computed hash. Normally, the length
  2861. ' is 20 bytes for SHA and 16 for MD5.
  2862. '
  2863. ' For all other PROP_IDs, pvData points to an encoded array of bytes.
  2864. '--------------------------------------------------------------------------
  2865. '+-------------------------------------------------------------------------
  2866. ' Enumerate the properties for the specified certificate context.
  2867. '
  2868. ' To get the first property, set dwPropId to 0. The ID of the first
  2869. ' property is returned. To get the next property, set dwPropId to the
  2870. ' ID returned by the last call. To enumerate all the properties continue
  2871. ' until 0 is returned.
  2872. '
  2873. ' CertGetCertificateContextProperty is called to get the property's data.
  2874. '
  2875. ' Note, since, the CERT_KEY_PROV_HANDLE_PROP_ID and CERT_KEY_SPEC_PROP_ID
  2876. ' properties are stored as fields in the CERT_KEY_CONTEXT_PROP_ID
  2877. ' property, they aren't enumerated individually.
  2878. '--------------------------------------------------------------------------
  2879. '+-------------------------------------------------------------------------
  2880. ' Get the first or next CRL context from the store for the specified
  2881. ' issuer certificate. Perform the enabled verification checks on the CRL.
  2882. '
  2883. ' If the first or next CRL isn't found, NULL is returned.
  2884. ' Otherwise, a pointer to a read only CRL_CONTEXT is returned. CRL_CONTEXT
  2885. ' must be freed by calling CertFreeCRLContext. However, the free must be
  2886. ' pPrevCrlContext on a subsequent call. CertDuplicateCRLContext
  2887. ' can be called to make a duplicate.
  2888. '
  2889. ' The pIssuerContext may have been obtained from this store, another store
  2890. ' or created by the caller application. When created by the caller, the
  2891. ' CertCreateCertificateContext function must have been called.
  2892. '
  2893. ' If pIssuerContext == NULL, finds all the CRLs in the store.
  2894. '
  2895. ' An issuer may have multiple CRLs. For example, it generates delta CRLs
  2896. ' using a X.509 v3 extension. pPrevCrlContext MUST BE NULL on the first
  2897. ' call to get the CRL. To get the next CRL for the issuer, the
  2898. ' pPrevCrlContext is set to the CRL_CONTEXT returned by a previous call.
  2899. '
  2900. ' NOTE: a NON-NULL pPrevCrlContext is always CertFreeCRLContext'ed by
  2901. ' this function, even for an error.
  2902. '
  2903. ' The following flags can be set in *pdwFlags to enable verification checks
  2904. ' on the returned CRL:
  2905. ' CERT_STORE_SIGNATURE_FLAG - use the public key in the
  2906. ' issuer's certificate to verify the
  2907. ' signature on the returned CRL.
  2908. ' Note, if pIssuerContext->hCertStore ==
  2909. ' hCertStore, the store provider might
  2910. ' be able to eliminate a redo of
  2911. ' the signature verify.
  2912. ' CERT_STORE_TIME_VALIDITY_FLAG - get the current time and verify that
  2913. ' its within the CRL's ThisUpdate and
  2914. ' NextUpdate validity period.
  2915. '
  2916. ' If an enabled verification check fails, then, its flag is set upon return.
  2917. '
  2918. ' If pIssuerContext == NULL, then, an enabled CERT_STORE_SIGNATURE_FLAG
  2919. ' always fails and the CERT_STORE_NO_ISSUER_FLAG is also set.
  2920. '
  2921. ' For a verification check failure, a pointer to the first or next
  2922. ' CRL_CONTEXT is still returned and SetLastError isn't updated.
  2923. '--------------------------------------------------------------------------
  2924. '+-------------------------------------------------------------------------
  2925. ' Duplicate a CRL context
  2926. '--------------------------------------------------------------------------
  2927. '+-------------------------------------------------------------------------
  2928. ' Create a CRL context from the encoded CRL. The created
  2929. ' context isn't put in a store.
  2930. '
  2931. ' Makes a copy of the encoded CRL in the created context.
  2932. '
  2933. ' If unable to decode and create the CRL context, NULL is returned.
  2934. ' Otherwise, a pointer to a read only CRL_CONTEXT is returned.
  2935. ' CRL_CONTEXT must be freed by calling CertFreeCRLContext.
  2936. ' CertDuplicateCRLContext can be called to make a duplicate.
  2937. '
  2938. ' CertSetCRLContextProperty and CertGetCRLContextProperty can be called
  2939. ' to store properties for the CRL.
  2940. '--------------------------------------------------------------------------
  2941. '+-------------------------------------------------------------------------
  2942. ' Free a CRL context
  2943. '
  2944. ' There needs to be a corresponding free for each context obtained by a
  2945. ' get, duplicate or create.
  2946. '--------------------------------------------------------------------------
  2947. '+-------------------------------------------------------------------------
  2948. ' Set the property for the specified CRL context.
  2949. '
  2950. ' Same Property Ids and semantics as CertSetCertificateContextProperty.
  2951. '--------------------------------------------------------------------------
  2952. '+-------------------------------------------------------------------------
  2953. ' Get the property for the specified CRL context.
  2954. '
  2955. ' Same Property Ids and semantics as CertGetCertificateContextProperty.
  2956. '
  2957. ' CERT_SHA1_HASH_PROP_ID or CERT_MD5_HASH_PROP_ID is the predefined
  2958. ' property of most interest.
  2959. '--------------------------------------------------------------------------
  2960. '+-------------------------------------------------------------------------
  2961. ' Enumerate the properties for the specified CRL context.
  2962. '
  2963. ' To get the first property, set dwPropId to 0. The ID of the first
  2964. ' property is returned. To get the next property, set dwPropId to the
  2965. ' ID returned by the last call. To enumerate all the properties continue
  2966. ' until 0 is returned.
  2967. '
  2968. ' CertGetCRLContextProperty is called to get the property's data.
  2969. '--------------------------------------------------------------------------
  2970. '+-------------------------------------------------------------------------
  2971. ' Add certificate/CRL, encoded, context or element disposition values.
  2972. '--------------------------------------------------------------------------
  2973. Public Const CERT_STORE_ADD_NEW As Long = 1
  2974. Public Const CERT_STORE_ADD_USE_EXISTING As Long = 2
  2975. Public Const CERT_STORE_ADD_REPLACE_EXISTING As Long = 3
  2976. Public Const CERT_STORE_ADD_ALWAYS As Long = 4
  2977. '+-------------------------------------------------------------------------
  2978. ' Add the encoded certificate to the store according to the specified
  2979. ' disposition action.
  2980. '
  2981. ' Makes a copy of the encoded certificate before adding to the store.
  2982. '
  2983. ' dwAddDispostion specifies the action to take if the certificate
  2984. ' already exists in the store. This parameter must be one of the following
  2985. ' values:
  2986. ' CERT_STORE_ADD_NEW
  2987. ' Fails if the certificate already exists in the store. LastError
  2988. ' is set to CRYPT_E_EXISTS.
  2989. ' CERT_STORE_ADD_USE_EXISTING
  2990. ' If the certifcate already exists, then, its used and if ppCertContext
  2991. ' is non-NULL, the existing context is duplicated.
  2992. ' CERT_STORE_ADD_REPLACE_EXISTING
  2993. ' If the certificate already exists, then, the existing certificate
  2994. ' context is deleted before creating and adding the new context.
  2995. ' CERT_STORE_ADD_ALWAYS
  2996. ' No check is made to see if the certificate already exists. A
  2997. ' new certificate context is always created. This may lead to
  2998. ' duplicates in the store.
  2999. '
  3000. ' CertGetSubjectCertificateFromStore is called to determine if the
  3001. ' certificate already exists in the store.
  3002. '
  3003. ' ppCertContext can be NULL, indicating the caller isn't interested
  3004. ' in getting the CERT_CONTEXT of the added or existing certificate.
  3005. '--------------------------------------------------------------------------
  3006. '+-------------------------------------------------------------------------
  3007. ' Add the certificate context to the store according to the specified
  3008. ' disposition action.
  3009. '
  3010. ' In addition to the encoded certificate, the context's properties are
  3011. ' CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  3012. '
  3013. ' Makes a copy of the certificate context before adding to the store.
  3014. '
  3015. ' dwAddDispostion specifies the action to take if the certificate
  3016. ' already exists in the store. This parameter must be one of the following
  3017. ' values:
  3018. ' CERT_STORE_ADD_NEW
  3019. ' Fails if the certificate already exists in the store. LastError
  3020. ' is set to CRYPT_E_EXISTS.
  3021. ' CERT_STORE_ADD_USE_EXISTING
  3022. ' If the certifcate already exists, then, its used and if ppStoreContext
  3023. ' is non-NULL, the existing context is duplicated. Iterates
  3024. ' through pCertContext's properties and only copies the properties
  3025. ' that don't already exist. The SHA1 and MD5 hash properties aren't
  3026. ' copied.
  3027. ' CERT_STORE_ADD_REPLACE_EXISTING
  3028. ' If the certificate already exists, then, the existing certificate
  3029. ' context is deleted before creating and adding a new context.
  3030. ' Properties are copied before doing the add.
  3031. ' CERT_STORE_ADD_ALWAYS
  3032. ' No check is made to see if the certificate already exists. A
  3033. ' new certificate context is always created and added. This may lead to
  3034. ' duplicates in the store. Properties are
  3035. ' copied before doing the add.
  3036. '
  3037. ' CertGetSubjectCertificateFromStore is called to determine if the
  3038. ' certificate already exists in the store.
  3039. '
  3040. ' ppStoreContext can be NULL, indicating the caller isn't interested
  3041. ' in getting the CERT_CONTEXT of the added or existing certificate.
  3042. '--------------------------------------------------------------------------
  3043. '+-------------------------------------------------------------------------
  3044. ' Certificate Store Context Types
  3045. '--------------------------------------------------------------------------
  3046. Public Const CERT_STORE_CERTIFICATE_CONTEXT As Long = 1
  3047. Public Const CERT_STORE_CRL_CONTEXT As Long = 2
  3048. Public Const CERT_STORE_CTL_CONTEXT As Long = 3
  3049. '+-------------------------------------------------------------------------
  3050. ' Certificate Store Context Bit Flags
  3051. '--------------------------------------------------------------------------
  3052. '+-------------------------------------------------------------------------
  3053. ' Add the serialized certificate or CRL element to the store.
  3054. '
  3055. ' The serialized element contains the encoded certificate, CRL or CTL and
  3056. ' its properties, such as, CERT_KEY_PROV_INFO_PROP_ID.
  3057. '
  3058. ' If hCertStore is NULL, creates a certificate, CRL or CTL context not
  3059. ' residing in any store.
  3060. '
  3061. ' dwAddDispostion specifies the action to take if the certificate or CRL
  3062. ' already exists in the store. See CertAddCertificateContextToStore for a
  3063. ' list of and actions taken.
  3064. '
  3065. ' dwFlags currently isn't used and should be set to 0.
  3066. '
  3067. ' dwContextTypeFlags specifies the set of allowable contexts. For example, to
  3068. ' add either a certificate or CRL, set dwContextTypeFlags to:
  3069. ' CERT_STORE_CERTIFICATE_CONTEXT_FLAG | CERT_STORE_CRL_CONTEXT_FLAG
  3070. '
  3071. ' *pdwContextType is updated with the type of the context returned in
  3072. ' *ppvContxt. pdwContextType or ppvContext can be NULL, indicating the
  3073. ' caller isn't interested in getting the output. If *ppvContext is
  3074. ' returned it must be freed by calling CertFreeCertificateContext or
  3075. ' CertFreeCRLContext.
  3076. '--------------------------------------------------------------------------
  3077. '+-------------------------------------------------------------------------
  3078. ' Delete the specified certificate from the store.
  3079. '
  3080. ' All subsequent gets or finds for the certificate will fail. However,
  3081. ' memory allocated for the certificate isn't freed until all of its contexts
  3082. ' have also been freed.
  3083. '
  3084. ' The pCertContext is obtained from a get, enum, find or duplicate.
  3085. '
  3086. ' Some store provider implementations might also delete the issuer's CRLs
  3087. ' if this is the last certificate for the issuer in the store.
  3088. '
  3089. ' NOTE: the pCertContext is always CertFreeCertificateContext'ed by
  3090. ' this function, even for an error.
  3091. '--------------------------------------------------------------------------
  3092. '+-------------------------------------------------------------------------
  3093. ' Add the encoded CRL to the store according to the specified
  3094. ' disposition option.
  3095. '
  3096. ' Makes a copy of the encoded CRL before adding to the store.
  3097. '
  3098. ' dwAddDispostion specifies the action to take if the CRL
  3099. ' already exists in the store. See CertAddEncodedCertificateToStore for a
  3100. ' list of and actions taken.
  3101. '
  3102. ' Compares the CRL's Issuer to determine if the CRL already exists in the
  3103. ' store.
  3104. '
  3105. ' ppCrlContext can be NULL, indicating the caller isn't interested
  3106. ' in getting the CRL_CONTEXT of the added or existing CRL.
  3107. '--------------------------------------------------------------------------
  3108. '+-------------------------------------------------------------------------
  3109. ' Add the CRL context to the store according to the specified
  3110. ' disposition option.
  3111. '
  3112. ' In addition to the encoded CRL, the context's properties are
  3113. ' CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  3114. '
  3115. ' Makes a copy of the encoded CRL before adding to the store.
  3116. '
  3117. ' dwAddDispostion specifies the action to take if the CRL
  3118. ' already exists in the store. See CertAddCertificateContextToStore for a
  3119. ' list of and actions taken.
  3120. '
  3121. ' Compares the CRL's Issuer, ThisUpdate and NextUpdate to determine
  3122. ' if the CRL already exists in the store.
  3123. '
  3124. ' ppStoreContext can be NULL, indicating the caller isn't interested
  3125. ' in getting the CRL_CONTEXT of the added or existing CRL.
  3126. '--------------------------------------------------------------------------
  3127. '+-------------------------------------------------------------------------
  3128. ' Delete the specified CRL from the store.
  3129. '
  3130. ' All subsequent gets for the CRL will fail. However,
  3131. ' memory allocated for the CRL isn't freed until all of its contexts
  3132. ' have also been freed.
  3133. '
  3134. ' The pCrlContext is obtained from a get or duplicate.
  3135. '
  3136. ' NOTE: the pCrlContext is always CertFreeCRLContext'ed by
  3137. ' this function, even for an error.
  3138. '--------------------------------------------------------------------------
  3139. '+-------------------------------------------------------------------------
  3140. ' Serialize the certificate context's encoded certificate and its
  3141. ' properties.
  3142. '--------------------------------------------------------------------------
  3143. '+-------------------------------------------------------------------------
  3144. ' Serialize the CRL context's encoded CRL and its properties.
  3145. '--------------------------------------------------------------------------
  3146. '+=========================================================================
  3147. '==========================================================================
  3148. '+-------------------------------------------------------------------------
  3149. ' Duplicate a CTL context
  3150. '--------------------------------------------------------------------------
  3151. '+-------------------------------------------------------------------------
  3152. ' Create a CTL context from the encoded CTL. The created
  3153. ' context isn't put in a store.
  3154. '
  3155. ' Makes a copy of the encoded CTL in the created context.
  3156. '
  3157. ' If unable to decode and create the CTL context, NULL is returned.
  3158. ' Otherwise, a pointer to a read only CTL_CONTEXT is returned.
  3159. ' CTL_CONTEXT must be freed by calling CertFreeCTLContext.
  3160. ' CertDuplicateCTLContext can be called to make a duplicate.
  3161. '
  3162. ' CertSetCTLContextProperty and CertGetCTLContextProperty can be called
  3163. ' to store properties for the CTL.
  3164. '--------------------------------------------------------------------------
  3165. '+-------------------------------------------------------------------------
  3166. ' Free a CTL context
  3167. '
  3168. ' There needs to be a corresponding free for each context obtained by a
  3169. ' get, duplicate or create.
  3170. '--------------------------------------------------------------------------
  3171. '+-------------------------------------------------------------------------
  3172. ' Set the property for the specified CTL context.
  3173. '
  3174. ' Same Property Ids and semantics as CertSetCertificateContextProperty.
  3175. '--------------------------------------------------------------------------
  3176. '+-------------------------------------------------------------------------
  3177. ' Get the property for the specified CTL context.
  3178. '
  3179. ' Same Property Ids and semantics as CertGetCertificateContextProperty.
  3180. '
  3181. ' CERT_SHA1_HASH_PROP_ID or CERT_NEXT_UPDATE_LOCATION_PROP_ID are the
  3182. ' predefined properties of most interest.
  3183. '--------------------------------------------------------------------------
  3184. '+-------------------------------------------------------------------------
  3185. ' Enumerate the properties for the specified CTL context.
  3186. '--------------------------------------------------------------------------
  3187. '+-------------------------------------------------------------------------
  3188. ' Enumerate the CTL contexts in the store.
  3189. '
  3190. ' If a CTL isn't found, NULL is returned.
  3191. ' Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  3192. ' must be freed by calling CertFreeCTLContext or is freed when passed as the
  3193. ' pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  3194. ' can be called to make a duplicate.
  3195. '
  3196. ' pPrevCtlContext MUST BE NULL to enumerate the first
  3197. ' CTL in the store. Successive CTLs are enumerated by setting
  3198. ' pPrevCtlContext to the CTL_CONTEXT returned by a previous call.
  3199. '
  3200. ' NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  3201. ' this function, even for an error.
  3202. '--------------------------------------------------------------------------
  3203. '+-------------------------------------------------------------------------
  3204. ' Attempt to find the specified subject in the CTL.
  3205. '
  3206. ' For CTL_CERT_SUBJECT_TYPE, pvSubject points to a CERT_CONTEXT. The CTL's
  3207. ' SubjectAlgorithm is examined to determine the representation of the
  3208. ' subject's identity. Initially, only SHA1 or MD5 hash will be supported.
  3209. ' The appropriate hash property is obtained from the CERT_CONTEXT.
  3210. '
  3211. ' For CTL_ANY_SUBJECT_TYPE, pvSubject points to the CTL_ANY_SUBJECT_INFO
  3212. ' structure which contains the SubjectAlgorithm to be matched in the CTL
  3213. ' and the SubjectIdentifer to be matched in one of the CTL entries.
  3214. '
  3215. ' The certificate's hash or the CTL_ANY_SUBJECT_INFO's SubjectIdentifier
  3216. ' is used as the key in searching the subject entries. A binary
  3217. ' memory comparison is done between the key and the entry's SubjectIdentifer.
  3218. '
  3219. ' dwEncodingType isn't used for either of the above SubjectTypes.
  3220. '--------------------------------------------------------------------------
  3221. ' Subject Types:
  3222. ' CTL_ANY_SUBJECT_TYPE, pvSubject points to following CTL_ANY_SUBJECT_INFO.
  3223. ' CTL_CERT_SUBJECT_TYPE, pvSubject points to CERT_CONTEXT.
  3224. Public Const CTL_ANY_SUBJECT_TYPE As Long = 1
  3225. Public Const CTL_CERT_SUBJECT_TYPE As Long = 2
  3226. '+-------------------------------------------------------------------------
  3227. ' Find the first or next CTL context in the store.
  3228. '
  3229. ' The CTL is found according to the dwFindType and its pvFindPara.
  3230. ' See below for a list of the find types and its parameters.
  3231. '
  3232. ' Currently dwFindFlags isn't used and must be set to 0.
  3233. '
  3234. ' Usage of dwMsgAndCertEncodingType depends on the dwFindType.
  3235. '
  3236. ' If the first or next CTL isn't found, NULL is returned.
  3237. ' Otherwise, a pointer to a read only CTL_CONTEXT is returned. CTL_CONTEXT
  3238. ' must be freed by calling CertFreeCTLContext or is freed when passed as the
  3239. ' pPrevCtlContext on a subsequent call. CertDuplicateCTLContext
  3240. ' can be called to make a duplicate.
  3241. '
  3242. ' pPrevCtlContext MUST BE NULL on the first
  3243. ' call to find the CTL. To find the next CTL, the
  3244. ' pPrevCtlContext is set to the CTL_CONTEXT returned by a previous call.
  3245. '
  3246. ' NOTE: a NON-NULL pPrevCtlContext is always CertFreeCTLContext'ed by
  3247. ' this function, even for an error.
  3248. '--------------------------------------------------------------------------
  3249. Public Const CTL_FIND_ANY As Long = 0
  3250. Public Const CTL_FIND_SHA1_HASH As Long = 1
  3251. Public Const CTL_FIND_MD5_HASH As Long = 2
  3252. Public Const CTL_FIND_USAGE As Long = 3
  3253. Public Const CTL_FIND_SUBJECT As Long = 4
  3254. Public Const CTL_FIND_NO_LIST_ID_CBDATA As Long = &HFFFFFFFF
  3255. Public Const CTL_FIND_SAME_USAGE_FLAG As Long = &H1
  3256. '+-------------------------------------------------------------------------
  3257. ' CTL_FIND_ANY
  3258. '
  3259. ' Find any CTL.
  3260. '
  3261. ' pvFindPara isn't used.
  3262. '--------------------------------------------------------------------------
  3263. '+-------------------------------------------------------------------------
  3264. ' CTL_FIND_SHA1_HASH
  3265. ' CTL_FIND_MD5_HASH
  3266. '
  3267. ' Find a CTL with the specified hash.
  3268. '
  3269. ' pvFindPara points to a CRYPT_HASH_BLOB.
  3270. '--------------------------------------------------------------------------
  3271. '+-------------------------------------------------------------------------
  3272. ' CTL_FIND_USAGE
  3273. '
  3274. ' Find a CTL having the specified usage identifiers, list identifier or
  3275. ' signer. The CertEncodingType of the signer is obtained from the
  3276. ' dwMsgAndCertEncodingType parameter.
  3277. '
  3278. ' pvFindPara points to a CTL_FIND_USAGE_PARA data structure. The
  3279. ' SubjectUsage.cUsageIdentifer can be 0 to match any usage. The
  3280. ' ListIdentifier.cbData can be 0 to match any list identifier. To only match
  3281. ' CTLs without a ListIdentifier, cbData must be set to
  3282. ' CTL_FIND_NO_LIST_ID_CBDATA. pSigner can be NULL to match any signer. Only
  3283. ' the Issuer and SerialNumber fields of the pSigner's PCERT_INFO are used.
  3284. ' To only match CTLs without a signer, pSigner must be set to
  3285. ' CTL_FIND_NO_SIGNER_PTR.
  3286. '
  3287. ' The CTL_FIND_SAME_USAGE_FLAG can be set in dwFindFlags to
  3288. ' only match CTLs with the same usage identifiers. CTLs having additional
  3289. ' usage identifiers aren't matched. For example, if only "1.2.3" is specified
  3290. ' in CTL_FIND_USAGE_PARA, then, for a match, the CTL must only contain
  3291. ' "1.2.3" and not any additional usage identifers.
  3292. '--------------------------------------------------------------------------
  3293. '+-------------------------------------------------------------------------
  3294. ' CTL_FIND_SUBJECT
  3295. '
  3296. ' Find a CTL having the specified subject. CertFindSubjectInCTL can be
  3297. ' called to get a pointer to the subject's entry in the CTL. pUsagePara can
  3298. ' optionally be set to enable the above CTL_FIND_USAGE matching.
  3299. '
  3300. ' pvFindPara points to a CTL_FIND_SUBJECT_PARA data structure.
  3301. '--------------------------------------------------------------------------
  3302. '+-------------------------------------------------------------------------
  3303. ' Add the encoded CTL to the store according to the specified
  3304. ' disposition option.
  3305. '
  3306. ' Makes a copy of the encoded CTL before adding to the store.
  3307. '
  3308. ' dwAddDispostion specifies the action to take if the CTL
  3309. ' already exists in the store. See CertAddEncodedCertificateToStore for a
  3310. ' list of and actions taken.
  3311. '
  3312. ' Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  3313. ' to determine if the CTL already exists in the store.
  3314. '
  3315. ' ppCtlContext can be NULL, indicating the caller isn't interested
  3316. ' in getting the CTL_CONTEXT of the added or existing CTL.
  3317. '--------------------------------------------------------------------------
  3318. '+-------------------------------------------------------------------------
  3319. ' Add the CTL context to the store according to the specified
  3320. ' disposition option.
  3321. '
  3322. ' In addition to the encoded CTL, the context's properties are
  3323. ' CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_SPEC_PROP_ID) isn't copied.
  3324. '
  3325. ' Makes a copy of the encoded CTL before adding to the store.
  3326. '
  3327. ' dwAddDispostion specifies the action to take if the CTL
  3328. ' already exists in the store. See CertAddCertificateContextToStore for a
  3329. ' list of and actions taken.
  3330. '
  3331. ' Compares the CTL's SubjectUsage, ListIdentifier and any of its signers
  3332. ' to determine if the CTL already exists in the store.
  3333. '
  3334. ' ppStoreContext can be NULL, indicating the caller isn't interested
  3335. ' in getting the CTL_CONTEXT of the added or existing CTL.
  3336. '--------------------------------------------------------------------------
  3337. '+-------------------------------------------------------------------------
  3338. ' Serialize the CTL context's encoded CTL and its properties.
  3339. '--------------------------------------------------------------------------
  3340. '+-------------------------------------------------------------------------
  3341. ' Delete the specified CTL from the store.
  3342. '
  3343. ' All subsequent gets for the CTL will fail. However,
  3344. ' memory allocated for the CTL isn't freed until all of its contexts
  3345. ' have also been freed.
  3346. '
  3347. ' The pCtlContext is obtained from a get or duplicate.
  3348. '
  3349. ' NOTE: the pCtlContext is always CertFreeCTLContext'ed by
  3350. ' this function, even for an error.
  3351. '--------------------------------------------------------------------------
  3352. '+=========================================================================
  3353. ' Enhanced Key Usage Helper Functions
  3354. '==========================================================================
  3355. '+-------------------------------------------------------------------------
  3356. ' Get the enhanced key usage extension or property from the certificate
  3357. ' and decode.
  3358. '
  3359. ' If the CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  3360. ' extension.
  3361. '
  3362. ' If the CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG is set, then, only get the
  3363. ' property.
  3364. '--------------------------------------------------------------------------
  3365. '+-------------------------------------------------------------------------
  3366. ' Set the enhanced key usage property for the certificate.
  3367. '--------------------------------------------------------------------------
  3368. '+-------------------------------------------------------------------------
  3369. ' Add the usage identifier to the certificate's enhanced key usage property.
  3370. '--------------------------------------------------------------------------
  3371. '+-------------------------------------------------------------------------
  3372. ' Remove the usage identifier from the certificate's enhanced key usage
  3373. ' property.
  3374. '--------------------------------------------------------------------------
  3375. '+=========================================================================
  3376. ' Cryptographic Message helper functions for verifying and signing a
  3377. ' CTL.
  3378. '==========================================================================
  3379. '+-------------------------------------------------------------------------
  3380. ' Get and verify the signer of a cryptographic message.
  3381. '
  3382. ' To verify a CTL, the hCryptMsg is obtained from the CTL_CONTEXT's
  3383. ' hCryptMsg field.
  3384. '
  3385. ' If CMSG_TRUSTED_SIGNER_FLAG is set, then, treat the Signer stores as being
  3386. ' trusted and only search them to find the certificate corresponding to the
  3387. ' signer's issuer and serial number. Otherwise, the SignerStores are
  3388. ' optionally provided to supplement the message's store of certificates.
  3389. ' If a signer certificate is found, its public key is used to verify
  3390. ' the message signature. The CMSG_SIGNER_ONLY_FLAG can be set to
  3391. ' return the signer without doing the signature verify.
  3392. '
  3393. ' If CMSG_USE_SIGNER_INDEX_FLAG is set, then, only get the signer specified
  3394. ' by *pdwSignerIndex. Otherwise, iterate through all the signers
  3395. ' until a signer verifies or no more signers.
  3396. '
  3397. ' For a verified signature, *ppSigner is updated with certificate context
  3398. ' of the signer and *pdwSignerIndex is updated with the index of the signer.
  3399. ' ppSigner and/or pdwSignerIndex can be NULL, indicating the caller isn't
  3400. ' interested in getting the CertContext and/or index of the signer.
  3401. '--------------------------------------------------------------------------
  3402. Public Const CMSG_TRUSTED_SIGNER_FLAG As Long = &H1
  3403. Public Const CMSG_SIGNER_ONLY_FLAG As Long = &H2
  3404. Public Const CMSG_USE_SIGNER_INDEX_FLAG As Long = &H4
  3405. '+-------------------------------------------------------------------------
  3406. ' Sign an encoded CTL.
  3407. '
  3408. ' The pbCtlContent can be obtained via a CTL_CONTEXT's pbCtlContent
  3409. '--------------------------------------------------------------------------
  3410. '+-------------------------------------------------------------------------
  3411. ' Encode the CTL and create a signed message containing the encoded CTL.
  3412. '--------------------------------------------------------------------------
  3413. '+=========================================================================
  3414. ' Certificate Verify CTL Usage Data Structures and APIs
  3415. '==========================================================================
  3416. Public Const CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG As Long = &H1
  3417. Public Const CERT_VERIFY_TRUSTED_SIGNERS_FLAG As Long = &H2
  3418. Public Const CERT_VERIFY_NO_TIME_CHECK_FLAG As Long = &H4
  3419. Public Const CERT_VERIFY_ALLOW_MORE_USAGE_FLAG As Long = &H8
  3420. Public Const CERT_VERIFY_UPDATED_CTL_FLAG As Long = &H1
  3421. '+-------------------------------------------------------------------------
  3422. ' Verify that a subject is trusted for the specified usage by finding a
  3423. ' signed and time valid CTL with the usage identifiers and containing the
  3424. ' the subject. A subject can be identified by either its certificate context
  3425. ' or any identifier such as its SHA1 hash.
  3426. '
  3427. ' See CertFindSubjectInCTL for definition of dwSubjectType and pvSubject
  3428. ' parameters.
  3429. '
  3430. ' Via pVerifyUsagePara, the caller can specify the stores to be searched
  3431. ' to find the CTL. The caller can also specify the stores containing
  3432. ' acceptable CTL signers. By setting the ListIdentifier, the caller
  3433. ' can also restrict to a particular signer CTL list.
  3434. '
  3435. ' Via pVerifyUsageStatus, the CTL containing the subject, the subject's
  3436. ' index into the CTL's array of entries, and the signer of the CTL
  3437. ' are returned. If the caller is not interested, ppCtl and ppSigner can be set
  3438. ' to NULL. Returned contexts must be freed via the store's free context APIs.
  3439. '
  3440. ' If the CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG isn't set, then, a time
  3441. ' invalid CTL in one of the CtlStores may be replaced. When replaced, the
  3442. ' CERT_VERIFY_UPDATED_CTL_FLAG is set in pVerifyUsageStatus->dwFlags.
  3443. '
  3444. ' If the CERT_VERIFY_TRUSTED_SIGNERS_FLAG is set, then, only the
  3445. ' SignerStores specified in pVerifyUsageStatus are searched to find
  3446. ' the signer. Otherwise, the SignerStores provide additional sources
  3447. ' to find the signer's certificate.
  3448. '
  3449. ' If CERT_VERIFY_NO_TIME_CHECK_FLAG is set, then, the CTLs aren't checked
  3450. ' for time validity.
  3451. '
  3452. ' If CERT_VERIFY_ALLOW_MORE_USAGE_FLAG is set, then, the CTL may contain
  3453. ' additional usage identifiers than specified by pSubjectUsage. Otherwise,
  3454. ' the found CTL will contain the same usage identifers and no more.
  3455. '
  3456. ' CertVerifyCTLUsage will be implemented as a dispatcher to OID installable
  3457. ' functions. First, it will try to find an OID function matching the first
  3458. ' usage object identifier in the pUsage sequence. Next, it will dispatch
  3459. ' to the default CertDllVerifyCTLUsage functions.
  3460. '
  3461. ' If the subject is trusted for the specified usage, then, TRUE is
  3462. ' returned. Otherwise, FALSE is returned with dwError set to one of the
  3463. ' following:
  3464. ' CRYPT_E_NO_VERIFY_USAGE_DLL
  3465. ' CRYPT_E_NO_VERIFY_USAGE_CHECK
  3466. ' CRYPT_E_VERIFY_USAGE_OFFLINE
  3467. ' CRYPT_E_NOT_IN_CTL
  3468. ' CRYPT_E_NO_TRUSTED_SIGNER
  3469. '--------------------------------------------------------------------------
  3470. '+=========================================================================
  3471. ' Certificate Revocation Data Structures and APIs
  3472. '==========================================================================
  3473. '+-------------------------------------------------------------------------
  3474. ' The following data structure may be passed to CertVerifyRevocation to
  3475. ' assist in finding the issuer of the context to be verified.
  3476. '
  3477. ' When pIssuerCert is specified, pIssuerCert is the issuer of
  3478. ' rgpvContext[cContext - 1].
  3479. '
  3480. ' When cCertStore and rgCertStore are specified, these stores may contain
  3481. ' an issuer certificate.
  3482. '--------------------------------------------------------------------------
  3483. '+-------------------------------------------------------------------------
  3484. ' The following data structure is returned by CertVerifyRevocation to
  3485. ' specify the status of the revoked or unchecked context. Review the
  3486. ' following CertVerifyRevocation comments for details.
  3487. '
  3488. ' Upon input to CertVerifyRevocation, cbSize must be set to a size
  3489. ' returns FALSE and sets LastError to E_INVALIDARG.
  3490. '
  3491. ' Upon input to the installed or registered CRYPT_OID_VERIFY_REVOCATION_FUNC
  3492. ' functions, the dwIndex, dwError and dwReason have been zero'ed.
  3493. '--------------------------------------------------------------------------
  3494. '+-------------------------------------------------------------------------
  3495. ' Verifies the array of contexts for revocation. The dwRevType parameter
  3496. ' indicates the type of the context data structure passed in rgpvContext.
  3497. ' Currently only the revocation of certificates is defined.
  3498. '
  3499. ' If the CERT_VERIFY_REV_CHAIN_FLAG flag is set, then, CertVerifyRevocation
  3500. ' is verifying a chain of certs where, rgpvContext[i + 1] is the issuer
  3501. ' of rgpvContext[i]. Otherwise, CertVerifyRevocation makes no assumptions
  3502. ' about the order of the contexts.
  3503. '
  3504. ' To assist in finding the issuer, the pRevPara may optionally be set. See
  3505. ' the CERT_REVOCATION_PARA data structure for details.
  3506. '
  3507. ' The contexts must contain enough information to allow the
  3508. ' installable or registered revocation DLLs to find the revocation server. For
  3509. ' certificates, this information would normally be conveyed in an
  3510. ' extension such as the IETF's AuthorityInfoAccess extension.
  3511. '
  3512. ' CertVerifyRevocation returns TRUE if all of the contexts were successfully
  3513. ' checked and none were revoked. Otherwise, returns FALSE and updates the
  3514. ' returned pRevStatus data structure as follows:
  3515. ' dwIndex
  3516. ' Index of the first context that was revoked or unable to
  3517. ' be checked for revocation
  3518. ' dwError
  3519. ' Error status. LastError is also set to this error status.
  3520. ' dwError can be set to one of the following error codes defined
  3521. ' in winerror.h:
  3522. ' ERROR_SUCCESS - good context
  3523. ' CRYPT_E_REVOKED - context was revoked. dwReason contains the
  3524. ' reason for revocation
  3525. ' CRYPT_E_REVOCATION_OFFLINE - unable to connect to the
  3526. ' revocation server
  3527. ' CRYPT_E_NOT_IN_REVOCATION_DATABASE - the context to be checked
  3528. ' was not found in the revocation server's database.
  3529. ' CRYPT_E_NO_REVOCATION_CHECK - the called revocation function
  3530. ' wasn't able to do a revocation check on the context
  3531. ' CRYPT_E_NO_REVOCATION_DLL - no installed or registered Dll was
  3532. ' found to verify revocation
  3533. ' dwReason
  3534. ' The dwReason is currently only set for CRYPT_E_REVOKED and contains
  3535. ' the reason why the context was revoked. May be one of the following
  3536. ' CRL_REASON_UNSPECIFIED 0
  3537. ' CRL_REASON_KEY_COMPROMISE 1
  3538. ' CRL_REASON_CA_COMPROMISE 2
  3539. ' CRL_REASON_AFFILIATION_CHANGED 3
  3540. ' CRL_REASON_SUPERSEDED 4
  3541. ' CRL_REASON_CESSATION_OF_OPERATION 5
  3542. ' CRL_REASON_CERTIFICATE_HOLD 6
  3543. '
  3544. ' For each entry in rgpvContext, CertVerifyRevocation iterates
  3545. ' through the CRYPT_OID_VERIFY_REVOCATION_FUNC
  3546. ' function set's list of installed DEFAULT functions.
  3547. ' CryptGetDefaultOIDFunctionAddress is called with pwszDll = NULL. If no
  3548. ' installed functions are found capable of doing the revocation verification,
  3549. ' CryptVerifyRevocation iterates through CRYPT_OID_VERIFY_REVOCATION_FUNC's
  3550. ' list of registered DEFAULT Dlls. CryptGetDefaultOIDDllList is called to
  3551. ' get the list. CryptGetDefaultOIDFunctionAddress is called to load the Dll.
  3552. '
  3553. ' The called functions have the same signature as CertVerifyRevocation. A
  3554. ' called function returns TRUE if it was able to successfully check all of
  3555. ' the contexts and none were revoked. Otherwise, the called function returns
  3556. ' FALSE and updates pRevStatus. dwIndex is set to the index of
  3557. ' the first context that was found to be revoked or unable to be checked.
  3558. ' dwError and LastError are updated. For CRYPT_E_REVOKED, dwReason
  3559. ' is updated. Upon input to the called function, dwIndex, dwError and
  3560. ' dwReason have been zero'ed. cbSize has been checked to be >=
  3561. '
  3562. ' If the called function returns FALSE, and dwError isn't set to
  3563. ' CRYPT_E_REVOKED, then, CertVerifyRevocation either continues on to the
  3564. ' next DLL in the list for a returned dwIndex of 0 or for a returned
  3565. ' dwIndex > 0, restarts the process of finding a verify function by
  3566. ' advancing the start of the context array to the returned dwIndex and
  3567. ' decrementing the count of remaining contexts.
  3568. '--------------------------------------------------------------------------
  3569. '+-------------------------------------------------------------------------
  3570. ' Revocation types
  3571. '--------------------------------------------------------------------------
  3572. Public Const CERT_CONTEXT_REVOCATION_TYPE As Long = 1
  3573. '+-------------------------------------------------------------------------
  3574. ' When the following flag is set, rgpvContext[] consists of a chain
  3575. ' of certificates, where rgpvContext[i + 1] is the issuer of rgpvContext[i].
  3576. '--------------------------------------------------------------------------
  3577. Public Const CERT_VERIFY_REV_CHAIN_FLAG As Long = &H1
  3578. '+-------------------------------------------------------------------------
  3579. ' CERT_CONTEXT_REVOCATION_TYPE
  3580. '
  3581. ' pvContext points to a const CERT_CONTEXT.
  3582. '--------------------------------------------------------------------------
  3583. '+=========================================================================
  3584. ' Certificate Helper APIs
  3585. '==========================================================================
  3586. '+-------------------------------------------------------------------------
  3587. ' Compare two multiple byte integer blobs to see if they are identical.
  3588. '
  3589. ' Before doing the comparison, leading zero bytes are removed from a
  3590. ' positive number and leading 0xFF bytes are removed from a negative
  3591. ' number.
  3592. '
  3593. ' The multiple byte integers are treated as Little Endian. pbData[0] is the
  3594. ' least significant byte and pbData[cbData - 1] is the most significant
  3595. ' byte.
  3596. '
  3597. ' Returns TRUE if the integer blobs are identical after removing leading
  3598. ' 0 or 0xFF bytes.
  3599. '--------------------------------------------------------------------------
  3600. '+-------------------------------------------------------------------------
  3601. ' Compare two certificates to see if they are identical.
  3602. '
  3603. ' Since a certificate is uniquely identified by its Issuer and SerialNumber,
  3604. ' these are the only fields needing to be compared.
  3605. '
  3606. ' Returns TRUE if the certificates are identical.
  3607. '--------------------------------------------------------------------------
  3608. '+-------------------------------------------------------------------------
  3609. ' Compare two certificate names to see if they are identical.
  3610. '
  3611. ' Returns TRUE if the names are identical.
  3612. '--------------------------------------------------------------------------
  3613. '+-------------------------------------------------------------------------
  3614. ' Compare the attributes in the certificate name with the specified
  3615. ' The comparison iterates through the CERT_RDN attributes and looks for an
  3616. ' attribute match in any of the certificate name's RDNs.
  3617. ' Returns TRUE if all the attributes are found and match.
  3618. '
  3619. ' The CERT_RDN_ATTR fields can have the following special values:
  3620. ' pszObjId == NULL - ignore the attribute object identifier
  3621. ' dwValueType == RDN_ANY_TYPE - ignore the value type
  3622. '
  3623. ' Currently only an exact, case sensitive match is supported.
  3624. '
  3625. ' CERT_UNICODE_IS_RDN_ATTRS_FLAG should be set if the pRDN was initialized
  3626. '--------------------------------------------------------------------------
  3627. Public Const CERT_UNICODE_IS_RDN_ATTRS_FLAG As Long = &H1
  3628. '+-------------------------------------------------------------------------
  3629. ' Compare two public keys to see if they are identical.
  3630. '
  3631. ' Returns TRUE if the keys are identical.
  3632. '--------------------------------------------------------------------------
  3633. '+-------------------------------------------------------------------------
  3634. ' Verify the signature of a subject certificate or a CRL using the
  3635. ' public key info
  3636. '
  3637. ' Returns TRUE for a valid signature.
  3638. '
  3639. ' hCryptProv specifies the crypto provider to use to verify the signature.
  3640. ' It doesn't need to use a private key.
  3641. '--------------------------------------------------------------------------
  3642. '+-------------------------------------------------------------------------
  3643. ' Compute the hash of the "to be signed" information in the encoded
  3644. '
  3645. ' hCryptProv specifies the crypto provider to use to compute the hash.
  3646. ' It doesn't need to use a private key.
  3647. '--------------------------------------------------------------------------
  3648. '+-------------------------------------------------------------------------
  3649. ' Hash the encoded content.
  3650. '
  3651. ' hCryptProv specifies the crypto provider to use to compute the hash.
  3652. ' It doesn't need to use a private key.
  3653. '
  3654. ' Algid specifies the CAPI hash algorithm to use. If Algid is 0, then, the
  3655. '--------------------------------------------------------------------------
  3656. '+-------------------------------------------------------------------------
  3657. ' Sign the "to be signed" information in the encoded signed content.
  3658. '
  3659. ' hCryptProv specifies the crypto provider to use to do the signature.
  3660. ' It uses the specified private key.
  3661. '--------------------------------------------------------------------------
  3662. '+-------------------------------------------------------------------------
  3663. ' Encode the "to be signed" information. Sign the encoded "to be signed".
  3664. ' Encode the "to be signed" and the signature.
  3665. '
  3666. ' hCryptProv specifies the crypto provider to use to do the signature.
  3667. ' It uses the specified private key.
  3668. '--------------------------------------------------------------------------
  3669. '+-------------------------------------------------------------------------
  3670. ' Verify the time validity of a certificate.
  3671. '
  3672. ' Returns -1 if before NotBefore, +1 if after NotAfter and otherwise 0 for
  3673. ' a valid certificate
  3674. '
  3675. ' If pTimeToVerify is NULL, uses the current time.
  3676. '--------------------------------------------------------------------------
  3677. '+-------------------------------------------------------------------------
  3678. ' Verify the time validity of a CRL.
  3679. '
  3680. ' Returns -1 if before ThisUpdate, +1 if after NextUpdate and otherwise 0 for
  3681. ' a valid CRL
  3682. '
  3683. ' If pTimeToVerify is NULL, uses the current time.
  3684. '--------------------------------------------------------------------------
  3685. '+-------------------------------------------------------------------------
  3686. ' Verify that the subject's time validity nests within the issuer's time
  3687. ' validity.
  3688. '
  3689. ' Returns TRUE if it nests. Otherwise, returns FALSE.
  3690. '--------------------------------------------------------------------------
  3691. '+-------------------------------------------------------------------------
  3692. ' Verify that the subject certificate isn't on its issuer CRL.
  3693. '
  3694. ' Returns true if the certificate isn't on the CRL.
  3695. '--------------------------------------------------------------------------
  3696. '+-------------------------------------------------------------------------
  3697. ' Convert the CAPI AlgId to the ASN.1 Object Identifier string
  3698. '
  3699. ' Returns NULL if there isn't an ObjId corresponding to the AlgId.
  3700. '--------------------------------------------------------------------------
  3701. '+-------------------------------------------------------------------------
  3702. ' Convert the ASN.1 Object Identifier string to the CAPI AlgId.
  3703. '
  3704. ' Returns 0 if there isn't an AlgId corresponding to the ObjId.
  3705. '--------------------------------------------------------------------------
  3706. '+-------------------------------------------------------------------------
  3707. ' Find an extension identified by its Object Identifier.
  3708. '
  3709. ' If found, returns pointer to the extension. Otherwise, returns NULL.
  3710. '--------------------------------------------------------------------------
  3711. '+-------------------------------------------------------------------------
  3712. ' Find the first attribute identified by its Object Identifier.
  3713. '
  3714. ' If found, returns pointer to the attribute. Otherwise, returns NULL.
  3715. '--------------------------------------------------------------------------
  3716. '+-------------------------------------------------------------------------
  3717. ' Find the first CERT_RDN attribute identified by its Object Identifier in
  3718. ' the name's list of Relative Distinguished Names.
  3719. '
  3720. ' If found, returns pointer to the attribute. Otherwise, returns NULL.
  3721. '--------------------------------------------------------------------------
  3722. '+-------------------------------------------------------------------------
  3723. ' Get the intended key usage bytes from the certificate.
  3724. '
  3725. ' If the certificate doesn't have any intended key usage bytes, returns FALSE
  3726. ' and *pbKeyUsage is zeroed. Otherwise, returns TRUE and up through
  3727. ' cbKeyUsage bytes are copied into *pbKeyUsage. Any remaining uncopied
  3728. ' bytes are zeroed.
  3729. '--------------------------------------------------------------------------
  3730. '+-------------------------------------------------------------------------
  3731. ' Export the public key info associated with the provider's corresponding
  3732. ' private key.
  3733. '
  3734. ' Calls CryptExportPublicKeyInfo with pszPublicKeyObjId = szOID_RSA_RSA,
  3735. ' dwFlags = 0 and pvAuxInfo = NULL.
  3736. '--------------------------------------------------------------------------
  3737. '+-------------------------------------------------------------------------
  3738. ' Export the public key info associated with the provider's corresponding
  3739. ' private key.
  3740. '
  3741. ' Uses the dwCertEncodingType and pszPublicKeyObjId to call the
  3742. ' installable CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC. The called function
  3743. ' has the same signature as CryptExportPublicKeyInfoEx.
  3744. '
  3745. ' If unable to find an installable OID function for the pszPublicKeyObjId,
  3746. '
  3747. ' The dwFlags and pvAuxInfo aren't used for szOID_RSA_RSA.
  3748. '--------------------------------------------------------------------------
  3749. Public Const CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC As String = "CryptDllExportPublicKeyInfoEx"
  3750. '+-------------------------------------------------------------------------
  3751. ' Convert and import the public key info into the provider and return a
  3752. ' handle to the public key.
  3753. '
  3754. ' Calls CryptImportPublicKeyInfoEx with aiKeyAlg = 0, dwFlags = 0 and
  3755. ' pvAuxInfo = NULL.
  3756. '--------------------------------------------------------------------------
  3757. '+-------------------------------------------------------------------------
  3758. ' Convert and import the public key info into the provider and return a
  3759. ' handle to the public key.
  3760. '
  3761. ' Uses the dwCertEncodingType and pInfo->Algorithm.pszObjId to call the
  3762. ' installable CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC. The called function
  3763. ' has the same signature as CryptImportPublicKeyInfoEx.
  3764. '
  3765. ' If unable to find an installable OID function for the pszObjId,
  3766. '
  3767. ' For szOID_RSA_RSA: aiKeyAlg may be set to CALG_RSA_SIGN or CALG_RSA_KEYX.
  3768. ' Defaults to CALG_RSA_KEYX. The dwFlags and pvAuxInfo aren't used.
  3769. '--------------------------------------------------------------------------
  3770. Public Const CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC As String = "CryptDllImportPublicKeyInfoEx"
  3771. '+-------------------------------------------------------------------------
  3772. ' Compute the hash of the encoded public key info.
  3773. '
  3774. ' The public key info is encoded and then hashed.
  3775. '--------------------------------------------------------------------------
  3776. '+-------------------------------------------------------------------------
  3777. ' Convert a Name Value to a null terminated char string
  3778. '
  3779. ' Returns the number of characters converted including the terminating null
  3780. ' character. If psz is NULL or csz is 0, returns the required size of the
  3781. '
  3782. ' If psz != NULL && csz != 0, returned psz is always NULL terminated.
  3783. '
  3784. ' Note: csz includes the NULL char.
  3785. '--------------------------------------------------------------------------
  3786. '+-------------------------------------------------------------------------
  3787. ' Convert a Name Value to a null terminated char string
  3788. '
  3789. ' Returns the number of characters converted including the terminating null
  3790. ' character. If psz is NULL or csz is 0, returns the required size of the
  3791. '
  3792. ' If psz != NULL && csz != 0, returned psz is always NULL terminated.
  3793. '
  3794. ' Note: csz includes the NULL char.
  3795. '--------------------------------------------------------------------------
  3796. '+-------------------------------------------------------------------------
  3797. ' Convert the certificate name blob to a null terminated char string.
  3798. '
  3799. ' Follows the string representation of distinguished names specified in
  3800. ' empty strings and don't quote strings containing consecutive spaces).
  3801. ' RDN values of type CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING are
  3802. '
  3803. ' The name string is formatted according to the dwStrType:
  3804. ' CERT_SIMPLE_NAME_STR
  3805. ' The object identifiers are discarded. CERT_RDN entries are separated
  3806. ' by ", ". Multiple attributes per CERT_RDN are separated by " + ".
  3807. ' For example:
  3808. ' Microsoft, Joe Cool + Programmer
  3809. ' CERT_OID_NAME_STR
  3810. ' The object identifiers are included with a "=" separator from their
  3811. ' attribute value. CERT_RDN entries are separated by ", ".
  3812. ' Multiple attributes per CERT_RDN are separated by " + ". For example:
  3813. ' 2.5.4.11=Microsoft, 2.5.4.3=Joe Cool + 2.5.4.12=Programmer
  3814. ' CERT_X500_NAME_STR
  3815. ' The object identifiers are converted to their X500 key name. Otherwise,
  3816. ' same as CERT_OID_NAME_STR. If the object identifier doesn't have
  3817. ' a corresponding X500 key name, then, the object identifier is used with
  3818. ' a "OID." prefix. For example:
  3819. ' OU=Microsoft, CN=Joe Cool + T=Programmer, OID.1.2.3.4.5.6=Unknown
  3820. '
  3821. ' We quote the RDN value if it contains leading or trailing whitespace
  3822. ' or one of the following characters: ",", "+", "=", """, "\n", "<", ">",
  3823. ' "#" or ";". The quoting character is ". If the the RDN Value contains
  3824. ' OU=" Microsoft", CN="Joe ""Cool""" + T="Programmer, Manager"
  3825. '
  3826. ' CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to replace
  3827. ' the ", " separator with a "; " separator.
  3828. '
  3829. ' CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to replace
  3830. ' the ", " separator with a "\r\n" separator.
  3831. '
  3832. ' CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to replace the
  3833. ' " + " separator with a single space, " ".
  3834. '
  3835. ' CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  3836. ' the above quoting.
  3837. '
  3838. ' Returns the number of characters converted including the terminating null
  3839. ' character. If psz is NULL or csz is 0, returns the required size of the
  3840. '
  3841. ' If psz != NULL && csz != 0, returned psz is always NULL terminated.
  3842. '
  3843. ' Note: csz includes the NULL char.
  3844. '--------------------------------------------------------------------------
  3845. '+-------------------------------------------------------------------------
  3846. '--------------------------------------------------------------------------
  3847. '+-------------------------------------------------------------------------
  3848. '--------------------------------------------------------------------------
  3849. '+-------------------------------------------------------------------------
  3850. ' Certificate name string types
  3851. '--------------------------------------------------------------------------
  3852. Public Const CERT_SIMPLE_NAME_STR As Long = 1
  3853. Public Const CERT_OID_NAME_STR As Long = 2
  3854. Public Const CERT_X500_NAME_STR As Long = 3
  3855. '+-------------------------------------------------------------------------
  3856. ' Certificate name string type flags OR'ed with the above types
  3857. '--------------------------------------------------------------------------
  3858. Public Const CERT_NAME_STR_SEMICOLON_FLAG As Long = &H40000000
  3859. Public Const CERT_NAME_STR_NO_PLUS_FLAG As Long = &H20000000
  3860. Public Const CERT_NAME_STR_NO_QUOTING_FLAG As Long = &H10000000
  3861. Public Const CERT_NAME_STR_CRLF_FLAG As Long = &H08000000
  3862. Public Const CERT_NAME_STR_COMMA_FLAG As Long = &H04000000
  3863. '+-------------------------------------------------------------------------
  3864. ' Convert the null terminated X500 string to an encoded certificate name.
  3865. '
  3866. ' The input string is expected to be formatted the same as the output
  3867. ' from the above CertNameToStr API.
  3868. '
  3869. ' The CERT_SIMPLE_NAME_STR type isn't supported. Otherwise, when dwStrType
  3870. ' is set to 0, CERT_OID_NAME_STR or CERT_X500_NAME_STR, allow either a
  3871. '
  3872. ' If no flags are OR'ed into dwStrType, then, allow "," or ";" as RDN
  3873. ' separators and "+" as the multiple RDN value separator. Quoting is
  3874. ' supported. A quote may be included in a quoted value by double quoting,
  3875. ' as ascii hex and converted to a CERT_RDN_OCTET_STRING. Embedded whitespace
  3876. '
  3877. ' Whitespace surrounding the keys, object identifers and values is removed.
  3878. '
  3879. ' CERT_NAME_STR_COMMA_FLAG can be or'ed into dwStrType to only allow the
  3880. ' "," as the RDN separator.
  3881. '
  3882. ' CERT_NAME_STR_SEMICOLON_FLAG can be or'ed into dwStrType to only allow the
  3883. ' ";" as the RDN separator.
  3884. '
  3885. ' CERT_NAME_STR_CRLF_FLAG can be or'ed into dwStrType to only allow
  3886. ' "\r" or "\n" as the RDN separator.
  3887. '
  3888. ' CERT_NAME_STR_NO_PLUS_FLAG can be or'ed into dwStrType to ignore "+"
  3889. ' as a separator and not allow multiple values per RDN.
  3890. '
  3891. ' CERT_NAME_STR_NO_QUOTING_FLAG can be or'ed into dwStrType to inhibit
  3892. ' quoting.
  3893. '
  3894. ' Support the following X500 Keys:
  3895. '
  3896. ' --- ----------------- -----------------
  3897. ' CN szOID_COMMON_NAME Printable, T61
  3898. ' L szOID_LOCALITY_NAME Printable, T61
  3899. ' O szOID_ORGANIZATION_NAME Printable, T61
  3900. ' OU szOID_ORGANIZATIONAL_UNIT_NAME Printable, T61
  3901. ' Email szOID_RSA_emailAddr Only IA5
  3902. ' C szOID_COUNTRY_NAME Only Printable
  3903. ' S szOID_STATE_OR_PROVINCE_NAME Printable, T61
  3904. ' ST szOID_STATE_OR_PROVINCE_NAME Printable, T61
  3905. ' STREET szOID_STREET_ADDRESS Printable, T61
  3906. ' T szOID_TITLE Printable, T61
  3907. ' Title szOID_TITLE Printable, T61
  3908. ' G szOID_GIVEN_NAME Printable, T61
  3909. ' GivenName szOID_GIVEN_NAME Printable, T61
  3910. ' I szOID_INITIALS Printable, T61
  3911. ' Initials szOID_INITIALS Printable, T61
  3912. ' SN szOID_SUR_NAME Printable, T61
  3913. ' DC szOID_DOMAIN_COMPONENT Only IA5
  3914. '
  3915. ' The T61 types are UTF-8 encoded.
  3916. '
  3917. ' Returns TRUE if successfully parsed the input string and encoded
  3918. ' the name.
  3919. '
  3920. ' If the input string is detected to be invalid, *ppszError is updated
  3921. ' to point to the beginning of the invalid character sequence. Otherwise,
  3922. ' *ppszError is set to NULL. *ppszError is updated with a non-NULL pointer
  3923. ' for the following errors:
  3924. ' CRYPT_E_INVALID_X500_STRING
  3925. ' CRYPT_E_INVALID_NUMERIC_STRING
  3926. ' CRYPT_E_INVALID_PRINTABLE_STRING
  3927. ' CRYPT_E_INVALID_IA5_STRING
  3928. '
  3929. ' ppszError can be set to NULL if not interested in getting a pointer
  3930. ' to the invalid character sequence.
  3931. '--------------------------------------------------------------------------
  3932. '+-------------------------------------------------------------------------
  3933. '--------------------------------------------------------------------------
  3934. '+-------------------------------------------------------------------------
  3935. '--------------------------------------------------------------------------
  3936. '+=========================================================================
  3937. ' Simplified Cryptographic Message Data Structures and APIs
  3938. '==========================================================================
  3939. '+-------------------------------------------------------------------------
  3940. ' Conventions for the *pb and *pcb output parameters:
  3941. '
  3942. ' Upon entry to the function:
  3943. ' if pcb is OPTIONAL && pcb == NULL, then,
  3944. ' No output is returned
  3945. ' else if pb == NULL && pcb != NULL, then,
  3946. ' Length only determination. No length error is
  3947. ' returned.
  3948. ' Output is returned. If *pcb isn't big enough a
  3949. ' length error is returned. In all cases *pcb is updated
  3950. ' with the actual length needed/returned.
  3951. '--------------------------------------------------------------------------
  3952. '+-------------------------------------------------------------------------
  3953. ' Type definitions of the parameters used for doing the cryptographic
  3954. ' operations.
  3955. '--------------------------------------------------------------------------
  3956. '+-------------------------------------------------------------------------
  3957. ' Callback to get and verify the signer's certificate.
  3958. '
  3959. ' handle to its cryptographic signed message's cert store.
  3960. '
  3961. ' For CRYPT_E_NO_SIGNER, called with pSignerId == NULL.
  3962. '
  3963. ' For a valid signer certificate, returns a pointer to a read only
  3964. ' CERT_CONTEXT. The returned CERT_CONTEXT is either obtained from a
  3965. ' cert store or was created via CertCreateCertificateContext. For either case,
  3966. ' its freed via CertFreeCertificateContext.
  3967. '
  3968. ' If a valid certificate isn't found, this callback returns NULL with
  3969. '
  3970. ' The NULL implementation tries to get the Signer certificate from the
  3971. ' message cert store. It doesn't verify the certificate.
  3972. '--------------------------------------------------------------------------
  3973. '+-------------------------------------------------------------------------
  3974. ' The CRYPT_SIGN_MESSAGE_PARA are used for signing messages using the
  3975. '
  3976. ' Either the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID must
  3977. ' be set for each rgpSigningCert[]. Either one specifies the private
  3978. ' signature key to use.
  3979. '
  3980. ' If any certificates and/or CRLs are to be included in the signed message,
  3981. ' then, the MsgCert and MsgCrl parameters need to be updated. If the
  3982. ' rgpSigningCerts are to be included, then, they must also be in the
  3983. ' rgpMsgCert array.
  3984. '
  3985. ' LastError will be updated with E_INVALIDARG.
  3986. '
  3987. ' pvHashAuxInfo currently isn't used and must be set to NULL.
  3988. '
  3989. ' dwFlags normally is set to 0. However, if the encoded output
  3990. ' is to be a CMSG_SIGNED inner content of an outer cryptographic message,
  3991. ' such as a CMSG_ENVELOPED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  3992. ' should be set. If not set, then it would be encoded as an inner content
  3993. ' type of CMSG_DATA.
  3994. '
  3995. ' dwInnerContentType is normally set to 0. It needs to be set if the
  3996. ' ToBeSigned input is the encoded output of another cryptographic
  3997. ' message, such as, an CMSG_ENVELOPED. When set, it's one of the cryptographic
  3998. ' message types, for example, CMSG_ENVELOPED.
  3999. '
  4000. ' the default), then, neither dwFlags or dwInnerContentType need to be set.
  4001. '--------------------------------------------------------------------------
  4002. Public Const CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG As Long = &H1
  4003. '+-------------------------------------------------------------------------
  4004. ' The CRYPT_VERIFY_MESSAGE_PARA are used to verify signed messages.
  4005. '
  4006. ' hCryptProv is used to do hashing and signature verification.
  4007. '
  4008. ' The dwCertEncodingType specifies the encoding type of the certificates
  4009. ' and/or CRLs in the message.
  4010. '
  4011. ' pfnGetSignerCertificate is called to get and verify the message signer's
  4012. ' certificate.
  4013. '
  4014. ' LastError will be updated with E_INVALIDARG.
  4015. '--------------------------------------------------------------------------
  4016. '+-------------------------------------------------------------------------
  4017. ' The CRYPT_ENCRYPT_MESSAGE_PARA are used for encrypting messages.
  4018. '
  4019. ' hCryptProv is used to do content encryption, recipient key
  4020. ' encryption, and recipient key export. Its private key
  4021. ' isn't used.
  4022. '
  4023. ' pvEncryptionAuxInfo currently isn't used and must be set to NULL.
  4024. '
  4025. ' LastError will be updated with E_INVALIDARG.
  4026. '
  4027. ' dwFlags normally is set to 0. However, if the encoded output
  4028. ' is to be a CMSG_ENVELOPED inner content of an outer cryptographic message,
  4029. ' such as a CMSG_SIGNED, then, the CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG
  4030. ' should be set. If not set, then it would be encoded as an inner content
  4031. ' type of CMSG_DATA.
  4032. '
  4033. ' dwInnerContentType is normally set to 0. It needs to be set if the
  4034. ' ToBeEncrypted input is the encoded output of another cryptographic
  4035. ' message, such as, an CMSG_SIGNED. When set, it's one of the cryptographic
  4036. ' message types, for example, CMSG_SIGNED.
  4037. '
  4038. ' the default), then, neither dwFlags or dwInnerContentType need to be set.
  4039. '--------------------------------------------------------------------------
  4040. '+-------------------------------------------------------------------------
  4041. ' The CRYPT_DECRYPT_MESSAGE_PARA are used for decrypting messages.
  4042. '
  4043. ' The CertContext to use for decrypting a message is obtained from one
  4044. ' of the specified cert stores. An encrypted message can have one or
  4045. ' and SerialNumber). The cert stores are searched to find the CertContext
  4046. ' corresponding to the CertId.
  4047. '
  4048. ' Only CertContexts in the store with either
  4049. ' the CERT_KEY_PROV_HANDLE_PROP_ID or CERT_KEY_PROV_INFO_PROP_ID set
  4050. ' can be used. Either property specifies the private exchange key to use.
  4051. '
  4052. ' LastError will be updated with E_INVALIDARG.
  4053. '--------------------------------------------------------------------------
  4054. '+-------------------------------------------------------------------------
  4055. ' The CRYPT_HASH_MESSAGE_PARA are used for hashing or unhashing
  4056. ' messages.
  4057. '
  4058. ' hCryptProv is used to compute the hash.
  4059. '
  4060. ' pvHashAuxInfo currently isn't used and must be set to NULL.
  4061. '
  4062. ' LastError will be updated with E_INVALIDARG.
  4063. '--------------------------------------------------------------------------
  4064. '+-------------------------------------------------------------------------
  4065. ' The CRYPT_KEY_SIGN_MESSAGE_PARA are used for signing messages until a
  4066. ' certificate has been created for the signature key.
  4067. '
  4068. ' pvHashAuxInfo currently isn't used and must be set to NULL.
  4069. '
  4070. ' LastError will be updated with E_INVALIDARG.
  4071. '--------------------------------------------------------------------------
  4072. '+-------------------------------------------------------------------------
  4073. ' The CRYPT_KEY_VERIFY_MESSAGE_PARA are used to verify signed messages without
  4074. ' a certificate for the signer.
  4075. '
  4076. ' Normally used until a certificate has been created for the key.
  4077. '
  4078. ' hCryptProv is used to do hashing and signature verification.
  4079. '
  4080. ' LastError will be updated with E_INVALIDARG.
  4081. '--------------------------------------------------------------------------
  4082. '+-------------------------------------------------------------------------
  4083. ' Sign the message.
  4084. '
  4085. ' If fDetachedSignature is TRUE, the "to be signed" content isn't included
  4086. ' in the encoded signed blob.
  4087. '--------------------------------------------------------------------------
  4088. '+-------------------------------------------------------------------------
  4089. ' Verify a signed message.
  4090. '
  4091. ' If pbDecoded == NULL, then, *pcbDecoded is implicitly set to 0 on input.
  4092. ' For *pcbDecoded == 0 && ppSignerCert == NULL on input, the signer isn't
  4093. ' verified.
  4094. '
  4095. ' A message might have more than one signer. Set dwSignerIndex to iterate
  4096. ' through all the signers. dwSignerIndex == 0 selects the first signer.
  4097. '
  4098. ' pVerifyPara's pfnGetSignerCertificate is called to get the signer's
  4099. ' certificate.
  4100. '
  4101. ' For a verified signer and message, *ppSignerCert is updated
  4102. ' with the CertContext of the signer. It must be freed by calling
  4103. ' CertFreeCertificateContext. Otherwise, *ppSignerCert is set to NULL.
  4104. '
  4105. ' ppSignerCert can be NULL, indicating the caller isn't interested
  4106. ' in getting the CertContext of the signer.
  4107. '
  4108. ' pcbDecoded can be NULL, indicating the caller isn't interested in getting
  4109. ' the decoded content. Furthermore, if the message doesn't contain any
  4110. ' content or signers, then, pcbDecoded must be set to NULL, to allow the
  4111. ' pVerifyPara->pfnGetCertificate to be called. Normally, this would be
  4112. ' the case when the signed message contains only certficates and CRLs.
  4113. ' If pcbDecoded is NULL and the message doesn't have the indicated signer,
  4114. ' pfnGetCertificate is called with pSignerId set to NULL.
  4115. '
  4116. ' If the message doesn't contain any signers || dwSignerIndex > message's
  4117. ' SignerCount, then, an error is returned with LastError set to
  4118. ' CRYPT_E_NO_SIGNER. Also, for CRYPT_E_NO_SIGNER, pfnGetSignerCertificate
  4119. ' is still called with pSignerId set to NULL.
  4120. '
  4121. ' Note, an alternative way to get the certificates and CRLs from a
  4122. ' signed message is to call CryptGetMessageCertificates.
  4123. '--------------------------------------------------------------------------
  4124. '+-------------------------------------------------------------------------
  4125. ' Returns the count of signers in the signed message. For no signers, returns
  4126. ' 0. For an error returns -1 with LastError updated accordingly.
  4127. '--------------------------------------------------------------------------
  4128. '+-------------------------------------------------------------------------
  4129. ' Returns the cert store containing the message's certs and CRLs.
  4130. ' For an error, returns NULL with LastError updated.
  4131. '--------------------------------------------------------------------------
  4132. '+-------------------------------------------------------------------------
  4133. ' The "to be signed" content is passed in separately. No
  4134. ' decoded output. Otherwise, identical to CryptVerifyMessageSignature.
  4135. '--------------------------------------------------------------------------
  4136. '+-------------------------------------------------------------------------
  4137. '--------------------------------------------------------------------------
  4138. '+-------------------------------------------------------------------------
  4139. ' Decrypts the message.
  4140. '
  4141. ' If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  4142. ' For *pcbDecrypted == 0 && ppXchgCert == NULL on input, the message isn't
  4143. ' decrypted.
  4144. '
  4145. ' For a successfully decrypted message, *ppXchgCert is updated
  4146. ' with the CertContext used to decrypt. It must be freed by calling
  4147. ' CertStoreFreeCert. Otherwise, *ppXchgCert is set to NULL.
  4148. '
  4149. ' ppXchgCert can be NULL, indicating the caller isn't interested
  4150. ' in getting the CertContext used to decrypt.
  4151. '--------------------------------------------------------------------------
  4152. '+-------------------------------------------------------------------------
  4153. ' followed with a CryptEncryptMessage.
  4154. '
  4155. ' Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  4156. ' inside of an CMSG_ENVELOPED.
  4157. '--------------------------------------------------------------------------
  4158. '+-------------------------------------------------------------------------
  4159. ' Decrypts the message and verifies the signer. Does a CryptDecryptMessage
  4160. ' followed with a CryptVerifyMessageSignature.
  4161. '
  4162. ' If pbDecrypted == NULL, then, *pcbDecrypted is implicitly set to 0 on input.
  4163. ' For *pcbDecrypted == 0 && ppSignerCert == NULL on input, the signer isn't
  4164. ' verified.
  4165. '
  4166. ' A message might have more than one signer. Set dwSignerIndex to iterate
  4167. ' through all the signers. dwSignerIndex == 0 selects the first signer.
  4168. '
  4169. ' The pVerifyPara's VerifySignerPolicy is called to verify the signer's
  4170. ' certificate.
  4171. '
  4172. ' For a successfully decrypted and verified message, *ppXchgCert and
  4173. ' *ppSignerCert are updated. They must be freed by calling
  4174. ' CertStoreFreeCert. Otherwise, they are set to NULL.
  4175. '
  4176. ' ppXchgCert and/or ppSignerCert can be NULL, indicating the
  4177. ' caller isn't interested in getting the CertContext.
  4178. '
  4179. ' Note: this isn't the CMSG_SIGNED_AND_ENVELOPED. Its a CMSG_SIGNED
  4180. ' inside of an CMSG_ENVELOPED.
  4181. '
  4182. ' The message always needs to be decrypted to allow access to the
  4183. ' signed message. Therefore, if ppXchgCert != NULL, its always updated.
  4184. '--------------------------------------------------------------------------
  4185. '+-------------------------------------------------------------------------
  4186. ' Decodes a cryptographic message which may be one of the following types:
  4187. ' CMSG_DATA
  4188. ' CMSG_SIGNED
  4189. ' CMSG_ENVELOPED
  4190. ' CMSG_SIGNED_AND_ENVELOPED
  4191. ' CMSG_HASHED
  4192. '
  4193. ' dwMsgTypeFlags specifies the set of allowable messages. For example, to
  4194. ' decode either SIGNED or ENVELOPED messages, set dwMsgTypeFlags to:
  4195. ' CMSG_SIGNED_FLAG | CMSG_ENVELOPED_FLAG.
  4196. '
  4197. ' dwProvInnerContentType is only applicable when processing nested
  4198. ' crytographic messages. When processing an outer crytographic message
  4199. ' it must be set to 0. When decoding a nested cryptographic message
  4200. ' its the dwInnerContentType returned by a previous CryptDecodeMessage
  4201. ' of the outer message. The InnerContentType can be any of the CMSG types,
  4202. ' for example, CMSG_DATA, CMSG_SIGNED, ...
  4203. '
  4204. ' The optional *pdwMsgType is updated with the type of message.
  4205. '
  4206. ' The optional *pdwInnerContentType is updated with the type of the inner
  4207. ' message. Unless there is cryptographic message nesting, CMSG_DATA
  4208. ' is returned.
  4209. '
  4210. ' For CMSG_DATA: returns decoded content.
  4211. ' For CMSG_SIGNED: same as CryptVerifyMessageSignature.
  4212. ' For CMSG_ENVELOPED: same as CryptDecryptMessage.
  4213. ' For CMSG_SIGNED_AND_ENVELOPED: same as CryptDecryptMessage plus
  4214. ' CryptVerifyMessageSignature.
  4215. ' For CMSG_HASHED: verifies the hash and returns decoded content.
  4216. '--------------------------------------------------------------------------
  4217. '+-------------------------------------------------------------------------
  4218. ' Hash the message.
  4219. '
  4220. ' If fDetachedHash is TRUE, only the ComputedHash is encoded in the
  4221. ' pbHashedBlob. Otherwise, both the ToBeHashed and ComputedHash
  4222. ' are encoded.
  4223. '
  4224. ' pcbHashedBlob or pcbComputedHash can be NULL, indicating the caller
  4225. ' isn't interested in getting the output.
  4226. '--------------------------------------------------------------------------
  4227. '+-------------------------------------------------------------------------
  4228. ' Verify a hashed message.
  4229. '
  4230. ' pcbToBeHashed or pcbComputedHash can be NULL,
  4231. ' indicating the caller isn't interested in getting the output.
  4232. '--------------------------------------------------------------------------
  4233. '+-------------------------------------------------------------------------
  4234. ' Verify a hashed message containing a detached hash.
  4235. ' The "to be hashed" content is passed in separately. No
  4236. ' decoded output. Otherwise, identical to CryptVerifyMessageHash.
  4237. '
  4238. ' pcbComputedHash can be NULL, indicating the caller isn't interested
  4239. ' in getting the output.
  4240. '--------------------------------------------------------------------------
  4241. '+-------------------------------------------------------------------------
  4242. ' Sign the message using the provider's private key specified in the
  4243. ' parameters. A dummy SignerId is created and stored in the message.
  4244. '
  4245. ' Normally used until a certificate has been created for the key.
  4246. '--------------------------------------------------------------------------
  4247. '+-------------------------------------------------------------------------
  4248. ' Verify a signed message using the specified public key info.
  4249. '
  4250. ' Normally called by a CA until it has created a certificate for the
  4251. ' key.
  4252. '
  4253. ' pPublicKeyInfo contains the public key to use to verify the signed
  4254. ' content may contain the PublicKeyInfo).
  4255. '
  4256. ' pcbDecoded can be NULL, indicating the caller isn't interested
  4257. ' in getting the decoded content.
  4258. '--------------------------------------------------------------------------
  4259. '+=========================================================================
  4260. ' System Certificate Store Data Structures and APIs
  4261. '==========================================================================
  4262. '+-------------------------------------------------------------------------
  4263. ' Get a system certificate store based on a subsystem protocol.
  4264. '
  4265. ' Current examples of subsystems protocols are:
  4266. ' "MY" Cert Store hold certs with associated Private Keys
  4267. ' "CA" Certifying Authority certs
  4268. ' "ROOT" Root Certs
  4269. ' "SPC" Software publisher certs
  4270. '
  4271. '
  4272. ' If hProv is NULL the default provider "1" is opened for you.
  4273. ' When the store is closed the provider is release. Otherwise
  4274. ' if hProv is not NULL, no provider is created or released.
  4275. '
  4276. ' The returned Cert Store can be searched for an appropriate Cert
  4277. '
  4278. ' When done, the cert store should be closed using CertStoreClose
  4279. '--------------------------------------------------------------------------
  4280. '+-------------------------------------------------------------------------
  4281. ' Find all certificate chains tying the given issuer name to any certificate
  4282. ' that the current user has a private key for.
  4283. '
  4284. ' If no certificate chain is found, FALSE is returned with LastError set
  4285. ' to CRYPT_E_NOT_FOUND and the counts zeroed.
  4286. '
  4287. ' IE 3.0 ASSUMPTION:
  4288. ' The client certificates are in the "My" system store. The issuer
  4289. ' cerificates may be in the "Root", "CA" or "My" system stores.
  4290. '--------------------------------------------------------------------------
  4291. ' WINCRYPT32API This is not exported by crypt32, it is exported by softpub
  4292. '+--------------------------------------------------------------------------
  4293. '
  4294. ' Microsoft Windows
  4295. '
  4296. ' File: cs.h
  4297. '
  4298. ' Contents: Cert Server common definitions
  4299. '
  4300. ' History: 25-Jul-96 vich created
  4301. '
  4302. '---------------------------------------------------------------------------
  4303. Public Const VR_PENDING As Long = 0
  4304. Public Const VR_INSTANT_OK As Long = 1
  4305. Public Const VR_INSTANT_BAD As Long = 2
  4306. ' Certificate types:
  4307. Public Const CERT_TYPE_NONE As Long = 0
  4308. Public Const CERT_TYPE_X509 As Long = 1
  4309. Public Const CERT_TYPE_SDSI As Long = 2
  4310. Public Const CERT_TYPE_PGP As Long = 3
  4311. ' Request types:
  4312. Public Const REQ_TYPE_NONE As Long = 0
  4313. Public Const REQ_TYPE_PKCS10 As Long = 1
  4314. Public Const REQ_TYPE_KEYGEN As Long = 2
  4315. ' RegisterNewRequest is called to deliver a new request to the certificate
  4316. ' server. dwType indicates the type of request that has been received.
  4317. ' The following values are valid:
  4318. Public Const RNR_T_UNK As Long = 0
  4319. Public Const RNR_T_PKCS10 As Long = 1
  4320. Public Const RNR_T_KEYGEN As Long = 2
  4321. Public Const RNR_T_CUSTOM As Long = 3
  4322. ' Transport Info:
  4323. ' The transport info structure is used several places in the certificate
  4324. ' server to describe how request arrived, or how a certificate or CRL is to be
  4325. ' sent. The structure can define an address in steps of precision. It can be
  4326. ' just a type of transport, a specific transport mechanism, a transport
  4327. ' address, or a specific authenticated user at an address.
  4328. ' Address Types:
  4329. Public Const ADR_TYPE As Long = &H00000001
  4330. Public Const ADR_STYPE As Long = &H00000002
  4331. Public Const ADR_ADDR As Long = &H00000004
  4332. Public Const ADR_USER As Long = &H00000008
  4333. Public Const ADR_AUTH As Long = &H00000010
  4334. Public Const ADR_TIME As Long = &H00000020
  4335. ' Transport Types:
  4336. Public Const TTYPE_FREE As Long = 0
  4337. Public Const TTYPE_EMAIL As Long = 1
  4338. Public Const TTYPE_DNS As Long = 2
  4339. ' EMAIL subtypes:
  4340. Public Const TSUB_MAIL_GENERIC As Long = 1
  4341. Public Const TSUB_MAIL_PEM As Long = 2
  4342. Public Const TSUB_MAIL_EXCHSEC As Long = 3
  4343. Public Const TSUB_MAIL_PGP As Long = 4
  4344. ' DNS subtypes:
  4345. Public Const TSUB_DNS_FTP As Long = 1
  4346. Public Const TSUB_DNS_HTTP As Long = 2
  4347. Public Const TSUB_DNS_HTTPS As Long = 3
  4348. ' Authentication Types:
  4349. Public Const AAT_CERT As Long = 1
  4350. Public Const AAT_NTLM As Long = 2
  4351. Public Const AAT_SICILY As Long = 3
  4352. '
  4353. ' VOID
  4354. ' PLIST_ENTRY ListHead
  4355. ' );
  4356. '
  4357. '
  4358. ' VOID
  4359. ' PLIST_ENTRY ListHead,
  4360. ' PLIST_ENTRY Entry
  4361. ' );
  4362. '
  4363. '
  4364. ' VOID
  4365. ' PLIST_ENTRY Entry
  4366. ' );
  4367. '
  4368. '+--------------------------------------------------------------------------
  4369. '
  4370. ' Microsoft Windows
  4371. '
  4372. ' File: csprop.h
  4373. '
  4374. ' Contents: Cert Server Property interfaces
  4375. '
  4376. ' History: 31-Jul-96 vich created
  4377. '
  4378. '---------------------------------------------------------------------------
  4379. '+--------------------------------------------------------------------------
  4380. ' Name properties:
  4381. Public Const wszPROPDISTINGUISHEDNAME As String = "DistinguishedName"
  4382. Public Const wszPROPRAWNAME As String = "RawName"
  4383. Public Const wszPROPNAMETYPE As String = "NameType"
  4384. Public Const wszPROPCOUNTRY As String = "Country"
  4385. Public Const wszPROPORGANIZATION As String = "Organization"
  4386. Public Const wszPROPORGUNIT As String = "OrgUnit"
  4387. Public Const wszPROPCOMMONNAME As String = "CommonName"
  4388. Public Const wszPROPLOCALITY As String = "Locality"
  4389. Public Const wszPROPSTATE As String = "State"
  4390. Public Const wszPROPTITLE As String = "Title"
  4391. Public Const wszPROPGIVENNAME As String = "GivenName"
  4392. Public Const wszPROPINITIALS As String = "Initials"
  4393. Public Const wszPROPSURNAME As String = "SurName"
  4394. Public Const wszPROPDOMAINCOMPONENT As String = "DomainComponent"
  4395. Public Const wszPROPEMAIL As String = "EMail"
  4396. '+--------------------------------------------------------------------------
  4397. ' Subject Name properties:
  4398. Public Const wszPROPSUBJECTDOT As String = "Subject."
  4399. '+--------------------------------------------------------------------------
  4400. ' Issuer Name properties:
  4401. Public Const wszPROPISSUERDOT As String = "Issuer."
  4402. '+--------------------------------------------------------------------------
  4403. ' For mapping request attribute names to internal property names:
  4404. ' Map to wszPROPSUBJECTCOMMONNAME:
  4405. Public Const wszATTRCOMMONNAME1 As String = "CN"
  4406. Public Const wszATTRCOMMONNAME2 As String = "CommonName"
  4407. ' Map to wszPROPSUBJECTLOCALITY:
  4408. Public Const wszATTRLOCALITY1 As String = ""
  4409. Public Const wszATTRLOCALITY2 As String = "Locality"
  4410. ' Map to wszPROPSUBJECTSTATE:
  4411. Public Const wszATTRSTATE1 As String = "S"
  4412. Public Const wszATTRSTATE2 As String = "State"
  4413. ' Map to wszPROPSUBJECTCOUNTRY:
  4414. Public Const wszATTRCOUNTRY1 As String = "C"
  4415. Public Const wszATTRCOUNTRY2 As String = "Country"
  4416. ' Map to wszPROPSUBJECTORGANIZATION:
  4417. Public Const wszATTRORG1 As String = "O"
  4418. Public Const wszATTRORG2 As String = "Org"
  4419. Public Const wszATTRORG3 As String = "Organization"
  4420. ' Map to wszPROPSUBJECTORGUNIT:
  4421. Public Const wszATTRORGUNIT1 As String = "OU"
  4422. Public Const wszATTRORGUNIT2 As String = "OrgUnit"
  4423. Public Const wszATTRORGUNIT3 As String = "OrganizationUnit"
  4424. Public Const wszATTRORGUNIT4 As String = "OrganizationalUnit"
  4425. ' Map to wszPROPSUBJECTDOMAINCOMPONENT:
  4426. Public Const wszATTRDOMAINCOMPONENT1 As String = "DC"
  4427. Public Const wszATTRDOMAINCOMPONENT2 As String = "DomainComponent"
  4428. ' Map to wszPROPSUBJECTEMAIL:
  4429. Public Const wszATTREMAIL1 As String = "EMail"
  4430. '+--------------------------------------------------------------------------
  4431. ' Request properties:
  4432. Public Const wszPROPREQUESTREQUESTID As String = "RequestID"
  4433. Public Const wszPROPREQUESTRAWREQUEST As String = "RawRequest"
  4434. Public Const wszPROPREQUESTATTRIBUTES As String = "RequestAttributes"
  4435. Public Const wszPROPREQUESTTYPE As String = "RequestType"
  4436. Public Const wszPROPREQUESTFLAGS As String = "RequestFlags"
  4437. Public Const wszPROPREQUESTSTATUS As String = "Status"
  4438. Public Const wszPROPREQUESTSTATUSCODE As String = "StatusCode"
  4439. Public Const wszPROPREQUESTDISPOSITION As String = "Disposition"
  4440. Public Const wszPROPREQUESTDISPOSITIONMESSAGE As String = "DispositionMessage"
  4441. Public Const wszPROPREQUESTSUBMITTEDWHEN As String = "SubmittedWhen"
  4442. Public Const wszPROPREQUESTRESOLVEDWHEN As String = "ResolvedWhen"
  4443. Public Const wszPROPREQUESTREVOKEDWHEN As String = "RevokedWhen"
  4444. Public Const wszPROPREQUESTREVOKEDEFFECTIVEWHEN As String = "RevokedEffectiveWhen"
  4445. Public Const wszPROPREQUESTREVOKEDREASON As String = "RevokedReason"
  4446. Public Const wszPROPREQUESTSUBJECTNAMEID As String = "SubjectNameID"
  4447. Public Const wszPROPREQUESTERNAME As String = "RequesterName"
  4448. Public Const wszPROPREQUESTERADDRESS As String = "RequesterAddress"
  4449. '+--------------------------------------------------------------------------
  4450. ' Request attribute properties:
  4451. Public Const wszPROPCHALLENGE As String = "Challenge"
  4452. Public Const wszPROPEXPECTEDCHALLENGE As String = "ExpectedChallenge"
  4453. '+--------------------------------------------------------------------------
  4454. ' Certificate properties:
  4455. Public Const wszPROPCERTIFICATEREQUESTID As String = "RequestID"
  4456. Public Const wszPROPRAWCERTIFICATE As String = "RawCertificate"
  4457. Public Const wszPROPCERTIFICATETYPE As String = "CertificateType"
  4458. Public Const wszPROPCERTIFICATESERIALNUMBER As String = "SerialNumber"
  4459. Public Const wszPROPCERTIFICATEISSUERNAMEID As String = "IssuerNameID"
  4460. Public Const wszPROPCERTIFICATESUBJECTNAMEID As String = "SubjectNameID"
  4461. Public Const wszPROPCERTIFICATENOTBEFOREDATE As String = "NotBefore"
  4462. Public Const wszPROPCERTIFICATENOTAFTERDATE As String = "NotAfter"
  4463. Public Const wszPROPCERTIFICATERAWPUBLICKEY As String = "RawPublicKey"
  4464. Public Const wszPROPCERTIFICATEPUBLICKEYALGORITHM As String = "PublicKeyAlgorithm"
  4465. '+--------------------------------------------------------------------------
  4466. ' Certificate extension properties:
  4467. Public Const wszPROPCERTIFICATEEXTENSIONFLAGS As String = "Flags"
  4468. Public Const wszPROPCERTIFICATEEXTENSIONVALUE As String = "Value"
  4469. Public Const EXTENSION_CRITICAL_FLAG As Long = &H00000001
  4470. Public Const EXTENSION_DISABLE_FLAG As Long = &H00000002
  4471. Public Const EXTENSION_POLICY_MASK As Long = &H0000ffff
  4472. Public Const EXTENSION_ORIGIN_REQUEST As Long = &H00010000
  4473. Public Const EXTENSION_ORIGIN_POLICY As Long = &H00020000
  4474. Public Const EXTENSION_ORIGIN_ADMIN As Long = &H00030000
  4475. Public Const EXTENSION_ORIGIN_SERVER As Long = &H00040000
  4476. Public Const EXTENSION_ORIGIN_MASK As Long = &H000f0000
  4477. '+--------------------------------------------------------------------------
  4478. ' GetProperty/SetProperty Flags:
  4479. '
  4480. ' Choose one Type
  4481. Public Const PROPTYPE_LONG As Long = &H00000001
  4482. Public Const PROPTYPE_DATE As Long = &H00000002
  4483. Public Const PROPTYPE_BINARY As Long = &H00000003
  4484. Public Const PROPTYPE_STRING As Long = &H00000004
  4485. Public Const PROPTYPE_ANSI As Long = &H00000005
  4486. Public Const PROPTYPE_MASK As Long = &H000000ff
  4487. ' Choose one Caller:
  4488. Public Const PROPCALLER_SERVER As Long = &H00000100
  4489. Public Const PROPCALLER_POLICY As Long = &H00000200
  4490. Public Const PROPCALLER_EXIT As Long = &H00000300
  4491. Public Const PROPCALLER_ADMIN As Long = &H00000400
  4492. Public Const PROPCALLER_MASK As Long = &H00000f00
  4493. ' Choose one Table:
  4494. Public Const PROPTABLE_REQUEST As Long = &H00001000
  4495. Public Const PROPTABLE_CERTIFICATE As Long = &H00002000
  4496. Public Const PROPTABLE_EXTENSIONS As Long = &H00003000
  4497. Public Const PROPTABLE_ATTRIBUTES As Long = &H00004000
  4498. Public Const PROPTABLE_MASK As Long = &H0000f000
  4499. ' Internal use only
  4500. Public Const PROPTABLE_EXTENSIONFLAGS As Long = &H00010000
  4501. Public Const PROPTABLE_EXTENSIONVALUE As Long = &H00020000
  4502. Public Const cchSERIALNUMBERMAX As Long = 64
  4503. Public Const cchOBJECTIDMAX As Long = 31
  4504. Public Const cchDISTINGUISHEDNAMEMAX As Long = 254
  4505. Public Const cchCOUNTRYNAMEMAX As Long = 2
  4506. ' Request Status property values:
  4507. Public Const REQSTATUS_ACTIVE As Long = 1
  4508. Public Const REQSTATUS_ACCEPTED As Long = 2
  4509. Public Const REQSTATUS_DENIED As Long = 3
  4510. Public Const REQSTATUS_PENDING As Long = 4
  4511. Public Const REQSTATUS_ERROR As Long = 5
  4512. ' CertIF property callback support:
  4513. ' CertIF property enumeration callback support:
  4514. Public Const CIE_OBJECTID As Long = &H00000001
  4515. Public Const CIE_TABLE_EXTENSIONS As Long = &H00000010
  4516. Public Const CIE_TABLE_ATTRIBUTES As Long = &H00000020
  4517. Public Const CIE_TABLE_MASK As Long = &H000000f0
  4518. '+--------------------------------------------------------------------------
  4519. '
  4520. ' Microsoft Windows
  4521. '
  4522. ' File: certreq.h
  4523. '
  4524. ' Contents: ICertRequest definitions
  4525. '
  4526. ' History: 03-Jan-97 vich created
  4527. '
  4528. '---------------------------------------------------------------------------
  4529. '+--------------------------------------------------------------------------
  4530. ' Known request Attribute names and Value strings
  4531. ' RequestType attribute name:
  4532. Public Const wszCERT_TYPE As String = "RequestType"
  4533. ' RequestType attribute values:
  4534. ' Not specified:
  4535. Public Const wszCERT_TYPE_CLIENT As String = "Client"
  4536. Public Const wszCERT_TYPE_SERVER As String = "Server"
  4537. Public Const wszCERT_TYPE_CODESIGN As String = "CodeSign"
  4538. Public Const wszCERT_TYPE_CUSTOMER As String = "SetCustomer"
  4539. Public Const wszCERT_TYPE_MERCHANT As String = "SetMerchant"
  4540. Public Const wszCERT_TYPE_PAYMENT As String = "SetPayment"
  4541. ' Version attribute name:
  4542. Public Const wszCERT_VERSION As String = "Version"
  4543. ' Version attribute values:
  4544. ' Not specified:
  4545. Public Const wszCERT_VERSION_1 As String = "1"
  4546. Public Const wszCERT_VERSION_2 As String = "2"
  4547. Public Const wszCERT_VERSION_3 As String = "3"
  4548.