1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef __WINCRYPT_H__ 7 #define __WINCRYPT_H__ 8 9 #include <_mingw.h> 10 #include <_mingw_unicode.h> 11 #include <guiddef.h> 12 #include <bcrypt.h> 13 #include <ncrypt.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #ifndef _HRESULT_DEFINED 20 #define _HRESULT_DEFINED 21 typedef LONG HRESULT; 22 #endif 23 24 #ifndef DECLSPEC_IMPORT 25 #define DECLSPEC_IMPORT __declspec(dllimport) 26 #endif 27 28 #ifndef WINIMPM 29 #define WINIMPM DECLSPEC_IMPORT 30 #endif 31 32 #ifndef WINADVAPI 33 #ifndef _ADVAPI32_ 34 #define WINADVAPI WINIMPM 35 #else 36 #define WINADVAPI 37 #endif 38 #endif 39 40 41 #ifndef WINAPI 42 #define WINAPI __stdcall 43 #endif 44 45 #ifndef CALLBACK 46 #define CALLBACK __stdcall 47 #endif 48 49 #ifndef CONST 50 #define CONST const 51 #endif 52 53 #ifndef _NO_W32_PSEUDO_MODIFIERS 54 #ifndef IN 55 #define IN 56 #endif 57 #ifndef OUT 58 #define OUT 59 #endif 60 #ifndef OPTIONAL 61 #define OPTIONAL 62 #endif 63 #endif 64 65 #define WINCRYPT32API WINIMPM 66 #define WINCRYPT32STRINGAPI WINIMPM 67 68 #define GET_ALG_CLASS(x) (x & (7 << 13)) 69 #define GET_ALG_TYPE(x) (x & (15 << 9)) 70 #define GET_ALG_SID(x) (x & (511)) 71 72 #define ALG_CLASS_ANY (0) 73 #define ALG_CLASS_SIGNATURE (1 << 13) 74 #define ALG_CLASS_MSG_ENCRYPT (2 << 13) 75 #define ALG_CLASS_DATA_ENCRYPT (3 << 13) 76 #define ALG_CLASS_HASH (4 << 13) 77 #define ALG_CLASS_KEY_EXCHANGE (5 << 13) 78 #define ALG_CLASS_ALL (7 << 13) 79 80 #define ALG_TYPE_ANY (0) 81 #define ALG_TYPE_DSS (1 << 9) 82 #define ALG_TYPE_RSA (2 << 9) 83 #define ALG_TYPE_BLOCK (3 << 9) 84 #define ALG_TYPE_STREAM (4 << 9) 85 #define ALG_TYPE_DH (5 << 9) 86 #define ALG_TYPE_SECURECHANNEL (6 << 9) 87 88 #define ALG_SID_ANY (0) 89 90 #define ALG_SID_RSA_ANY 0 91 #define ALG_SID_RSA_PKCS 1 92 #define ALG_SID_RSA_MSATWORK 2 93 #define ALG_SID_RSA_ENTRUST 3 94 #define ALG_SID_RSA_PGP 4 95 96 #define ALG_SID_DSS_ANY 0 97 #define ALG_SID_DSS_PKCS 1 98 #define ALG_SID_DSS_DMS 2 99 100 #define ALG_SID_DES 1 101 #define ALG_SID_3DES 3 102 #define ALG_SID_DESX 4 103 #define ALG_SID_IDEA 5 104 #define ALG_SID_CAST 6 105 #define ALG_SID_SAFERSK64 7 106 #define ALG_SID_SAFERSK128 8 107 #define ALG_SID_3DES_112 9 108 #define ALG_SID_CYLINK_MEK 12 109 #define ALG_SID_RC5 13 110 #define ALG_SID_AES_128 14 111 #define ALG_SID_AES_192 15 112 #define ALG_SID_AES_256 16 113 #define ALG_SID_AES 17 114 115 #define ALG_SID_SKIPJACK 10 116 #define ALG_SID_TEK 11 117 118 #define CRYPT_MODE_CBCI 6 119 #define CRYPT_MODE_CFBP 7 120 #define CRYPT_MODE_OFBP 8 121 #define CRYPT_MODE_CBCOFM 9 122 #define CRYPT_MODE_CBCOFMI 10 123 124 #define ALG_SID_RC2 2 125 126 #define ALG_SID_RC4 1 127 #define ALG_SID_SEAL 2 128 129 #define ALG_SID_DH_SANDF 1 130 #define ALG_SID_DH_EPHEM 2 131 #define ALG_SID_AGREED_KEY_ANY 3 132 #define ALG_SID_KEA 4 133 134 #define ALG_SID_MD2 1 135 #define ALG_SID_MD4 2 136 #define ALG_SID_MD5 3 137 #define ALG_SID_SHA 4 138 #define ALG_SID_SHA1 4 139 #define ALG_SID_MAC 5 140 #define ALG_SID_RIPEMD 6 141 #define ALG_SID_RIPEMD160 7 142 #define ALG_SID_SSL3SHAMD5 8 143 #define ALG_SID_HMAC 9 144 #define ALG_SID_TLS1PRF 10 145 #define ALG_SID_HASH_REPLACE_OWF 11 146 #define ALG_SID_SHA_256 12 147 #define ALG_SID_SHA_384 13 148 #define ALG_SID_SHA_512 14 149 150 #define ALG_SID_SSL3_MASTER 1 151 #define ALG_SID_SCHANNEL_MASTER_HASH 2 152 #define ALG_SID_SCHANNEL_MAC_KEY 3 153 #define ALG_SID_PCT1_MASTER 4 154 #define ALG_SID_SSL2_MASTER 5 155 #define ALG_SID_TLS1_MASTER 6 156 #define ALG_SID_SCHANNEL_ENC_KEY 7 157 158 #define ALG_SID_EXAMPLE 80 159 160 #ifndef ALGIDDEF 161 #define ALGIDDEF 162 typedef unsigned int ALG_ID; 163 #endif 164 165 #define CALG_MD2 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2) 166 #define CALG_MD4 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4) 167 #define CALG_MD5 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5) 168 #define CALG_SHA (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA) 169 #define CALG_SHA1 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1) 170 #define CALG_MAC (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC) 171 #define CALG_RSA_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY) 172 #define CALG_DSS_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY) 173 #define CALG_NO_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY) 174 #define CALG_RSA_KEYX (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_RSA|ALG_SID_RSA_ANY) 175 #define CALG_DES (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_DES) 176 #define CALG_3DES_112 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_3DES_112) 177 #define CALG_3DES (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_3DES) 178 #define CALG_DESX (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_DESX) 179 #define CALG_RC2 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_RC2) 180 #define CALG_RC4 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_STREAM|ALG_SID_RC4) 181 #define CALG_SEAL (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_STREAM|ALG_SID_SEAL) 182 #define CALG_DH_SF (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_DH|ALG_SID_DH_SANDF) 183 #define CALG_DH_EPHEM (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_DH|ALG_SID_DH_EPHEM) 184 #define CALG_AGREEDKEY_ANY (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_DH|ALG_SID_AGREED_KEY_ANY) 185 #define CALG_KEA_KEYX (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_DH|ALG_SID_KEA) 186 #define CALG_HUGHES_MD5 (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_ANY|ALG_SID_MD5) 187 #define CALG_SKIPJACK (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_SKIPJACK) 188 #define CALG_TEK (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_TEK) 189 #define CALG_CYLINK_MEK (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_CYLINK_MEK) 190 #define CALG_SSL3_SHAMD5 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5) 191 #define CALG_SSL3_MASTER (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_SSL3_MASTER) 192 #define CALG_SCHANNEL_MASTER_HASH (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_SCHANNEL_MASTER_HASH) 193 #define CALG_SCHANNEL_MAC_KEY (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_SCHANNEL_MAC_KEY) 194 #define CALG_SCHANNEL_ENC_KEY (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_SCHANNEL_ENC_KEY) 195 #define CALG_PCT1_MASTER (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_PCT1_MASTER) 196 #define CALG_SSL2_MASTER (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_SSL2_MASTER) 197 #define CALG_TLS1_MASTER (ALG_CLASS_MSG_ENCRYPT|ALG_TYPE_SECURECHANNEL|ALG_SID_TLS1_MASTER) 198 #define CALG_RC5 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_RC5) 199 #define CALG_HMAC (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC) 200 #define CALG_TLS1PRF (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF) 201 #define CALG_HASH_REPLACE_OWF (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF) 202 #define CALG_AES_128 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_128) 203 #define CALG_AES_192 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_192) 204 #define CALG_AES_256 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_256) 205 #define CALG_AES (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES) 206 #define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) 207 #define CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) 208 #define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) 209 210 #if (_WIN32_WINNT >= 0x0600) 211 #define CALG_ECDH 0x0000aa05 212 #define CALG_ECDSA 0x00002203 213 #endif /*(_WIN32_WINNT >= 0x0600)*/ 214 215 #ifndef __HCRYPTKEY__ 216 #define __HCRYPTKEY__ 217 /* In ncrypt.h too */ 218 typedef ULONG_PTR HCRYPTKEY; 219 typedef ULONG_PTR HCRYPTPROV; 220 #endif 221 typedef ULONG_PTR HCRYPTHASH; 222 223 #define CRYPT_VERIFYCONTEXT 0xF0000000 224 #define CRYPT_NEWKEYSET 0x8 225 #define CRYPT_DELETEKEYSET 0x10 226 #define CRYPT_MACHINE_KEYSET 0x20 227 #define CRYPT_SILENT 0x40 228 229 #define CRYPT_EXPORTABLE 0x1 230 #define CRYPT_USER_PROTECTED 0x2 231 #define CRYPT_CREATE_SALT 0x4 232 #define CRYPT_UPDATE_KEY 0x8 233 #define CRYPT_NO_SALT 0x10 234 #define CRYPT_PREGEN 0x40 235 #define CRYPT_RECIPIENT 0x10 236 #define CRYPT_INITIATOR 0x40 237 #define CRYPT_ONLINE 0x80 238 #define CRYPT_SF 0x100 239 #define CRYPT_CREATE_IV 0x200 240 #define CRYPT_KEK 0x400 241 #define CRYPT_DATA_KEY 0x800 242 #define CRYPT_VOLATILE 0x1000 243 #define CRYPT_SGCKEY 0x2000 244 #define CRYPT_ARCHIVABLE 0x4000 245 246 #define RSA1024BIT_KEY 0x4000000 247 248 #define CRYPT_SERVER 0x400 249 250 #define KEY_LENGTH_MASK 0xFFFF0000 251 252 #define CRYPT_Y_ONLY 0x1 253 #define CRYPT_SSL2_FALLBACK 0x2 254 #define CRYPT_DESTROYKEY 0x4 255 #define CRYPT_OAEP 0x40 256 257 #define CRYPT_BLOB_VER3 0x80 258 #define CRYPT_IPSEC_HMAC_KEY 0x100 259 260 #define CRYPT_DECRYPT_RSA_NO_PADDING_CHECK 0x20 261 262 #define CRYPT_SECRETDIGEST 0x1 263 264 #define CRYPT_OWF_REPL_LM_HASH 0x1 265 266 #define CRYPT_LITTLE_ENDIAN 0x1 267 268 #define CRYPT_NOHASHOID 0x1 269 #define CRYPT_TYPE2_FORMAT 0x2 270 #define CRYPT_X931_FORMAT 0x4 271 272 #define CRYPT_MACHINE_DEFAULT 0x1 273 #define CRYPT_USER_DEFAULT 0x2 274 #define CRYPT_DELETE_DEFAULT 0x4 275 276 #define SIMPLEBLOB 0x1 277 #define PUBLICKEYBLOB 0x6 278 #define PRIVATEKEYBLOB 0x7 279 #define PLAINTEXTKEYBLOB 0x8 280 #define OPAQUEKEYBLOB 0x9 281 #define PUBLICKEYBLOBEX 0xa 282 #define SYMMETRICWRAPKEYBLOB 0xb 283 #define KEYSTATEBLOB 0xc 284 285 #define AT_KEYEXCHANGE 1 286 #define AT_SIGNATURE 2 287 288 #define CRYPT_USERDATA 1 289 290 #define KP_IV 1 291 #define KP_SALT 2 292 #define KP_PADDING 3 293 #define KP_MODE 4 294 #define KP_MODE_BITS 5 295 #define KP_PERMISSIONS 6 296 #define KP_ALGID 7 297 #define KP_BLOCKLEN 8 298 #define KP_KEYLEN 9 299 #define KP_SALT_EX 10 300 #define KP_P 11 301 #define KP_G 12 302 #define KP_Q 13 303 #define KP_X 14 304 #define KP_Y 15 305 #define KP_RA 16 306 #define KP_RB 17 307 #define KP_INFO 18 308 #define KP_EFFECTIVE_KEYLEN 19 309 #define KP_SCHANNEL_ALG 20 310 #define KP_CLIENT_RANDOM 21 311 #define KP_SERVER_RANDOM 22 312 #define KP_RP 23 313 #define KP_PRECOMP_MD5 24 314 #define KP_PRECOMP_SHA 25 315 #define KP_CERTIFICATE 26 316 #define KP_CLEAR_KEY 27 317 #define KP_PUB_EX_LEN 28 318 #define KP_PUB_EX_VAL 29 319 #define KP_KEYVAL 30 320 #define KP_ADMIN_PIN 31 321 #define KP_KEYEXCHANGE_PIN 32 322 #define KP_SIGNATURE_PIN 33 323 #define KP_PREHASH 34 324 #define KP_ROUNDS 35 325 #define KP_OAEP_PARAMS 36 326 #define KP_CMS_KEY_INFO 37 327 #define KP_CMS_DH_KEY_INFO 38 328 #define KP_PUB_PARAMS 39 329 #define KP_VERIFY_PARAMS 40 330 #define KP_HIGHEST_VERSION 41 331 #define KP_GET_USE_COUNT 42 332 333 #define PKCS5_PADDING 1 334 #define RANDOM_PADDING 2 335 #define ZERO_PADDING 3 336 337 #define CRYPT_MODE_CBC 1 338 #define CRYPT_MODE_ECB 2 339 #define CRYPT_MODE_OFB 3 340 #define CRYPT_MODE_CFB 4 341 #define CRYPT_MODE_CTS 5 342 343 #define CRYPT_ENCRYPT 0x1 344 #define CRYPT_DECRYPT 0x2 345 #define CRYPT_EXPORT 0x4 346 #define CRYPT_READ 0x8 347 #define CRYPT_WRITE 0x10 348 #define CRYPT_MAC 0x20 349 #define CRYPT_EXPORT_KEY 0x40 350 #define CRYPT_IMPORT_KEY 0x80 351 #define CRYPT_ARCHIVE 0x100 352 353 #define HP_ALGID 0x1 354 #define HP_HASHVAL 0x2 355 #define HP_HASHSIZE 0x4 356 #define HP_HMAC_INFO 0x5 357 #define HP_TLS1PRF_LABEL 0x6 358 #define HP_TLS1PRF_SEED 0x7 359 360 #define CRYPT_FAILED FALSE 361 #define CRYPT_SUCCEED TRUE 362 363 #define RCRYPT_SUCCEEDED(RT) ((RT) == CRYPT_SUCCEED) 364 #define RCRYPT_FAILED(RT) ((RT) == CRYPT_FAILED) 365 366 #define PP_ENUMALGS 1 367 #define PP_ENUMCONTAINERS 2 368 #define PP_IMPTYPE 3 369 #define PP_NAME 4 370 #define PP_VERSION 5 371 #define PP_CONTAINER 6 372 #define PP_CHANGE_PASSWORD 7 373 #define PP_KEYSET_SEC_DESCR 8 374 #define PP_CERTCHAIN 9 375 #define PP_KEY_TYPE_SUBTYPE 10 376 #define PP_PROVTYPE 16 377 #define PP_KEYSTORAGE 17 378 #define PP_APPLI_CERT 18 379 #define PP_SYM_KEYSIZE 19 380 #define PP_SESSION_KEYSIZE 20 381 #define PP_UI_PROMPT 21 382 #define PP_ENUMALGS_EX 22 383 #define PP_ENUMMANDROOTS 25 384 #define PP_ENUMELECTROOTS 26 385 #define PP_KEYSET_TYPE 27 386 #define PP_ADMIN_PIN 31 387 #define PP_KEYEXCHANGE_PIN 32 388 #define PP_SIGNATURE_PIN 33 389 #define PP_SIG_KEYSIZE_INC 34 390 #define PP_KEYX_KEYSIZE_INC 35 391 #define PP_UNIQUE_CONTAINER 36 392 #define PP_SGC_INFO 37 393 #define PP_USE_HARDWARE_RNG 38 394 #define PP_KEYSPEC 39 395 #define PP_ENUMEX_SIGNING_PROT 40 396 #define PP_CRYPT_COUNT_KEY_USE 41 397 398 #define CRYPT_FIRST 1 399 #define CRYPT_NEXT 2 400 #define CRYPT_SGC_ENUM 4 401 402 #define CRYPT_IMPL_HARDWARE 1 403 #define CRYPT_IMPL_SOFTWARE 2 404 #define CRYPT_IMPL_MIXED 3 405 #define CRYPT_IMPL_UNKNOWN 4 406 #define CRYPT_IMPL_REMOVABLE 8 407 408 #define CRYPT_SEC_DESCR 0x1 409 #define CRYPT_PSTORE 0x2 410 #define CRYPT_UI_PROMPT 0x4 411 412 #define CRYPT_FLAG_PCT1 0x1 413 #define CRYPT_FLAG_SSL2 0x2 414 #define CRYPT_FLAG_SSL3 0x4 415 #define CRYPT_FLAG_TLS1 0x8 416 #define CRYPT_FLAG_IPSEC 0x10 417 #define CRYPT_FLAG_SIGNING 0x20 418 419 #define CRYPT_SGC 0x1 420 #define CRYPT_FASTSGC 0x2 421 422 #define PP_CLIENT_HWND 1 423 #define PP_CONTEXT_INFO 11 424 #define PP_KEYEXCHANGE_KEYSIZE 12 425 #define PP_SIGNATURE_KEYSIZE 13 426 #define PP_KEYEXCHANGE_ALG 14 427 #define PP_SIGNATURE_ALG 15 428 #define PP_DELETEKEY 24 429 430 #define PROV_RSA_FULL 1 431 #define PROV_RSA_SIG 2 432 #define PROV_DSS 3 433 #define PROV_FORTEZZA 4 434 #define PROV_MS_EXCHANGE 5 435 #define PROV_SSL 6 436 #define PROV_RSA_SCHANNEL 12 437 #define PROV_DSS_DH 13 438 #define PROV_EC_ECDSA_SIG 14 439 #define PROV_EC_ECNRA_SIG 15 440 #define PROV_EC_ECDSA_FULL 16 441 #define PROV_EC_ECNRA_FULL 17 442 #define PROV_DH_SCHANNEL 18 443 #define PROV_SPYRUS_LYNKS 20 444 #define PROV_RNG 21 445 #define PROV_INTEL_SEC 22 446 #define PROV_REPLACE_OWF 23 447 #define PROV_RSA_AES 24 448 449 #define MS_DEF_PROV __MINGW_NAME_UAW(MS_DEF_PROV) 450 #define MS_ENHANCED_PROV __MINGW_NAME_UAW(MS_ENHANCED_PROV) 451 #define MS_STRONG_PROV __MINGW_NAME_UAW(MS_STRONG_PROV) 452 #define MS_DEF_RSA_SIG_PROV __MINGW_NAME_UAW(MS_DEF_RSA_SIG_PROV) 453 #define MS_DEF_RSA_SCHANNEL_PROV __MINGW_NAME_UAW(MS_DEF_RSA_SCHANNEL_PROV) 454 #define MS_DEF_DSS_PROV __MINGW_NAME_UAW(MS_DEF_DSS_PROV) 455 #define MS_DEF_DSS_DH_PROV __MINGW_NAME_UAW(MS_DEF_DSS_DH_PROV) 456 #define MS_ENH_DSS_DH_PROV __MINGW_NAME_UAW(MS_ENH_DSS_DH_PROV) 457 #define MS_DEF_DH_SCHANNEL_PROV __MINGW_NAME_UAW(MS_DEF_DH_SCHANNEL_PROV) 458 459 #define MS_DEF_PROV_A "Microsoft Base Cryptographic Provider v1.0" 460 #define MS_DEF_PROV_W L"Microsoft Base Cryptographic Provider v1.0" 461 #define MS_ENHANCED_PROV_A "Microsoft Enhanced Cryptographic Provider v1.0" 462 #define MS_ENHANCED_PROV_W L"Microsoft Enhanced Cryptographic Provider v1.0" 463 #define MS_STRONG_PROV_A "Microsoft Strong Cryptographic Provider" 464 #define MS_STRONG_PROV_W L"Microsoft Strong Cryptographic Provider" 465 #define MS_DEF_RSA_SIG_PROV_A "Microsoft RSA Signature Cryptographic Provider" 466 #define MS_DEF_RSA_SIG_PROV_W L"Microsoft RSA Signature Cryptographic Provider" 467 #define MS_DEF_RSA_SCHANNEL_PROV_A "Microsoft RSA SChannel Cryptographic Provider" 468 #define MS_DEF_RSA_SCHANNEL_PROV_W L"Microsoft RSA SChannel Cryptographic Provider" 469 #define MS_DEF_DSS_PROV_A "Microsoft Base DSS Cryptographic Provider" 470 #define MS_DEF_DSS_PROV_W L"Microsoft Base DSS Cryptographic Provider" 471 #define MS_DEF_DSS_DH_PROV_A "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider" 472 #define MS_DEF_DSS_DH_PROV_W L"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider" 473 #define MS_ENH_DSS_DH_PROV_A "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider" 474 #define MS_ENH_DSS_DH_PROV_W L"Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider" 475 #define MS_DEF_DH_SCHANNEL_PROV_A "Microsoft DH SChannel Cryptographic Provider" 476 #define MS_DEF_DH_SCHANNEL_PROV_W L"Microsoft DH SChannel Cryptographic Provider" 477 478 #define MS_SCARD_PROV __MINGW_NAME_UAW(MS_SCARD_PROV) 479 #define MS_ENH_RSA_AES_PROV __MINGW_NAME_UAW(MS_ENH_RSA_AES_PROV) 480 #define MS_ENH_RSA_AES_PROV_XP __MINGW_NAME_UAW(MS_ENH_RSA_AES_PROV_XP) 481 482 #define MS_SCARD_PROV_A "Microsoft Base Smart Card Crypto Provider" 483 #define MS_SCARD_PROV_W L"Microsoft Base Smart Card Crypto Provider" 484 485 #define MS_ENH_RSA_AES_PROV_A "Microsoft Enhanced RSA and AES Cryptographic Provider" 486 #define MS_ENH_RSA_AES_PROV_W L"Microsoft Enhanced RSA and AES Cryptographic Provider" 487 #define MS_ENH_RSA_AES_PROV_XP_A "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)" 488 #define MS_ENH_RSA_AES_PROV_XP_W L"Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)" 489 490 #define MAXUIDLEN 64 491 492 #define EXPO_OFFLOAD_REG_VALUE "ExpoOffload" 493 #define EXPO_OFFLOAD_FUNC_NAME "OffloadModExpo" 494 495 #define szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS "Software\\Policies\\Microsoft\\Cryptography" 496 497 #define szFORCE_KEY_PROTECTION "ForceKeyProtection" 498 499 #define dwFORCE_KEY_PROTECTION_DISABLED 0x0 500 #define dwFORCE_KEY_PROTECTION_USER_SELECT 0x1 501 #define dwFORCE_KEY_PROTECTION_HIGH 0x2 502 503 #define szKEY_CACHE_ENABLED "CachePrivateKeys" 504 #define szKEY_CACHE_SECONDS "PrivateKeyLifetimeSeconds" 505 506 #define szPRIV_KEY_CACHE_MAX_ITEMS "PrivKeyCacheMaxItems" 507 #define cPRIV_KEY_CACHE_MAX_ITEMS_DEFAULT 20 508 509 #define szPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS "PrivKeyCachePurgeIntervalSeconds" 510 #define cPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS_DEFAULT 86400 511 512 #define CUR_BLOB_VERSION 2 513 514 typedef struct _CMS_KEY_INFO { 515 DWORD dwVersion; 516 ALG_ID Algid; 517 BYTE *pbOID; 518 DWORD cbOID; 519 } CMS_KEY_INFO,*PCMS_KEY_INFO; 520 521 typedef struct _HMAC_Info { 522 ALG_ID HashAlgid; 523 BYTE *pbInnerString; 524 DWORD cbInnerString; 525 BYTE *pbOuterString; 526 DWORD cbOuterString; 527 } HMAC_INFO,*PHMAC_INFO; 528 529 typedef struct _SCHANNEL_ALG { 530 DWORD dwUse; 531 ALG_ID Algid; 532 DWORD cBits; 533 DWORD dwFlags; 534 DWORD dwReserved; 535 } SCHANNEL_ALG,*PSCHANNEL_ALG; 536 537 #define SCHANNEL_MAC_KEY 0x0 538 #define SCHANNEL_ENC_KEY 0x1 539 540 #define INTERNATIONAL_USAGE 0x1 541 542 typedef struct _PROV_ENUMALGS { 543 ALG_ID aiAlgid; 544 DWORD dwBitLen; 545 DWORD dwNameLen; 546 CHAR szName[20]; 547 } PROV_ENUMALGS; 548 549 typedef struct _PROV_ENUMALGS_EX { 550 ALG_ID aiAlgid; 551 DWORD dwDefaultLen; 552 DWORD dwMinLen; 553 DWORD dwMaxLen; 554 DWORD dwProtocols; 555 DWORD dwNameLen; 556 CHAR szName[20]; 557 DWORD dwLongNameLen; 558 CHAR szLongName[40]; 559 } PROV_ENUMALGS_EX; 560 561 typedef struct _PUBLICKEYSTRUC { 562 BYTE bType; 563 BYTE bVersion; 564 WORD reserved; 565 ALG_ID aiKeyAlg; 566 } BLOBHEADER,PUBLICKEYSTRUC; 567 568 typedef struct _RSAPUBKEY { 569 DWORD magic; 570 DWORD bitlen; 571 DWORD pubexp; 572 573 } RSAPUBKEY; 574 575 typedef struct _PUBKEY { 576 DWORD magic; 577 DWORD bitlen; 578 } DHPUBKEY,DSSPUBKEY,KEAPUBKEY,TEKPUBKEY; 579 580 typedef struct _DSSSEED { 581 DWORD counter; 582 BYTE seed[20]; 583 } DSSSEED; 584 585 typedef struct _PUBKEYVER3 { 586 DWORD magic; 587 DWORD bitlenP; 588 DWORD bitlenQ; 589 DWORD bitlenJ; 590 DSSSEED DSSSeed; 591 } DHPUBKEY_VER3,DSSPUBKEY_VER3; 592 593 typedef struct _PRIVKEYVER3 { 594 DWORD magic; 595 DWORD bitlenP; 596 DWORD bitlenQ; 597 DWORD bitlenJ; 598 DWORD bitlenX; 599 DSSSEED DSSSeed; 600 } DHPRIVKEY_VER3,DSSPRIVKEY_VER3; 601 602 typedef struct _KEY_TYPE_SUBTYPE { 603 DWORD dwKeySpec; 604 GUID Type; 605 GUID Subtype; 606 } KEY_TYPE_SUBTYPE,*PKEY_TYPE_SUBTYPE; 607 608 typedef struct _CERT_FORTEZZA_DATA_PROP { 609 unsigned char SerialNumber[8]; 610 int CertIndex; 611 unsigned char CertLabel[36]; 612 } CERT_FORTEZZA_DATA_PROP; 613 614 typedef struct _CRYPT_RC4_KEY_STATE { 615 unsigned char Key[16]; 616 unsigned char SBox[256]; 617 unsigned char i; 618 unsigned char j; 619 } CRYPT_RC4_KEY_STATE,*PCRYPT_RC4_KEY_STATE; 620 621 typedef struct _CRYPT_DES_KEY_STATE { 622 unsigned char Key[8]; 623 unsigned char IV[8]; 624 unsigned char Feedback[8]; 625 } CRYPT_DES_KEY_STATE,*PCRYPT_DES_KEY_STATE; 626 627 typedef struct _CRYPT_3DES_KEY_STATE { 628 unsigned char Key[24]; 629 unsigned char IV[8]; 630 unsigned char Feedback[8]; 631 } CRYPT_3DES_KEY_STATE,*PCRYPT_3DES_KEY_STATE; 632 633 typedef struct _CRYPTOAPI_BLOB { 634 DWORD cbData; 635 BYTE *pbData; 636 } CRYPT_INTEGER_BLOB,*PCRYPT_INTEGER_BLOB,CRYPT_UINT_BLOB,*PCRYPT_UINT_BLOB,CRYPT_OBJID_BLOB,*PCRYPT_OBJID_BLOB,CERT_NAME_BLOB,*PCERT_NAME_BLOB,CERT_RDN_VALUE_BLOB,*PCERT_RDN_VALUE_BLOB,CERT_BLOB,*PCERT_BLOB,CRL_BLOB,*PCRL_BLOB,DATA_BLOB,*PDATA_BLOB,CRYPT_DATA_BLOB,*PCRYPT_DATA_BLOB,CRYPT_HASH_BLOB,*PCRYPT_HASH_BLOB,CRYPT_DIGEST_BLOB,*PCRYPT_DIGEST_BLOB,CRYPT_DER_BLOB,*PCRYPT_DER_BLOB,CRYPT_ATTR_BLOB,*PCRYPT_ATTR_BLOB; 637 638 typedef struct _CMS_DH_KEY_INFO { 639 DWORD dwVersion; 640 ALG_ID Algid; 641 LPSTR pszContentEncObjId; 642 CRYPT_DATA_BLOB PubInfo; 643 void *pReserved; 644 } CMS_DH_KEY_INFO,*PCMS_DH_KEY_INFO; 645 646 #define CryptAcquireContext __MINGW_NAME_AW(CryptAcquireContext) 647 #define CryptSignHash __MINGW_NAME_AW(CryptSignHash) 648 #define CryptVerifySignature __MINGW_NAME_AW(CryptVerifySignature) 649 650 WINIMPM WINBOOL WINAPI CryptAcquireContextA(HCRYPTPROV *phProv,LPCSTR szContainer,LPCSTR szProvider,DWORD dwProvType,DWORD dwFlags); 651 WINIMPM WINBOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv,LPCWSTR szContainer,LPCWSTR szProvider,DWORD dwProvType,DWORD dwFlags); 652 WINIMPM WINBOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv,DWORD dwFlags); 653 WINIMPM WINBOOL WINAPI CryptGenKey(HCRYPTPROV hProv,ALG_ID Algid,DWORD dwFlags,HCRYPTKEY *phKey); 654 WINIMPM WINBOOL WINAPI CryptDeriveKey(HCRYPTPROV hProv,ALG_ID Algid,HCRYPTHASH hBaseData,DWORD dwFlags,HCRYPTKEY *phKey); 655 WINIMPM WINBOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey); 656 WINIMPM WINBOOL WINAPI CryptSetKeyParam(HCRYPTKEY hKey,DWORD dwParam,CONST BYTE *pbData,DWORD dwFlags); 657 WINIMPM WINBOOL WINAPI CryptGetKeyParam(HCRYPTKEY hKey,DWORD dwParam,BYTE *pbData,DWORD *pdwDataLen,DWORD dwFlags); 658 WINIMPM WINBOOL WINAPI CryptSetHashParam(HCRYPTHASH hHash,DWORD dwParam,CONST BYTE *pbData,DWORD dwFlags); 659 WINIMPM WINBOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash,DWORD dwParam,BYTE *pbData,DWORD *pdwDataLen,DWORD dwFlags); 660 WINIMPM WINBOOL WINAPI CryptSetProvParam(HCRYPTPROV hProv,DWORD dwParam,CONST BYTE *pbData,DWORD dwFlags); 661 WINIMPM WINBOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv,DWORD dwParam,BYTE *pbData,DWORD *pdwDataLen,DWORD dwFlags); 662 WINIMPM WINBOOL WINAPI CryptGenRandom(HCRYPTPROV hProv,DWORD dwLen,BYTE *pbBuffer); 663 WINIMPM WINBOOL WINAPI CryptGetUserKey(HCRYPTPROV hProv,DWORD dwKeySpec,HCRYPTKEY *phUserKey); 664 WINIMPM WINBOOL WINAPI CryptExportKey(HCRYPTKEY hKey,HCRYPTKEY hExpKey,DWORD dwBlobType,DWORD dwFlags,BYTE *pbData,DWORD *pdwDataLen); 665 WINIMPM WINBOOL WINAPI CryptImportKey(HCRYPTPROV hProv,CONST BYTE *pbData,DWORD dwDataLen,HCRYPTKEY hPubKey,DWORD dwFlags,HCRYPTKEY *phKey); 666 WINIMPM WINBOOL WINAPI CryptEncrypt(HCRYPTKEY hKey,HCRYPTHASH hHash,WINBOOL Final,DWORD dwFlags,BYTE *pbData,DWORD *pdwDataLen,DWORD dwBufLen); 667 WINIMPM WINBOOL WINAPI CryptDecrypt(HCRYPTKEY hKey,HCRYPTHASH hHash,WINBOOL Final,DWORD dwFlags,BYTE *pbData,DWORD *pdwDataLen); 668 WINIMPM WINBOOL WINAPI CryptCreateHash(HCRYPTPROV hProv,ALG_ID Algid,HCRYPTKEY hKey,DWORD dwFlags,HCRYPTHASH *phHash); 669 WINIMPM WINBOOL WINAPI CryptHashData(HCRYPTHASH hHash,CONST BYTE *pbData,DWORD dwDataLen,DWORD dwFlags); 670 WINIMPM WINBOOL WINAPI CryptHashSessionKey(HCRYPTHASH hHash,HCRYPTKEY hKey,DWORD dwFlags); 671 WINIMPM WINBOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash); 672 WINIMPM WINBOOL WINAPI CryptSignHashA(HCRYPTHASH hHash,DWORD dwKeySpec,LPCSTR szDescription,DWORD dwFlags,BYTE *pbSignature,DWORD *pdwSigLen); 673 WINIMPM WINBOOL WINAPI CryptSignHashW(HCRYPTHASH hHash,DWORD dwKeySpec,LPCWSTR szDescription,DWORD dwFlags,BYTE *pbSignature,DWORD *pdwSigLen); 674 WINIMPM WINBOOL WINAPI CryptVerifySignatureA(HCRYPTHASH hHash,CONST BYTE *pbSignature,DWORD dwSigLen,HCRYPTKEY hPubKey,LPCSTR szDescription,DWORD dwFlags); 675 WINIMPM WINBOOL WINAPI CryptVerifySignatureW(HCRYPTHASH hHash,CONST BYTE *pbSignature,DWORD dwSigLen,HCRYPTKEY hPubKey,LPCWSTR szDescription,DWORD dwFlags); 676 WINIMPM WINBOOL WINAPI CryptSetProviderA(LPCSTR pszProvName,DWORD dwProvType); 677 WINIMPM WINBOOL WINAPI CryptSetProviderW(LPCWSTR pszProvName,DWORD dwProvType); 678 679 #define CryptSetProvider __MINGW_NAME_AW(CryptSetProvider) 680 #define CryptSetProviderEx __MINGW_NAME_AW(CryptSetProviderEx) 681 #define CryptGetDefaultProvider __MINGW_NAME_AW(CryptGetDefaultProvider) 682 #define CryptEnumProviderTypes __MINGW_NAME_AW(CryptEnumProviderTypes) 683 #define CryptEnumProviders __MINGW_NAME_AW(CryptEnumProviders) 684 685 WINIMPM WINBOOL WINAPI CryptSetProviderExA(LPCSTR pszProvName,DWORD dwProvType,DWORD *pdwReserved,DWORD dwFlags); 686 WINIMPM WINBOOL WINAPI CryptSetProviderExW(LPCWSTR pszProvName,DWORD dwProvType,DWORD *pdwReserved,DWORD dwFlags); 687 WINIMPM WINBOOL WINAPI CryptGetDefaultProviderA(DWORD dwProvType,DWORD *pdwReserved,DWORD dwFlags,LPSTR pszProvName,DWORD *pcbProvName); 688 WINIMPM WINBOOL WINAPI CryptGetDefaultProviderW(DWORD dwProvType,DWORD *pdwReserved,DWORD dwFlags,LPWSTR pszProvName,DWORD *pcbProvName); 689 WINIMPM WINBOOL WINAPI CryptEnumProviderTypesA(DWORD dwIndex,DWORD *pdwReserved,DWORD dwFlags,DWORD *pdwProvType,LPSTR szTypeName,DWORD *pcbTypeName); 690 WINIMPM WINBOOL WINAPI CryptEnumProviderTypesW(DWORD dwIndex,DWORD *pdwReserved,DWORD dwFlags,DWORD *pdwProvType,LPWSTR szTypeName,DWORD *pcbTypeName); 691 WINIMPM WINBOOL WINAPI CryptEnumProvidersA(DWORD dwIndex,DWORD *pdwReserved,DWORD dwFlags,DWORD *pdwProvType,LPSTR szProvName,DWORD *pcbProvName); 692 WINIMPM WINBOOL WINAPI CryptEnumProvidersW(DWORD dwIndex,DWORD *pdwReserved,DWORD dwFlags,DWORD *pdwProvType,LPWSTR szProvName,DWORD *pcbProvName); 693 WINIMPM WINBOOL WINAPI CryptContextAddRef(HCRYPTPROV hProv,DWORD *pdwReserved,DWORD dwFlags); 694 WINIMPM WINBOOL WINAPI CryptDuplicateKey(HCRYPTKEY hKey,DWORD *pdwReserved,DWORD dwFlags,HCRYPTKEY *phKey); 695 WINIMPM WINBOOL WINAPI CryptDuplicateHash(HCRYPTHASH hHash,DWORD *pdwReserved,DWORD dwFlags,HCRYPTHASH *phHash); 696 WINBOOL __cdecl GetEncSChannel(BYTE **pData,DWORD *dwDecSize); 697 698 typedef struct _CRYPT_BIT_BLOB { 699 DWORD cbData; 700 BYTE *pbData; 701 DWORD cUnusedBits; 702 } CRYPT_BIT_BLOB,*PCRYPT_BIT_BLOB; 703 704 typedef struct _CRYPT_ALGORITHM_IDENTIFIER { 705 LPSTR pszObjId; 706 CRYPT_OBJID_BLOB Parameters; 707 } CRYPT_ALGORITHM_IDENTIFIER,*PCRYPT_ALGORITHM_IDENTIFIER; 708 709 #define szOID_RSA "1.2.840.113549" 710 #define szOID_PKCS "1.2.840.113549.1" 711 #define szOID_RSA_HASH "1.2.840.113549.2" 712 #define szOID_RSA_ENCRYPT "1.2.840.113549.3" 713 #define szOID_PKCS_1 "1.2.840.113549.1.1" 714 #define szOID_PKCS_2 "1.2.840.113549.1.2" 715 #define szOID_PKCS_3 "1.2.840.113549.1.3" 716 #define szOID_PKCS_4 "1.2.840.113549.1.4" 717 #define szOID_PKCS_5 "1.2.840.113549.1.5" 718 #define szOID_PKCS_6 "1.2.840.113549.1.6" 719 #define szOID_PKCS_7 "1.2.840.113549.1.7" 720 #define szOID_PKCS_8 "1.2.840.113549.1.8" 721 #define szOID_PKCS_9 "1.2.840.113549.1.9" 722 #define szOID_PKCS_10 "1.2.840.113549.1.10" 723 #define szOID_PKCS_12 "1.2.840.113549.1.12" 724 #define szOID_RSA_RSA "1.2.840.113549.1.1.1" 725 #define szOID_RSA_MD2RSA "1.2.840.113549.1.1.2" 726 #define szOID_RSA_MD4RSA "1.2.840.113549.1.1.3" 727 #define szOID_RSA_MD5RSA "1.2.840.113549.1.1.4" 728 #define szOID_RSA_SHA1RSA "1.2.840.113549.1.1.5" 729 #define szOID_RSA_SETOAEP_RSA "1.2.840.113549.1.1.6" 730 #define szOID_RSA_DH "1.2.840.113549.1.3.1" 731 #define szOID_RSA_data "1.2.840.113549.1.7.1" 732 #define szOID_RSA_signedData "1.2.840.113549.1.7.2" 733 #define szOID_RSA_envelopedData "1.2.840.113549.1.7.3" 734 #define szOID_RSA_signEnvData "1.2.840.113549.1.7.4" 735 #define szOID_RSA_digestedData "1.2.840.113549.1.7.5" 736 #define szOID_RSA_hashedData "1.2.840.113549.1.7.5" 737 #define szOID_RSA_encryptedData "1.2.840.113549.1.7.6" 738 #define szOID_RSA_emailAddr "1.2.840.113549.1.9.1" 739 #define szOID_RSA_unstructName "1.2.840.113549.1.9.2" 740 #define szOID_RSA_contentType "1.2.840.113549.1.9.3" 741 #define szOID_RSA_messageDigest "1.2.840.113549.1.9.4" 742 #define szOID_RSA_signingTime "1.2.840.113549.1.9.5" 743 #define szOID_RSA_counterSign "1.2.840.113549.1.9.6" 744 #define szOID_RSA_challengePwd "1.2.840.113549.1.9.7" 745 #define szOID_RSA_unstructAddr "1.2.840.113549.1.9.8" 746 #define szOID_RSA_extCertAttrs "1.2.840.113549.1.9.9" 747 #define szOID_RSA_certExtensions "1.2.840.113549.1.9.14" 748 #define szOID_RSA_SMIMECapabilities "1.2.840.113549.1.9.15" 749 #define szOID_RSA_preferSignedData "1.2.840.113549.1.9.15.1" 750 #define szOID_RSA_SMIMEalg "1.2.840.113549.1.9.16.3" 751 #define szOID_RSA_SMIMEalgESDH "1.2.840.113549.1.9.16.3.5" 752 #define szOID_RSA_SMIMEalgCMS3DESwrap "1.2.840.113549.1.9.16.3.6" 753 #define szOID_RSA_SMIMEalgCMSRC2wrap "1.2.840.113549.1.9.16.3.7" 754 #define szOID_RSA_MD2 "1.2.840.113549.2.2" 755 #define szOID_RSA_MD4 "1.2.840.113549.2.4" 756 #define szOID_RSA_MD5 "1.2.840.113549.2.5" 757 758 #define szOID_RSA_RC2CBC "1.2.840.113549.3.2" 759 #define szOID_RSA_RC4 "1.2.840.113549.3.4" 760 #define szOID_RSA_DES_EDE3_CBC "1.2.840.113549.3.7" 761 #define szOID_RSA_RC5_CBCPad "1.2.840.113549.3.9" 762 763 #define szOID_ANSI_X942 "1.2.840.10046" 764 #define szOID_ANSI_X942_DH "1.2.840.10046.2.1" 765 766 #define szOID_X957 "1.2.840.10040" 767 #define szOID_X957_DSA "1.2.840.10040.4.1" 768 #define szOID_X957_SHA1DSA "1.2.840.10040.4.3" 769 770 #define szOID_DS "2.5" 771 #define szOID_DSALG "2.5.8" 772 #define szOID_DSALG_CRPT "2.5.8.1" 773 #define szOID_DSALG_HASH "2.5.8.2" 774 #define szOID_DSALG_SIGN "2.5.8.3" 775 #define szOID_DSALG_RSA "2.5.8.1.1" 776 777 #define szOID_OIW "1.3.14" 778 779 #define szOID_OIWSEC "1.3.14.3.2" 780 #define szOID_OIWSEC_md4RSA "1.3.14.3.2.2" 781 #define szOID_OIWSEC_md5RSA "1.3.14.3.2.3" 782 #define szOID_OIWSEC_md4RSA2 "1.3.14.3.2.4" 783 #define szOID_OIWSEC_desECB "1.3.14.3.2.6" 784 #define szOID_OIWSEC_desCBC "1.3.14.3.2.7" 785 #define szOID_OIWSEC_desOFB "1.3.14.3.2.8" 786 #define szOID_OIWSEC_desCFB "1.3.14.3.2.9" 787 #define szOID_OIWSEC_desMAC "1.3.14.3.2.10" 788 #define szOID_OIWSEC_rsaSign "1.3.14.3.2.11" 789 #define szOID_OIWSEC_dsa "1.3.14.3.2.12" 790 #define szOID_OIWSEC_shaDSA "1.3.14.3.2.13" 791 #define szOID_OIWSEC_mdc2RSA "1.3.14.3.2.14" 792 #define szOID_OIWSEC_shaRSA "1.3.14.3.2.15" 793 #define szOID_OIWSEC_dhCommMod "1.3.14.3.2.16" 794 #define szOID_OIWSEC_desEDE "1.3.14.3.2.17" 795 #define szOID_OIWSEC_sha "1.3.14.3.2.18" 796 #define szOID_OIWSEC_mdc2 "1.3.14.3.2.19" 797 #define szOID_OIWSEC_dsaComm "1.3.14.3.2.20" 798 #define szOID_OIWSEC_dsaCommSHA "1.3.14.3.2.21" 799 #define szOID_OIWSEC_rsaXchg "1.3.14.3.2.22" 800 #define szOID_OIWSEC_keyHashSeal "1.3.14.3.2.23" 801 #define szOID_OIWSEC_md2RSASign "1.3.14.3.2.24" 802 #define szOID_OIWSEC_md5RSASign "1.3.14.3.2.25" 803 #define szOID_OIWSEC_sha1 "1.3.14.3.2.26" 804 #define szOID_OIWSEC_dsaSHA1 "1.3.14.3.2.27" 805 #define szOID_OIWSEC_dsaCommSHA1 "1.3.14.3.2.28" 806 #define szOID_OIWSEC_sha1RSASign "1.3.14.3.2.29" 807 808 #define szOID_OIWDIR "1.3.14.7.2" 809 #define szOID_OIWDIR_CRPT "1.3.14.7.2.1" 810 #define szOID_OIWDIR_HASH "1.3.14.7.2.2" 811 #define szOID_OIWDIR_SIGN "1.3.14.7.2.3" 812 #define szOID_OIWDIR_md2 "1.3.14.7.2.2.1" 813 #define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1" 814 815 #define szOID_INFOSEC "2.16.840.1.101.2.1" 816 #define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1" 817 #define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2" 818 #define szOID_INFOSEC_sdnsConfidentiality "2.16.840.1.101.2.1.1.3" 819 #define szOID_INFOSEC_mosaicConfidentiality "2.16.840.1.101.2.1.1.4" 820 #define szOID_INFOSEC_sdnsIntegrity "2.16.840.1.101.2.1.1.5" 821 #define szOID_INFOSEC_mosaicIntegrity "2.16.840.1.101.2.1.1.6" 822 #define szOID_INFOSEC_sdnsTokenProtection "2.16.840.1.101.2.1.1.7" 823 #define szOID_INFOSEC_mosaicTokenProtection "2.16.840.1.101.2.1.1.8" 824 #define szOID_INFOSEC_sdnsKeyManagement "2.16.840.1.101.2.1.1.9" 825 #define szOID_INFOSEC_mosaicKeyManagement "2.16.840.1.101.2.1.1.10" 826 #define szOID_INFOSEC_sdnsKMandSig "2.16.840.1.101.2.1.1.11" 827 #define szOID_INFOSEC_mosaicKMandSig "2.16.840.1.101.2.1.1.12" 828 #define szOID_INFOSEC_SuiteASignature "2.16.840.1.101.2.1.1.13" 829 #define szOID_INFOSEC_SuiteAConfidentiality "2.16.840.1.101.2.1.1.14" 830 #define szOID_INFOSEC_SuiteAIntegrity "2.16.840.1.101.2.1.1.15" 831 #define szOID_INFOSEC_SuiteATokenProtection "2.16.840.1.101.2.1.1.16" 832 #define szOID_INFOSEC_SuiteAKeyManagement "2.16.840.1.101.2.1.1.17" 833 #define szOID_INFOSEC_SuiteAKMandSig "2.16.840.1.101.2.1.1.18" 834 #define szOID_INFOSEC_mosaicUpdatedSig "2.16.840.1.101.2.1.1.19" 835 #define szOID_INFOSEC_mosaicKMandUpdSig "2.16.840.1.101.2.1.1.20" 836 #define szOID_INFOSEC_mosaicUpdatedInteg "2.16.840.1.101.2.1.1.21" 837 838 #define szOID_NIST_AES128_CBC "2.16.840.1.101.3.4.1.2" 839 #define szOID_NIST_AES192_CBC "2.16.840.1.101.3.4.1.22" 840 #define szOID_NIST_AES256_CBC "2.16.840.1.101.3.4.1.42" 841 842 typedef struct _CRYPT_OBJID_TABLE { 843 DWORD dwAlgId; 844 LPCSTR pszObjId; 845 } CRYPT_OBJID_TABLE,*PCRYPT_OBJID_TABLE; 846 847 typedef struct _CRYPT_HASH_INFO { 848 CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; 849 CRYPT_HASH_BLOB Hash; 850 } CRYPT_HASH_INFO,*PCRYPT_HASH_INFO; 851 852 typedef struct _CERT_EXTENSION { 853 LPSTR pszObjId; 854 WINBOOL fCritical; 855 CRYPT_OBJID_BLOB Value; 856 } CERT_EXTENSION,*PCERT_EXTENSION; 857 858 typedef struct _CRYPT_ATTRIBUTE_TYPE_VALUE { 859 LPSTR pszObjId; 860 CRYPT_OBJID_BLOB Value; 861 } CRYPT_ATTRIBUTE_TYPE_VALUE,*PCRYPT_ATTRIBUTE_TYPE_VALUE; 862 863 typedef struct _CRYPT_ATTRIBUTE { 864 LPSTR pszObjId; 865 DWORD cValue; 866 PCRYPT_ATTR_BLOB rgValue; 867 } CRYPT_ATTRIBUTE,*PCRYPT_ATTRIBUTE; 868 869 typedef struct _CRYPT_ATTRIBUTES { 870 DWORD cAttr; 871 PCRYPT_ATTRIBUTE rgAttr; 872 } CRYPT_ATTRIBUTES,*PCRYPT_ATTRIBUTES; 873 874 typedef struct _CERT_RDN_ATTR { 875 LPSTR pszObjId; 876 DWORD dwValueType; 877 CERT_RDN_VALUE_BLOB Value; 878 } CERT_RDN_ATTR,*PCERT_RDN_ATTR; 879 880 #define szOID_COMMON_NAME "2.5.4.3" 881 #define szOID_SUR_NAME "2.5.4.4" 882 #define szOID_DEVICE_SERIAL_NUMBER "2.5.4.5" 883 #define szOID_COUNTRY_NAME "2.5.4.6" 884 #define szOID_LOCALITY_NAME "2.5.4.7" 885 #define szOID_STATE_OR_PROVINCE_NAME "2.5.4.8" 886 #define szOID_STREET_ADDRESS "2.5.4.9" 887 #define szOID_ORGANIZATION_NAME "2.5.4.10" 888 #define szOID_ORGANIZATIONAL_UNIT_NAME "2.5.4.11" 889 #define szOID_TITLE "2.5.4.12" 890 #define szOID_DESCRIPTION "2.5.4.13" 891 #define szOID_SEARCH_GUIDE "2.5.4.14" 892 #define szOID_BUSINESS_CATEGORY "2.5.4.15" 893 #define szOID_POSTAL_ADDRESS "2.5.4.16" 894 #define szOID_POSTAL_CODE "2.5.4.17" 895 #define szOID_POST_OFFICE_BOX "2.5.4.18" 896 #define szOID_PHYSICAL_DELIVERY_OFFICE_NAME "2.5.4.19" 897 #define szOID_TELEPHONE_NUMBER "2.5.4.20" 898 #define szOID_TELEX_NUMBER "2.5.4.21" 899 #define szOID_TELETEXT_TERMINAL_IDENTIFIER "2.5.4.22" 900 #define szOID_FACSIMILE_TELEPHONE_NUMBER "2.5.4.23" 901 #define szOID_X21_ADDRESS "2.5.4.24" 902 #define szOID_INTERNATIONAL_ISDN_NUMBER "2.5.4.25" 903 #define szOID_REGISTERED_ADDRESS "2.5.4.26" 904 #define szOID_DESTINATION_INDICATOR "2.5.4.27" 905 #define szOID_PREFERRED_DELIVERY_METHOD "2.5.4.28" 906 #define szOID_PRESENTATION_ADDRESS "2.5.4.29" 907 #define szOID_SUPPORTED_APPLICATION_CONTEXT "2.5.4.30" 908 #define szOID_MEMBER "2.5.4.31" 909 #define szOID_OWNER "2.5.4.32" 910 #define szOID_ROLE_OCCUPANT "2.5.4.33" 911 #define szOID_SEE_ALSO "2.5.4.34" 912 #define szOID_USER_PASSWORD "2.5.4.35" 913 #define szOID_USER_CERTIFICATE "2.5.4.36" 914 #define szOID_CA_CERTIFICATE "2.5.4.37" 915 #define szOID_AUTHORITY_REVOCATION_LIST "2.5.4.38" 916 #define szOID_CERTIFICATE_REVOCATION_LIST "2.5.4.39" 917 #define szOID_CROSS_CERTIFICATE_PAIR "2.5.4.40" 918 #define szOID_GIVEN_NAME "2.5.4.42" 919 #define szOID_INITIALS "2.5.4.43" 920 #define szOID_DN_QUALIFIER "2.5.4.46" 921 #define szOID_DOMAIN_COMPONENT "0.9.2342.19200300.100.1.25" 922 #define szOID_PKCS_12_FRIENDLY_NAME_ATTR "1.2.840.113549.1.9.20" 923 #define szOID_PKCS_12_LOCAL_KEY_ID "1.2.840.113549.1.9.21" 924 #define szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR "1.3.6.1.4.1.311.17.1" 925 #define szOID_LOCAL_MACHINE_KEYSET "1.3.6.1.4.1.311.17.2" 926 #define szOID_KEYID_RDN "1.3.6.1.4.1.311.10.7.1" 927 928 #define CERT_RDN_ANY_TYPE 0 929 #define CERT_RDN_ENCODED_BLOB 1 930 #define CERT_RDN_OCTET_STRING 2 931 #define CERT_RDN_NUMERIC_STRING 3 932 #define CERT_RDN_PRINTABLE_STRING 4 933 #define CERT_RDN_TELETEX_STRING 5 934 #define CERT_RDN_T61_STRING 5 935 #define CERT_RDN_VIDEOTEX_STRING 6 936 #define CERT_RDN_IA5_STRING 7 937 #define CERT_RDN_GRAPHIC_STRING 8 938 #define CERT_RDN_VISIBLE_STRING 9 939 #define CERT_RDN_ISO646_STRING 9 940 #define CERT_RDN_GENERAL_STRING 10 941 #define CERT_RDN_UNIVERSAL_STRING 11 942 #define CERT_RDN_INT4_STRING 11 943 #define CERT_RDN_BMP_STRING 12 944 #define CERT_RDN_UNICODE_STRING 12 945 #define CERT_RDN_UTF8_STRING 13 946 #define CERT_RDN_TYPE_MASK 0xff 947 #define CERT_RDN_FLAGS_MASK 0xff000000 948 #define CERT_RDN_ENABLE_T61_UNICODE_FLAG 0x80000000 949 #define CERT_RDN_ENABLE_UTF8_UNICODE_FLAG 0x20000000 950 #define CERT_RDN_FORCE_UTF8_UNICODE_FLAG 0x10000000 951 #define CERT_RDN_DISABLE_CHECK_TYPE_FLAG 0x40000000 952 #define CERT_RDN_DISABLE_IE4_UTF8_FLAG 0x1000000 953 954 #define IS_CERT_RDN_CHAR_STRING(X) (((X) & CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING) 955 956 typedef struct _CERT_RDN { 957 DWORD cRDNAttr; 958 PCERT_RDN_ATTR rgRDNAttr; 959 } CERT_RDN,*PCERT_RDN; 960 961 typedef struct _CERT_NAME_INFO { 962 DWORD cRDN; 963 PCERT_RDN rgRDN; 964 } CERT_NAME_INFO,*PCERT_NAME_INFO; 965 966 typedef struct _CERT_NAME_VALUE { 967 DWORD dwValueType; 968 CERT_RDN_VALUE_BLOB Value; 969 } CERT_NAME_VALUE,*PCERT_NAME_VALUE; 970 971 typedef struct _CERT_PUBLIC_KEY_INFO { 972 CRYPT_ALGORITHM_IDENTIFIER Algorithm; 973 CRYPT_BIT_BLOB PublicKey; 974 } CERT_PUBLIC_KEY_INFO,*PCERT_PUBLIC_KEY_INFO; 975 976 #define CERT_RSA_PUBLIC_KEY_OBJID szOID_RSA_RSA 977 #define CERT_DEFAULT_OID_PUBLIC_KEY_SIGN szOID_RSA_RSA 978 #define CERT_DEFAULT_OID_PUBLIC_KEY_XCHG szOID_RSA_RSA 979 980 typedef struct _CRYPT_PRIVATE_KEY_INFO{ 981 DWORD Version; 982 CRYPT_ALGORITHM_IDENTIFIER Algorithm; 983 CRYPT_DER_BLOB PrivateKey; 984 PCRYPT_ATTRIBUTES pAttributes; 985 } CRYPT_PRIVATE_KEY_INFO,*PCRYPT_PRIVATE_KEY_INFO; 986 987 typedef struct _CRYPT_ENCRYPTED_PRIVATE_KEY_INFO { 988 CRYPT_ALGORITHM_IDENTIFIER EncryptionAlgorithm; 989 CRYPT_DATA_BLOB EncryptedPrivateKey; 990 } CRYPT_ENCRYPTED_PRIVATE_KEY_INFO,*PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO; 991 992 typedef WINBOOL (CALLBACK *PCRYPT_DECRYPT_PRIVATE_KEY_FUNC)(CRYPT_ALGORITHM_IDENTIFIER Algorithm,CRYPT_DATA_BLOB EncryptedPrivateKey,BYTE *pbClearTextKey,DWORD *pcbClearTextKey,LPVOID pVoidDecryptFunc); 993 typedef WINBOOL (CALLBACK *PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC)(CRYPT_ALGORITHM_IDENTIFIER *pAlgorithm,CRYPT_DATA_BLOB *pClearTextPrivateKey,BYTE *pbEncryptedKey,DWORD *pcbEncryptedKey,LPVOID pVoidEncryptFunc); 994 typedef WINBOOL (CALLBACK *PCRYPT_RESOLVE_HCRYPTPROV_FUNC)(CRYPT_PRIVATE_KEY_INFO *pPrivateKeyInfo,HCRYPTPROV *phCryptProv,LPVOID pVoidResolveFunc); 995 996 typedef struct _CRYPT_PKCS8_IMPORT_PARAMS { 997 CRYPT_DIGEST_BLOB PrivateKey; 998 PCRYPT_RESOLVE_HCRYPTPROV_FUNC pResolvehCryptProvFunc; 999 LPVOID pVoidResolveFunc; 1000 PCRYPT_DECRYPT_PRIVATE_KEY_FUNC pDecryptPrivateKeyFunc; 1001 LPVOID pVoidDecryptFunc; 1002 } CRYPT_PKCS8_IMPORT_PARAMS,*PCRYPT_PKCS8_IMPORT_PARAMS,CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS,*PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS; 1003 1004 typedef struct _CRYPT_PKCS8_EXPORT_PARAMS { 1005 HCRYPTPROV hCryptProv; 1006 DWORD dwKeySpec; 1007 LPSTR pszPrivateKeyObjId; 1008 PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC pEncryptPrivateKeyFunc; 1009 LPVOID pVoidEncryptFunc; 1010 } CRYPT_PKCS8_EXPORT_PARAMS,*PCRYPT_PKCS8_EXPORT_PARAMS; 1011 1012 typedef struct _CERT_INFO { 1013 DWORD dwVersion; 1014 CRYPT_INTEGER_BLOB SerialNumber; 1015 CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; 1016 CERT_NAME_BLOB Issuer; 1017 FILETIME NotBefore; 1018 FILETIME NotAfter; 1019 CERT_NAME_BLOB Subject; 1020 CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo; 1021 CRYPT_BIT_BLOB IssuerUniqueId; 1022 CRYPT_BIT_BLOB SubjectUniqueId; 1023 DWORD cExtension; 1024 PCERT_EXTENSION rgExtension; 1025 } CERT_INFO,*PCERT_INFO; 1026 1027 #define CERT_V1 0 1028 #define CERT_V2 1 1029 #define CERT_V3 2 1030 1031 #define CERT_INFO_VERSION_FLAG 1 1032 #define CERT_INFO_SERIAL_NUMBER_FLAG 2 1033 #define CERT_INFO_SIGNATURE_ALGORITHM_FLAG 3 1034 #define CERT_INFO_ISSUER_FLAG 4 1035 #define CERT_INFO_NOT_BEFORE_FLAG 5 1036 #define CERT_INFO_NOT_AFTER_FLAG 6 1037 #define CERT_INFO_SUBJECT_FLAG 7 1038 #define CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG 8 1039 #define CERT_INFO_ISSUER_UNIQUE_ID_FLAG 9 1040 #define CERT_INFO_SUBJECT_UNIQUE_ID_FLAG 10 1041 #define CERT_INFO_EXTENSION_FLAG 11 1042 1043 typedef struct _CRL_ENTRY { 1044 CRYPT_INTEGER_BLOB SerialNumber; 1045 FILETIME RevocationDate; 1046 DWORD cExtension; 1047 PCERT_EXTENSION rgExtension; 1048 } CRL_ENTRY,*PCRL_ENTRY; 1049 1050 typedef struct _CRL_INFO { 1051 DWORD dwVersion; 1052 CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; 1053 CERT_NAME_BLOB Issuer; 1054 FILETIME ThisUpdate; 1055 FILETIME NextUpdate; 1056 DWORD cCRLEntry; 1057 PCRL_ENTRY rgCRLEntry; 1058 DWORD cExtension; 1059 PCERT_EXTENSION rgExtension; 1060 } CRL_INFO,*PCRL_INFO; 1061 1062 #define CRL_V1 0 1063 #define CRL_V2 1 1064 1065 typedef struct _CERT_REQUEST_INFO { 1066 DWORD dwVersion; 1067 CERT_NAME_BLOB Subject; 1068 CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo; 1069 DWORD cAttribute; 1070 PCRYPT_ATTRIBUTE rgAttribute; 1071 } CERT_REQUEST_INFO,*PCERT_REQUEST_INFO; 1072 1073 #define CERT_REQUEST_V1 0 1074 1075 typedef struct _CERT_KEYGEN_REQUEST_INFO { 1076 DWORD dwVersion; 1077 CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo; 1078 LPWSTR pwszChallengeString; 1079 } CERT_KEYGEN_REQUEST_INFO,*PCERT_KEYGEN_REQUEST_INFO; 1080 1081 #define CERT_KEYGEN_REQUEST_V1 0 1082 1083 typedef struct _CERT_SIGNED_CONTENT_INFO { 1084 CRYPT_DER_BLOB ToBeSigned; 1085 CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; 1086 CRYPT_BIT_BLOB Signature; 1087 } CERT_SIGNED_CONTENT_INFO,*PCERT_SIGNED_CONTENT_INFO; 1088 1089 typedef struct _CTL_USAGE { 1090 DWORD cUsageIdentifier; 1091 LPSTR *rgpszUsageIdentifier; 1092 } CTL_USAGE,*PCTL_USAGE,CERT_ENHKEY_USAGE,*PCERT_ENHKEY_USAGE; 1093 1094 typedef struct _CTL_ENTRY { 1095 CRYPT_DATA_BLOB SubjectIdentifier; 1096 DWORD cAttribute; 1097 PCRYPT_ATTRIBUTE rgAttribute; 1098 } CTL_ENTRY,*PCTL_ENTRY; 1099 1100 typedef struct _CTL_INFO { 1101 DWORD dwVersion; 1102 CTL_USAGE SubjectUsage; 1103 CRYPT_DATA_BLOB ListIdentifier; 1104 CRYPT_INTEGER_BLOB SequenceNumber; 1105 FILETIME ThisUpdate; 1106 FILETIME NextUpdate; 1107 CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm; 1108 DWORD cCTLEntry; 1109 PCTL_ENTRY rgCTLEntry; 1110 DWORD cExtension; 1111 PCERT_EXTENSION rgExtension; 1112 } CTL_INFO,*PCTL_INFO; 1113 1114 #define CTL_V1 0 1115 1116 typedef struct _CRYPT_TIME_STAMP_REQUEST_INFO { 1117 LPSTR pszTimeStampAlgorithm; 1118 LPSTR pszContentType; 1119 CRYPT_OBJID_BLOB Content; 1120 DWORD cAttribute; 1121 PCRYPT_ATTRIBUTE rgAttribute; 1122 } CRYPT_TIME_STAMP_REQUEST_INFO,*PCRYPT_TIME_STAMP_REQUEST_INFO; 1123 1124 typedef struct _CRYPT_ENROLLMENT_NAME_VALUE_PAIR { 1125 LPWSTR pwszName; 1126 LPWSTR pwszValue; 1127 } CRYPT_ENROLLMENT_NAME_VALUE_PAIR,*PCRYPT_ENROLLMENT_NAME_VALUE_PAIR; 1128 1129 typedef struct _CRYPT_CSP_PROVIDER { 1130 DWORD dwKeySpec; 1131 LPWSTR pwszProviderName; 1132 CRYPT_BIT_BLOB Signature; 1133 } CRYPT_CSP_PROVIDER,*PCRYPT_CSP_PROVIDER; 1134 1135 #define CERT_ENCODING_TYPE_MASK 0xffff 1136 #define CMSG_ENCODING_TYPE_MASK 0xffff0000 1137 #define GET_CERT_ENCODING_TYPE(T) ((T) & CERT_ENCODING_TYPE_MASK) 1138 #define GET_CMSG_ENCODING_TYPE(T) ((T) & CMSG_ENCODING_TYPE_MASK) 1139 1140 #define CRYPT_ASN_ENCODING 0x1 1141 #define CRYPT_NDR_ENCODING 0x2 1142 #define X509_ASN_ENCODING 0x1 1143 #define X509_NDR_ENCODING 0x2 1144 #define PKCS_7_ASN_ENCODING 0x10000 1145 #define PKCS_7_NDR_ENCODING 0x20000 1146 1147 WINIMPM WINBOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType,DWORD dwFormatType,DWORD dwFormatStrType,void *pFormatStruct,LPCSTR lpszStructType,const BYTE *pbEncoded,DWORD cbEncoded,void *pbFormat,DWORD *pcbFormat); 1148 1149 #define CRYPT_FORMAT_STR_MULTI_LINE 0x1 1150 #define CRYPT_FORMAT_STR_NO_HEX 0x10 1151 #define CRYPT_FORMAT_SIMPLE 0x1 1152 #define CRYPT_FORMAT_X509 0x2 1153 #define CRYPT_FORMAT_OID 0x4 1154 #define CRYPT_FORMAT_RDN_SEMICOLON 0x100 1155 #define CRYPT_FORMAT_RDN_CRLF 0x200 1156 #define CRYPT_FORMAT_RDN_UNQUOTE 0x400 1157 #define CRYPT_FORMAT_RDN_REVERSE 0x800 1158 #define CRYPT_FORMAT_COMMA 0x1000 1159 #define CRYPT_FORMAT_SEMICOLON CRYPT_FORMAT_RDN_SEMICOLON 1160 #define CRYPT_FORMAT_CRLF CRYPT_FORMAT_RDN_CRLF 1161 1162 typedef LPVOID (WINAPI *PFN_CRYPT_ALLOC)(size_t cbSize); 1163 typedef VOID (WINAPI *PFN_CRYPT_FREE)(LPVOID pv); 1164 1165 typedef struct _CRYPT_ENCODE_PARA { 1166 DWORD cbSize; 1167 PFN_CRYPT_ALLOC pfnAlloc; 1168 PFN_CRYPT_FREE pfnFree; 1169 } CRYPT_ENCODE_PARA,*PCRYPT_ENCODE_PARA; 1170 1171 WINIMPM WINBOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType,LPCSTR lpszStructType,const void *pvStructInfo,DWORD dwFlags,PCRYPT_ENCODE_PARA pEncodePara,void *pvEncoded,DWORD *pcbEncoded); 1172 WINIMPM WINBOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType,LPCSTR lpszStructType,const void *pvStructInfo,BYTE *pbEncoded,DWORD *pcbEncoded); 1173 1174 #define CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG 0x8 1175 #define CRYPT_ENCODE_ALLOC_FLAG 0x8000 1176 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG CERT_RDN_ENABLE_T61_UNICODE_FLAG 1177 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG CERT_RDN_ENABLE_UTF8_UNICODE_FLAG 1178 #define CRYPT_UNICODE_NAME_ENCODE_FORCE_UTF8_UNICODE_FLAG CERT_RDN_FORCE_UTF8_UNICODE_FLAG 1179 #define CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG CERT_RDN_DISABLE_CHECK_TYPE_FLAG 1180 #define CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG 0x10000 1181 1182 typedef struct _CRYPT_DECODE_PARA { 1183 DWORD cbSize; 1184 PFN_CRYPT_ALLOC pfnAlloc; 1185 PFN_CRYPT_FREE pfnFree; 1186 } CRYPT_DECODE_PARA,*PCRYPT_DECODE_PARA; 1187 1188 WINIMPM WINBOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType,LPCSTR lpszStructType,const BYTE *pbEncoded,DWORD cbEncoded,DWORD dwFlags,PCRYPT_DECODE_PARA pDecodePara,void *pvStructInfo,DWORD *pcbStructInfo); 1189 WINIMPM WINBOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType,LPCSTR lpszStructType,const BYTE *pbEncoded,DWORD cbEncoded,DWORD dwFlags,void *pvStructInfo,DWORD *pcbStructInfo); 1190 1191 #define CRYPT_DECODE_NOCOPY_FLAG 0x1 1192 #define CRYPT_DECODE_TO_BE_SIGNED_FLAG 0x2 1193 #define CRYPT_DECODE_SHARE_OID_STRING_FLAG 0x4 1194 #define CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG 0x8 1195 #define CRYPT_DECODE_ALLOC_FLAG 0x8000 1196 #define CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG CERT_RDN_DISABLE_IE4_UTF8_FLAG 1197 #define CRYPT_ENCODE_DECODE_NONE 0 1198 #define X509_CERT ((LPCSTR) 1) 1199 #define X509_CERT_TO_BE_SIGNED ((LPCSTR) 2) 1200 #define X509_CERT_CRL_TO_BE_SIGNED ((LPCSTR) 3) 1201 #define X509_CERT_REQUEST_TO_BE_SIGNED ((LPCSTR) 4) 1202 #define X509_EXTENSIONS ((LPCSTR) 5) 1203 #define X509_NAME_VALUE ((LPCSTR) 6) 1204 #define X509_NAME ((LPCSTR) 7) 1205 #define X509_PUBLIC_KEY_INFO ((LPCSTR) 8) 1206 #define X509_AUTHORITY_KEY_ID ((LPCSTR) 9) 1207 #define X509_KEY_ATTRIBUTES ((LPCSTR) 10) 1208 #define X509_KEY_USAGE_RESTRICTION ((LPCSTR) 11) 1209 #define X509_ALTERNATE_NAME ((LPCSTR) 12) 1210 #define X509_BASIC_CONSTRAINTS ((LPCSTR) 13) 1211 #define X509_KEY_USAGE ((LPCSTR) 14) 1212 #define X509_BASIC_CONSTRAINTS2 ((LPCSTR) 15) 1213 #define X509_CERT_POLICIES ((LPCSTR) 16) 1214 #define PKCS_UTC_TIME ((LPCSTR) 17) 1215 #define PKCS_TIME_REQUEST ((LPCSTR) 18) 1216 #define RSA_CSP_PUBLICKEYBLOB ((LPCSTR) 19) 1217 #define X509_UNICODE_NAME ((LPCSTR) 20) 1218 #define X509_KEYGEN_REQUEST_TO_BE_SIGNED ((LPCSTR) 21) 1219 #define PKCS_ATTRIBUTE ((LPCSTR) 22) 1220 #define PKCS_CONTENT_INFO_SEQUENCE_OF_ANY ((LPCSTR) 23) 1221 #define X509_UNICODE_NAME_VALUE ((LPCSTR) 24) 1222 #define X509_ANY_STRING X509_NAME_VALUE 1223 #define X509_UNICODE_ANY_STRING X509_UNICODE_NAME_VALUE 1224 #define X509_OCTET_STRING ((LPCSTR) 25) 1225 #define X509_BITS ((LPCSTR) 26) 1226 #define X509_INTEGER ((LPCSTR) 27) 1227 #define X509_MULTI_BYTE_INTEGER ((LPCSTR) 28) 1228 #define X509_ENUMERATED ((LPCSTR) 29) 1229 #define X509_CHOICE_OF_TIME ((LPCSTR) 30) 1230 #define X509_AUTHORITY_KEY_ID2 ((LPCSTR) 31) 1231 #define X509_AUTHORITY_INFO_ACCESS ((LPCSTR) 32) 1232 #define X509_CRL_REASON_CODE X509_ENUMERATED 1233 #define PKCS_CONTENT_INFO ((LPCSTR) 33) 1234 #define X509_SEQUENCE_OF_ANY ((LPCSTR) 34) 1235 #define X509_CRL_DIST_POINTS ((LPCSTR) 35) 1236 #define X509_ENHANCED_KEY_USAGE ((LPCSTR) 36) 1237 #define PKCS_CTL ((LPCSTR) 37) 1238 #define X509_MULTI_BYTE_UINT ((LPCSTR) 38) 1239 #define X509_DSS_PUBLICKEY X509_MULTI_BYTE_UINT 1240 #define X509_DSS_PARAMETERS ((LPCSTR) 39) 1241 #define X509_DSS_SIGNATURE ((LPCSTR) 40) 1242 #define PKCS_RC2_CBC_PARAMETERS ((LPCSTR) 41) 1243 #define PKCS_SMIME_CAPABILITIES ((LPCSTR) 42) 1244 #define PKCS_RSA_PRIVATE_KEY ((LPCSTR) 43) 1245 #define PKCS_PRIVATE_KEY_INFO ((LPCSTR) 44) 1246 #define PKCS_ENCRYPTED_PRIVATE_KEY_INFO ((LPCSTR) 45) 1247 #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR) 46) 1248 #define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT 1249 #define X509_DH_PARAMETERS ((LPCSTR) 47) 1250 #define PKCS_ATTRIBUTES ((LPCSTR) 48) 1251 #define PKCS_SORTED_CTL ((LPCSTR) 49) 1252 1253 #define X509_ECC_SIGNATURE ((LPCSTR) 47) 1254 1255 #define X942_DH_PARAMETERS ((LPCSTR) 50) 1256 #define X509_BITS_WITHOUT_TRAILING_ZEROES ((LPCSTR) 51) 1257 #define X942_OTHER_INFO ((LPCSTR) 52) 1258 #define X509_CERT_PAIR ((LPCSTR) 53) 1259 #define X509_ISSUING_DIST_POINT ((LPCSTR) 54) 1260 #define X509_NAME_CONSTRAINTS ((LPCSTR) 55) 1261 #define X509_POLICY_MAPPINGS ((LPCSTR) 56) 1262 #define X509_POLICY_CONSTRAINTS ((LPCSTR) 57) 1263 #define X509_CROSS_CERT_DIST_POINTS ((LPCSTR) 58) 1264 #define CMC_DATA ((LPCSTR) 59) 1265 #define CMC_RESPONSE ((LPCSTR) 60) 1266 #define CMC_STATUS ((LPCSTR) 61) 1267 #define CMC_ADD_EXTENSIONS ((LPCSTR) 62) 1268 #define CMC_ADD_ATTRIBUTES ((LPCSTR) 63) 1269 #define X509_CERTIFICATE_TEMPLATE ((LPCSTR) 64) 1270 #define OCSP_SIGNED_REQUEST ((LPCSTR) 65) 1271 #define OCSP_REQUEST ((LPCSTR) 66) 1272 #define OCSP_RESPONSE ((LPCSTR) 67) 1273 #define OCSP_BASIC_SIGNED_RESPONSE ((LPCSTR) 68) 1274 #define OCSP_BASIC_RESPONSE ((LPCSTR) 69) 1275 #define X509_LOGOTYPE_EXT ((LPCSTR) 70) 1276 #define X509_BIOMETRIC_EXT ((LPCSTR) 71) 1277 #define CNG_RSA_PUBLIC_KEY_BLOB ((LPCSTR) 72) 1278 #define X509_OBJECT_IDENTIFIER ((LPCSTR) 73) 1279 #define X509_ALGORITHM_IDENTIFIER ((LPCSTR) 74) 1280 #define PKCS_RSA_SSA_PSS_PARAMETERS ((LPCSTR) 75) 1281 #define PKCS_RSAES_OAEP_PARAMETERS ((LPCSTR) 76) 1282 #define ECC_CMS_SHARED_INFO ((LPCSTR) 77) 1283 #define PKCS7_SIGNER_INFO ((LPCSTR) 500) 1284 #define CMS_SIGNER_INFO ((LPCSTR) 501) 1285 #define szOID_AUTHORITY_KEY_IDENTIFIER "2.5.29.1" 1286 #define szOID_KEY_ATTRIBUTES "2.5.29.2" 1287 #define szOID_CERT_POLICIES_95 "2.5.29.3" 1288 #define szOID_KEY_USAGE_RESTRICTION "2.5.29.4" 1289 #define szOID_SUBJECT_ALT_NAME "2.5.29.7" 1290 #define szOID_ISSUER_ALT_NAME "2.5.29.8" 1291 #define szOID_BASIC_CONSTRAINTS "2.5.29.10" 1292 /* szOID_KEY_USAGE is defined incorrectly in msdn as 2.5.29.4 -- 1293 http://www.oid-info.com/get/2.5.29.15 RFC3280 */ 1294 #define szOID_KEY_USAGE "2.5.29.15" 1295 #define szOID_PRIVATEKEY_USAGE_PERIOD "2.5.29.16" 1296 #define szOID_BASIC_CONSTRAINTS2 "2.5.29.19" 1297 #define szOID_CERT_POLICIES "2.5.29.32" 1298 #define szOID_ANY_CERT_POLICY "2.5.29.32.0" 1299 #define szOID_AUTHORITY_KEY_IDENTIFIER2 "2.5.29.35" 1300 #define szOID_SUBJECT_KEY_IDENTIFIER "2.5.29.14" 1301 #define szOID_SUBJECT_ALT_NAME2 "2.5.29.17" 1302 #define szOID_ISSUER_ALT_NAME2 "2.5.29.18" 1303 #define szOID_CRL_REASON_CODE "2.5.29.21" 1304 #define szOID_REASON_CODE_HOLD "2.5.29.23" 1305 #define szOID_CRL_DIST_POINTS "2.5.29.31" 1306 #define szOID_ENHANCED_KEY_USAGE "2.5.29.37" 1307 #define szOID_CRL_NUMBER "2.5.29.20" 1308 #define szOID_DELTA_CRL_INDICATOR "2.5.29.27" 1309 #define szOID_ISSUING_DIST_POINT "2.5.29.28" 1310 #define szOID_FRESHEST_CRL "2.5.29.46" 1311 #define szOID_NAME_CONSTRAINTS "2.5.29.30" 1312 #define szOID_POLICY_MAPPINGS "2.5.29.33" 1313 #define szOID_LEGACY_POLICY_MAPPINGS "2.5.29.5" 1314 #define szOID_POLICY_CONSTRAINTS "2.5.29.36" 1315 #define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1" 1316 #define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3" 1317 #define szOID_RSA_SSA_PSS "1.2.840.113549.1.1.10" 1318 #define szOID_RSAES_OAEP "1.2.840.113549.1.1.7" 1319 #define szOID_RENEWAL_CERTIFICATE "1.3.6.1.4.1.311.13.1" 1320 #define szOID_ENROLLMENT_NAME_VALUE_PAIR "1.3.6.1.4.1.311.13.2.1" 1321 #define szOID_ENROLLMENT_CSP_PROVIDER "1.3.6.1.4.1.311.13.2.2" 1322 #define szOID_OS_VERSION "1.3.6.1.4.1.311.13.2.3" 1323 #define szOID_ENROLLMENT_AGENT "1.3.6.1.4.1.311.20.2.1" 1324 #define szOID_PKIX "1.3.6.1.5.5.7" 1325 #define szOID_PKIX_PE "1.3.6.1.5.5.7.1" 1326 #define szOID_AUTHORITY_INFO_ACCESS "1.3.6.1.5.5.7.1.1" 1327 #define szOID_BIOMETRIC_EXT "1.3.6.1.5.5.7.1.2" 1328 #define szOID_LOGOTYPE_EXT "1.3.6.1.5.5.7.1.12" 1329 #define szOID_CERT_EXTENSIONS "1.3.6.1.4.1.311.2.1.14" 1330 #define szOID_NEXT_UPDATE_LOCATION "1.3.6.1.4.1.311.10.2" 1331 #define szOID_REMOVE_CERTIFICATE "1.3.6.1.4.1.311.10.8.1" 1332 #define szOID_CROSS_CERT_DIST_POINTS "1.3.6.1.4.1.311.10.9.1" 1333 #define szOID_CTL "1.3.6.1.4.1.311.10.1" 1334 #define szOID_SORTED_CTL "1.3.6.1.4.1.311.10.1.1" 1335 1336 #ifndef szOID_SERIALIZED 1337 #define szOID_SERIALIZED "1.3.6.1.4.1.311.10.3.3.1" 1338 #endif 1339 1340 #ifndef szOID_NT_PRINCIPAL_NAME 1341 #define szOID_NT_PRINCIPAL_NAME "1.3.6.1.4.1.311.20.2.3" 1342 #endif 1343 1344 #ifndef szOID_PRODUCT_UPDATE 1345 #define szOID_PRODUCT_UPDATE "1.3.6.1.4.1.311.31.1" 1346 #endif 1347 1348 #define szOID_ANY_APPLICATION_POLICY "1.3.6.1.4.1.311.10.12.1" 1349 1350 #define szOID_AUTO_ENROLL_CTL_USAGE "1.3.6.1.4.1.311.20.1" 1351 1352 #define szOID_ENROLL_CERTTYPE_EXTENSION "1.3.6.1.4.1.311.20.2" 1353 1354 #define szOID_CERT_MANIFOLD "1.3.6.1.4.1.311.20.3" 1355 1356 #ifndef szOID_CERTSRV_CA_VERSION 1357 #define szOID_CERTSRV_CA_VERSION "1.3.6.1.4.1.311.21.1" 1358 #endif 1359 1360 #define szOID_CERTSRV_PREVIOUS_CERT_HASH "1.3.6.1.4.1.311.21.2" 1361 #define szOID_CRL_VIRTUAL_BASE "1.3.6.1.4.1.311.21.3" 1362 #define szOID_CRL_NEXT_PUBLISH "1.3.6.1.4.1.311.21.4" 1363 #define szOID_KP_CA_EXCHANGE "1.3.6.1.4.1.311.21.5" 1364 #define szOID_KP_KEY_RECOVERY_AGENT "1.3.6.1.4.1.311.21.6" 1365 #define szOID_CERTIFICATE_TEMPLATE "1.3.6.1.4.1.311.21.7" 1366 #define szOID_ENTERPRISE_OID_ROOT "1.3.6.1.4.1.311.21.8" 1367 #define szOID_RDN_DUMMY_SIGNER "1.3.6.1.4.1.311.21.9" 1368 #define szOID_APPLICATION_CERT_POLICIES "1.3.6.1.4.1.311.21.10" 1369 #define szOID_APPLICATION_POLICY_MAPPINGS "1.3.6.1.4.1.311.21.11" 1370 #define szOID_APPLICATION_POLICY_CONSTRAINTS "1.3.6.1.4.1.311.21.12" 1371 #define szOID_ARCHIVED_KEY_ATTR "1.3.6.1.4.1.311.21.13" 1372 #define szOID_CRL_SELF_CDP "1.3.6.1.4.1.311.21.14" 1373 #define szOID_REQUIRE_CERT_CHAIN_POLICY "1.3.6.1.4.1.311.21.15" 1374 #define szOID_ARCHIVED_KEY_CERT_HASH "1.3.6.1.4.1.311.21.16" 1375 #define szOID_ISSUED_CERT_HASH "1.3.6.1.4.1.311.21.17" 1376 #define szOID_DS_EMAIL_REPLICATION "1.3.6.1.4.1.311.21.19" 1377 #define szOID_REQUEST_CLIENT_INFO "1.3.6.1.4.1.311.21.20" 1378 #define szOID_ENCRYPTED_KEY_HASH "1.3.6.1.4.1.311.21.21" 1379 #define szOID_CERTSRV_CROSSCA_VERSION "1.3.6.1.4.1.311.21.22" 1380 #define szOID_NTDS_REPLICATION "1.3.6.1.4.1.311.25.1" 1381 #define szOID_SUBJECT_DIR_ATTRS "2.5.29.9" 1382 #define szOID_PKIX_KP "1.3.6.1.5.5.7.3" 1383 #define szOID_PKIX_KP_SERVER_AUTH "1.3.6.1.5.5.7.3.1" 1384 #define szOID_PKIX_KP_CLIENT_AUTH "1.3.6.1.5.5.7.3.2" 1385 #define szOID_PKIX_KP_CODE_SIGNING "1.3.6.1.5.5.7.3.3" 1386 #define szOID_PKIX_KP_EMAIL_PROTECTION "1.3.6.1.5.5.7.3.4" 1387 #define szOID_PKIX_KP_IPSEC_END_SYSTEM "1.3.6.1.5.5.7.3.5" 1388 #define szOID_PKIX_KP_IPSEC_TUNNEL "1.3.6.1.5.5.7.3.6" 1389 #define szOID_PKIX_KP_IPSEC_USER "1.3.6.1.5.5.7.3.7" 1390 #define szOID_PKIX_KP_TIMESTAMP_SIGNING "1.3.6.1.5.5.7.3.8" 1391 #define szOID_IPSEC_KP_IKE_INTERMEDIATE "1.3.6.1.5.5.8.2.2" 1392 #define szOID_KP_CTL_USAGE_SIGNING "1.3.6.1.4.1.311.10.3.1" 1393 #define szOID_KP_TIME_STAMP_SIGNING "1.3.6.1.4.1.311.10.3.2" 1394 1395 #ifndef szOID_SERVER_GATED_CRYPTO 1396 #define szOID_SERVER_GATED_CRYPTO "1.3.6.1.4.1.311.10.3.3" 1397 #endif 1398 1399 #ifndef szOID_SGC_NETSCAPE 1400 #define szOID_SGC_NETSCAPE "2.16.840.1.113730.4.1" 1401 #endif 1402 #define szOID_KP_EFS "1.3.6.1.4.1.311.10.3.4" 1403 #define szOID_EFS_RECOVERY "1.3.6.1.4.1.311.10.3.4.1" 1404 #define szOID_WHQL_CRYPTO "1.3.6.1.4.1.311.10.3.5" 1405 #define szOID_NT5_CRYPTO "1.3.6.1.4.1.311.10.3.6" 1406 #define szOID_OEM_WHQL_CRYPTO "1.3.6.1.4.1.311.10.3.7" 1407 #define szOID_EMBEDDED_NT_CRYPTO "1.3.6.1.4.1.311.10.3.8" 1408 #define szOID_ROOT_LIST_SIGNER "1.3.6.1.4.1.311.10.3.9" 1409 #define szOID_KP_QUALIFIED_SUBORDINATION "1.3.6.1.4.1.311.10.3.10" 1410 #define szOID_KP_KEY_RECOVERY "1.3.6.1.4.1.311.10.3.11" 1411 #define szOID_KP_DOCUMENT_SIGNING "1.3.6.1.4.1.311.10.3.12" 1412 #define szOID_KP_LIFETIME_SIGNING "1.3.6.1.4.1.311.10.3.13" 1413 #define szOID_KP_MOBILE_DEVICE_SOFTWARE "1.3.6.1.4.1.311.10.3.14" 1414 1415 #ifndef szOID_DRM 1416 #define szOID_DRM "1.3.6.1.4.1.311.10.5.1" 1417 #endif 1418 1419 #ifndef szOID_DRM_INDIVIDUALIZATION 1420 #define szOID_DRM_INDIVIDUALIZATION "1.3.6.1.4.1.311.10.5.2" 1421 #endif 1422 1423 #ifndef szOID_LICENSES 1424 #define szOID_LICENSES "1.3.6.1.4.1.311.10.6.1" 1425 #endif 1426 1427 #ifndef szOID_LICENSE_SERVER 1428 #define szOID_LICENSE_SERVER "1.3.6.1.4.1.311.10.6.2" 1429 #endif 1430 1431 #ifndef szOID_KP_SMARTCARD_LOGON 1432 #define szOID_KP_SMARTCARD_LOGON "1.3.6.1.4.1.311.20.2.2" 1433 #endif 1434 1435 #define szOID_YESNO_TRUST_ATTR "1.3.6.1.4.1.311.10.4.1" 1436 1437 #define szOID_PKIX_POLICY_QUALIFIER_CPS "1.3.6.1.5.5.7.2.1" 1438 #define szOID_PKIX_POLICY_QUALIFIER_USERNOTICE "1.3.6.1.5.5.7.2.2" 1439 1440 #define szOID_CERT_POLICIES_95_QUALIFIER1 "2.16.840.1.113733.1.7.1.1" 1441 1442 typedef struct _CERT_EXTENSIONS { 1443 DWORD cExtension; 1444 PCERT_EXTENSION rgExtension; 1445 } CERT_EXTENSIONS,*PCERT_EXTENSIONS; 1446 1447 #define CERT_UNICODE_RDN_ERR_INDEX_MASK 0x3FF 1448 #define CERT_UNICODE_RDN_ERR_INDEX_SHIFT 22 1449 #define CERT_UNICODE_ATTR_ERR_INDEX_MASK 0x3f 1450 #define CERT_UNICODE_ATTR_ERR_INDEX_SHIFT 16 1451 #define CERT_UNICODE_VALUE_ERR_INDEX_MASK 0xffff 1452 #define CERT_UNICODE_VALUE_ERR_INDEX_SHIFT 0 1453 1454 #define GET_CERT_UNICODE_RDN_ERR_INDEX(X) (((X) >> CERT_UNICODE_RDN_ERR_INDEX_SHIFT) & CERT_UNICODE_RDN_ERR_INDEX_MASK) 1455 #define GET_CERT_UNICODE_ATTR_ERR_INDEX(X) (((X) >> CERT_UNICODE_ATTR_ERR_INDEX_SHIFT) & CERT_UNICODE_ATTR_ERR_INDEX_MASK) 1456 #define GET_CERT_UNICODE_VALUE_ERR_INDEX(X) ((X) & CERT_UNICODE_VALUE_ERR_INDEX_MASK) 1457 1458 typedef struct _CERT_AUTHORITY_KEY_ID_INFO { 1459 CRYPT_DATA_BLOB KeyId; 1460 CERT_NAME_BLOB CertIssuer; 1461 CRYPT_INTEGER_BLOB CertSerialNumber; 1462 } CERT_AUTHORITY_KEY_ID_INFO,*PCERT_AUTHORITY_KEY_ID_INFO; 1463 1464 typedef struct _CERT_PRIVATE_KEY_VALIDITY { 1465 FILETIME NotBefore; 1466 FILETIME NotAfter; 1467 } CERT_PRIVATE_KEY_VALIDITY,*PCERT_PRIVATE_KEY_VALIDITY; 1468 1469 typedef struct _CERT_KEY_ATTRIBUTES_INFO { 1470 CRYPT_DATA_BLOB KeyId; 1471 CRYPT_BIT_BLOB IntendedKeyUsage; 1472 PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod; 1473 } CERT_KEY_ATTRIBUTES_INFO,*PCERT_KEY_ATTRIBUTES_INFO; 1474 1475 #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80 1476 #define CERT_NON_REPUDIATION_KEY_USAGE 0x40 1477 #define CERT_KEY_ENCIPHERMENT_KEY_USAGE 0x20 1478 #define CERT_DATA_ENCIPHERMENT_KEY_USAGE 0x10 1479 #define CERT_KEY_AGREEMENT_KEY_USAGE 0x8 1480 #define CERT_KEY_CERT_SIGN_KEY_USAGE 0x4 1481 #define CERT_OFFLINE_CRL_SIGN_KEY_USAGE 0x2 1482 #define CERT_CRL_SIGN_KEY_USAGE 0x2 1483 #define CERT_ENCIPHER_ONLY_KEY_USAGE 0x1 1484 1485 #define CERT_DECIPHER_ONLY_KEY_USAGE 0x80 1486 1487 typedef struct _CERT_POLICY_ID { 1488 DWORD cCertPolicyElementId; 1489 LPSTR *rgpszCertPolicyElementId; 1490 } CERT_POLICY_ID,*PCERT_POLICY_ID; 1491 1492 typedef struct _CERT_KEY_USAGE_RESTRICTION_INFO { 1493 DWORD cCertPolicyId; 1494 PCERT_POLICY_ID rgCertPolicyId; 1495 CRYPT_BIT_BLOB RestrictedKeyUsage; 1496 } CERT_KEY_USAGE_RESTRICTION_INFO,*PCERT_KEY_USAGE_RESTRICTION_INFO; 1497 1498 typedef struct _CERT_OTHER_NAME { 1499 LPSTR pszObjId; 1500 CRYPT_OBJID_BLOB Value; 1501 } CERT_OTHER_NAME,*PCERT_OTHER_NAME; 1502 1503 typedef struct _CERT_ALT_NAME_ENTRY { 1504 DWORD dwAltNameChoice; 1505 __C89_NAMELESS union { 1506 PCERT_OTHER_NAME pOtherName; 1507 LPWSTR pwszRfc822Name; 1508 LPWSTR pwszDNSName; 1509 /* CERT_DATA_BLOB is not documented, and x400Address is documented 1510 * to be not implemented; commented out to prevent compile errors 1511 * see http://msdn.microsoft.com/en-us/library/aa377173.aspx for 1512 * CERT_ALT_NAME_ENTRY documentation where this is specified. 1513 CERT_DATA_BLOB x400Address; 1514 */ 1515 CERT_NAME_BLOB DirectoryName; 1516 /* pEdiPartyName is not implemented, either. see: 1517 * http://msdn.microsoft.com/en-us/library/aa924681.aspx or 1518 * http://msdn.microsoft.com/en-us/library/aa377173.aspx 1519 LPWSTR pEdiPartyName; 1520 */ 1521 LPWSTR pwszURL; 1522 CRYPT_DATA_BLOB IPAddress; 1523 LPSTR pszRegisteredID; 1524 }; 1525 } CERT_ALT_NAME_ENTRY,*PCERT_ALT_NAME_ENTRY; 1526 1527 #define CERT_ALT_NAME_OTHER_NAME 1 1528 #define CERT_ALT_NAME_RFC822_NAME 2 1529 #define CERT_ALT_NAME_DNS_NAME 3 1530 #define CERT_ALT_NAME_X400_ADDRESS 4 1531 #define CERT_ALT_NAME_DIRECTORY_NAME 5 1532 #define CERT_ALT_NAME_EDI_PARTY_NAME 6 1533 #define CERT_ALT_NAME_URL 7 1534 #define CERT_ALT_NAME_IP_ADDRESS 8 1535 #define CERT_ALT_NAME_REGISTERED_ID 9 1536 1537 typedef struct _CERT_ALT_NAME_INFO { 1538 DWORD cAltEntry; 1539 PCERT_ALT_NAME_ENTRY rgAltEntry; 1540 } CERT_ALT_NAME_INFO,*PCERT_ALT_NAME_INFO; 1541 1542 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK 0xFF 1543 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT 16 1544 #define CERT_ALT_NAME_VALUE_ERR_INDEX_MASK 0xffff 1545 #define CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT 0 1546 1547 #define GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(X) (((X) >> CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) & CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK) 1548 #define GET_CERT_ALT_NAME_VALUE_ERR_INDEX(X) ((X) & CERT_ALT_NAME_VALUE_ERR_INDEX_MASK) 1549 1550 typedef struct _CERT_BASIC_CONSTRAINTS_INFO { 1551 CRYPT_BIT_BLOB SubjectType; 1552 WINBOOL fPathLenConstraint; 1553 DWORD dwPathLenConstraint; 1554 DWORD cSubtreesConstraint; 1555 CERT_NAME_BLOB *rgSubtreesConstraint; 1556 } CERT_BASIC_CONSTRAINTS_INFO, *PCERT_BASIC_CONSTRAINTS_INFO; 1557 1558 #define CERT_CA_SUBJECT_FLAG 0x80 1559 #define CERT_END_ENTITY_SUBJECT_FLAG 0x40 1560 1561 typedef struct _CERT_BASIC_CONSTRAINTS2_INFO { 1562 WINBOOL fCA; 1563 WINBOOL fPathLenConstraint; 1564 DWORD dwPathLenConstraint; 1565 } CERT_BASIC_CONSTRAINTS2_INFO,*PCERT_BASIC_CONSTRAINTS2_INFO; 1566 1567 typedef struct _CERT_POLICY_QUALIFIER_INFO { 1568 LPSTR pszPolicyQualifierId; 1569 CRYPT_OBJID_BLOB Qualifier; 1570 } CERT_POLICY_QUALIFIER_INFO,*PCERT_POLICY_QUALIFIER_INFO; 1571 1572 typedef struct _CERT_POLICY_INFO { 1573 LPSTR pszPolicyIdentifier; 1574 DWORD cPolicyQualifier; 1575 CERT_POLICY_QUALIFIER_INFO *rgPolicyQualifier; 1576 } CERT_POLICY_INFO,*PCERT_POLICY_INFO; 1577 1578 typedef struct _CERT_POLICIES_INFO { 1579 DWORD cPolicyInfo; 1580 CERT_POLICY_INFO *rgPolicyInfo; 1581 } CERT_POLICIES_INFO,*PCERT_POLICIES_INFO; 1582 1583 typedef struct _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE { 1584 LPSTR pszOrganization; 1585 DWORD cNoticeNumbers; 1586 int *rgNoticeNumbers; 1587 } CERT_POLICY_QUALIFIER_NOTICE_REFERENCE,*PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE; 1588 1589 typedef struct _CERT_POLICY_QUALIFIER_USER_NOTICE { 1590 CERT_POLICY_QUALIFIER_NOTICE_REFERENCE *pNoticeReference; 1591 LPWSTR pszDisplayText; 1592 } CERT_POLICY_QUALIFIER_USER_NOTICE,*PCERT_POLICY_QUALIFIER_USER_NOTICE; 1593 1594 typedef struct _CPS_URLS { 1595 LPWSTR pszURL; 1596 CRYPT_ALGORITHM_IDENTIFIER *pAlgorithm; 1597 CRYPT_DATA_BLOB *pDigest; 1598 } CPS_URLS,*PCPS_URLS; 1599 1600 typedef struct _CERT_POLICY95_QUALIFIER1 { 1601 LPWSTR pszPracticesReference; 1602 LPSTR pszNoticeIdentifier; 1603 LPSTR pszNSINoticeIdentifier; 1604 DWORD cCPSURLs; 1605 CPS_URLS *rgCPSURLs; 1606 } CERT_POLICY95_QUALIFIER1,*PCERT_POLICY95_QUALIFIER1; 1607 1608 typedef struct _CERT_POLICY_MAPPING { 1609 LPSTR pszIssuerDomainPolicy; 1610 LPSTR pszSubjectDomainPolicy; 1611 } CERT_POLICY_MAPPING,*PCERT_POLICY_MAPPING; 1612 1613 typedef struct _CERT_POLICY_MAPPINGS_INFO { 1614 DWORD cPolicyMapping; 1615 PCERT_POLICY_MAPPING rgPolicyMapping; 1616 } CERT_POLICY_MAPPINGS_INFO,*PCERT_POLICY_MAPPINGS_INFO; 1617 1618 typedef struct _CERT_POLICY_CONSTRAINTS_INFO { 1619 WINBOOL fRequireExplicitPolicy; 1620 DWORD dwRequireExplicitPolicySkipCerts; 1621 WINBOOL fInhibitPolicyMapping; 1622 DWORD dwInhibitPolicyMappingSkipCerts; 1623 } CERT_POLICY_CONSTRAINTS_INFO,*PCERT_POLICY_CONSTRAINTS_INFO; 1624 1625 typedef struct _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY { 1626 LPSTR pszObjId; 1627 DWORD cValue; 1628 PCRYPT_DER_BLOB rgValue; 1629 } CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY,*PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY; 1630 1631 typedef struct _CRYPT_CONTENT_INFO { 1632 LPSTR pszObjId; 1633 CRYPT_DER_BLOB Content; 1634 } CRYPT_CONTENT_INFO,*PCRYPT_CONTENT_INFO; 1635 1636 typedef struct _CRYPT_SEQUENCE_OF_ANY { 1637 DWORD cValue; 1638 PCRYPT_DER_BLOB rgValue; 1639 } CRYPT_SEQUENCE_OF_ANY,*PCRYPT_SEQUENCE_OF_ANY; 1640 1641 typedef struct _CERT_AUTHORITY_KEY_ID2_INFO { 1642 CRYPT_DATA_BLOB KeyId; 1643 CERT_ALT_NAME_INFO AuthorityCertIssuer; 1644 1645 CRYPT_INTEGER_BLOB AuthorityCertSerialNumber; 1646 } CERT_AUTHORITY_KEY_ID2_INFO,*PCERT_AUTHORITY_KEY_ID2_INFO; 1647 1648 typedef struct _CERT_ACCESS_DESCRIPTION { 1649 LPSTR pszAccessMethod; 1650 CERT_ALT_NAME_ENTRY AccessLocation; 1651 } CERT_ACCESS_DESCRIPTION,*PCERT_ACCESS_DESCRIPTION; 1652 1653 typedef struct _CERT_AUTHORITY_INFO_ACCESS { 1654 DWORD cAccDescr; 1655 PCERT_ACCESS_DESCRIPTION rgAccDescr; 1656 } CERT_AUTHORITY_INFO_ACCESS,*PCERT_AUTHORITY_INFO_ACCESS; 1657 1658 #define szOID_PKIX_ACC_DESCR "1.3.6.1.5.5.7.48" 1659 #define szOID_PKIX_OCSP "1.3.6.1.5.5.7.48.1" 1660 #define szOID_PKIX_CA_ISSUERS "1.3.6.1.5.5.7.48.2" 1661 1662 #define CRL_REASON_UNSPECIFIED 0 1663 #define CRL_REASON_KEY_COMPROMISE 1 1664 #define CRL_REASON_CA_COMPROMISE 2 1665 #define CRL_REASON_AFFILIATION_CHANGED 3 1666 #define CRL_REASON_SUPERSEDED 4 1667 #define CRL_REASON_CESSATION_OF_OPERATION 5 1668 #define CRL_REASON_CERTIFICATE_HOLD 6 1669 #define CRL_REASON_REMOVE_FROM_CRL 8 1670 1671 typedef struct _CRL_DIST_POINT_NAME { 1672 DWORD dwDistPointNameChoice; 1673 __C89_NAMELESS union { 1674 CERT_ALT_NAME_INFO FullName; 1675 }; 1676 } CRL_DIST_POINT_NAME,*PCRL_DIST_POINT_NAME; 1677 1678 #define CRL_DIST_POINT_NO_NAME 0 1679 #define CRL_DIST_POINT_FULL_NAME 1 1680 #define CRL_DIST_POINT_ISSUER_RDN_NAME 2 1681 1682 typedef struct _CRL_DIST_POINT { 1683 CRL_DIST_POINT_NAME DistPointName; 1684 CRYPT_BIT_BLOB ReasonFlags; 1685 CERT_ALT_NAME_INFO CRLIssuer; 1686 } CRL_DIST_POINT,*PCRL_DIST_POINT; 1687 1688 #define CRL_REASON_UNUSED_FLAG 0x80 1689 #define CRL_REASON_KEY_COMPROMISE_FLAG 0x40 1690 #define CRL_REASON_CA_COMPROMISE_FLAG 0x20 1691 #define CRL_REASON_AFFILIATION_CHANGED_FLAG 0x10 1692 #define CRL_REASON_SUPERSEDED_FLAG 0x8 1693 #define CRL_REASON_CESSATION_OF_OPERATION_FLAG 0x4 1694 #define CRL_REASON_CERTIFICATE_HOLD_FLAG 0x2 1695 1696 typedef struct _CRL_DIST_POINTS_INFO { 1697 DWORD cDistPoint; 1698 PCRL_DIST_POINT rgDistPoint; 1699 } CRL_DIST_POINTS_INFO,*PCRL_DIST_POINTS_INFO; 1700 1701 #define CRL_DIST_POINT_ERR_INDEX_MASK 0x7F 1702 #define CRL_DIST_POINT_ERR_INDEX_SHIFT 24 1703 #define GET_CRL_DIST_POINT_ERR_INDEX(X) ((X >> CRL_DIST_POINT_ERR_INDEX_SHIFT) & CRL_DIST_POINT_ERR_INDEX_MASK) 1704 1705 #define CRL_DIST_POINT_ERR_CRL_ISSUER_BIT __MSABI_LONG(0x80000000) 1706 #define IS_CRL_DIST_POINT_ERR_CRL_ISSUER(X) (0!=(X & CRL_DIST_POINT_ERR_CRL_ISSUER_BIT)) 1707 1708 typedef struct _CROSS_CERT_DIST_POINTS_INFO { 1709 DWORD dwSyncDeltaTime; 1710 DWORD cDistPoint; 1711 PCERT_ALT_NAME_INFO rgDistPoint; 1712 } CROSS_CERT_DIST_POINTS_INFO,*PCROSS_CERT_DIST_POINTS_INFO; 1713 1714 #define CROSS_CERT_DIST_POINT_ERR_INDEX_MASK 0xFF 1715 #define CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT 24 1716 #define GET_CROSS_CERT_DIST_POINT_ERR_INDEX(X) ((X >> CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT) & CROSS_CERT_DIST_POINT_ERR_INDEX_MASK) 1717 1718 typedef struct _CERT_PAIR { 1719 CERT_BLOB Forward; 1720 CERT_BLOB Reverse; 1721 } CERT_PAIR,*PCERT_PAIR; 1722 1723 typedef struct _CRL_ISSUING_DIST_POINT { 1724 CRL_DIST_POINT_NAME DistPointName; 1725 WINBOOL fOnlyContainsUserCerts; 1726 WINBOOL fOnlyContainsCACerts; 1727 CRYPT_BIT_BLOB OnlySomeReasonFlags; 1728 WINBOOL fIndirectCRL; 1729 } CRL_ISSUING_DIST_POINT,*PCRL_ISSUING_DIST_POINT; 1730 1731 typedef struct _CERT_GENERAL_SUBTREE { 1732 CERT_ALT_NAME_ENTRY Base; 1733 DWORD dwMinimum; 1734 WINBOOL fMaximum; 1735 DWORD dwMaximum; 1736 } CERT_GENERAL_SUBTREE,*PCERT_GENERAL_SUBTREE; 1737 1738 typedef struct _CERT_NAME_CONSTRAINTS_INFO { 1739 DWORD cPermittedSubtree; 1740 PCERT_GENERAL_SUBTREE rgPermittedSubtree; 1741 DWORD cExcludedSubtree; 1742 PCERT_GENERAL_SUBTREE rgExcludedSubtree; 1743 } CERT_NAME_CONSTRAINTS_INFO,*PCERT_NAME_CONSTRAINTS_INFO; 1744 1745 #define CERT_EXCLUDED_SUBTREE_BIT __MSABI_LONG(0x80000000) 1746 #define IS_CERT_EXCLUDED_SUBTREE(X) (0!=(X & CERT_EXCLUDED_SUBTREE_BIT)) 1747 1748 #define SORTED_CTL_EXT_FLAGS_OFFSET (0*4) 1749 #define SORTED_CTL_EXT_COUNT_OFFSET (1*4) 1750 #define SORTED_CTL_EXT_MAX_COLLISION_OFFSET (2*4) 1751 #define SORTED_CTL_EXT_HASH_BUCKET_OFFSET (3*4) 1752 1753 #define SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG 0x1 1754 1755 typedef struct _CERT_DSS_PARAMETERS { 1756 CRYPT_UINT_BLOB p; 1757 CRYPT_UINT_BLOB q; 1758 CRYPT_UINT_BLOB g; 1759 } CERT_DSS_PARAMETERS,*PCERT_DSS_PARAMETERS; 1760 1761 #define CERT_DSS_R_LEN 20 1762 #define CERT_DSS_S_LEN 20 1763 #define CERT_DSS_SIGNATURE_LEN (CERT_DSS_R_LEN + CERT_DSS_S_LEN) 1764 1765 #define CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN (2 + 2*(2 + 20 +1)) 1766 1767 typedef struct _CERT_DH_PARAMETERS { 1768 CRYPT_UINT_BLOB p; 1769 CRYPT_UINT_BLOB g; 1770 } CERT_DH_PARAMETERS,*PCERT_DH_PARAMETERS; 1771 1772 typedef struct _CERT_X942_DH_VALIDATION_PARAMS { 1773 CRYPT_BIT_BLOB seed; 1774 DWORD pgenCounter; 1775 } CERT_X942_DH_VALIDATION_PARAMS,*PCERT_X942_DH_VALIDATION_PARAMS; 1776 1777 typedef struct _CERT_X942_DH_PARAMETERS { 1778 CRYPT_UINT_BLOB p; 1779 CRYPT_UINT_BLOB g; 1780 CRYPT_UINT_BLOB q; 1781 CRYPT_UINT_BLOB j; 1782 PCERT_X942_DH_VALIDATION_PARAMS pValidationParams; 1783 } CERT_X942_DH_PARAMETERS,*PCERT_X942_DH_PARAMETERS; 1784 1785 #define CRYPT_X942_COUNTER_BYTE_LENGTH 4 1786 #define CRYPT_X942_KEY_LENGTH_BYTE_LENGTH 4 1787 #define CRYPT_X942_PUB_INFO_BYTE_LENGTH (512/8) 1788 typedef struct _CRYPT_X942_OTHER_INFO { 1789 LPSTR pszContentEncryptionObjId; 1790 BYTE rgbCounter[CRYPT_X942_COUNTER_BYTE_LENGTH]; 1791 BYTE rgbKeyLength[CRYPT_X942_KEY_LENGTH_BYTE_LENGTH]; 1792 CRYPT_DATA_BLOB PubInfo; 1793 } CRYPT_X942_OTHER_INFO,*PCRYPT_X942_OTHER_INFO; 1794 1795 typedef struct _CRYPT_RC2_CBC_PARAMETERS { 1796 DWORD dwVersion; 1797 WINBOOL fIV; 1798 BYTE rgbIV[8]; 1799 } CRYPT_RC2_CBC_PARAMETERS,*PCRYPT_RC2_CBC_PARAMETERS; 1800 1801 #define CRYPT_RC2_40BIT_VERSION 160 1802 #define CRYPT_RC2_56BIT_VERSION 52 1803 #define CRYPT_RC2_64BIT_VERSION 120 1804 #define CRYPT_RC2_128BIT_VERSION 58 1805 1806 typedef struct _CRYPT_SMIME_CAPABILITY { 1807 LPSTR pszObjId; 1808 CRYPT_OBJID_BLOB Parameters; 1809 } CRYPT_SMIME_CAPABILITY,*PCRYPT_SMIME_CAPABILITY; 1810 1811 typedef struct _CRYPT_SMIME_CAPABILITIES { 1812 DWORD cCapability; 1813 PCRYPT_SMIME_CAPABILITY rgCapability; 1814 } CRYPT_SMIME_CAPABILITIES,*PCRYPT_SMIME_CAPABILITIES; 1815 1816 #define szOID_VERISIGN_PRIVATE_6_9 "2.16.840.1.113733.1.6.9" 1817 #define szOID_VERISIGN_ONSITE_JURISDICTION_HASH "2.16.840.1.113733.1.6.11" 1818 #define szOID_VERISIGN_BITSTRING_6_13 "2.16.840.1.113733.1.6.13" 1819 #define szOID_VERISIGN_ISS_STRONG_CRYPTO "2.16.840.1.113733.1.8.1" 1820 #define szOID_NETSCAPE "2.16.840.1.113730" 1821 #define szOID_NETSCAPE_CERT_EXTENSION "2.16.840.1.113730.1" 1822 #define szOID_NETSCAPE_CERT_TYPE "2.16.840.1.113730.1.1" 1823 #define szOID_NETSCAPE_BASE_URL "2.16.840.1.113730.1.2" 1824 #define szOID_NETSCAPE_REVOCATION_URL "2.16.840.1.113730.1.3" 1825 #define szOID_NETSCAPE_CA_REVOCATION_URL "2.16.840.1.113730.1.4" 1826 #define szOID_NETSCAPE_CERT_RENEWAL_URL "2.16.840.1.113730.1.7" 1827 #define szOID_NETSCAPE_CA_POLICY_URL "2.16.840.1.113730.1.8" 1828 #define szOID_NETSCAPE_SSL_SERVER_NAME "2.16.840.1.113730.1.12" 1829 #define szOID_NETSCAPE_COMMENT "2.16.840.1.113730.1.13" 1830 #define szOID_NETSCAPE_DATA_TYPE "2.16.840.1.113730.2" 1831 #define szOID_NETSCAPE_CERT_SEQUENCE "2.16.840.1.113730.2.5" 1832 1833 #define NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE 0x80 1834 #define NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE 0x40 1835 #define NETSCAPE_SMIME_CERT_TYPE 0x20 1836 #define NETSCAPE_SIGN_CERT_TYPE 0x10 1837 #define NETSCAPE_SSL_CA_CERT_TYPE 0x4 1838 #define NETSCAPE_SMIME_CA_CERT_TYPE 0x2 1839 #define NETSCAPE_SIGN_CA_CERT_TYPE 0x1 1840 1841 #define szOID_CT_PKI_DATA "1.3.6.1.5.5.7.12.2" 1842 #define szOID_CT_PKI_RESPONSE "1.3.6.1.5.5.7.12.3" 1843 #define szOID_PKIX_NO_SIGNATURE "1.3.6.1.5.5.7.6.2" 1844 #define szOID_CMC "1.3.6.1.5.5.7.7" 1845 #define szOID_CMC_STATUS_INFO "1.3.6.1.5.5.7.7.1" 1846 #define szOID_CMC_IDENTIFICATION "1.3.6.1.5.5.7.7.2" 1847 #define szOID_CMC_IDENTITY_PROOF "1.3.6.1.5.5.7.7.3" 1848 #define szOID_CMC_DATA_RETURN "1.3.6.1.5.5.7.7.4" 1849 #define szOID_CMC_TRANSACTION_ID "1.3.6.1.5.5.7.7.5" 1850 #define szOID_CMC_SENDER_NONCE "1.3.6.1.5.5.7.7.6" 1851 #define szOID_CMC_RECIPIENT_NONCE "1.3.6.1.5.5.7.7.7" 1852 #define szOID_CMC_ADD_EXTENSIONS "1.3.6.1.5.5.7.7.8" 1853 #define szOID_CMC_ENCRYPTED_POP "1.3.6.1.5.5.7.7.9" 1854 #define szOID_CMC_DECRYPTED_POP "1.3.6.1.5.5.7.7.10" 1855 #define szOID_CMC_LRA_POP_WITNESS "1.3.6.1.5.5.7.7.11" 1856 #define szOID_CMC_GET_CERT "1.3.6.1.5.5.7.7.15" 1857 #define szOID_CMC_GET_CRL "1.3.6.1.5.5.7.7.16" 1858 #define szOID_CMC_REVOKE_REQUEST "1.3.6.1.5.5.7.7.17" 1859 #define szOID_CMC_REG_INFO "1.3.6.1.5.5.7.7.18" 1860 #define szOID_CMC_RESPONSE_INFO "1.3.6.1.5.5.7.7.19" 1861 #define szOID_CMC_QUERY_PENDING "1.3.6.1.5.5.7.7.21" 1862 #define szOID_CMC_ID_POP_LINK_RANDOM "1.3.6.1.5.5.7.7.22" 1863 #define szOID_CMC_ID_POP_LINK_WITNESS "1.3.6.1.5.5.7.7.23" 1864 #define szOID_CMC_ID_CONFIRM_CERT_ACCEPTANCE "1.3.6.1.5.5.7.7.24" 1865 1866 #define szOID_CMC_ADD_ATTRIBUTES "1.3.6.1.4.1.311.10.10.1" 1867 1868 typedef struct _CMC_TAGGED_ATTRIBUTE { 1869 DWORD dwBodyPartID; 1870 CRYPT_ATTRIBUTE Attribute; 1871 } CMC_TAGGED_ATTRIBUTE,*PCMC_TAGGED_ATTRIBUTE; 1872 1873 typedef struct _CMC_TAGGED_CERT_REQUEST { 1874 DWORD dwBodyPartID; 1875 CRYPT_DER_BLOB SignedCertRequest; 1876 } CMC_TAGGED_CERT_REQUEST,*PCMC_TAGGED_CERT_REQUEST; 1877 1878 typedef struct _CMC_TAGGED_REQUEST { 1879 DWORD dwTaggedRequestChoice; 1880 __C89_NAMELESS union { 1881 PCMC_TAGGED_CERT_REQUEST pTaggedCertRequest; 1882 }; 1883 } CMC_TAGGED_REQUEST,*PCMC_TAGGED_REQUEST; 1884 1885 #define CMC_TAGGED_CERT_REQUEST_CHOICE 1 1886 1887 typedef struct _CMC_TAGGED_CONTENT_INFO { 1888 DWORD dwBodyPartID; 1889 CRYPT_DER_BLOB EncodedContentInfo; 1890 } CMC_TAGGED_CONTENT_INFO,*PCMC_TAGGED_CONTENT_INFO; 1891 1892 typedef struct _CMC_TAGGED_OTHER_MSG { 1893 DWORD dwBodyPartID; 1894 LPSTR pszObjId; 1895 CRYPT_OBJID_BLOB Value; 1896 } CMC_TAGGED_OTHER_MSG,*PCMC_TAGGED_OTHER_MSG; 1897 1898 typedef struct _CMC_DATA_INFO { 1899 DWORD cTaggedAttribute; 1900 PCMC_TAGGED_ATTRIBUTE rgTaggedAttribute; 1901 DWORD cTaggedRequest; 1902 PCMC_TAGGED_REQUEST rgTaggedRequest; 1903 DWORD cTaggedContentInfo; 1904 PCMC_TAGGED_CONTENT_INFO rgTaggedContentInfo; 1905 DWORD cTaggedOtherMsg; 1906 PCMC_TAGGED_OTHER_MSG rgTaggedOtherMsg; 1907 } CMC_DATA_INFO,*PCMC_DATA_INFO; 1908 1909 typedef struct _CMC_RESPONSE_INFO { 1910 DWORD cTaggedAttribute; 1911 PCMC_TAGGED_ATTRIBUTE rgTaggedAttribute; 1912 DWORD cTaggedContentInfo; 1913 PCMC_TAGGED_CONTENT_INFO rgTaggedContentInfo; 1914 DWORD cTaggedOtherMsg; 1915 PCMC_TAGGED_OTHER_MSG rgTaggedOtherMsg; 1916 } CMC_RESPONSE_INFO,*PCMC_RESPONSE_INFO; 1917 1918 typedef struct _CMC_PEND_INFO { 1919 CRYPT_DATA_BLOB PendToken; 1920 FILETIME PendTime; 1921 } CMC_PEND_INFO,*PCMC_PEND_INFO; 1922 1923 typedef struct _CMC_STATUS_INFO { 1924 DWORD dwStatus; 1925 DWORD cBodyList; 1926 DWORD *rgdwBodyList; 1927 LPWSTR pwszStatusString; 1928 DWORD dwOtherInfoChoice; 1929 __C89_NAMELESS union { 1930 DWORD dwFailInfo; 1931 PCMC_PEND_INFO pPendInfo; 1932 }; 1933 } CMC_STATUS_INFO,*PCMC_STATUS_INFO; 1934 1935 #define CMC_OTHER_INFO_NO_CHOICE 0 1936 #define CMC_OTHER_INFO_FAIL_CHOICE 1 1937 #define CMC_OTHER_INFO_PEND_CHOICE 2 1938 1939 #define CMC_STATUS_SUCCESS 0 1940 #define CMC_STATUS_FAILED 2 1941 #define CMC_STATUS_PENDING 3 1942 #define CMC_STATUS_NO_SUPPORT 4 1943 #define CMC_STATUS_CONFIRM_REQUIRED 5 1944 #define CMC_FAIL_BAD_ALG 0 1945 #define CMC_FAIL_BAD_MESSAGE_CHECK 1 1946 #define CMC_FAIL_BAD_REQUEST 2 1947 #define CMC_FAIL_BAD_TIME 3 1948 #define CMC_FAIL_BAD_CERT_ID 4 1949 #define CMC_FAIL_UNSUPORTED_EXT 5 1950 #define CMC_FAIL_MUST_ARCHIVE_KEYS 6 1951 #define CMC_FAIL_BAD_IDENTITY 7 1952 #define CMC_FAIL_POP_REQUIRED 8 1953 #define CMC_FAIL_POP_FAILED 9 1954 #define CMC_FAIL_NO_KEY_REUSE 10 1955 #define CMC_FAIL_INTERNAL_CA_ERROR 11 1956 #define CMC_FAIL_TRY_LATER 12 1957 1958 typedef struct _CMC_ADD_EXTENSIONS_INFO { 1959 DWORD dwCmcDataReference; 1960 DWORD cCertReference; 1961 DWORD *rgdwCertReference; 1962 DWORD cExtension; 1963 PCERT_EXTENSION rgExtension; 1964 } CMC_ADD_EXTENSIONS_INFO,*PCMC_ADD_EXTENSIONS_INFO; 1965 1966 typedef struct _CMC_ADD_ATTRIBUTES_INFO { 1967 DWORD dwCmcDataReference; 1968 DWORD cCertReference; 1969 DWORD *rgdwCertReference; 1970 DWORD cAttribute; 1971 PCRYPT_ATTRIBUTE rgAttribute; 1972 } CMC_ADD_ATTRIBUTES_INFO,*PCMC_ADD_ATTRIBUTES_INFO; 1973 1974 typedef struct _CERT_TEMPLATE_EXT { 1975 LPSTR pszObjId; 1976 DWORD dwMajorVersion; 1977 WINBOOL fMinorVersion; 1978 DWORD dwMinorVersion; 1979 } CERT_TEMPLATE_EXT,*PCERT_TEMPLATE_EXT; 1980 1981 typedef void *HCRYPTOIDFUNCSET; 1982 typedef void *HCRYPTOIDFUNCADDR; 1983 1984 #define CRYPT_OID_ENCODE_OBJECT_FUNC "CryptDllEncodeObject" 1985 #define CRYPT_OID_DECODE_OBJECT_FUNC "CryptDllDecodeObject" 1986 #define CRYPT_OID_ENCODE_OBJECT_EX_FUNC "CryptDllEncodeObjectEx" 1987 #define CRYPT_OID_DECODE_OBJECT_EX_FUNC "CryptDllDecodeObjectEx" 1988 #define CRYPT_OID_CREATE_COM_OBJECT_FUNC "CryptDllCreateCOMObject" 1989 #define CRYPT_OID_VERIFY_REVOCATION_FUNC "CertDllVerifyRevocation" 1990 #define CRYPT_OID_VERIFY_CTL_USAGE_FUNC "CertDllVerifyCTLUsage" 1991 #define CRYPT_OID_FORMAT_OBJECT_FUNC "CryptDllFormatObject" 1992 #define CRYPT_OID_FIND_OID_INFO_FUNC "CryptDllFindOIDInfo" 1993 #define CRYPT_OID_FIND_LOCALIZED_NAME_FUNC "CryptDllFindLocalizedName" 1994 1995 #define CRYPT_OID_REGPATH "Software\\Microsoft\\Cryptography\\OID" 1996 #define CRYPT_OID_REG_ENCODING_TYPE_PREFIX "EncodingType " 1997 #define CRYPT_OID_REG_DLL_VALUE_NAME L"Dll" 1998 #define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME L"FuncName" 1999 #define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A "FuncName" 2000 2001 #define CRYPT_OID_REG_FLAGS_VALUE_NAME L"CryptFlags" 2002 2003 #define CRYPT_DEFAULT_OID "DEFAULT" 2004 2005 typedef struct _CRYPT_OID_FUNC_ENTRY { 2006 LPCSTR pszOID; 2007 void *pvFuncAddr; 2008 } CRYPT_OID_FUNC_ENTRY,*PCRYPT_OID_FUNC_ENTRY; 2009 2010 #define CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG 1 2011 2012 WINIMPM WINBOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule,DWORD dwEncodingType,LPCSTR pszFuncName,DWORD cFuncEntry,const CRYPT_OID_FUNC_ENTRY rgFuncEntry[],DWORD dwFlags); 2013 WINIMPM HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName,DWORD dwFlags); 2014 WINIMPM WINBOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,DWORD dwEncodingType,LPCSTR pszOID,DWORD dwFlags,void **ppvFuncAddr,HCRYPTOIDFUNCADDR *phFuncAddr); 2015 2016 #define CRYPT_GET_INSTALLED_OID_FUNC_FLAG 0x1 2017 2018 WINIMPM WINBOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet,DWORD dwEncodingType,LPWSTR pwszDllList,DWORD *pcchDllList); 2019 WINIMPM WINBOOL WINAPI CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,DWORD dwEncodingType,LPCWSTR pwszDll,DWORD dwFlags,void **ppvFuncAddr,HCRYPTOIDFUNCADDR *phFuncAddr); 2020 WINIMPM WINBOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,DWORD dwFlags); 2021 WINIMPM WINBOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID,LPCWSTR pwszDll,LPCSTR pszOverrideFuncName); 2022 WINIMPM WINBOOL WINAPI CryptUnregisterOIDFunction(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID); 2023 WINIMPM WINBOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD dwEncodingType,LPCSTR pszFuncName,DWORD dwIndex,LPCWSTR pwszDll); 2024 2025 #define CRYPT_REGISTER_FIRST_INDEX 0 2026 #define CRYPT_REGISTER_LAST_INDEX 0xFFFFFFFF 2027 2028 WINIMPM WINBOOL WINAPI CryptUnregisterDefaultOIDFunction(DWORD dwEncodingType,LPCSTR pszFuncName,LPCWSTR pwszDll); 2029 WINIMPM WINBOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID,LPCWSTR pwszValueName,DWORD dwValueType,const BYTE *pbValueData,DWORD cbValueData); 2030 WINIMPM WINBOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID,LPCWSTR pwszValueName,DWORD *pdwValueType,BYTE *pbValueData,DWORD *pcbValueData); 2031 2032 typedef WINBOOL (WINAPI *PFN_CRYPT_ENUM_OID_FUNC)(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID,DWORD cValue,const DWORD rgdwValueType[],LPCWSTR const rgpwszValueName[],const BYTE *const rgpbValueData[],const DWORD rgcbValueData[],void *pvArg); 2033 2034 WINIMPM WINBOOL WINAPI CryptEnumOIDFunction(DWORD dwEncodingType,LPCSTR pszFuncName,LPCSTR pszOID,DWORD dwFlags,void *pvArg,PFN_CRYPT_ENUM_OID_FUNC pfnEnumOIDFunc); 2035 2036 #define CRYPT_MATCH_ANY_ENCODING_TYPE 0xFFFFFFFF 2037 2038 typedef struct _CRYPT_OID_INFO { 2039 DWORD cbSize; 2040 LPCSTR pszOID; 2041 LPCWSTR pwszName; 2042 DWORD dwGroupId; 2043 __C89_NAMELESS union { 2044 DWORD dwValue; 2045 ALG_ID Algid; 2046 DWORD dwLength; 2047 }; 2048 CRYPT_DATA_BLOB ExtraInfo; 2049 } CRYPT_OID_INFO,*PCRYPT_OID_INFO; 2050 typedef const CRYPT_OID_INFO CCRYPT_OID_INFO,*PCCRYPT_OID_INFO; 2051 2052 #define CRYPT_HASH_ALG_OID_GROUP_ID 1 2053 #define CRYPT_ENCRYPT_ALG_OID_GROUP_ID 2 2054 #define CRYPT_PUBKEY_ALG_OID_GROUP_ID 3 2055 #define CRYPT_SIGN_ALG_OID_GROUP_ID 4 2056 #define CRYPT_RDN_ATTR_OID_GROUP_ID 5 2057 #define CRYPT_EXT_OR_ATTR_OID_GROUP_ID 6 2058 #define CRYPT_ENHKEY_USAGE_OID_GROUP_ID 7 2059 #define CRYPT_POLICY_OID_GROUP_ID 8 2060 #define CRYPT_TEMPLATE_OID_GROUP_ID 9 2061 #define CRYPT_LAST_OID_GROUP_ID 9 2062 #define CRYPT_FIRST_ALG_OID_GROUP_ID CRYPT_HASH_ALG_OID_GROUP_ID 2063 #define CRYPT_LAST_ALG_OID_GROUP_ID CRYPT_SIGN_ALG_OID_GROUP_ID 2064 2065 #define CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG 0x1 2066 #define CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG 0x2 2067 #define CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG 0x4 2068 2069 WINIMPM PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType,void *pvKey,DWORD dwGroupId); 2070 2071 #define CRYPT_OID_INFO_OID_KEY 1 2072 #define CRYPT_OID_INFO_NAME_KEY 2 2073 #define CRYPT_OID_INFO_ALGID_KEY 3 2074 #define CRYPT_OID_INFO_SIGN_KEY 4 2075 2076 WINIMPM WINBOOL WINAPI CryptRegisterOIDInfo(PCCRYPT_OID_INFO pInfo,DWORD dwFlags); 2077 2078 #define CRYPT_INSTALL_OID_INFO_BEFORE_FLAG 1 2079 2080 WINIMPM WINBOOL WINAPI CryptUnregisterOIDInfo(PCCRYPT_OID_INFO pInfo); 2081 2082 typedef WINBOOL (WINAPI *PFN_CRYPT_ENUM_OID_INFO)(PCCRYPT_OID_INFO pInfo,void *pvArg); 2083 2084 WINIMPM WINBOOL WINAPI CryptEnumOIDInfo(DWORD dwGroupId,DWORD dwFlags,void *pvArg,PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo); 2085 WINIMPM LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName); 2086 2087 #define CRYPT_LOCALIZED_NAME_ENCODING_TYPE 0 2088 #define CRYPT_LOCALIZED_NAME_OID "LocalizedNames" 2089 2090 typedef void *HCRYPTMSG; 2091 2092 #define szOID_PKCS_7_DATA "1.2.840.113549.1.7.1" 2093 #define szOID_PKCS_7_SIGNED "1.2.840.113549.1.7.2" 2094 #define szOID_PKCS_7_ENVELOPED "1.2.840.113549.1.7.3" 2095 #define szOID_PKCS_7_SIGNEDANDENVELOPED "1.2.840.113549.1.7.4" 2096 #define szOID_PKCS_7_DIGESTED "1.2.840.113549.1.7.5" 2097 #define szOID_PKCS_7_ENCRYPTED "1.2.840.113549.1.7.6" 2098 2099 #define szOID_PKCS_9_CONTENT_TYPE "1.2.840.113549.1.9.3" 2100 #define szOID_PKCS_9_MESSAGE_DIGEST "1.2.840.113549.1.9.4" 2101 2102 #define CMSG_DATA 1 2103 #define CMSG_SIGNED 2 2104 #define CMSG_ENVELOPED 3 2105 #define CMSG_SIGNED_AND_ENVELOPED 4 2106 #define CMSG_HASHED 5 2107 #define CMSG_ENCRYPTED 6 2108 2109 #define CMSG_ALL_FLAGS (~__MSABI_LONG(0U)) 2110 #define CMSG_DATA_FLAG (1 << CMSG_DATA) 2111 #define CMSG_SIGNED_FLAG (1 << CMSG_SIGNED) 2112 #define CMSG_ENVELOPED_FLAG (1 << CMSG_ENVELOPED) 2113 #define CMSG_SIGNED_AND_ENVELOPED_FLAG (1 << CMSG_SIGNED_AND_ENVELOPED) 2114 #define CMSG_HASHED_FLAG (1 << CMSG_HASHED) 2115 #define CMSG_ENCRYPTED_FLAG (1 << CMSG_ENCRYPTED) 2116 2117 typedef struct _CERT_ISSUER_SERIAL_NUMBER { 2118 CERT_NAME_BLOB Issuer; 2119 CRYPT_INTEGER_BLOB SerialNumber; 2120 } CERT_ISSUER_SERIAL_NUMBER,*PCERT_ISSUER_SERIAL_NUMBER; 2121 2122 typedef struct _CERT_ID { 2123 DWORD dwIdChoice; 2124 __C89_NAMELESS union { 2125 CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber; 2126 CRYPT_HASH_BLOB KeyId; 2127 CRYPT_HASH_BLOB HashId; 2128 }; 2129 } CERT_ID,*PCERT_ID; 2130 2131 #define CERT_ID_ISSUER_SERIAL_NUMBER 1 2132 #define CERT_ID_KEY_IDENTIFIER 2 2133 #define CERT_ID_SHA1_HASH 3 2134 2135 typedef struct _CMSG_SIGNER_ENCODE_INFO { 2136 DWORD cbSize; 2137 PCERT_INFO pCertInfo; 2138 HCRYPTPROV hCryptProv; 2139 DWORD dwKeySpec; 2140 CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; 2141 void *pvHashAuxInfo; 2142 DWORD cAuthAttr; 2143 PCRYPT_ATTRIBUTE rgAuthAttr; 2144 DWORD cUnauthAttr; 2145 PCRYPT_ATTRIBUTE rgUnauthAttr; 2146 #ifdef CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS 2147 CERT_ID SignerId; 2148 CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm; 2149 void *pvHashEncryptionAuxInfo; 2150 #endif 2151 } CMSG_SIGNER_ENCODE_INFO,*PCMSG_SIGNER_ENCODE_INFO; 2152 2153 typedef struct _CMSG_SIGNED_ENCODE_INFO { 2154 DWORD cbSize; 2155 DWORD cSigners; 2156 PCMSG_SIGNER_ENCODE_INFO rgSigners; 2157 DWORD cCertEncoded; 2158 PCERT_BLOB rgCertEncoded; 2159 DWORD cCrlEncoded; 2160 PCRL_BLOB rgCrlEncoded; 2161 #ifdef CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS 2162 DWORD cAttrCertEncoded; 2163 PCERT_BLOB rgAttrCertEncoded; 2164 #endif 2165 } CMSG_SIGNED_ENCODE_INFO,*PCMSG_SIGNED_ENCODE_INFO; 2166 2167 typedef struct _CMSG_RECIPIENT_ENCODE_INFO CMSG_RECIPIENT_ENCODE_INFO,*PCMSG_RECIPIENT_ENCODE_INFO; 2168 2169 typedef struct _CMSG_ENVELOPED_ENCODE_INFO { 2170 DWORD cbSize; 2171 HCRYPTPROV hCryptProv; 2172 CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm; 2173 void *pvEncryptionAuxInfo; 2174 DWORD cRecipients; 2175 PCERT_INFO *rgpRecipients; 2176 #ifdef CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS 2177 PCMSG_RECIPIENT_ENCODE_INFO rgCmsRecipients; 2178 DWORD cCertEncoded; 2179 PCERT_BLOB rgCertEncoded; 2180 DWORD cCrlEncoded; 2181 PCRL_BLOB rgCrlEncoded; 2182 DWORD cAttrCertEncoded; 2183 PCERT_BLOB rgAttrCertEncoded; 2184 DWORD cUnprotectedAttr; 2185 PCRYPT_ATTRIBUTE rgUnprotectedAttr; 2186 #endif 2187 } CMSG_ENVELOPED_ENCODE_INFO,*PCMSG_ENVELOPED_ENCODE_INFO; 2188 2189 typedef struct _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO { 2190 DWORD cbSize; 2191 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2192 void *pvKeyEncryptionAuxInfo; 2193 HCRYPTPROV hCryptProv; 2194 CRYPT_BIT_BLOB RecipientPublicKey; 2195 CERT_ID RecipientId; 2196 } CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO,*PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO; 2197 2198 typedef struct _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO { 2199 DWORD cbSize; 2200 CRYPT_BIT_BLOB RecipientPublicKey; 2201 CERT_ID RecipientId; 2202 FILETIME Date; 2203 PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr; 2204 } CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO,*PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO; 2205 2206 typedef struct _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO { 2207 DWORD cbSize; 2208 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2209 void *pvKeyEncryptionAuxInfo; 2210 CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm; 2211 void *pvKeyWrapAuxInfo; 2212 HCRYPTPROV hCryptProv; 2213 DWORD dwKeySpec; 2214 DWORD dwKeyChoice; 2215 __C89_NAMELESS union { 2216 PCRYPT_ALGORITHM_IDENTIFIER pEphemeralAlgorithm; 2217 PCERT_ID pSenderId; 2218 }; 2219 CRYPT_DATA_BLOB UserKeyingMaterial; 2220 DWORD cRecipientEncryptedKeys; 2221 PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO *rgpRecipientEncryptedKeys; 2222 } CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO,*PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO; 2223 2224 #define CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE 1 2225 #define CMSG_KEY_AGREE_STATIC_KEY_CHOICE 2 2226 2227 typedef struct _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO { 2228 DWORD cbSize; 2229 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2230 void *pvKeyEncryptionAuxInfo; 2231 HCRYPTPROV hCryptProv; 2232 DWORD dwKeyChoice; 2233 __C89_NAMELESS union { 2234 2235 HCRYPTKEY hKeyEncryptionKey; 2236 void *pvKeyEncryptionKey; 2237 }; 2238 CRYPT_DATA_BLOB KeyId; 2239 FILETIME Date; 2240 PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr; 2241 } CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO,*PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO; 2242 2243 #define CMSG_MAIL_LIST_HANDLE_KEY_CHOICE 1 2244 2245 struct _CMSG_RECIPIENT_ENCODE_INFO { 2246 DWORD dwRecipientChoice; 2247 __C89_NAMELESS union { 2248 PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO pKeyTrans; 2249 PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO pKeyAgree; 2250 PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO pMailList; 2251 }; 2252 }; 2253 2254 #define CMSG_KEY_TRANS_RECIPIENT 1 2255 #define CMSG_KEY_AGREE_RECIPIENT 2 2256 #define CMSG_MAIL_LIST_RECIPIENT 3 2257 2258 typedef struct _CMSG_RC2_AUX_INFO { 2259 DWORD cbSize; 2260 DWORD dwBitLen; 2261 } CMSG_RC2_AUX_INFO,*PCMSG_RC2_AUX_INFO; 2262 2263 typedef struct _CMSG_SP3_COMPATIBLE_AUX_INFO { 2264 DWORD cbSize; 2265 DWORD dwFlags; 2266 } CMSG_SP3_COMPATIBLE_AUX_INFO,*PCMSG_SP3_COMPATIBLE_AUX_INFO; 2267 2268 #define CMSG_SP3_COMPATIBLE_ENCRYPT_FLAG 0x80000000 2269 2270 typedef struct _CMSG_RC4_AUX_INFO { 2271 DWORD cbSize; 2272 DWORD dwBitLen; 2273 } CMSG_RC4_AUX_INFO,*PCMSG_RC4_AUX_INFO; 2274 2275 #define CMSG_RC4_NO_SALT_FLAG 0x40000000 2276 2277 typedef struct _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO { 2278 DWORD cbSize; 2279 CMSG_SIGNED_ENCODE_INFO SignedInfo; 2280 CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo; 2281 } CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO,*PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO; 2282 2283 typedef struct _CMSG_HASHED_ENCODE_INFO { 2284 DWORD cbSize; 2285 HCRYPTPROV hCryptProv; 2286 CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; 2287 void *pvHashAuxInfo; 2288 } CMSG_HASHED_ENCODE_INFO,*PCMSG_HASHED_ENCODE_INFO; 2289 2290 typedef struct _CMSG_ENCRYPTED_ENCODE_INFO { 2291 DWORD cbSize; 2292 CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm; 2293 void *pvEncryptionAuxInfo; 2294 } CMSG_ENCRYPTED_ENCODE_INFO,*PCMSG_ENCRYPTED_ENCODE_INFO; 2295 2296 typedef WINBOOL (WINAPI *PFN_CMSG_STREAM_OUTPUT)(const void *pvArg,BYTE *pbData,DWORD cbData,WINBOOL fFinal); 2297 2298 #define CMSG_INDEFINITE_LENGTH (0xFFFFFFFF) 2299 2300 typedef struct _CMSG_STREAM_INFO { 2301 DWORD cbContent; 2302 PFN_CMSG_STREAM_OUTPUT pfnStreamOutput; 2303 void *pvArg; 2304 } CMSG_STREAM_INFO,*PCMSG_STREAM_INFO; 2305 2306 #define CMSG_BARE_CONTENT_FLAG 0x1 2307 #define CMSG_LENGTH_ONLY_FLAG 0x2 2308 #define CMSG_DETACHED_FLAG 0x4 2309 #define CMSG_AUTHENTICATED_ATTRIBUTES_FLAG 0x8 2310 #define CMSG_CONTENTS_OCTETS_FLAG 0x10 2311 #define CMSG_MAX_LENGTH_FLAG 0x20 2312 2313 #define CMSG_CMS_ENCAPSULATED_CONTENT_FLAG 0x40 2314 2315 #define CMSG_CRYPT_RELEASE_CONTEXT_FLAG 0x8000 2316 2317 WINIMPM HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType,DWORD dwFlags,DWORD dwMsgType,void const *pvMsgEncodeInfo,LPSTR pszInnerContentObjID,PCMSG_STREAM_INFO pStreamInfo); 2318 WINIMPM DWORD WINAPI CryptMsgCalculateEncodedLength(DWORD dwMsgEncodingType,DWORD dwFlags,DWORD dwMsgType,void const *pvMsgEncodeInfo,LPSTR pszInnerContentObjID,DWORD cbData); 2319 WINIMPM HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType,DWORD dwFlags,DWORD dwMsgType,HCRYPTPROV hCryptProv,PCERT_INFO pRecipientInfo,PCMSG_STREAM_INFO pStreamInfo); 2320 WINIMPM HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg); 2321 WINIMPM WINBOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg); 2322 WINIMPM WINBOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg,const BYTE *pbData,DWORD cbData,WINBOOL fFinal); 2323 WINIMPM WINBOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg,DWORD dwParamType,DWORD dwIndex,void *pvData,DWORD *pcbData); 2324 2325 #define CMSG_TYPE_PARAM 1 2326 #define CMSG_CONTENT_PARAM 2 2327 #define CMSG_BARE_CONTENT_PARAM 3 2328 #define CMSG_INNER_CONTENT_TYPE_PARAM 4 2329 #define CMSG_SIGNER_COUNT_PARAM 5 2330 #define CMSG_SIGNER_INFO_PARAM 6 2331 #define CMSG_SIGNER_CERT_INFO_PARAM 7 2332 #define CMSG_SIGNER_HASH_ALGORITHM_PARAM 8 2333 #define CMSG_SIGNER_AUTH_ATTR_PARAM 9 2334 #define CMSG_SIGNER_UNAUTH_ATTR_PARAM 10 2335 #define CMSG_CERT_COUNT_PARAM 11 2336 #define CMSG_CERT_PARAM 12 2337 #define CMSG_CRL_COUNT_PARAM 13 2338 #define CMSG_CRL_PARAM 14 2339 #define CMSG_ENVELOPE_ALGORITHM_PARAM 15 2340 #define CMSG_RECIPIENT_COUNT_PARAM 17 2341 #define CMSG_RECIPIENT_INDEX_PARAM 18 2342 #define CMSG_RECIPIENT_INFO_PARAM 19 2343 #define CMSG_HASH_ALGORITHM_PARAM 20 2344 #define CMSG_HASH_DATA_PARAM 21 2345 #define CMSG_COMPUTED_HASH_PARAM 22 2346 #define CMSG_ENCRYPT_PARAM 26 2347 #define CMSG_ENCRYPTED_DIGEST 27 2348 #define CMSG_ENCODED_SIGNER 28 2349 #define CMSG_ENCODED_MESSAGE 29 2350 #define CMSG_VERSION_PARAM 30 2351 #define CMSG_ATTR_CERT_COUNT_PARAM 31 2352 #define CMSG_ATTR_CERT_PARAM 32 2353 #define CMSG_CMS_RECIPIENT_COUNT_PARAM 33 2354 #define CMSG_CMS_RECIPIENT_INDEX_PARAM 34 2355 #define CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM 35 2356 #define CMSG_CMS_RECIPIENT_INFO_PARAM 36 2357 #define CMSG_UNPROTECTED_ATTR_PARAM 37 2358 #define CMSG_SIGNER_CERT_ID_PARAM 38 2359 #define CMSG_CMS_SIGNER_INFO_PARAM 39 2360 2361 typedef struct _CMSG_SIGNER_INFO { 2362 DWORD dwVersion; 2363 CERT_NAME_BLOB Issuer; 2364 CRYPT_INTEGER_BLOB SerialNumber; 2365 CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; 2366 CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm; 2367 CRYPT_DATA_BLOB EncryptedHash; 2368 CRYPT_ATTRIBUTES AuthAttrs; 2369 CRYPT_ATTRIBUTES UnauthAttrs; 2370 } CMSG_SIGNER_INFO,*PCMSG_SIGNER_INFO; 2371 2372 typedef struct _CMSG_CMS_SIGNER_INFO { 2373 DWORD dwVersion; 2374 CERT_ID SignerId; 2375 CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; 2376 CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm; 2377 CRYPT_DATA_BLOB EncryptedHash; 2378 CRYPT_ATTRIBUTES AuthAttrs; 2379 CRYPT_ATTRIBUTES UnauthAttrs; 2380 } CMSG_CMS_SIGNER_INFO,*PCMSG_CMS_SIGNER_INFO; 2381 2382 typedef CRYPT_ATTRIBUTES CMSG_ATTR; 2383 typedef CRYPT_ATTRIBUTES *PCMSG_ATTR; 2384 2385 #define CMSG_SIGNED_DATA_V1 1 2386 #define CMSG_SIGNED_DATA_V3 3 2387 #define CMSG_SIGNED_DATA_PKCS_1_5_VERSION CMSG_SIGNED_DATA_V1 2388 #define CMSG_SIGNED_DATA_CMS_VERSION CMSG_SIGNED_DATA_V3 2389 2390 #define CMSG_SIGNER_INFO_V1 1 2391 #define CMSG_SIGNER_INFO_V3 3 2392 #define CMSG_SIGNER_INFO_PKCS_1_5_VERSION CMSG_SIGNER_INFO_V1 2393 #define CMSG_SIGNER_INFO_CMS_VERSION CMSG_SIGNER_INFO_V3 2394 2395 #define CMSG_HASHED_DATA_V0 0 2396 #define CMSG_HASHED_DATA_V2 2 2397 #define CMSG_HASHED_DATA_PKCS_1_5_VERSION CMSG_HASHED_DATA_V0 2398 #define CMSG_HASHED_DATA_CMS_VERSION CMSG_HASHED_DATA_V2 2399 2400 #define CMSG_ENVELOPED_DATA_V0 0 2401 #define CMSG_ENVELOPED_DATA_V2 2 2402 #define CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION CMSG_ENVELOPED_DATA_V0 2403 #define CMSG_ENVELOPED_DATA_CMS_VERSION CMSG_ENVELOPED_DATA_V2 2404 2405 typedef struct _CMSG_KEY_TRANS_RECIPIENT_INFO { 2406 DWORD dwVersion; 2407 CERT_ID RecipientId; 2408 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2409 CRYPT_DATA_BLOB EncryptedKey; 2410 } CMSG_KEY_TRANS_RECIPIENT_INFO,*PCMSG_KEY_TRANS_RECIPIENT_INFO; 2411 2412 typedef struct _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO { 2413 CERT_ID RecipientId; 2414 CRYPT_DATA_BLOB EncryptedKey; 2415 FILETIME Date; 2416 PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr; 2417 } CMSG_RECIPIENT_ENCRYPTED_KEY_INFO,*PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO; 2418 2419 typedef struct _CMSG_KEY_AGREE_RECIPIENT_INFO { 2420 DWORD dwVersion; 2421 DWORD dwOriginatorChoice; 2422 __C89_NAMELESS union { 2423 CERT_ID OriginatorCertId; 2424 CERT_PUBLIC_KEY_INFO OriginatorPublicKeyInfo; 2425 }; 2426 CRYPT_DATA_BLOB UserKeyingMaterial; 2427 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2428 DWORD cRecipientEncryptedKeys; 2429 PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO *rgpRecipientEncryptedKeys; 2430 } CMSG_KEY_AGREE_RECIPIENT_INFO,*PCMSG_KEY_AGREE_RECIPIENT_INFO; 2431 2432 #define CMSG_KEY_AGREE_ORIGINATOR_CERT 1 2433 #define CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY 2 2434 2435 typedef struct _CMSG_MAIL_LIST_RECIPIENT_INFO { 2436 DWORD dwVersion; 2437 CRYPT_DATA_BLOB KeyId; 2438 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2439 CRYPT_DATA_BLOB EncryptedKey; 2440 FILETIME Date; 2441 PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr; 2442 } CMSG_MAIL_LIST_RECIPIENT_INFO,*PCMSG_MAIL_LIST_RECIPIENT_INFO; 2443 2444 typedef struct _CMSG_CMS_RECIPIENT_INFO { 2445 DWORD dwRecipientChoice; 2446 __C89_NAMELESS union { 2447 PCMSG_KEY_TRANS_RECIPIENT_INFO pKeyTrans; 2448 PCMSG_KEY_AGREE_RECIPIENT_INFO pKeyAgree; 2449 PCMSG_MAIL_LIST_RECIPIENT_INFO pMailList; 2450 }; 2451 } CMSG_CMS_RECIPIENT_INFO,*PCMSG_CMS_RECIPIENT_INFO; 2452 2453 #define CMSG_ENVELOPED_RECIPIENT_V0 0 2454 #define CMSG_ENVELOPED_RECIPIENT_V2 2 2455 #define CMSG_ENVELOPED_RECIPIENT_V3 3 2456 #define CMSG_ENVELOPED_RECIPIENT_V4 4 2457 #define CMSG_KEY_TRANS_PKCS_1_5_VERSION CMSG_ENVELOPED_RECIPIENT_V0 2458 #define CMSG_KEY_TRANS_CMS_VERSION CMSG_ENVELOPED_RECIPIENT_V2 2459 #define CMSG_KEY_AGREE_VERSION CMSG_ENVELOPED_RECIPIENT_V3 2460 #define CMSG_MAIL_LIST_VERSION CMSG_ENVELOPED_RECIPIENT_V4 2461 2462 WINIMPM WINBOOL WINAPI CryptMsgControl(HCRYPTMSG hCryptMsg,DWORD dwFlags,DWORD dwCtrlType,void const *pvCtrlPara); 2463 2464 #define CMSG_CTRL_VERIFY_SIGNATURE 1 2465 #define CMSG_CTRL_DECRYPT 2 2466 #define CMSG_CTRL_VERIFY_HASH 5 2467 #define CMSG_CTRL_ADD_SIGNER 6 2468 #define CMSG_CTRL_DEL_SIGNER 7 2469 #define CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR 8 2470 #define CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR 9 2471 #define CMSG_CTRL_ADD_CERT 10 2472 #define CMSG_CTRL_DEL_CERT 11 2473 #define CMSG_CTRL_ADD_CRL 12 2474 #define CMSG_CTRL_DEL_CRL 13 2475 #define CMSG_CTRL_ADD_ATTR_CERT 14 2476 #define CMSG_CTRL_DEL_ATTR_CERT 15 2477 #define CMSG_CTRL_KEY_TRANS_DECRYPT 16 2478 #define CMSG_CTRL_KEY_AGREE_DECRYPT 17 2479 #define CMSG_CTRL_MAIL_LIST_DECRYPT 18 2480 #define CMSG_CTRL_VERIFY_SIGNATURE_EX 19 2481 #define CMSG_CTRL_ADD_CMS_SIGNER_INFO 20 2482 2483 typedef struct _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA { 2484 DWORD cbSize; 2485 HCRYPTPROV hCryptProv; 2486 DWORD dwSignerIndex; 2487 DWORD dwSignerType; 2488 void *pvSigner; 2489 } CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA,*PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA; 2490 2491 #define CMSG_VERIFY_SIGNER_PUBKEY 1 2492 #define CMSG_VERIFY_SIGNER_CERT 2 2493 #define CMSG_VERIFY_SIGNER_CHAIN 3 2494 #define CMSG_VERIFY_SIGNER_NULL 4 2495 2496 typedef struct _CMSG_CTRL_DECRYPT_PARA { 2497 DWORD cbSize; 2498 HCRYPTPROV hCryptProv; 2499 DWORD dwKeySpec; 2500 DWORD dwRecipientIndex; 2501 } CMSG_CTRL_DECRYPT_PARA,*PCMSG_CTRL_DECRYPT_PARA; 2502 2503 typedef struct _CMSG_CTRL_KEY_TRANS_DECRYPT_PARA { 2504 DWORD cbSize; 2505 HCRYPTPROV hCryptProv; 2506 DWORD dwKeySpec; 2507 PCMSG_KEY_TRANS_RECIPIENT_INFO pKeyTrans; 2508 DWORD dwRecipientIndex; 2509 } CMSG_CTRL_KEY_TRANS_DECRYPT_PARA,*PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA; 2510 2511 typedef struct _CMSG_CTRL_KEY_AGREE_DECRYPT_PARA { 2512 DWORD cbSize; 2513 HCRYPTPROV hCryptProv; 2514 DWORD dwKeySpec; 2515 PCMSG_KEY_AGREE_RECIPIENT_INFO pKeyAgree; 2516 DWORD dwRecipientIndex; 2517 DWORD dwRecipientEncryptedKeyIndex; 2518 CRYPT_BIT_BLOB OriginatorPublicKey; 2519 } CMSG_CTRL_KEY_AGREE_DECRYPT_PARA,*PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA; 2520 2521 typedef struct _CMSG_CTRL_MAIL_LIST_DECRYPT_PARA { 2522 DWORD cbSize; 2523 HCRYPTPROV hCryptProv; 2524 PCMSG_MAIL_LIST_RECIPIENT_INFO pMailList; 2525 DWORD dwRecipientIndex; 2526 DWORD dwKeyChoice; 2527 __C89_NAMELESS union { 2528 HCRYPTKEY hKeyEncryptionKey; 2529 void *pvKeyEncryptionKey; 2530 }; 2531 } CMSG_CTRL_MAIL_LIST_DECRYPT_PARA,*PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA; 2532 2533 typedef struct _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA { 2534 DWORD cbSize; 2535 DWORD dwSignerIndex; 2536 CRYPT_DATA_BLOB blob; 2537 } CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA,*PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA; 2538 2539 typedef struct _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA { 2540 DWORD cbSize; 2541 DWORD dwSignerIndex; 2542 DWORD dwUnauthAttrIndex; 2543 } CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA,*PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA; 2544 2545 WINBOOL WINAPI CryptMsgVerifyCountersignatureEncoded(HCRYPTPROV hCryptProv,DWORD dwEncodingType,PBYTE pbSignerInfo,DWORD cbSignerInfo,PBYTE pbSignerInfoCountersignature,DWORD cbSignerInfoCountersignature,PCERT_INFO pciCountersigner); 2546 WINBOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx(HCRYPTPROV hCryptProv,DWORD dwEncodingType,PBYTE pbSignerInfo,DWORD cbSignerInfo,PBYTE pbSignerInfoCountersignature,DWORD cbSignerInfoCountersignature,DWORD dwSignerType,void *pvSigner,DWORD dwFlags,void *pvReserved); 2547 WINBOOL WINAPI CryptMsgCountersign(HCRYPTMSG hCryptMsg,DWORD dwIndex,DWORD cCountersigners,PCMSG_SIGNER_ENCODE_INFO rgCountersigners); 2548 WINBOOL WINAPI CryptMsgCountersignEncoded(DWORD dwEncodingType,PBYTE pbSignerInfo,DWORD cbSignerInfo,DWORD cCountersigners,PCMSG_SIGNER_ENCODE_INFO rgCountersigners,PBYTE pbCountersignature,PDWORD pcbCountersignature); 2549 2550 typedef void *(WINAPI *PFN_CMSG_ALLOC)(size_t cb); 2551 typedef void (WINAPI *PFN_CMSG_FREE)(void *pv); 2552 2553 #define CMSG_OID_GEN_ENCRYPT_KEY_FUNC "CryptMsgDllGenEncryptKey" 2554 typedef WINBOOL (WINAPI *PFN_CMSG_GEN_ENCRYPT_KEY)(HCRYPTPROV *phCryptProv,PCRYPT_ALGORITHM_IDENTIFIER paiEncrypt,PVOID pvEncryptAuxInfo,PCERT_PUBLIC_KEY_INFO pPublicKeyInfo,PFN_CMSG_ALLOC pfnAlloc,HCRYPTKEY *phEncryptKey,PBYTE *ppbEncryptParameters,PDWORD pcbEncryptParameters); 2555 2556 #define CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC "CryptMsgDllExportEncryptKey" 2557 typedef WINBOOL (WINAPI *PFN_CMSG_EXPORT_ENCRYPT_KEY)(HCRYPTPROV hCryptProv,HCRYPTKEY hEncryptKey,PCERT_PUBLIC_KEY_INFO pPublicKeyInfo,PBYTE pbData,PDWORD pcbData); 2558 2559 #define CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC "CryptMsgDllImportEncryptKey" 2560 typedef WINBOOL (WINAPI *PFN_CMSG_IMPORT_ENCRYPT_KEY)(HCRYPTPROV hCryptProv,DWORD dwKeySpec,PCRYPT_ALGORITHM_IDENTIFIER paiEncrypt,PCRYPT_ALGORITHM_IDENTIFIER paiPubKey,PBYTE pbEncodedKey,DWORD cbEncodedKey,HCRYPTKEY *phEncryptKey); 2561 2562 #define CMSG_DEFAULT_INSTALLABLE_FUNC_OID ((LPCSTR) 1) 2563 2564 typedef struct _CMSG_CONTENT_ENCRYPT_INFO { 2565 DWORD cbSize; 2566 HCRYPTPROV hCryptProv; 2567 CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm; 2568 void *pvEncryptionAuxInfo; 2569 DWORD cRecipients; 2570 PCMSG_RECIPIENT_ENCODE_INFO rgCmsRecipients; 2571 PFN_CMSG_ALLOC pfnAlloc; 2572 PFN_CMSG_FREE pfnFree; 2573 DWORD dwEncryptFlags; 2574 HCRYPTKEY hContentEncryptKey; 2575 DWORD dwFlags; 2576 } CMSG_CONTENT_ENCRYPT_INFO,*PCMSG_CONTENT_ENCRYPT_INFO; 2577 2578 #define CMSG_CONTENT_ENCRYPT_PAD_ENCODED_LEN_FLAG 0x1 2579 2580 #define CMSG_CONTENT_ENCRYPT_FREE_PARA_FLAG 0x1 2581 #define CMSG_CONTENT_ENCRYPT_RELEASE_CONTEXT_FLAG 0x8000 2582 2583 #define CMSG_OID_GEN_CONTENT_ENCRYPT_KEY_FUNC "CryptMsgDllGenContentEncryptKey" 2584 typedef WINBOOL (WINAPI *PFN_CMSG_GEN_CONTENT_ENCRYPT_KEY)(PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo,DWORD dwFlags,void *pvReserved); 2585 2586 typedef struct _CMSG_KEY_TRANS_ENCRYPT_INFO { 2587 DWORD cbSize; 2588 DWORD dwRecipientIndex; 2589 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2590 CRYPT_DATA_BLOB EncryptedKey; 2591 DWORD dwFlags; 2592 } CMSG_KEY_TRANS_ENCRYPT_INFO,*PCMSG_KEY_TRANS_ENCRYPT_INFO; 2593 2594 #define CMSG_KEY_TRANS_ENCRYPT_FREE_PARA_FLAG 0x1 2595 2596 #define CMSG_OID_EXPORT_KEY_TRANS_FUNC "CryptMsgDllExportKeyTrans" 2597 typedef WINBOOL (WINAPI *PFN_CMSG_EXPORT_KEY_TRANS)(PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo,PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO pKeyTransEncodeInfo,PCMSG_KEY_TRANS_ENCRYPT_INFO pKeyTransEncryptInfo,DWORD dwFlags,void *pvReserved); 2598 2599 typedef struct _CMSG_KEY_AGREE_KEY_ENCRYPT_INFO { 2600 DWORD cbSize; 2601 CRYPT_DATA_BLOB EncryptedKey; 2602 } CMSG_KEY_AGREE_KEY_ENCRYPT_INFO,*PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO; 2603 2604 typedef struct _CMSG_KEY_AGREE_ENCRYPT_INFO { 2605 DWORD cbSize; 2606 DWORD dwRecipientIndex; 2607 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2608 CRYPT_DATA_BLOB UserKeyingMaterial; 2609 DWORD dwOriginatorChoice; 2610 __C89_NAMELESS union { 2611 CERT_ID OriginatorCertId; 2612 CERT_PUBLIC_KEY_INFO OriginatorPublicKeyInfo; 2613 }; 2614 DWORD cKeyAgreeKeyEncryptInfo; 2615 PCMSG_KEY_AGREE_KEY_ENCRYPT_INFO *rgpKeyAgreeKeyEncryptInfo; 2616 DWORD dwFlags; 2617 } CMSG_KEY_AGREE_ENCRYPT_INFO,*PCMSG_KEY_AGREE_ENCRYPT_INFO; 2618 2619 #define CMSG_KEY_AGREE_ENCRYPT_FREE_PARA_FLAG 0x1 2620 #define CMSG_KEY_AGREE_ENCRYPT_FREE_MATERIAL_FLAG 0x2 2621 #define CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_ALG_FLAG 0x4 2622 #define CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_PARA_FLAG 0x8 2623 #define CMSG_KEY_AGREE_ENCRYPT_FREE_PUBKEY_BITS_FLAG 0x10 2624 2625 #define CMSG_OID_EXPORT_KEY_AGREE_FUNC "CryptMsgDllExportKeyAgree" 2626 2627 typedef WINBOOL (WINAPI *PFN_CMSG_EXPORT_KEY_AGREE)(PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo,PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO pKeyAgreeEncodeInfo,PCMSG_KEY_AGREE_ENCRYPT_INFO pKeyAgreeEncryptInfo,DWORD dwFlags,void *pvReserved); 2628 2629 typedef struct _CMSG_MAIL_LIST_ENCRYPT_INFO { 2630 DWORD cbSize; 2631 DWORD dwRecipientIndex; 2632 CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm; 2633 CRYPT_DATA_BLOB EncryptedKey; 2634 DWORD dwFlags; 2635 } CMSG_MAIL_LIST_ENCRYPT_INFO,*PCMSG_MAIL_LIST_ENCRYPT_INFO; 2636 2637 #define CMSG_MAIL_LIST_ENCRYPT_FREE_PARA_FLAG 0x1 2638 2639 #define CMSG_OID_EXPORT_MAIL_LIST_FUNC "CryptMsgDllExportMailList" 2640 typedef WINBOOL (WINAPI *PFN_CMSG_EXPORT_MAIL_LIST)(PCMSG_CONTENT_ENCRYPT_INFO pContentEncryptInfo,PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO pMailListEncodeInfo,PCMSG_MAIL_LIST_ENCRYPT_INFO pMailListEncryptInfo,DWORD dwFlags,void *pvReserved); 2641 2642 #define CMSG_OID_IMPORT_KEY_TRANS_FUNC "CryptMsgDllImportKeyTrans" 2643 typedef WINBOOL (WINAPI *PFN_CMSG_IMPORT_KEY_TRANS)(PCRYPT_ALGORITHM_IDENTIFIER pContentEncryptionAlgorithm,PCMSG_CTRL_KEY_TRANS_DECRYPT_PARA pKeyTransDecryptPara,DWORD dwFlags,void *pvReserved,HCRYPTKEY *phContentEncryptKey); 2644 2645 #define CMSG_OID_IMPORT_KEY_AGREE_FUNC "CryptMsgDllImportKeyAgree" 2646 typedef WINBOOL (WINAPI *PFN_CMSG_IMPORT_KEY_AGREE)(PCRYPT_ALGORITHM_IDENTIFIER pContentEncryptionAlgorithm,PCMSG_CTRL_KEY_AGREE_DECRYPT_PARA pKeyAgreeDecryptPara,DWORD dwFlags,void *pvReserved,HCRYPTKEY *phContentEncryptKey); 2647 2648 #define CMSG_OID_IMPORT_MAIL_LIST_FUNC "CryptMsgDllImportMailList" 2649 typedef WINBOOL (WINAPI *PFN_CMSG_IMPORT_MAIL_LIST)(PCRYPT_ALGORITHM_IDENTIFIER pContentEncryptionAlgorithm,PCMSG_CTRL_MAIL_LIST_DECRYPT_PARA pMailListDecryptPara,DWORD dwFlags,void *pvReserved,HCRYPTKEY *phContentEncryptKey); 2650 2651 typedef void *HCERTSTORE; 2652 2653 typedef struct _CERT_CONTEXT { 2654 DWORD dwCertEncodingType; 2655 BYTE *pbCertEncoded; 2656 DWORD cbCertEncoded; 2657 PCERT_INFO pCertInfo; 2658 HCERTSTORE hCertStore; 2659 } CERT_CONTEXT,*PCERT_CONTEXT; 2660 2661 typedef const CERT_CONTEXT *PCCERT_CONTEXT; 2662 2663 typedef struct _CRL_CONTEXT { 2664 DWORD dwCertEncodingType; 2665 BYTE *pbCrlEncoded; 2666 DWORD cbCrlEncoded; 2667 PCRL_INFO pCrlInfo; 2668 HCERTSTORE hCertStore; 2669 } CRL_CONTEXT,*PCRL_CONTEXT; 2670 2671 typedef const CRL_CONTEXT *PCCRL_CONTEXT; 2672 2673 typedef struct _CTL_CONTEXT { 2674 DWORD dwMsgAndCertEncodingType; 2675 BYTE *pbCtlEncoded; 2676 DWORD cbCtlEncoded; 2677 PCTL_INFO pCtlInfo; 2678 HCERTSTORE hCertStore; 2679 HCRYPTMSG hCryptMsg; 2680 BYTE *pbCtlContent; 2681 DWORD cbCtlContent; 2682 } CTL_CONTEXT,*PCTL_CONTEXT; 2683 2684 typedef const CTL_CONTEXT *PCCTL_CONTEXT; 2685 2686 #define CERT_KEY_PROV_HANDLE_PROP_ID 1 2687 #define CERT_KEY_PROV_INFO_PROP_ID 2 2688 #define CERT_SHA1_HASH_PROP_ID 3 2689 #define CERT_MD5_HASH_PROP_ID 4 2690 #define CERT_HASH_PROP_ID CERT_SHA1_HASH_PROP_ID 2691 #define CERT_KEY_CONTEXT_PROP_ID 5 2692 #define CERT_KEY_SPEC_PROP_ID 6 2693 #define CERT_IE30_RESERVED_PROP_ID 7 2694 #define CERT_PUBKEY_HASH_RESERVED_PROP_ID 8 2695 #define CERT_ENHKEY_USAGE_PROP_ID 9 2696 #define CERT_CTL_USAGE_PROP_ID CERT_ENHKEY_USAGE_PROP_ID 2697 #define CERT_NEXT_UPDATE_LOCATION_PROP_ID 10 2698 #define CERT_FRIENDLY_NAME_PROP_ID 11 2699 #define CERT_PVK_FILE_PROP_ID 12 2700 #define CERT_DESCRIPTION_PROP_ID 13 2701 #define CERT_ACCESS_STATE_PROP_ID 14 2702 #define CERT_SIGNATURE_HASH_PROP_ID 15 2703 #define CERT_SMART_CARD_DATA_PROP_ID 16 2704 #define CERT_EFS_PROP_ID 17 2705 #define CERT_FORTEZZA_DATA_PROP_ID 18 2706 #define CERT_ARCHIVED_PROP_ID 19 2707 #define CERT_KEY_IDENTIFIER_PROP_ID 20 2708 #define CERT_AUTO_ENROLL_PROP_ID 21 2709 #define CERT_PUBKEY_ALG_PARA_PROP_ID 22 2710 #define CERT_CROSS_CERT_DIST_POINTS_PROP_ID 23 2711 #define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID 24 2712 #define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID 25 2713 #define CERT_ENROLLMENT_PROP_ID 26 2714 #define CERT_DATE_STAMP_PROP_ID 27 2715 #define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID 28 2716 #define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID 29 2717 #define CERT_EXTENDED_ERROR_INFO_PROP_ID 30 2718 #define CERT_RENEWAL_PROP_ID 64 2719 #define CERT_ARCHIVED_KEY_HASH_PROP_ID 65 2720 #define CERT_AUTO_ENROLL_RETRY_PROP_ID 66 2721 #define CERT_AIA_URL_RETRIEVED_PROP_ID 67 2722 #define CERT_REQUEST_ORIGINATOR_PROP_ID 71 2723 #define CERT_FIRST_RESERVED_PROP_ID 72 2724 #define CERT_LAST_RESERVED_PROP_ID 0x7fff 2725 #define CERT_FIRST_USER_PROP_ID 0x8000 2726 #define CERT_LAST_USER_PROP_ID 0xffff 2727 2728 #define IS_CERT_HASH_PROP_ID(X) (CERT_SHA1_HASH_PROP_ID==(X) || CERT_MD5_HASH_PROP_ID==(X) || CERT_SIGNATURE_HASH_PROP_ID==(X)) 2729 #define IS_PUBKEY_HASH_PROP_ID(X) (CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID==(X) || CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID==(X)) 2730 #define IS_CHAIN_HASH_PROP_ID(X) (CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID==(X) || CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID==(X) || CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID==(X) || CERT_SUBJECT_NAME_MD5_HASH_PROP_ID==(X)) 2731 2732 #define szOID_CERT_PROP_ID_PREFIX "1.3.6.1.4.1.311.10.11." 2733 #define szOID_CERT_KEY_IDENTIFIER_PROP_ID "1.3.6.1.4.1.311.10.11.20" 2734 #define szOID_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID "1.3.6.1.4.1.311.10.11.28" 2735 #define szOID_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID "1.3.6.1.4.1.311.10.11.29" 2736 2737 #define CERT_ACCESS_STATE_WRITE_PERSIST_FLAG 0x1 2738 2739 #define CERT_ACCESS_STATE_SYSTEM_STORE_FLAG 0x2 2740 2741 #define CERT_ACCESS_STATE_LM_SYSTEM_STORE_FLAG 0x4 2742 2743 typedef struct _CRYPT_KEY_PROV_PARAM { 2744 DWORD dwParam; 2745 BYTE *pbData; 2746 DWORD cbData; 2747 DWORD dwFlags; 2748 } CRYPT_KEY_PROV_PARAM,*PCRYPT_KEY_PROV_PARAM; 2749 2750 typedef struct _CRYPT_KEY_PROV_INFO { 2751 LPWSTR pwszContainerName; 2752 LPWSTR pwszProvName; 2753 DWORD dwProvType; 2754 DWORD dwFlags; 2755 DWORD cProvParam; 2756 PCRYPT_KEY_PROV_PARAM rgProvParam; 2757 DWORD dwKeySpec; 2758 } CRYPT_KEY_PROV_INFO,*PCRYPT_KEY_PROV_INFO; 2759 2760 #define CERT_SET_KEY_PROV_HANDLE_PROP_ID 0x1 2761 #define CERT_SET_KEY_CONTEXT_PROP_ID 0x1 2762 2763 typedef struct _CERT_KEY_CONTEXT { 2764 DWORD cbSize; 2765 HCRYPTPROV hCryptProv; 2766 DWORD dwKeySpec; 2767 } CERT_KEY_CONTEXT,*PCERT_KEY_CONTEXT; 2768 2769 #define CERT_STORE_PROV_MSG ((LPCSTR) 1) 2770 #define CERT_STORE_PROV_MEMORY ((LPCSTR) 2) 2771 #define CERT_STORE_PROV_FILE ((LPCSTR) 3) 2772 #define CERT_STORE_PROV_REG ((LPCSTR) 4) 2773 2774 #define CERT_STORE_PROV_PKCS7 ((LPCSTR) 5) 2775 #define CERT_STORE_PROV_SERIALIZED ((LPCSTR) 6) 2776 #define CERT_STORE_PROV_FILENAME_A ((LPCSTR) 7) 2777 #define CERT_STORE_PROV_FILENAME_W ((LPCSTR) 8) 2778 #define CERT_STORE_PROV_FILENAME CERT_STORE_PROV_FILENAME_W 2779 #define CERT_STORE_PROV_SYSTEM_A ((LPCSTR) 9) 2780 #define CERT_STORE_PROV_SYSTEM_W ((LPCSTR) 10) 2781 #define CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_W 2782 2783 #define CERT_STORE_PROV_COLLECTION ((LPCSTR) 11) 2784 #define CERT_STORE_PROV_SYSTEM_REGISTRY_A ((LPCSTR) 12) 2785 #define CERT_STORE_PROV_SYSTEM_REGISTRY_W ((LPCSTR) 13) 2786 #define CERT_STORE_PROV_SYSTEM_REGISTRY CERT_STORE_PROV_SYSTEM_REGISTRY_W 2787 #define CERT_STORE_PROV_PHYSICAL_W ((LPCSTR) 14) 2788 #define CERT_STORE_PROV_PHYSICAL CERT_STORE_PROV_PHYSICAL_W 2789 #define CERT_STORE_PROV_SMART_CARD_W ((LPCSTR) 15) 2790 #define CERT_STORE_PROV_SMART_CARD CERT_STORE_PROV_SMART_CARD_W 2791 #define CERT_STORE_PROV_LDAP_W ((LPCSTR) 16) 2792 #define CERT_STORE_PROV_LDAP CERT_STORE_PROV_LDAP_W 2793 #define sz_CERT_STORE_PROV_MEMORY "Memory" 2794 #define sz_CERT_STORE_PROV_FILENAME_W "File" 2795 #define sz_CERT_STORE_PROV_FILENAME sz_CERT_STORE_PROV_FILENAME_W 2796 #define sz_CERT_STORE_PROV_SYSTEM_W "System" 2797 #define sz_CERT_STORE_PROV_SYSTEM sz_CERT_STORE_PROV_SYSTEM_W 2798 #define sz_CERT_STORE_PROV_PKCS7 "PKCS7" 2799 #define sz_CERT_STORE_PROV_SERIALIZED "Serialized" 2800 #define sz_CERT_STORE_PROV_COLLECTION "Collection" 2801 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W "SystemRegistry" 2802 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W 2803 #define sz_CERT_STORE_PROV_PHYSICAL_W "Physical" 2804 #define sz_CERT_STORE_PROV_PHYSICAL sz_CERT_STORE_PROV_PHYSICAL_W 2805 #define sz_CERT_STORE_PROV_SMART_CARD_W "SmartCard" 2806 #define sz_CERT_STORE_PROV_SMART_CARD sz_CERT_STORE_PROV_SMART_CARD_W 2807 #define sz_CERT_STORE_PROV_LDAP_W "Ldap" 2808 #define sz_CERT_STORE_PROV_LDAP sz_CERT_STORE_PROV_LDAP_W 2809 #define CERT_STORE_SIGNATURE_FLAG 0x1 2810 #define CERT_STORE_TIME_VALIDITY_FLAG 0x2 2811 #define CERT_STORE_REVOCATION_FLAG 0x4 2812 #define CERT_STORE_NO_CRL_FLAG 0x10000 2813 #define CERT_STORE_NO_ISSUER_FLAG 0x20000 2814 #define CERT_STORE_BASE_CRL_FLAG 0x100 2815 #define CERT_STORE_DELTA_CRL_FLAG 0x200 2816 #define CERT_STORE_NO_CRYPT_RELEASE_FLAG 0x1 2817 #define CERT_STORE_SET_LOCALIZED_NAME_FLAG 0x2 2818 #define CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG 0x4 2819 #define CERT_STORE_DELETE_FLAG 0x10 2820 #define CERT_STORE_UNSAFE_PHYSICAL_FLAG 0x20 2821 #define CERT_STORE_SHARE_STORE_FLAG 0x40 2822 #define CERT_STORE_SHARE_CONTEXT_FLAG 0x80 2823 #define CERT_STORE_MANIFOLD_FLAG 0x100 2824 #define CERT_STORE_ENUM_ARCHIVED_FLAG 0x200 2825 #define CERT_STORE_UPDATE_KEYID_FLAG 0x400 2826 #define CERT_STORE_BACKUP_RESTORE_FLAG 0x800 2827 #define CERT_STORE_READONLY_FLAG 0x8000 2828 #define CERT_STORE_OPEN_EXISTING_FLAG 0x4000 2829 #define CERT_STORE_CREATE_NEW_FLAG 0x2000 2830 #define CERT_STORE_MAXIMUM_ALLOWED_FLAG 0x1000 2831 2832 #define CERT_SYSTEM_STORE_MASK 0xFFFF0000 2833 #define CERT_SYSTEM_STORE_RELOCATE_FLAG 0x80000000 2834 2835 typedef struct _CERT_SYSTEM_STORE_RELOCATE_PARA { 2836 __C89_NAMELESS union { 2837 HKEY hKeyBase; 2838 void *pvBase; 2839 }; 2840 __C89_NAMELESS union { 2841 void *pvSystemStore; 2842 LPCSTR pszSystemStore; 2843 LPCWSTR pwszSystemStore; 2844 }; 2845 } CERT_SYSTEM_STORE_RELOCATE_PARA,*PCERT_SYSTEM_STORE_RELOCATE_PARA; 2846 2847 #define CERT_SYSTEM_STORE_UNPROTECTED_FLAG 0x40000000 2848 #define CERT_SYSTEM_STORE_LOCATION_MASK 0xff0000 2849 #define CERT_SYSTEM_STORE_LOCATION_SHIFT 16 2850 #define CERT_SYSTEM_STORE_CURRENT_USER_ID 1 2851 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ID 2 2852 #define CERT_SYSTEM_STORE_CURRENT_SERVICE_ID 4 2853 #define CERT_SYSTEM_STORE_SERVICES_ID 5 2854 #define CERT_SYSTEM_STORE_USERS_ID 6 2855 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID 7 2856 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID 8 2857 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID 9 2858 #define CERT_SYSTEM_STORE_CURRENT_USER (CERT_SYSTEM_STORE_CURRENT_USER_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2859 #define CERT_SYSTEM_STORE_LOCAL_MACHINE (CERT_SYSTEM_STORE_LOCAL_MACHINE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2860 #define CERT_SYSTEM_STORE_CURRENT_SERVICE (CERT_SYSTEM_STORE_CURRENT_SERVICE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2861 #define CERT_SYSTEM_STORE_SERVICES (CERT_SYSTEM_STORE_SERVICES_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2862 #define CERT_SYSTEM_STORE_USERS (CERT_SYSTEM_STORE_USERS_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2863 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY (CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2864 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY (CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2865 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE (CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) 2866 2867 #define CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"Software\\Policies\\Microsoft\\SystemCertificates" 2868 2869 #define CERT_EFSBLOB_REGPATH CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"\\EFS" 2870 #define CERT_EFSBLOB_VALUE_NAME L"EFSBlob" 2871 2872 #define CERT_PROT_ROOT_FLAGS_REGPATH CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"\\Root\\ProtectedRoots" 2873 #define CERT_PROT_ROOT_FLAGS_VALUE_NAME L"Flags" 2874 #define CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG 0x1 2875 #define CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG 0x2 2876 #define CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG 0x4 2877 #define CERT_PROT_ROOT_DISABLE_LM_AUTH_FLAG 0x8 2878 #define CERT_PROT_ROOT_ONLY_LM_GPT_FLAG 0x8 2879 #define CERT_PROT_ROOT_DISABLE_NT_AUTH_REQUIRED_FLAG 0x10 2880 #define CERT_PROT_ROOT_DISABLE_NOT_DEFINED_NAME_CONSTRAINT_FLAG 0x20 2881 2882 #define CERT_TRUST_PUB_SAFER_GROUP_POLICY_REGPATH CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"\\TrustedPublisher\\Safer" 2883 #define CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH L"Software\\Microsoft\\SystemCertificates" 2884 #define CERT_TRUST_PUB_SAFER_LOCAL_MACHINE_REGPATH CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH L"\\TrustedPublisher\\Safer" 2885 #define CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME L"AuthenticodeFlags" 2886 #define CERT_TRUST_PUB_ALLOW_TRUST_MASK 0x3 2887 #define CERT_TRUST_PUB_ALLOW_END_USER_TRUST 0x0 2888 #define CERT_TRUST_PUB_ALLOW_MACHINE_ADMIN_TRUST 0x1 2889 #define CERT_TRUST_PUB_ALLOW_ENTERPRISE_ADMIN_TRUST 0x2 2890 #define CERT_TRUST_PUB_CHECK_PUBLISHER_REV_FLAG 0x100 2891 #define CERT_TRUST_PUB_CHECK_TIMESTAMP_REV_FLAG 0x200 2892 2893 #define CERT_OCM_SUBCOMPONENTS_LOCAL_MACHINE_REGPATH L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\OC Manager\\Subcomponents" 2894 #define CERT_OCM_SUBCOMPONENTS_ROOT_AUTO_UPDATE_VALUE_NAME L"RootAutoUpdate" 2895 2896 #define CERT_AUTH_ROOT_AUTO_UPDATE_LOCAL_MACHINE_REGPATH CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH L"\\AuthRoot\\AutoUpdate" 2897 #define CERT_AUTH_ROOT_AUTO_UPDATE_ROOT_DIR_URL_VALUE_NAME L"RootDirUrl" 2898 #define CERT_AUTH_ROOT_AUTO_UPDATE_SYNC_DELTA_TIME_VALUE_NAME L"SyncDeltaTime" 2899 #define CERT_AUTH_ROOT_AUTO_UPDATE_FLAGS_VALUE_NAME L"Flags" 2900 #define CERT_AUTH_ROOT_AUTO_UPDATE_DISABLE_UNTRUSTED_ROOT_LOGGING_FLAG 0x1 2901 #define CERT_AUTH_ROOT_AUTO_UPDATE_DISABLE_PARTIAL_CHAIN_LOGGING_FLAG 0x2 2902 #define CERT_AUTH_ROOT_CTL_FILENAME L"authroot.stl" 2903 #define CERT_AUTH_ROOT_CTL_FILENAME_A "authroot.stl" 2904 #define CERT_AUTH_ROOT_CAB_FILENAME L"authrootstl.cab" 2905 #define CERT_AUTH_ROOT_SEQ_FILENAME L"authrootseq.txt" 2906 #define CERT_AUTH_ROOT_CERT_EXT L".crt" 2907 2908 #define CERT_REGISTRY_STORE_REMOTE_FLAG 0x10000 2909 #define CERT_REGISTRY_STORE_SERIALIZED_FLAG 0x20000 2910 #define CERT_REGISTRY_STORE_CLIENT_GPT_FLAG 0x80000000 2911 #define CERT_REGISTRY_STORE_LM_GPT_FLAG 0x1000000 2912 2913 typedef struct _CERT_REGISTRY_STORE_CLIENT_GPT_PARA { 2914 HKEY hKeyBase; 2915 LPWSTR pwszRegPath; 2916 } CERT_REGISTRY_STORE_CLIENT_GPT_PARA,*PCERT_REGISTRY_STORE_CLIENT_GPT_PARA; 2917 2918 #define CERT_REGISTRY_STORE_ROAMING_FLAG 0x40000 2919 2920 typedef struct _CERT_REGISTRY_STORE_ROAMING_PARA { 2921 HKEY hKey; 2922 LPWSTR pwszStoreDirectory; 2923 } CERT_REGISTRY_STORE_ROAMING_PARA,*PCERT_REGISTRY_STORE_ROAMING_PARA; 2924 2925 #define CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG 0x80000 2926 #define CERT_IE_DIRTY_FLAGS_REGPATH L"Software\\Microsoft\\Cryptography\\IEDirtyFlags" 2927 #define CERT_FILE_STORE_COMMIT_ENABLE_FLAG 0x10000 2928 #define CERT_LDAP_STORE_SIGN_FLAG 0x10000 2929 #define CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG 0x20000 2930 #define CERT_LDAP_STORE_OPENED_FLAG 0x40000 2931 2932 typedef struct _CERT_LDAP_STORE_OPENED_PARA { 2933 void *pvLdapSessionHandle; 2934 LPCWSTR pwszLdapUrl; 2935 } CERT_LDAP_STORE_OPENED_PARA,*PCERT_LDAP_STORE_OPENED_PARA; 2936 2937 #define CERT_LDAP_STORE_UNBIND_FLAG 0x80000 2938 2939 WINIMPM HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider,DWORD dwEncodingType,HCRYPTPROV hCryptProv,DWORD dwFlags,const void *pvPara); 2940 2941 typedef void *HCERTSTOREPROV; 2942 2943 #define CRYPT_OID_OPEN_STORE_PROV_FUNC "CertDllOpenStoreProv" 2944 2945 typedef struct _CERT_STORE_PROV_INFO { 2946 DWORD cbSize; 2947 DWORD cStoreProvFunc; 2948 void **rgpvStoreProvFunc; 2949 HCERTSTOREPROV hStoreProv; 2950 DWORD dwStoreProvFlags; 2951 HCRYPTOIDFUNCADDR hStoreProvFuncAddr2; 2952 } CERT_STORE_PROV_INFO,*PCERT_STORE_PROV_INFO; 2953 2954 typedef WINBOOL (WINAPI *PFN_CERT_DLL_OPEN_STORE_PROV_FUNC)(LPCSTR lpszStoreProvider,DWORD dwEncodingType,HCRYPTPROV hCryptProv,DWORD dwFlags,const void *pvPara,HCERTSTORE hCertStore,PCERT_STORE_PROV_INFO pStoreProvInfo); 2955 2956 #define CERT_STORE_PROV_EXTERNAL_FLAG 0x1 2957 #define CERT_STORE_PROV_DELETED_FLAG 0x2 2958 #define CERT_STORE_PROV_NO_PERSIST_FLAG 0x4 2959 #define CERT_STORE_PROV_SYSTEM_STORE_FLAG 0x8 2960 #define CERT_STORE_PROV_LM_SYSTEM_STORE_FLAG 0x10 2961 #define CERT_STORE_PROV_CLOSE_FUNC 0 2962 #define CERT_STORE_PROV_READ_CERT_FUNC 1 2963 #define CERT_STORE_PROV_WRITE_CERT_FUNC 2 2964 #define CERT_STORE_PROV_DELETE_CERT_FUNC 3 2965 #define CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC 4 2966 #define CERT_STORE_PROV_READ_CRL_FUNC 5 2967 #define CERT_STORE_PROV_WRITE_CRL_FUNC 6 2968 #define CERT_STORE_PROV_DELETE_CRL_FUNC 7 2969 #define CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC 8 2970 #define CERT_STORE_PROV_READ_CTL_FUNC 9 2971 #define CERT_STORE_PROV_WRITE_CTL_FUNC 10 2972 #define CERT_STORE_PROV_DELETE_CTL_FUNC 11 2973 #define CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC 12 2974 #define CERT_STORE_PROV_CONTROL_FUNC 13 2975 #define CERT_STORE_PROV_FIND_CERT_FUNC 14 2976 #define CERT_STORE_PROV_FREE_FIND_CERT_FUNC 15 2977 #define CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC 16 2978 #define CERT_STORE_PROV_FIND_CRL_FUNC 17 2979 #define CERT_STORE_PROV_FREE_FIND_CRL_FUNC 18 2980 #define CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC 19 2981 #define CERT_STORE_PROV_FIND_CTL_FUNC 20 2982 #define CERT_STORE_PROV_FREE_FIND_CTL_FUNC 21 2983 #define CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC 22 2984 2985 typedef void (WINAPI *PFN_CERT_STORE_PROV_CLOSE)(HCERTSTOREPROV hStoreProv,DWORD dwFlags); 2986 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CERT)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pStoreCertContext,DWORD dwFlags,PCCERT_CONTEXT *ppProvCertContext); 2987 2988 #define CERT_STORE_PROV_WRITE_ADD_FLAG 0x1 2989 2990 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CERT)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pCertContext,DWORD dwFlags); 2991 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CERT)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pCertContext,DWORD dwFlags); 2992 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CERT_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pCertContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 2993 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CRL)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pStoreCrlContext,DWORD dwFlags,PCCRL_CONTEXT *ppProvCrlContext); 2994 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CRL)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pCrlContext,DWORD dwFlags); 2995 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CRL)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pCrlContext,DWORD dwFlags); 2996 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CRL_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pCrlContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 2997 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CTL)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pStoreCtlContext,DWORD dwFlags,PCCTL_CONTEXT *ppProvCtlContext); 2998 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CTL)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pCtlContext,DWORD dwFlags); 2999 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CTL)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pCtlContext,DWORD dwFlags); 3000 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CTL_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pCtlContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 3001 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_CONTROL)(HCERTSTOREPROV hStoreProv,DWORD dwFlags,DWORD dwCtrlType,void const *pvCtrlPara); 3002 3003 typedef struct _CERT_STORE_PROV_FIND_INFO { 3004 DWORD cbSize; 3005 DWORD dwMsgAndCertEncodingType; 3006 DWORD dwFindFlags; 3007 DWORD dwFindType; 3008 const void *pvFindPara; 3009 } CERT_STORE_PROV_FIND_INFO,*PCERT_STORE_PROV_FIND_INFO; 3010 3011 typedef const CERT_STORE_PROV_FIND_INFO CCERT_STORE_PROV_FIND_INFO,*PCCERT_STORE_PROV_FIND_INFO; 3012 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CERT)(HCERTSTOREPROV hStoreProv,PCCERT_STORE_PROV_FIND_INFO pFindInfo,PCCERT_CONTEXT pPrevCertContext,DWORD dwFlags,void **ppvStoreProvFindInfo,PCCERT_CONTEXT *ppProvCertContext); 3013 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CERT)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pCertContext,void *pvStoreProvFindInfo,DWORD dwFlags); 3014 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CERT_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCERT_CONTEXT pCertContext,DWORD dwPropId,DWORD dwFlags,void *pvData,DWORD *pcbData); 3015 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CRL)(HCERTSTOREPROV hStoreProv,PCCERT_STORE_PROV_FIND_INFO pFindInfo,PCCRL_CONTEXT pPrevCrlContext,DWORD dwFlags,void **ppvStoreProvFindInfo,PCCRL_CONTEXT *ppProvCrlContext); 3016 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CRL)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pCrlContext,void *pvStoreProvFindInfo,DWORD dwFlags); 3017 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CRL_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCRL_CONTEXT pCrlContext,DWORD dwPropId,DWORD dwFlags,void *pvData,DWORD *pcbData); 3018 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CTL)(HCERTSTOREPROV hStoreProv,PCCERT_STORE_PROV_FIND_INFO pFindInfo,PCCTL_CONTEXT pPrevCtlContext,DWORD dwFlags,void **ppvStoreProvFindInfo,PCCTL_CONTEXT *ppProvCtlContext); 3019 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CTL)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pCtlContext,void *pvStoreProvFindInfo,DWORD dwFlags); 3020 typedef WINBOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CTL_PROPERTY)(HCERTSTOREPROV hStoreProv,PCCTL_CONTEXT pCtlContext,DWORD dwPropId,DWORD dwFlags,void *pvData,DWORD *pcbData); 3021 3022 WINIMPM HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore); 3023 3024 #define CERT_STORE_SAVE_AS_STORE 1 3025 #define CERT_STORE_SAVE_AS_PKCS7 2 3026 #define CERT_STORE_SAVE_TO_FILE 1 3027 #define CERT_STORE_SAVE_TO_MEMORY 2 3028 #define CERT_STORE_SAVE_TO_FILENAME_A 3 3029 #define CERT_STORE_SAVE_TO_FILENAME_W 4 3030 #define CERT_STORE_SAVE_TO_FILENAME CERT_STORE_SAVE_TO_FILENAME_W 3031 3032 WINIMPM WINBOOL WINAPI CertSaveStore(HCERTSTORE hCertStore,DWORD dwEncodingType,DWORD dwSaveAs,DWORD dwSaveTo,void *pvSaveToPara,DWORD dwFlags); 3033 3034 #define CERT_CLOSE_STORE_FORCE_FLAG 0x1 3035 #define CERT_CLOSE_STORE_CHECK_FLAG 0x2 3036 3037 WINIMPM WINBOOL WINAPI CertCloseStore(HCERTSTORE hCertStore,DWORD dwFlags); 3038 WINIMPM PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(HCERTSTORE hCertStore,DWORD dwCertEncodingType,PCERT_INFO pCertId); 3039 WINIMPM PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore,PCCERT_CONTEXT pPrevCertContext); 3040 WINIMPM PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore,DWORD dwCertEncodingType,DWORD dwFindFlags,DWORD dwFindType,const void *pvFindPara,PCCERT_CONTEXT pPrevCertContext); 3041 3042 #define CERT_COMPARE_MASK 0xFFFF 3043 #define CERT_COMPARE_SHIFT 16 3044 #define CERT_COMPARE_ANY 0 3045 #define CERT_COMPARE_SHA1_HASH 1 3046 #define CERT_COMPARE_NAME 2 3047 #define CERT_COMPARE_ATTR 3 3048 #define CERT_COMPARE_MD5_HASH 4 3049 #define CERT_COMPARE_PROPERTY 5 3050 #define CERT_COMPARE_PUBLIC_KEY 6 3051 #define CERT_COMPARE_HASH CERT_COMPARE_SHA1_HASH 3052 #define CERT_COMPARE_NAME_STR_A 7 3053 #define CERT_COMPARE_NAME_STR_W 8 3054 #define CERT_COMPARE_KEY_SPEC 9 3055 #define CERT_COMPARE_ENHKEY_USAGE 10 3056 #define CERT_COMPARE_CTL_USAGE CERT_COMPARE_ENHKEY_USAGE 3057 #define CERT_COMPARE_SUBJECT_CERT 11 3058 #define CERT_COMPARE_ISSUER_OF 12 3059 #define CERT_COMPARE_EXISTING 13 3060 #define CERT_COMPARE_SIGNATURE_HASH 14 3061 #define CERT_COMPARE_KEY_IDENTIFIER 15 3062 #define CERT_COMPARE_CERT_ID 16 3063 #define CERT_COMPARE_CROSS_CERT_DIST_POINTS 17 3064 #define CERT_COMPARE_PUBKEY_MD5_HASH 18 3065 3066 #define CERT_FIND_ANY (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT) 3067 #define CERT_FIND_SHA1_HASH (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT) 3068 #define CERT_FIND_MD5_HASH (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT) 3069 #define CERT_FIND_SIGNATURE_HASH (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT) 3070 #define CERT_FIND_KEY_IDENTIFIER (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT) 3071 #define CERT_FIND_HASH CERT_FIND_SHA1_HASH 3072 #define CERT_FIND_PROPERTY (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT) 3073 #define CERT_FIND_PUBLIC_KEY (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT) 3074 #define CERT_FIND_SUBJECT_NAME (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) 3075 #define CERT_FIND_SUBJECT_ATTR (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) 3076 #define CERT_FIND_ISSUER_NAME (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) 3077 #define CERT_FIND_ISSUER_ATTR (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) 3078 #define CERT_FIND_SUBJECT_STR_A (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) 3079 #define CERT_FIND_SUBJECT_STR_W (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) 3080 #define CERT_FIND_SUBJECT_STR CERT_FIND_SUBJECT_STR_W 3081 #define CERT_FIND_ISSUER_STR_A (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) 3082 #define CERT_FIND_ISSUER_STR_W (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) 3083 #define CERT_FIND_ISSUER_STR CERT_FIND_ISSUER_STR_W 3084 #define CERT_FIND_KEY_SPEC (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT) 3085 #define CERT_FIND_ENHKEY_USAGE (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT) 3086 #define CERT_FIND_CTL_USAGE CERT_FIND_ENHKEY_USAGE 3087 #define CERT_FIND_SUBJECT_CERT (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT) 3088 #define CERT_FIND_ISSUER_OF (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT) 3089 #define CERT_FIND_EXISTING (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT) 3090 #define CERT_FIND_CERT_ID (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT) 3091 #define CERT_FIND_CROSS_CERT_DIST_POINTS (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT) 3092 #define CERT_FIND_PUBKEY_MD5_HASH (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT) 3093 #define CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG 0x1 3094 #define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG 0x2 3095 #define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG 0x4 3096 #define CERT_FIND_NO_ENHKEY_USAGE_FLAG 0x8 3097 #define CERT_FIND_OR_ENHKEY_USAGE_FLAG 0x10 3098 #define CERT_FIND_VALID_ENHKEY_USAGE_FLAG 0x20 3099 #define CERT_FIND_OPTIONAL_CTL_USAGE_FLAG CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG 3100 #define CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG 3101 #define CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG 3102 #define CERT_FIND_NO_CTL_USAGE_FLAG CERT_FIND_NO_ENHKEY_USAGE_FLAG 3103 #define CERT_FIND_OR_CTL_USAGE_FLAG CERT_FIND_OR_ENHKEY_USAGE_FLAG 3104 #define CERT_FIND_VALID_CTL_USAGE_FLAG CERT_FIND_VALID_ENHKEY_USAGE_FLAG 3105 3106 WINIMPM PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore,PCCERT_CONTEXT pSubjectContext,PCCERT_CONTEXT pPrevIssuerContext,DWORD *pdwFlags); 3107 WINIMPM WINBOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject,PCCERT_CONTEXT pIssuer,DWORD *pdwFlags); 3108 WINIMPM PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext); 3109 WINIMPM PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,const BYTE *pbCertEncoded,DWORD cbCertEncoded); 3110 WINIMPM WINBOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext); 3111 WINIMPM WINBOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 3112 3113 #define CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG 0x80000000 3114 #define CERT_SET_PROPERTY_INHIBIT_PERSIST_FLAG 0x40000000 3115 3116 WINIMPM WINBOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,DWORD dwPropId,void *pvData,DWORD *pcbData); 3117 WINIMPM DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,DWORD dwPropId); 3118 WINIMPM WINBOOL WINAPI CertCreateCTLEntryFromCertificateContextProperties(PCCERT_CONTEXT pCertContext,DWORD cOptAttr,PCRYPT_ATTRIBUTE rgOptAttr,DWORD dwFlags,void *pvReserved,PCTL_ENTRY pCtlEntry,DWORD *pcbCtlEntry); 3119 3120 #define CTL_ENTRY_FROM_PROP_CHAIN_FLAG 0x1 3121 3122 WINIMPM WINBOOL WINAPI CertSetCertificateContextPropertiesFromCTLEntry(PCCERT_CONTEXT pCertContext,PCTL_ENTRY pCtlEntry,DWORD dwFlags); 3123 WINIMPM PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore,PCCERT_CONTEXT pIssuerContext,PCCRL_CONTEXT pPrevCrlContext,DWORD *pdwFlags); 3124 WINIMPM PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore,PCCRL_CONTEXT pPrevCrlContext); 3125 WINIMPM PCCRL_CONTEXT WINAPI CertFindCRLInStore(HCERTSTORE hCertStore,DWORD dwCertEncodingType,DWORD dwFindFlags,DWORD dwFindType,const void *pvFindPara,PCCRL_CONTEXT pPrevCrlContext); 3126 3127 #define CRL_FIND_ANY 0 3128 #define CRL_FIND_ISSUED_BY 1 3129 #define CRL_FIND_EXISTING 2 3130 #define CRL_FIND_ISSUED_FOR 3 3131 #define CRL_FIND_ISSUED_BY_AKI_FLAG 0x1 3132 #define CRL_FIND_ISSUED_BY_SIGNATURE_FLAG 0x2 3133 #define CRL_FIND_ISSUED_BY_DELTA_FLAG 0x4 3134 #define CRL_FIND_ISSUED_BY_BASE_FLAG 0x8 3135 3136 typedef struct _CRL_FIND_ISSUED_FOR_PARA { 3137 PCCERT_CONTEXT pSubjectCert; 3138 PCCERT_CONTEXT pIssuerCert; 3139 } CRL_FIND_ISSUED_FOR_PARA,*PCRL_FIND_ISSUED_FOR_PARA; 3140 3141 WINIMPM PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext); 3142 WINIMPM PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,const BYTE *pbCrlEncoded,DWORD cbCrlEncoded); 3143 WINIMPM WINBOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext); 3144 WINIMPM WINBOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCrlContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 3145 WINIMPM WINBOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCrlContext,DWORD dwPropId,void *pvData,DWORD *pcbData); 3146 WINIMPM DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCrlContext,DWORD dwPropId); 3147 WINIMPM WINBOOL WINAPI CertFindCertificateInCRL(PCCERT_CONTEXT pCert,PCCRL_CONTEXT pCrlContext,DWORD dwFlags,void *pvReserved,PCRL_ENTRY *ppCrlEntry); 3148 WINIMPM WINBOOL WINAPI CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert,PCCRL_CONTEXT pCrl,DWORD dwFlags,void *pvReserved); 3149 3150 #define CERT_STORE_ADD_NEW 1 3151 #define CERT_STORE_ADD_USE_EXISTING 2 3152 #define CERT_STORE_ADD_REPLACE_EXISTING 3 3153 #define CERT_STORE_ADD_ALWAYS 4 3154 #define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES 5 3155 #define CERT_STORE_ADD_NEWER 6 3156 #define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES 7 3157 3158 WINIMPM WINBOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore,DWORD dwCertEncodingType,const BYTE *pbCertEncoded,DWORD cbCertEncoded,DWORD dwAddDisposition,PCCERT_CONTEXT *ppCertContext); 3159 WINIMPM WINBOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,PCCERT_CONTEXT pCertContext,DWORD dwAddDisposition,PCCERT_CONTEXT *ppStoreContext); 3160 3161 #define CERT_STORE_CERTIFICATE_CONTEXT 1 3162 #define CERT_STORE_CRL_CONTEXT 2 3163 #define CERT_STORE_CTL_CONTEXT 3 3164 #define CERT_STORE_ALL_CONTEXT_FLAG (~__MSABI_LONG(0U)) 3165 #define CERT_STORE_CERTIFICATE_CONTEXT_FLAG (1 << CERT_STORE_CERTIFICATE_CONTEXT) 3166 #define CERT_STORE_CRL_CONTEXT_FLAG (1 << CERT_STORE_CRL_CONTEXT) 3167 #define CERT_STORE_CTL_CONTEXT_FLAG (1 << CERT_STORE_CTL_CONTEXT) 3168 3169 WINIMPM WINBOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,const BYTE *pbElement,DWORD cbElement,DWORD dwAddDisposition,DWORD dwFlags,DWORD dwContextTypeFlags,DWORD *pdwContextType,const void **ppvContext); 3170 WINIMPM WINBOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext); 3171 WINIMPM WINBOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore,DWORD dwCertEncodingType,const BYTE *pbCrlEncoded,DWORD cbCrlEncoded,DWORD dwAddDisposition,PCCRL_CONTEXT *ppCrlContext); 3172 WINIMPM WINBOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore,PCCRL_CONTEXT pCrlContext,DWORD dwAddDisposition,PCCRL_CONTEXT *ppStoreContext); 3173 WINIMPM WINBOOL WINAPI CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext); 3174 WINIMPM WINBOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,DWORD dwFlags,BYTE *pbElement,DWORD *pcbElement); 3175 WINIMPM WINBOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,DWORD dwFlags,BYTE *pbElement,DWORD *pcbElement); 3176 WINIMPM PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext); 3177 WINIMPM PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType,const BYTE *pbCtlEncoded,DWORD cbCtlEncoded); 3178 WINIMPM WINBOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCtlContext); 3179 WINIMPM WINBOOL WINAPI CertSetCTLContextProperty(PCCTL_CONTEXT pCtlContext,DWORD dwPropId,DWORD dwFlags,const void *pvData); 3180 WINIMPM WINBOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCtlContext,DWORD dwPropId,void *pvData,DWORD *pcbData); 3181 WINIMPM DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCtlContext,DWORD dwPropId); 3182 WINIMPM PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(HCERTSTORE hCertStore,PCCTL_CONTEXT pPrevCtlContext); 3183 WINIMPM PCTL_ENTRY WINAPI CertFindSubjectInCTL(DWORD dwEncodingType,DWORD dwSubjectType,void *pvSubject,PCCTL_CONTEXT pCtlContext,DWORD dwFlags); 3184 3185 #define CTL_ANY_SUBJECT_TYPE 1 3186 #define CTL_CERT_SUBJECT_TYPE 2 3187 3188 typedef struct _CTL_ANY_SUBJECT_INFO { 3189 CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm; 3190 CRYPT_DATA_BLOB SubjectIdentifier; 3191 } CTL_ANY_SUBJECT_INFO,*PCTL_ANY_SUBJECT_INFO; 3192 3193 WINIMPM PCCTL_CONTEXT WINAPI CertFindCTLInStore(HCERTSTORE hCertStore,DWORD dwMsgAndCertEncodingType,DWORD dwFindFlags,DWORD dwFindType,const void *pvFindPara,PCCTL_CONTEXT pPrevCtlContext); 3194 3195 #define CTL_FIND_ANY 0 3196 #define CTL_FIND_SHA1_HASH 1 3197 #define CTL_FIND_MD5_HASH 2 3198 #define CTL_FIND_USAGE 3 3199 #define CTL_FIND_SUBJECT 4 3200 #define CTL_FIND_EXISTING 5 3201 3202 typedef struct _CTL_FIND_USAGE_PARA { 3203 DWORD cbSize; 3204 CTL_USAGE SubjectUsage; 3205 CRYPT_DATA_BLOB ListIdentifier; 3206 PCERT_INFO pSigner; 3207 } CTL_FIND_USAGE_PARA,*PCTL_FIND_USAGE_PARA; 3208 3209 #define CTL_FIND_NO_LIST_ID_CBDATA 0xFFFFFFFF 3210 #define CTL_FIND_NO_SIGNER_PTR ((PCERT_INFO) -1) 3211 3212 #define CTL_FIND_SAME_USAGE_FLAG 0x1 3213 3214 typedef struct _CTL_FIND_SUBJECT_PARA { 3215 DWORD cbSize; 3216 PCTL_FIND_USAGE_PARA pUsagePara; 3217 DWORD dwSubjectType; 3218 void *pvSubject; 3219 } CTL_FIND_SUBJECT_PARA,*PCTL_FIND_SUBJECT_PARA; 3220 3221 WINIMPM WINBOOL WINAPI CertAddEncodedCTLToStore(HCERTSTORE hCertStore,DWORD dwMsgAndCertEncodingType,const BYTE *pbCtlEncoded,DWORD cbCtlEncoded,DWORD dwAddDisposition,PCCTL_CONTEXT *ppCtlContext); 3222 WINIMPM WINBOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,PCCTL_CONTEXT pCtlContext,DWORD dwAddDisposition,PCCTL_CONTEXT *ppStoreContext); 3223 WINIMPM WINBOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,DWORD dwFlags,BYTE *pbElement,DWORD *pcbElement); 3224 WINIMPM WINBOOL WINAPI