ifndef __WINCRYPT_H__
define __WINCRYPT_H__
ifndef _WINDEF_
 include windef.inc
endif

include specstrings.inc
include winapifamily.inc

.pragma comment(lib, advapi32)

if(_WIN32_WINNT GE 0x0400)

ifndef _HRESULT_DEFINED
define _HRESULT_DEFINED
HRESULT typedef LONG
endif

GET_ALG_CLASS macro x
	exitm<(x AND (7 SHL 13))>
	endm
GET_ALG_TYPE macro x
	exitm<(x AND (15 SHL 9))>
	endm
GET_ALG_SID macro x
	exitm<(x AND (511))>
	endm

ALG_CLASS_ANY		equ (0)
ALG_CLASS_SIGNATURE	equ (1 SHL 13)
ALG_CLASS_MSG_ENCRYPT	equ (2 SHL 13)
ALG_CLASS_DATA_ENCRYPT	equ (3 SHL 13)
ALG_CLASS_HASH		equ (4 SHL 13)
ALG_CLASS_KEY_EXCHANGE	equ (5 SHL 13)
ALG_CLASS_ALL		equ (7 SHL 13)

ALG_TYPE_ANY		equ (0)
ALG_TYPE_DSS		equ (1 SHL 9)
ALG_TYPE_RSA		equ (2 SHL 9)
ALG_TYPE_BLOCK		equ (3 SHL 9)
ALG_TYPE_STREAM		equ (4 SHL 9)
ALG_TYPE_DH		equ (5 SHL 9)
ALG_TYPE_SECURECHANNEL	equ (6 SHL 9)

ALG_SID_ANY		equ (0)

ALG_SID_RSA_ANY		equ 0
ALG_SID_RSA_PKCS	equ 1
ALG_SID_RSA_MSATWORK	equ 2
ALG_SID_RSA_ENTRUST	equ 3
ALG_SID_RSA_PGP		equ 4

ALG_SID_DSS_ANY		equ 0
ALG_SID_DSS_PKCS	equ 1
ALG_SID_DSS_DMS		equ 2

ALG_SID_DES		equ 1
ALG_SID_3DES		equ 3
ALG_SID_DESX		equ 4
ALG_SID_IDEA		equ 5
ALG_SID_CAST		equ 6
ALG_SID_SAFERSK64	equ 7
ALG_SID_SAFERSK128	equ 8
ALG_SID_3DES_112	equ 9
ALG_SID_CYLINK_MEK	equ 12
ALG_SID_RC5		equ 13
if (NTDDI_VERSION GE NTDDI_WINXP)
ALG_SID_AES_128		equ 14
ALG_SID_AES_192		equ 15
ALG_SID_AES_256		equ 16
ALG_SID_AES		equ 17
endif

ALG_SID_SKIPJACK	equ 10
ALG_SID_TEK		equ 11

CRYPT_MODE_CBCI		equ 6
CRYPT_MODE_CFBP		equ 7
CRYPT_MODE_OFBP		equ 8
CRYPT_MODE_CBCOFM	equ 9
CRYPT_MODE_CBCOFMI	equ 10

ALG_SID_RC2		equ 2

ALG_SID_RC4		equ 1
ALG_SID_SEAL		equ 2

ALG_SID_DH_SANDF	equ 1
ALG_SID_DH_EPHEM	equ 2
ALG_SID_AGREED_KEY_ANY	equ 3
ALG_SID_KEA		equ 4

ALG_SID_MD2		equ 1
ALG_SID_MD4		equ 2
ALG_SID_MD5		equ 3
ALG_SID_SHA		equ 4
ALG_SID_SHA1		equ 4
ALG_SID_MAC		equ 5
ALG_SID_RIPEMD		equ 6
ALG_SID_RIPEMD160	equ 7
ALG_SID_SSL3SHAMD5	equ 8
ALG_SID_HMAC		equ 9
if (NTDDI_VERSION GE NTDDI_WINXP)
ALG_SID_HASH_REPLACE_OWF equ 11
endif
if (NTDDI_VERSION GT NTDDI_WINXPSP2)
ALG_SID_SHA_256		equ 12
ALG_SID_SHA_384		equ 13
ALG_SID_SHA_512		equ 14
endif

ALG_SID_SSL3_MASTER	equ 1
ALG_SID_SCHANNEL_MASTER_HASH equ 2
ALG_SID_SCHANNEL_MAC_KEY equ 3
ALG_SID_PCT1_MASTER	equ 4
ALG_SID_SSL2_MASTER	equ 5
ALG_SID_TLS1_MASTER	equ 6
ALG_SID_SCHANNEL_ENC_KEY equ 7

if (NTDDI_VERSION GE NTDDI_VISTA)
ALG_SID_ECMQV		equ 1
endif
ALG_SID_EXAMPLE		equ 80

ifndef ALGIDDEF
ALGIDDEF equ 1
ALG_ID			typedef UINT
endif

CALG_MD2		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_MD2)
CALG_MD4		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_MD4)
CALG_MD5		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_MD5)
CALG_SHA		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_SHA)
CALG_SHA1		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_SHA1)
CALG_MAC		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_MAC)
CALG_RSA_SIGN		equ (ALG_CLASS_SIGNATURE OR ALG_TYPE_RSA OR AG_SID_RSA_ANY)
CALG_DSS_SIGN		equ (ALG_CLASS_SIGNATURE OR ALG_TYPE_DSS OR AG_SID_DSS_ANY)
if (NTDDI_VERSION GE NTDDI_WINXP)
CALG_NO_SIGN		equ (ALG_CLASS_SIGNATURE OR ALG_TYPE_ANY OR ALG_SID_ANY)
endif
CALG_RSA_KEYX		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_RSA OR AG_SID_RSA_ANY)

CALG_DES		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_DES)
CALG_3DES_112		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_3DES_112)
CALG_3DES		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_3DES)
CALG_RC2		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_RC2)
CALG_RC4		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_STREAM OR AG_SID_RC4)
CALG_SEAL		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_STREAM OR ALG_SID_SEA)
CALG_DH_SF		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_DH OR AG_SID_DH_SANDF)
CALG_DH_EPHEM		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_DH OR AG_SID_DH_EPHEM)
CALG_AGREEDKEY_ANY	equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_DH OR AG_SID_AGREED_KEY_ANY)
CALG_KEA_KEYX		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_DH OR AG_SID_KEA)
CALG_HUGHES_MD5		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_ANY OR AG_SID_MD5)
CALG_SKIPJACK		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_SKIPJACK)
CALG_TEK		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_TEK)
CALG_CYLINK_MEK		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_CYLINK_MEK)
CALG_SSL3_SHAMD5	equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_SSL3SHAMD5)
CALG_SSL3_MASTER	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_SSL3_MASTER)
CALG_SCHANNEL_MASTER_HASH equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_SCHANNE_MASTER_HASH)
CALG_SCHANNEL_MAC_KEY	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_SCHANNE_MAC_KEY)
CALG_SCHANNEL_ENC_KEY	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_SCHANNE_ENC_KEY)
CALG_PCT1_MASTER	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR AG_SID_PCT1_MASTER)
CALG_SSL2_MASTER	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_SSL2_MASTER)
CALG_TLS1_MASTER	equ (ALG_CLASS_MSG_ENCRYPT OR ALG_TYPE_SECURECHANNEL OR ALG_SID_TLS1_MASTER)
CALG_RC5		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR AG_SID_RC5)
CALG_HMAC		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR AG_SID_HMAC)
CALG_TLS1PRF		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_TLS1PRF)
if (NTDDI_VERSION GE NTDDI_WINXP)
CALG_HASH_REPLACE_OWF	equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_HASH_REPLACE_OWF)
CALG_AES_128		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_AES_128)
CALG_AES_192		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_AES_192)
CALG_AES_256		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_AES_256)
CALG_AES		equ (ALG_CLASS_DATA_ENCRYPT OR ALG_TYPE_BLOCK OR ALG_SID_AES)
endif
if (NTDDI_VERSION GT NTDDI_WINXPSP2)
CALG_SHA_256		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_SHA_256)
CALG_SHA_384		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_SHA_384)
CALG_SHA_512		equ (ALG_CLASS_HASH OR ALG_TYPE_ANY OR ALG_SID_SHA_512)
endif
if (NTDDI_VERSION GE NTDDI_VISTA)
CALG_ECDH		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_DH OR ALG_SID_ECDH)
CALG_ECMQV		equ (ALG_CLASS_KEY_EXCHANGE OR ALG_TYPE_ANY OR ALG_SID_ECMQV)
CALG_ECDSA		equ (ALG_CLASS_SIGNATURE OR ALG_TYPE_DSS OR ALG_SID_ECDSA)
endif

if (NTDDI_VERSION LT NTDDI_WINXP)
SIGNATURE_RESOURCE_NUMBER equ 0x29A

VTableProvStruc		STRUC
Version			dd ?
FuncVerifyImage		FARPROC ?
FuncReturnhWnd		FARPROC ?
dwProvType		dd ?
pbContextInfo		LPSTR ?
cbContextInfo		dd ?
VTableProvStruc		ENDS
PVTableProvStruc	typedef ptr VTableProvStruc
endif

ifndef HCRYPTPROV_DEFINED
define HCRYPTPROV_DEFINED
HCRYPTPROV		typedef ULONG_PTR
HCRYPTKEY		typedef ULONG_PTR
HCRYPTHASH		typedef ULONG_PTR
endif

CRYPT_VERIFYCONTEXT	equ 0xF0000000
CRYPT_NEWKEYSET		equ 0x00000008
CRYPT_DELETEKEYSET	equ 0x00000010
CRYPT_MACHINE_KEYSET	equ 0x00000020
CRYPT_SILENT		equ 0x00000040
if (NTDDI_VERSION GE NTDDI_VISTA)
CRYPT_DEFAULT_CONTAINER_OPTIONAL equ 0x00000080
endif

CRYPT_EXPORTABLE	equ 0x00000001
CRYPT_USER_PROTECTED	equ 0x00000002
CRYPT_CREATE_SALT	equ 0x00000004
CRYPT_UPDATE_KEY	equ 0x00000008
CRYPT_NO_SALT		equ 0x00000010
CRYPT_PREGEN		equ 0x00000040
CRYPT_RECIPIENT		equ 0x00000010
CRYPT_INITIATOR		equ 0x00000040
CRYPT_ONLINE		equ 0x00000080
CRYPT_SF		equ 0x00000100
CRYPT_CREATE_IV		equ 0x00000200
CRYPT_KEK		equ 0x00000400
CRYPT_DATA_KEY		equ 0x00000800
CRYPT_VOLATILE		equ 0x00001000
CRYPT_SGCKEY		equ 0x00002000
CRYPT_USER_PROTECTED_STRONG equ 0x00100000
if (NTDDI_VERSION GE NTDDI_WINXP)
CRYPT_ARCHIVABLE	equ 0x00004000
endif
if (NTDDI_VERSION GE NTDDI_VISTA)
CRYPT_FORCE_KEY_PROTECTION_HIGH equ 0x00008000
endif
RSA1024BIT_KEY		equ 0x04000000

CRYPT_SERVER		equ 0x00000400

KEY_LENGTH_MASK		equ 0xFFFF0000

CRYPT_Y_ONLY		equ 0x00000001
CRYPT_SSL2_SLUMMING	equ 0x00000002
CRYPT_SSL2_FALLBACK	equ 0x00000002
CRYPT_DESTROYKEY	equ 0x00000004
CRYPT_OAEP		equ 0x00000040
CRYPT_BLOB_VER3		equ 0x00000080
if (NTDDI_VERSION GE NTDDI_WINXP)
CRYPT_IPSEC_HMAC_KEY	equ 0x00000100
endif
if (NTDDI_VERSION GE NTDDI_WS03)
CRYPT_DECRYPT_RSA_NO_PADDING_CHECK equ 0x00000020
endif
CRYPT_SECRETDIGEST	equ 0x00000001

if (NTDDI_VERSION GE NTDDI_WINXP)
CRYPT_OWF_REPL_LM_HASH	equ 0x00000001
endif

CRYPT_LITTLE_ENDIAN	equ 0x00000001

CRYPT_NOHASHOID		equ 0x00000001
CRYPT_TYPE2_FORMAT	equ 0x00000002
CRYPT_X931_FORMAT	equ 0x00000004

CRYPT_MACHINE_DEFAULT	equ 0x00000001
CRYPT_USER_DEFAULT	equ 0x00000002
CRYPT_DELETE_DEFAULT	equ 0x00000004

SIMPLEBLOB		equ 0x1
PUBLICKEYBLOB		equ 0x6
PRIVATEKEYBLOB		equ 0x7
PLAINTEXTKEYBLOB	equ 0x8
OPAQUEKEYBLOB		equ 0x9
PUBLICKEYBLOBEX		equ 0xA
SYMMETRICWRAPKEYBLOB	equ 0xB
if (NTDDI_VERSION GE NTDDI_WS03)
KEYSTATEBLOB		equ 0xC
endif

AT_KEYEXCHANGE		equ 1
AT_SIGNATURE		equ 2

CRYPT_USERDATA		equ 1

KP_IV			equ 1
KP_SALT			equ 2
KP_PADDING		equ 3
KP_MODE			equ 4
KP_MODE_BITS		equ 5
KP_PERMISSIONS		equ 6
KP_ALGID		equ 7
KP_BLOCKLEN		equ 8
KP_KEYLEN		equ 9
KP_SALT_EX		equ 10
KP_P			equ 11
KP_G			equ 12
KP_Q			equ 13
KP_X			equ 14
KP_Y			equ 15
KP_RA			equ 16
KP_RB			equ 17
KP_INFO			equ 18
KP_EFFECTIVE_KEYLEN	equ 19
KP_SCHANNEL_ALG		equ 20
KP_CLIENT_RANDOM	equ 21
KP_SERVER_RANDOM	equ 22
KP_RP			equ 23
KP_PRECOMP_MD5		equ 24
KP_PRECOMP_SHA		equ 25
KP_CERTIFICATE		equ 26
KP_CLEAR_KEY		equ 27
KP_PUB_EX_LEN		equ 28
KP_PUB_EX_VAL		equ 29
KP_KEYVAL		equ 30
KP_ADMIN_PIN		equ 31
KP_KEYEXCHANGE_PIN	equ 32
KP_SIGNATURE_PIN	equ 33
KP_PREHASH		equ 34
if (NTDDI_VERSION GE NTDDI_WS03)
KP_ROUNDS		equ 35
endif
KP_OAEP_PARAMS		equ 36
KP_CMS_KEY_INFO		equ 37
KP_CMS_DH_KEY_INFO	equ 38
KP_PUB_PARAMS		equ 39
KP_VERIFY_PARAMS	equ 40
KP_HIGHEST_VERSION	equ 41
if (NTDDI_VERSION GE NTDDI_WS03)
KP_GET_USE_COUNT	equ 42
endif
KP_PIN_ID		equ 43
KP_PIN_INFO		equ 44

PKCS5_PADDING		equ 1
RANDOM_PADDING		equ 2
ZERO_PADDING		equ 3

CRYPT_MODE_CBC		equ 1
CRYPT_MODE_ECB		equ 2
CRYPT_MODE_OFB		equ 3
CRYPT_MODE_CFB		equ 4
CRYPT_MODE_CTS		equ 5

CRYPT_ENCRYPT		equ 0x0001
CRYPT_DECRYPT		equ 0x0002
CRYPT_EXPORT		equ 0x0004
CRYPT_READ		equ 0x0008
CRYPT_WRITE		equ 0x0010
CRYPT_MAC		equ 0x0020
CRYPT_EXPORT_KEY	equ 0x0040
CRYPT_IMPORT_KEY	equ 0x0080
if (NTDDI_VERSION GE NTDDI_WINXP)
CRYPT_ARCHIVE		equ 0x0100
endif

HP_ALGID		equ 0x0001
HP_HASHVAL		equ 0x0002
HP_HASHSIZE		equ 0x0004
HP_HMAC_INFO		equ 0x0005
HP_TLS1PRF_LABEL	equ 0x0006
HP_TLS1PRF_SEED		equ 0x0007

CRYPT_FAILED		equ FASE
CRYPT_SUCCEED		equ TRUE

RCRYPT_SUCCEEDED macro rt
	exitm<((rt) EQ CRYPT_SUCCEED)>
	endm
RCRYPT_FAILED macro rt
	exitm<((rt) EQ CRYPT_FAILED)>
	endm

PP_ENUMALGS		equ 1
PP_ENUMCONTAINERS	equ 2
PP_IMPTYPE		equ 3
PP_NAME			equ 4
PP_VERSION		equ 5
PP_CONTAINER		equ 6
PP_CHANGE_PASSWORD	equ 7
PP_KEYSET_SEC_DESCR	equ 8
PP_CERTCHAIN		equ 9
PP_KEY_TYPE_SUBTYPE	equ 10
PP_PROVTYPE		equ 16
PP_KEYSTORAGE		equ 17
PP_APPLI_CERT		equ 18
PP_SYM_KEYSIZE		equ 19
PP_SESSION_KEYSIZE	equ 20
PP_UI_PROMPT		equ 21
PP_ENUMALGS_EX		equ 22
PP_ENUMMANDROOTS	equ 25
PP_ENUMELECTROOTS	equ 26
PP_KEYSET_TYPE		equ 27
PP_ADMIN_PIN		equ 31
PP_KEYEXCHANGE_PIN	equ 32
PP_SIGNATURE_PIN	equ 33
PP_SIG_KEYSIZE_INC	equ 34
PP_KEYX_KEYSIZE_INC	equ 35
PP_UNIQUE_CONTAINER	equ 36
PP_SGC_INFO		equ 37
PP_USE_HARDWARE_RNG	equ 38
PP_KEYSPEC		equ 39
PP_ENUMEX_SIGNING_PROT	equ 40
if (NTDDI_VERSION GE NTDDI_WS03)
PP_CRYPT_COUNT_KEY_USE	equ 41
endif
if (NTDDI_VERSION GE NTDDI_VISTA)
PP_USER_CERTSTORE	equ 42
PP_SMARTCARD_READER	equ 43
PP_SMARTCARD_GUID	equ 45
PP_ROOT_CERTSTORE	equ 46
endif
if (NTDDI_VERSION GE NTDDI_WIN8)
PP_SMARTCARD_READER_ICON equ 47
endif

CRYPT_FIRST		equ 1
CRYPT_NEXT		equ 2
CRYPT_SGC_ENUM		equ 4

CRYPT_IMPL_HARDWARE	equ 1
CRYPT_IMPL_SOFTWARE	equ 2
CRYPT_IMPL_MIXED	equ 3
CRYPT_IMPL_UNKNOWN	equ 4
CRYPT_IMPL_REMOVABLE	equ 8

CRYPT_SEC_DESCR		equ 0x00000001
CRYPT_PSTORE		equ 0x00000002
CRYPT_UI_PROMPT		equ 0x00000004

CRYPT_FLAG_PCT1		equ 0x0001
CRYPT_FLAG_SSL2		equ 0x0002
CRYPT_FLAG_SSL3		equ 0x0004
CRYPT_FLAG_TLS1		equ 0x0008
CRYPT_FLAG_IPSEC	equ 0x0010
CRYPT_FLAG_SIGNING	equ 0x0020

CRYPT_SGC		equ 0x0001
CRYPT_FASTSGC		equ 0x0002

PP_CLIENT_HWND		equ 1
PP_CONTEXT_INFO		equ 11
PP_KEYEXCHANGE_KEYSIZE	equ 12
PP_SIGNATURE_KEYSIZE	equ 13
PP_KEYEXCHANGE_ALG	equ 14
PP_SIGNATURE_ALG	equ 15
PP_DELETEKEY		equ 24
if (NTDDI_VERSION GE NTDDI_VISTA)
PP_PIN_PROMPT_STRING	equ 44
PP_SECURE_KEYEXCHANGE_PIN equ 47
PP_SECURE_SIGNATURE_PIN equ 48
endif

PROV_RSA_FULL		equ 1
PROV_RSA_SIG		equ 2
PROV_DSS		equ 3
PROV_FORTEZZA		equ 4
PROV_MS_EXCHANGE	equ 5
PROV_SSL		equ 6
PROV_RSA_SCHANNEL	equ 12
PROV_DSS_DH		equ 13
PROV_EC_ECDSA_SIG	equ 14
PROV_EC_ECNRA_SIG	equ 15
PROV_EC_ECDSA_FULL	equ 16
PROV_EC_ECNRA_FULL	equ 17
PROV_SPYRUS_LYNKS	equ 20
PROV_RNG		equ 21
PROV_INTEL_SEC		equ 22
if (NTDDI_VERSION GE NTDDI_WINXP)
PROV_REPLACE_OWF	equ 23
PROV_RSA_AES		equ 24
endif

if (NTDDI_VERSION LE NTDDI_WINXP)
PROV_STT_MER		equ 7
PROV_STT_ACQ		equ 8
PROV_STT_BRND		equ 9
PROV_STT_ROOT		equ 10
PROV_STT_ISS		equ 11
endif

MS_DEF_PROV		equ <"Microsoft Base Cryptographic Provider v1.0">
MS_ENHANCED_PROV	equ <"Microsoft Enhanced Cryptographic Provider v1.0">
MS_STRONG_PROV		equ <"Microsoft Strong Cryptographic Provider">
MS_DEF_RSA_SIG_PROV	equ <"Microsoft RSA Signature Cryptographic Provider">
MS_DEF_RSA_SCHANNEL_PROV equ <"Microsoft Base RSA SChannel Cryptographic Provider">
MS_ENHANCED_RSA_SCHANNEL_PROV equ <"Microsoft Enhanced RSA SChannel Cryptographic Provider">
MS_DEF_DSS_PROV		equ <"Microsoft Base DSS Cryptographic Provider">
MS_DEF_DSS_DH_PROV	equ <"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider">
MS_ENH_DSS_DH_PROV	equ <"Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider">
MS_DEF_DH_SCHANNEL_PROV equ <"Microsoft DH SChannel Cryptographic Provider">
MS_SCARD_PROV		equ <"Microsoft Base Smart Card Crypto Provider">
if (NTDDI_VERSION GE NTDDI_WINXP)
MS_ENH_RSA_AES_PROV	equ <"Microsoft Enhanced RSA and AES Cryptographic Provider">
MS_ENH_RSA_AES_PROV_XP	equ <"Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)">
endif

MAXUIDLEN		equ 64

EXPO_OFFLOAD_REG_VALUE	equ <"ExpoOffload">
EXPO_OFFLOAD_FUNC_NAME	equ <"OffloadModExpo">

ifndef szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS
szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS equ <"Software\\Policies\\Microsoft\\Cryptography">
endif

szKEY_CACHE_ENABLED	equ <"CachePrivateKeys">
szKEY_CACHE_SECONDS	equ <"PrivateKeyLifetimeSeconds">

if (NTDDI_VERSION GE NTDDI_WINXP)
szPRIV_KEY_CACHE_MAX_ITEMS equ <"PrivKeyCacheMaxItems">
cPRIV_KEY_CACHE_MAX_ITEMS_DEFAULT equ 20

szPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS equ <"PrivKeyCachePurgeIntervalSeconds">
cPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS_DEFAULT equ 86400
endif

CUR_BLOB_VERSION	equ 2

CMS_KEY_INFO		STRUC
dwVersion		dd ?
Algid			ALG_ID ?
pbOID			LPBYTE ?
cbOID			dd ?
CMS_KEY_INFO		ENDS
PCMS_KEY_INFO		typedef ptr CMS_KEY_INFO

HMAC_INFO		STRUC
HashAlgid		ALG_ID ?
pbInnerString		LPSTR ?
cbInnerString		dd ?
pbOuterString		LPSTR ?
cbOuterString		dd ?
HMAC_INFO		ENDS
PHMAC_INFO		typedef ptr HMAC_INFO

SCHANNEL_ALG		STRUC
dwUse			dd ?
Algid			ALG_ID ?
cBits			dd ?
SCHANNEL_ALG		ENDS
PSCHANNEL_ALG		typedef ptr SCHANNEL_ALG

SCHANNEL_MAC_KEY	equ 0x00000000
SCHANNEL_ENC_KEY	equ 0x00000001

INTERNATIONAL_USAGE	equ 0x00000001

PROV_ENUMALGS		STRUC
aiAlgid			ALG_ID ?
dwBitLen		dd ?
dwNameLen		dd ?
szName			db 20 dup(?)
PROV_ENUMALGS		ENDS

PROV_ENUMALGS_EX	STRUC
aiAlgid			ALG_ID ?
dwDefaultLen		dd ?
dwMinLen		dd ?
dwMaxLen		dd ?
dwProtocols		dd ?
dwNameLen		dd ?
szName			db 20 dup(?)
dwLongNameLen		dd ?
szLongName		db 40 dup(?)
PROV_ENUMALGS_EX	ENDS

BLOBHEADER		STRUC
bType			db ?
bVersion		db ?
reserved		dw ?
aiKeyAlg		ALG_ID ?
BLOBHEADER		ENDS
PUBLICKEYSTRUC		typedef BLOBHEADER

RSAPUBKEY		STRUC
magic			dd ?
bitlen			dd ?
pubexp			dd ?
RSAPUBKEY		ENDS

DHPUBKEY		STRUC
magic			dd ?
bitlen			dd ?
DHPUBKEY		ENDS
DSSPUBKEY		typedef DHPUBKEY
KEAPUBKEY		typedef DHPUBKEY
TEKPUBKEY		typedef DHPUBKEY

DSSSEED			STRUC
counter			dd ?
seed			db 20 dup(?)
DSSSEED			ENDS

DHPUBKEY_VER3		STRUC
magic			dd ?
bitlenP			dd ?
bitlenQ			dd ?
bitlenJ			dd ?
DSSSeed			DSSSEED <>
DHPUBKEY_VER3		ENDS
DSSPUBKEY_VER3		typedef DHPUBKEY_VER3

DHPRIVKEY_VER3		STRUC
magic			dd ?
bitlenP			dd ?
bitlenQ			dd ?
bitlenJ			dd ?
bitlenX			dd ?
DSSSeed			DSSSEED <>
DHPRIVKEY_VER3		ENDS
DSSPRIVKEY_VER3		typedef DHPRIVKEY_VER3

KEY_TYPE_SUBTYPE	STRUC
dwKeySpec		dd ?
Type			GUID <>
Subtype			GUID <>
KEY_TYPE_SUBTYPE	ENDS
PKEY_TYPE_SUBTYPE	typedef ptr KEY_TYPE_SUBTYPE

CERT_FORTEZZA_DATA_PROP STRUC
SerialNumber		db 8 dup(?)
CertIndex		int_t ?
CertLabel		db 36 dup(?)
CERT_FORTEZZA_DATA_PROP ENDS

if (NTDDI_VERSION GE NTDDI_WS03)
CRYPT_RC4_KEY_STATE	STRUC
Key			db 16 dup(?)
SBox			db 256 dup(?)
i			db ?
j			db ?
CRYPT_RC4_KEY_STATE	ENDS
PCRYPT_RC4_KEY_STATE	typedef ptr CRYPT_RC4_KEY_STATE

CRYPT_DES_KEY_STATE	STRUC
Key			db 8 dup(?)
IV			db 8 dup(?)
Feedback		db 8 dup(?)
CRYPT_DES_KEY_STATE	ENDS
PCRYPT_DES_KEY_STATE	typedef ptr CRYPT_DES_KEY_STATE

CRYPT_3DES_KEY_STATE	STRUC
Key			db 24 dup(?)
IV			db 8 dup(?)
Feedback		db 8 dup(?)
CRYPT_3DES_KEY_STATE	ENDS
PCRYPT_3DES_KEY_STATE	typedef ptr CRYPT_3DES_KEY_STATE
endif

if (NTDDI_VERSION GE NTDDI_VISTA)
CRYPT_AES_128_KEY_STATE STRUC
Key			db 16 dup(?)
IV			db 16 dup(?)
EncryptionState		db 16*11 dup(?)
DecryptionState		db 16*11 dup(?)
Feedback		db 16 dup(?)
CRYPT_AES_128_KEY_STATE ENDS
PCRYPT_AES_128_KEY_STATE typedef ptr CRYPT_AES_128_KEY_STATE

CRYPT_AES_256_KEY_STATE STRUC
Key			db 32 dup(?)
IV			db 16 dup(?)
EncryptionState		db 16*15 dup(?)
DecryptionState		db 16*15 dup(?)
Feedback		db 16 dup(?)
CRYPT_AES_256_KEY_STATE ENDS
PCRYPT_AES_256_KEY_STATE typedef ptr CRYPT_AES_256_KEY_STATE
endif

endif ; (NTDDI_VERSION LT NTDDI_WINXP)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

ifndef CRYPTO_BLOBS_DEFINED
define CRYPTO_BLOBS_DEFINED

CRYPT_INTEGER_BLOB	STRUC
cbData			dd ?
pbData			LPBYTE ?
CRYPT_INTEGER_BLOB	ENDS
PCRYPT_INTEGER_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_UINT_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_UINT_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_OBJID_BLOB	typedef CRYPT_INTEGER_BLOB
PCRYPT_OBJID_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CERT_NAME_BLOB		typedef CRYPT_INTEGER_BLOB
PCERT_NAME_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CERT_RDN_VALUE_BLOB	typedef CRYPT_INTEGER_BLOB
PCERT_RDN_VALUE_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CERT_BLOB		typedef CRYPT_INTEGER_BLOB
PCERT_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRL_BLOB		typedef CRYPT_INTEGER_BLOB
PCRL_BLOB		typedef ptr CRYPT_INTEGER_BLOB
DATA_BLOB		typedef CRYPT_INTEGER_BLOB
PDATA_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DATA_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_DATA_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_HASH_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_HASH_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DIGEST_BLOB	typedef CRYPT_INTEGER_BLOB
PCRYPT_DIGEST_BLOB	typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DER_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_DER_BLOB		typedef ptr CRYPT_INTEGER_BLOB
CRYPT_ATTR_BLOB		typedef CRYPT_INTEGER_BLOB
PCRYPT_ATTR_BLOB	typedef ptr CRYPT_INTEGER_BLOB
endif

endif ; WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

CMS_DH_KEY_INFO		STRUC
dwVersion		dd ?
Algid			ALG_ID ?
pszContentEncObjId	LPSTR ?
PubInfo			CRYPT_DATA_BLOB <>
pReserved		PVOID ?
CMS_DH_KEY_INFO		ENDS
PCMS_DH_KEY_INFO	typedef ptr CMS_DH_KEY_INFO

CryptAcquireContextA proto WINAPI :ptr, :LPCSTR, :LPCSTR, :DWORD, :DWORD
CryptAcquireContextW proto WINAPI :ptr, :LPCWSTR, :LPCWSTR, :DWORD, :DWORD
ifdef _UNICODE
CryptAcquireContext	equ <CryptAcquireContextW>
else
CryptAcquireContext	equ <CryptAcquireContextA>
endif
CryptReleaseContext proto WINAPI :HCRYPTPROV, :DWORD
CryptGenKey proto WINAPI :HCRYPTPROV, :ALG_ID, :DWORD, :ptr
CryptDeriveKey proto WINAPI :HCRYPTPROV, :ALG_ID, :HCRYPTHASH, :DWORD, :ptr
CryptDestroyKey proto WINAPI :HCRYPTKEY
CryptSetKeyParam proto WINAPI :HCRYPTKEY, :DWORD, :LPBYTE, :DWORD
CryptGetKeyParam proto WINAPI :HCRYPTKEY, :DWORD, :LPBYTE, :LPDWORD, :DWORD
CryptSetHashParam proto WINAPI :HCRYPTHASH, :DWORD, :LPBYTE, :DWORD
CryptGetHashParam proto WINAPI :HCRYPTHASH, :DWORD, :LPBYTE, :LPDWORD, :DWORD
CryptSetProvParam proto WINAPI :HCRYPTPROV, :DWORD, :LPBYTE, :DWORD
CryptGetProvParam proto WINAPI :HCRYPTPROV, :DWORD, :LPBYTE, :LPDWORD, :DWORD
CryptGenRandom proto WINAPI :HCRYPTPROV, :DWORD, :LPBYTE
CryptGetUserKey proto WINAPI :HCRYPTPROV, :DWORD, :ptr
CryptExportKey proto WINAPI :HCRYPTKEY, :HCRYPTKEY, :DWORD, :DWORD, :LPBYTE, :LPDWORD
CryptImportKey proto WINAPI :HCRYPTPROV, :LPBYTE, :DWORD, :HCRYPTKEY, :DWORD, :ptr
CryptEncrypt proto WINAPI :HCRYPTKEY, :HCRYPTHASH, :BOOL, :DWORD, :LPBYTE, :LPDWORD, :DWORD
CryptDecrypt proto WINAPI :HCRYPTKEY, :HCRYPTHASH, :BOOL, :DWORD, :LPBYTE, :LPDWORD
CryptCreateHash proto WINAPI :HCRYPTPROV, :ALG_ID, :HCRYPTKEY, :DWORD, :ptr
CryptHashData proto WINAPI :HCRYPTHASH, :LPBYTE, :DWORD, :DWORD
CryptHashSessionKey proto WINAPI :HCRYPTHASH, :HCRYPTKEY, :DWORD
CryptDestroyHash proto WINAPI :HCRYPTHASH
CryptSignHashA proto WINAPI :HCRYPTHASH, :DWORD, :LPCSTR, :DWORD, :LPBYTE, :LPDWORD
CryptSignHashW proto WINAPI :HCRYPTHASH, :DWORD, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
ifdef _UNICODE
CryptSignHash		equ <CryptSignHashW>
else
CryptSignHash		equ <CryptSignHashA>
endif

CryptVerifySignatureA proto WINAPI :HCRYPTHASH, :LPBYTE, :DWORD, :HCRYPTKEY, :LPCSTR, :DWORD
CryptVerifySignatureW proto WINAPI :HCRYPTHASH, :LPBYTE, :DWORD, :HCRYPTKEY, :LPCWSTR, :DWORD
ifdef _UNICODE
CryptVerifySignature	equ <CryptVerifySignatureW>
else
CryptVerifySignature	equ <CryptVerifySignatureA>
endif
CryptSetProviderA proto WINAPI :LPCSTR, :DWORD
CryptSetProviderW proto WINAPI :LPCWSTR, :DWORD
ifdef _UNICODE
CryptSetProvider	equ <CryptSetProviderW>
else
CryptSetProvider	equ <CryptSetProviderA>
endif

CryptSetProviderExA proto WINAPI :LPCSTR, :DWORD, :LPDWORD, :DWORD
CryptSetProviderExW proto WINAPI :LPCWSTR, :DWORD, :LPDWORD, :DWORD
ifdef _UNICODE
CryptSetProviderEx	equ <CryptSetProviderExW>
else
CryptSetProviderEx	equ <CryptSetProviderExA>
endif

CryptGetDefaultProviderA proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPSTR, :LPDWORD
CryptGetDefaultProviderW proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPWSTR, :LPDWORD
ifdef _UNICODE
CryptGetDefaultProvider equ <CryptGetDefaultProviderW>
else
CryptGetDefaultProvider equ <CryptGetDefaultProviderA>
endif

CryptEnumProviderTypesA proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPDWORD, :LPSTR, :LPDWORD
CryptEnumProviderTypesW proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPDWORD, :LPWSTR, :LPDWORD
ifdef _UNICODE
CryptEnumProviderTypes	equ <CryptEnumProviderTypesW>
else
CryptEnumProviderTypes	equ <CryptEnumProviderTypesA>
endif

CryptEnumProvidersA proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPDWORD, :LPSTR, :LPDWORD
CryptEnumProvidersW proto WINAPI :DWORD, :LPDWORD, :DWORD, :LPDWORD, :LPWSTR, :LPDWORD
ifdef _UNICODE
CryptEnumProviders	equ <CryptEnumProvidersW>
else
CryptEnumProviders	equ <CryptEnumProvidersA>
endif
CryptContextAddRef proto WINAPI :HCRYPTPROV, :LPDWORD, :DWORD
CryptDuplicateKey proto WINAPI :HCRYPTKEY, :LPDWORD, :DWORD, :ptr
CryptDuplicateHash proto WINAPI :HCRYPTHASH, :LPDWORD, :DWORD, :ptr
if (NTDDI_VERSION GE NTDDI_WS03)
GetEncSChannel proto WINAPI :ptr, :ptr
endif

ifndef _DDK_DRIVER_

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
include bcrypt.inc
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
include ncrypt.inc
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
HCRYPTPROV_OR_NCRYPT_KEY_HANDLE typedef ULONG_PTR
HCRYPTPROV_LEGACY typedef ULONG_PTR
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

CRYPT_BIT_BLOB		STRUC
cbData			dd ?
pbData			LPSTR ?
cUnusedBits		dd ?
CRYPT_BIT_BLOB		ENDS
PCRYPT_BIT_BLOB		typedef ptr CRYPT_BIT_BLOB

CRYPT_ALGORITHM_IDENTIFIER STRUC
pszObjId		LPSTR ?
Parameters		CRYPT_OBJID_BLOB <>
CRYPT_ALGORITHM_IDENTIFIER ENDS
PCRYPT_ALGORITHM_IDENTIFIER typedef ptr CRYPT_ALGORITHM_IDENTIFIER

endif

szOID_RSA		equ <"1.2.840.113549">
szOID_PKCS		equ <"1.2.840.113549.1">
szOID_RSA_HASH		equ <"1.2.840.113549.2">
szOID_RSA_ENCRYPT	equ <"1.2.840.113549.3">

szOID_PKCS_1		equ <"1.2.840.113549.1.1">
szOID_PKCS_2		equ <"1.2.840.113549.1.2">
szOID_PKCS_3		equ <"1.2.840.113549.1.3">
szOID_PKCS_4		equ <"1.2.840.113549.1.4">
szOID_PKCS_5		equ <"1.2.840.113549.1.5">
szOID_PKCS_6		equ <"1.2.840.113549.1.6">
szOID_PKCS_7		equ <"1.2.840.113549.1.7">
szOID_PKCS_8		equ <"1.2.840.113549.1.8">
szOID_PKCS_9		equ <"1.2.840.113549.1.9">
szOID_PKCS_10		equ <"1.2.840.113549.1.10">
szOID_PKCS_12		equ <"1.2.840.113549.1.12">

szOID_RSA_RSA		equ <"1.2.840.113549.1.1.1">
szOID_RSA_MD2RSA	equ <"1.2.840.113549.1.1.2">
szOID_RSA_MD4RSA	equ <"1.2.840.113549.1.1.3">
szOID_RSA_MD5RSA	equ <"1.2.840.113549.1.1.4">
szOID_RSA_SHA1RSA	equ <"1.2.840.113549.1.1.5">
szOID_RSA_SETOAEP_RSA	equ <"1.2.840.113549.1.1.6">

szOID_RSAES_OAEP	equ <"1.2.840.113549.1.1.7">
szOID_RSA_MGF1		equ <"1.2.840.113549.1.1.8">
szOID_RSA_PSPECIFIED	equ <"1.2.840.113549.1.1.9">
szOID_RSA_SSA_PSS	equ <"1.2.840.113549.1.1.10">
szOID_RSA_SHA256RSA	equ <"1.2.840.113549.1.1.11">
szOID_RSA_SHA384RSA	equ <"1.2.840.113549.1.1.12">
szOID_RSA_SHA512RSA	equ <"1.2.840.113549.1.1.13">

szOID_RSA_DH		equ <"1.2.840.113549.1.3.1">

szOID_RSA_data		equ <"1.2.840.113549.1.7.1">
szOID_RSA_signedData	equ <"1.2.840.113549.1.7.2">
szOID_RSA_envelopedData equ <"1.2.840.113549.1.7.3">
szOID_RSA_signEnvData	equ <"1.2.840.113549.1.7.4">
szOID_RSA_digestedData	equ <"1.2.840.113549.1.7.5">
szOID_RSA_hashedData	equ <"1.2.840.113549.1.7.5">
szOID_RSA_encryptedData equ <"1.2.840.113549.1.7.6">


szOID_RSA_emailAddr	equ <"1.2.840.113549.1.9.1">
szOID_RSA_unstructName	equ <"1.2.840.113549.1.9.2">
szOID_RSA_contentType	equ <"1.2.840.113549.1.9.3">
szOID_RSA_messageDigest equ <"1.2.840.113549.1.9.4">
szOID_RSA_signingTime	equ <"1.2.840.113549.1.9.5">
szOID_RSA_counterSign	equ <"1.2.840.113549.1.9.6">
szOID_RSA_challengePwd	equ <"1.2.840.113549.1.9.7">
szOID_RSA_unstructAddr	equ <"1.2.840.113549.1.9.8">
szOID_RSA_extCertAttrs	equ <"1.2.840.113549.1.9.9">
szOID_RSA_SMIMECapabilities equ <"1.2.840.113549.1.9.15">
szOID_RSA_preferSignedData equ <"1.2.840.113549.1.9.15.1">

szOID_TIMESTAMP_TOKEN	 equ <"1.2.840.113549.1.9.16.1.4">
szOID_RFC3161_counterSign equ <"1.3.6.1.4.1.311.3.3.1">

szOID_RSA_SMIMEalg	  equ <"1.2.840.113549.1.9.16.3">
szOID_RSA_SMIMEalgESDH	  equ <"1.2.840.113549.1.9.16.3.5">
szOID_RSA_SMIMEalgCMS3DESwrap equ <"1.2.840.113549.1.9.16.3.6">
szOID_RSA_SMIMEalgCMSRC2wrap equ <"1.2.840.113549.1.9.16.3.7">

szOID_RSA_MD2		equ <"1.2.840.113549.2.2">
szOID_RSA_MD4		equ <"1.2.840.113549.2.4">
szOID_RSA_MD5		equ <"1.2.840.113549.2.5">

szOID_RSA_RC2CBC	equ <"1.2.840.113549.3.2">
szOID_RSA_RC4		equ <"1.2.840.113549.3.4">
szOID_RSA_DES_EDE3_CBC	equ <"1.2.840.113549.3.7">
szOID_RSA_RC5_CBCPad	equ <"1.2.840.113549.3.9">

szOID_ANSI_X942		equ <"1.2.840.10046">
szOID_ANSI_X942_DH	equ <"1.2.840.10046.2.1">

szOID_X957		equ <"1.2.840.10040">
szOID_X957_DSA		equ <"1.2.840.10040.4.1">
szOID_X957_SHA1DSA	equ <"1.2.840.10040.4.3">

szOID_ECC_PUBLIC_KEY	equ <"1.2.840.10045.2.1">
szOID_ECC_CURVE_P256	equ <"1.2.840.10045.3.1.7">
szOID_ECC_CURVE_P384	equ <"1.3.132.0.34">
szOID_ECC_CURVE_P521	equ <"1.3.132.0.35">
szOID_ECDSA_SHA1	equ <"1.2.840.10045.4.1">
szOID_ECDSA_SPECIFIED	equ <"1.2.840.10045.4.3">
szOID_ECDSA_SHA256	equ <"1.2.840.10045.4.3.2">
szOID_ECDSA_SHA384	equ <"1.2.840.10045.4.3.3">
szOID_ECDSA_SHA512	equ <"1.2.840.10045.4.3.4">

szOID_NIST_AES128_CBC	equ <"2.16.840.1.101.3.4.1.2">
szOID_NIST_AES192_CBC	equ <"2.16.840.1.101.3.4.1.22">
szOID_NIST_AES256_CBC	equ <"2.16.840.1.101.3.4.1.42">

szOID_NIST_AES128_WRAP	equ <"2.16.840.1.101.3.4.1.5">
szOID_NIST_AES192_WRAP	equ <"2.16.840.1.101.3.4.1.25">
szOID_NIST_AES256_WRAP	equ <"2.16.840.1.101.3.4.1.45">

szOID_DH_SINGLE_PASS_STDDH_SHA1_KDF   equ <"1.3.133.16.840.63.0.2">
szOID_DH_SINGLE_PASS_STDDH_SHA256_KDF equ <"1.3.132.1.11.1">
szOID_DH_SINGLE_PASS_STDDH_SHA384_KDF equ <"1.3.132.1.11.2">

szOID_DS		equ <"2.5">
szOID_DSALG		equ <"2.5.8">
szOID_DSALG_CRPT	equ <"2.5.8.1">
szOID_DSALG_HASH	equ <"2.5.8.2">
szOID_DSALG_SIGN	equ <"2.5.8.3">
szOID_DSALG_RSA		equ <"2.5.8.1.1">
szOID_OIW		equ <"1.3.14">
szOID_OIWSEC		equ <"1.3.14.3.2">
szOID_OIWSEC_md4RSA	equ <"1.3.14.3.2.2">
szOID_OIWSEC_md5RSA	equ <"1.3.14.3.2.3">
szOID_OIWSEC_md4RSA2	equ <"1.3.14.3.2.4">
szOID_OIWSEC_desECB	equ <"1.3.14.3.2.6">
szOID_OIWSEC_desCBC	equ <"1.3.14.3.2.7">
szOID_OIWSEC_desOFB	equ <"1.3.14.3.2.8">
szOID_OIWSEC_desCFB	equ <"1.3.14.3.2.9">
szOID_OIWSEC_desMAC	equ <"1.3.14.3.2.10">
szOID_OIWSEC_rsaSign	equ <"1.3.14.3.2.11">
szOID_OIWSEC_dsa	equ <"1.3.14.3.2.12">
szOID_OIWSEC_shaDSA	equ <"1.3.14.3.2.13">
szOID_OIWSEC_mdc2RSA	equ <"1.3.14.3.2.14">
szOID_OIWSEC_shaRSA	equ <"1.3.14.3.2.15">
szOID_OIWSEC_dhCommMod	equ <"1.3.14.3.2.16">
szOID_OIWSEC_desEDE	equ <"1.3.14.3.2.17">
szOID_OIWSEC_sha	equ <"1.3.14.3.2.18">
szOID_OIWSEC_mdc2	equ <"1.3.14.3.2.19">
szOID_OIWSEC_dsaComm	equ <"1.3.14.3.2.20">
szOID_OIWSEC_dsaCommSHA equ <"1.3.14.3.2.21">
szOID_OIWSEC_rsaXchg	equ <"1.3.14.3.2.22">
szOID_OIWSEC_keyHashSeal equ <"1.3.14.3.2.23">
szOID_OIWSEC_md2RSASign equ <"1.3.14.3.2.24">
szOID_OIWSEC_md5RSASign equ <"1.3.14.3.2.25">
szOID_OIWSEC_sha1	equ <"1.3.14.3.2.26">
szOID_OIWSEC_dsaSHA1	equ <"1.3.14.3.2.27">
szOID_OIWSEC_dsaCommSHA1 equ <"1.3.14.3.2.28">
szOID_OIWSEC_sha1RSASign equ <"1.3.14.3.2.29">
szOID_OIWDIR		equ <"1.3.14.7.2">
szOID_OIWDIR_CRPT	equ <"1.3.14.7.2.1">
szOID_OIWDIR_HASH	equ <"1.3.14.7.2.2">
szOID_OIWDIR_SIGN	equ <"1.3.14.7.2.3">
szOID_OIWDIR_md2	equ <"1.3.14.7.2.2.1">
szOID_OIWDIR_md2RSA	equ <"1.3.14.7.2.3.1">


szOID_INFOSEC				equ <"2.16.840.1.101.2.1">
szOID_INFOSEC_sdnsSignature		equ <"2.16.840.1.101.2.1.1.1">
szOID_INFOSEC_mosaicSignature		equ <"2.16.840.1.101.2.1.1.2">
szOID_INFOSEC_sdnsConfidentiality	equ <"2.16.840.1.101.2.1.1.3">
szOID_INFOSEC_mosaicConfidentiality	equ <"2.16.840.1.101.2.1.1.4">
szOID_INFOSEC_sdnsIntegrity		equ <"2.16.840.1.101.2.1.1.5">
szOID_INFOSEC_mosaicIntegrity		equ <"2.16.840.1.101.2.1.1.6">
szOID_INFOSEC_sdnsTokenProtection	equ <"2.16.840.1.101.2.1.1.7">
szOID_INFOSEC_mosaicTokenProtection	equ <"2.16.840.1.101.2.1.1.8">
szOID_INFOSEC_sdnsKeyManagement		equ <"2.16.840.1.101.2.1.1.9">
szOID_INFOSEC_mosaicKeyManagement	equ <"2.16.840.1.101.2.1.1.10">
szOID_INFOSEC_sdnsKMandSig		equ <"2.16.840.1.101.2.1.1.11">
szOID_INFOSEC_mosaicKMandSig		equ <"2.16.840.1.101.2.1.1.12">
szOID_INFOSEC_SuiteASignature		equ <"2.16.840.1.101.2.1.1.13">
szOID_INFOSEC_SuiteAConfidentiality	equ <"2.16.840.1.101.2.1.1.14">
szOID_INFOSEC_SuiteAIntegrity		equ <"2.16.840.1.101.2.1.1.15">
szOID_INFOSEC_SuiteATokenProtection	equ <"2.16.840.1.101.2.1.1.16">
szOID_INFOSEC_SuiteAKeyManagement	equ <"2.16.840.1.101.2.1.1.17">
szOID_INFOSEC_SuiteAKMandSig		equ <"2.16.840.1.101.2.1.1.18">
szOID_INFOSEC_mosaicUpdatedSig		equ <"2.16.840.1.101.2.1.1.19">
szOID_INFOSEC_mosaicKMandUpdSig		equ <"2.16.840.1.101.2.1.1.20">
szOID_INFOSEC_mosaicUpdatedInteg	equ <"2.16.840.1.101.2.1.1.21">

szOID_NIST_sha256	equ <"2.16.840.1.101.3.4.2.1">
szOID_NIST_sha384	equ <"2.16.840.1.101.3.4.2.2">
szOID_NIST_sha512	equ <"2.16.840.1.101.3.4.2.3">

CRYPT_OBJID_TABLE	STRUC
dwAlgId			dd ?
pszObjId		LPCSTR ?
CRYPT_OBJID_TABLE	ENDS
PCRYPT_OBJID_TABLE	typedef ptr CRYPT_OBJID_TABLE


CRYPT_HASH_INFO		STRUC
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
Hash			CRYPT_HASH_BLOB <>
CRYPT_HASH_INFO		ENDS
PCRYPT_HASH_INFO	typedef ptr CRYPT_HASH_INFO

CERT_EXTENSION		STRUC
pszObjId		LPSTR ?
fCritical		BOOL ?
Value			CRYPT_OBJID_BLOB <>
CERT_EXTENSION		ENDS
PCERT_EXTENSION		typedef ptr CERT_EXTENSION

CRYPT_ATTRIBUTE_TYPE_VALUE  STRUC
pszObjId		LPSTR ?
Value			CRYPT_OBJID_BLOB <>
CRYPT_ATTRIBUTE_TYPE_VALUE ENDS
PCRYPT_ATTRIBUTE_TYPE_VALUE typedef ptr CRYPT_ATTRIBUTE_TYPE_VALUE

CRYPT_ATTRIBUTE		STRUC
pszObjId		LPSTR ?
cValue			dd ?
rgValue			PCRYPT_ATTR_BLOB ?
CRYPT_ATTRIBUTE		ENDS
PCRYPT_ATTRIBUTE	typedef ptr CRYPT_ATTRIBUTE

CRYPT_ATTRIBUTES	STRUC
cAttr			dd ?
rgAttr			PCRYPT_ATTRIBUTE ?
CRYPT_ATTRIBUTES	ENDS
PCRYPT_ATTRIBUTES	typedef ptr CRYPT_ATTRIBUTES

CERT_RDN_ATTR		STRUC
pszObjId		LPSTR ?
dwValueType		dd ?
Value			CERT_RDN_VALUE_BLOB <>
CERT_RDN_ATTR		ENDS
PCERT_RDN_ATTR		typedef ptr CERT_RDN_ATTR

szOID_COMMON_NAME	equ <"2.5.4.3">
szOID_SUR_NAME		equ <"2.5.4.4">
szOID_DEVICE_SERIAL_NUMBER equ <"2.5.4.5">

szOID_COUNTRY_NAME	equ <"2.5.4.6">
szOID_LOCALITY_NAME	equ <"2.5.4.7">
szOID_STATE_OR_PROVINCE_NAME equ <"2.5.4.8">
szOID_STREET_ADDRESS	equ <"2.5.4.9">

szOID_ORGANIZATION_NAME equ <"2.5.4.10">
szOID_ORGANIZATIONAL_UNIT_NAME equ <"2.5.4.11">
szOID_TITLE		equ <"2.5.4.12">

szOID_DESCRIPTION	equ <"2.5.4.13">
szOID_SEARCH_GUIDE	equ <"2.5.4.14">
szOID_BUSINESS_CATEGORY equ <"2.5.4.15">

szOID_POSTAL_ADDRESS	equ <"2.5.4.16">
szOID_POSTAL_CODE	equ <"2.5.4.17">
szOID_POST_OFFICE_BOX	equ <"2.5.4.18">
szOID_PHYSICAL_DELIVERY_OFFICE_NAME equ <"2.5.4.19">

szOID_TELEPHONE_NUMBER	equ <"2.5.4.20">
szOID_TELEX_NUMBER	equ <"2.5.4.21">
szOID_TELETEXT_TERMINAL_IDENTIFIER equ <"2.5.4.22">
szOID_FACSIMILE_TELEPHONE_NUMBER equ <"2.5.4.23">
szOID_X21_ADDRESS	equ <"2.5.4.24">
szOID_INTERNATIONAL_ISDN_NUMBER equ <"2.5.4.25">
szOID_REGISTERED_ADDRESS equ <"2.5.4.26">
szOID_DESTINATION_INDICATOR equ <"2.5.4.27">

szOID_PREFERRED_DELIVERY_METHOD equ <"2.5.4.28">

szOID_PRESENTATION_ADDRESS equ <"2.5.4.29">
szOID_SUPPORTED_APPLICATION_CONTEXT equ <"2.5.4.30">

szOID_MEMBER		equ <"2.5.4.31">
szOID_OWNER		equ <"2.5.4.32">
szOID_ROLE_OCCUPANT	equ <"2.5.4.33">
szOID_SEE_ALSO		equ <"2.5.4.34">

szOID_USER_PASSWORD	equ <"2.5.4.35">
szOID_USER_CERTIFICATE	equ <"2.5.4.36">
szOID_CA_CERTIFICATE	equ <"2.5.4.37">
szOID_AUTHORITY_REVOCATION_LIST equ <"2.5.4.38">
szOID_CERTIFICATE_REVOCATION_LIST equ <"2.5.4.39">
szOID_CROSS_CERTIFICATE_PAIR equ <"2.5.4.40">

szOID_GIVEN_NAME	equ <"2.5.4.42">
szOID_INITIALS		equ <"2.5.4.43">

szOID_DOMAIN_COMPONENT	equ <"0.9.2342.19200300.100.1.25">

szOID_PKCS_12_FRIENDLY_NAME_ATTR     equ <"1.2.840.113549.1.9.20">
szOID_PKCS_12_LOCAL_KEY_ID	     equ <"1.2.840.113549.1.9.21">
szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR equ <"1.3.6.1.4.1.311.17.1">
szOID_LOCAL_MACHINE_KEYSET	     equ <"1.3.6.1.4.1.311.17.2">
szOID_PKCS_12_EXTENDED_ATTRIBUTES    equ <"1.3.6.1.4.1.311.17.3">
szOID_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID equ <"1.3.6.1.4.1.311.17.4">

szOID_KEYID_RDN		equ <"1.3.6.1.4.1.311.10.7.1">

szOID_EV_RDN_LOCALE	equ <"1.3.6.1.4.1.311.60.2.1.1">
szOID_EV_RDN_STATE_OR_PROVINCE equ <"1.3.6.1.4.1.311.60.2.1.2">
szOID_EV_RDN_COUNTRY	equ <"1.3.6.1.4.1.311.60.2.1.3">

CERT_RDN_ANY_TYPE	equ 0
CERT_RDN_ENCODED_BLOB	equ 1
CERT_RDN_OCTET_STRING	equ 2
CERT_RDN_NUMERIC_STRING equ 3
CERT_RDN_PRINTABLE_STRING equ 4
CERT_RDN_TELETEX_STRING equ 5
CERT_RDN_T61_STRING	equ 5
CERT_RDN_VIDEOTEX_STRING equ 6
CERT_RDN_IA5_STRING	equ 7
CERT_RDN_GRAPHIC_STRING equ 8
CERT_RDN_VISIBLE_STRING equ 9
CERT_RDN_ISO646_STRING	equ 9
CERT_RDN_GENERAL_STRING equ 10
CERT_RDN_UNIVERSAL_STRING equ 11
CERT_RDN_INT4_STRING	equ 11
CERT_RDN_BMP_STRING	equ 12
CERT_RDN_UNICODE_STRING equ 12
CERT_RDN_UTF8_STRING	equ 13

CERT_RDN_TYPE_MASK	equ 0x000000FF
CERT_RDN_FLAGS_MASK	equ 0xFF000000

CERT_RDN_ENABLE_T61_UNICODE_FLAG    equ 0x80000000
CERT_RDN_ENABLE_UTF8_UNICODE_FLAG   equ 0x20000000
CERT_RDN_FORCE_UTF8_UNICODE_FLAG    equ 0x10000000
CERT_RDN_DISABLE_CHECK_TYPE_FLAG    equ 0x40000000
CERT_RDN_DISABLE_IE4_UTF8_FLAG	    equ 0x01000000
CERT_RDN_ENABLE_PUNYCODE_FLAG	    equ 0x02000000

IS_CERT_RDN_CHAR_STRING macro X
	exitm<(X GE CERT_RDN_NUMERIC_STRING)>
	endm

CERT_RDN		STRUC
cRDNAttr		dd ?
rgRDNAttr		PCERT_RDN_ATTR ?
CERT_RDN		ENDS
PCERT_RDN		typedef ptr CERT_RDN

CERT_NAME_INFO		STRUC
cRDN			dd ?
rgRDN			PCERT_RDN ?
CERT_NAME_INFO		ENDS
PCERT_NAME_INFO		typedef ptr CERT_NAME_INFO

CERT_NAME_VALUE		STRUC
dwValueType		dd ?
Value			CERT_RDN_VALUE_BLOB <>
CERT_NAME_VALUE		ENDS
PCERT_NAME_VALUE	typedef ptr CERT_NAME_VALUE

CERT_PUBLIC_KEY_INFO	STRUC
Algorithm		CRYPT_ALGORITHM_IDENTIFIER <>
PublicKey		CRYPT_BIT_BLOB <>
CERT_PUBLIC_KEY_INFO	ENDS
PCERT_PUBLIC_KEY_INFO	typedef ptr CERT_PUBLIC_KEY_INFO

CERT_RSA_PUBLIC_KEY_OBJID equ szOID_RSA_RSA
CERT_DEFAULT_OID_PUBLIC_KEY_SIGN equ szOID_RSA_RSA
CERT_DEFAULT_OID_PUBLIC_KEY_XCHG equ szOID_RSA_RSA

CRYPT_ECC_PRIVATE_KEY_INFO STRUC
dwVersion		dd ?
PrivateKey		CRYPT_DER_BLOB <>
szCurveOid		LPSTR ?
PublicKey		CRYPT_BIT_BLOB <>
CRYPT_ECC_PRIVATE_KEY_INFO ENDS
PCRYPT_ECC_PRIVATE_KEY_INFO typedef ptr CRYPT_ECC_PRIVATE_KEY_INFO

CRYPT_ECC_PRIVATE_KEY_INFO_v1 equ 1

CRYPT_PRIVATE_KEY_INFO	STRUC
Version			dd ?
Algorithm		CRYPT_ALGORITHM_IDENTIFIER <>
PrivateKey		CRYPT_DER_BLOB <>
pAttributes		PCRYPT_ATTRIBUTES ?
CRYPT_PRIVATE_KEY_INFO	ENDS
PCRYPT_PRIVATE_KEY_INFO typedef ptr CRYPT_PRIVATE_KEY_INFO

CRYPT_ENCRYPTED_PRIVATE_KEY_INFO STRUC
EncryptionAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedPrivateKey	CRYPT_DATA_BLOB <>
CRYPT_ENCRYPTED_PRIVATE_KEY_INFO ENDS
PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO typedef ptr CRYPT_ENCRYPTED_PRIVATE_KEY_INFO

CALLBACK(PCRYPT_DECRYPT_PRIVATE_KEY_FUNC, :CRYPT_ALGORITHM_IDENTIFIER, :CRYPT_DATA_BLOB, :ptr, :ptr, :ptr)
CALLBACK(PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC, :ptr, :ptr, :ptr, :ptr, :ptr)
CALLBACK(PCRYPT_RESOLVE_HCRYPTPROV_FUNC, :ptr, :ptr, :ptr)

CRYPT_PKCS8_IMPORT_PARAMS STRUC
PrivateKey		CRYPT_DIGEST_BLOB <>
pResolvehCryptProvFunc	PCRYPT_RESOLVE_HCRYPTPROV_FUNC ?
pVoidResolveFunc	PVOID ?
pDecryptPrivateKeyFunc	PCRYPT_DECRYPT_PRIVATE_KEY_FUNC ?
pVoidDecryptFunc	PVOID ?
CRYPT_PKCS8_IMPORT_PARAMS ENDS
PCRYPT_PKCS8_IMPORT_PARAMS typedef ptr CRYPT_PKCS8_IMPORT_PARAMS
CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS typedef CRYPT_PKCS8_IMPORT_PARAMS
PCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS typedef ptr CRYPT_PKCS8_IMPORT_PARAMS

CRYPT_PKCS8_EXPORT_PARAMS STRUC
hCryptProv		HCRYPTPROV ?
dwKeySpec		dd ?
pszPrivateKeyObjId	LPSTR ?
pEncryptPrivateKeyFunc	PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC ?
pVoidEncryptFunc	PVOID ?
CRYPT_PKCS8_EXPORT_PARAMS ENDS
PCRYPT_PKCS8_EXPORT_PARAMS typedef ptr CRYPT_PKCS8_EXPORT_PARAMS

ifndef LPFILETIME
FILETIME		STRUC
dwLowDateTime		dd ?
dwHighDateTime		dd ?
FILETIME		ENDS
LPFILETIME		typedef ptr FILETIME
endif

CERT_INFO		STRUC
dwVersion		dd ?
SerialNumber		CRYPT_INTEGER_BLOB <>
SignatureAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
Issuer			CERT_NAME_BLOB <>
NotBefore		FILETIME <>
NotAfter		FILETIME <>
Subject			CERT_NAME_BLOB <>
SubjectPublicKeyInfo	CERT_PUBLIC_KEY_INFO <>
IssuerUniqueId		CRYPT_BIT_BLOB <>
SubjectUniqueId		CRYPT_BIT_BLOB <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CERT_INFO		ENDS
PCERT_INFO		typedef ptr CERT_INFO

CERT_V1			equ 0
CERT_V2			equ 1
CERT_V3			equ 2

CERT_INFO_VERSION_FLAG	equ 1
CERT_INFO_SERIAL_NUMBER_FLAG equ 2
CERT_INFO_SIGNATURE_ALGORITHM_FLAG equ 3
CERT_INFO_ISSUER_FLAG	equ 4
CERT_INFO_NOT_BEFORE_FLAG equ 5
CERT_INFO_NOT_AFTER_FLAG equ 6
CERT_INFO_SUBJECT_FLAG	equ 7
CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG equ 8
CERT_INFO_ISSUER_UNIQUE_ID_FLAG equ 9
CERT_INFO_SUBJECT_UNIQUE_ID_FLAG equ 10
CERT_INFO_EXTENSION_FLAG equ 11

CRL_ENTRY		STRUC
SerialNumber		CRYPT_INTEGER_BLOB <>
RevocationDate		FILETIME <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CRL_ENTRY		ENDS
PCRL_ENTRY		typedef ptr CRL_ENTRY

CRL_INFO		STRUC
dwVersion		dd ?
SignatureAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
Issuer			CERT_NAME_BLOB <>
ThisUpdate		FILETIME <>
NextUpdate		FILETIME <>
cCRLEntry		dd ?
rgCRLEntry		PCRL_ENTRY ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CRL_INFO		ENDS
PCRL_INFO		typedef ptr CRL_INFO

CRL_V1			equ 0
CRL_V2			equ 1

CERT_BUNDLE_CERTIFICATE equ 0
CERT_BUNDLE_CRL		equ 1

CERT_OR_CRL_BLOB	STRUC
dwChoice		dd ?
cbEncoded		dd ?
pbEncoded		LPBYTE ?
CERT_OR_CRL_BLOB	ENDS
PCERT_OR_CRL_BLOB	typedef ptr CERT_OR_CRL_BLOB

CERT_OR_CRL_BUNDLE	STRUC
cItem			dd ?
rgItem			PCERT_OR_CRL_BLOB ?
CERT_OR_CRL_BUNDLE	ENDS
PCERT_OR_CRL_BUNDLE	typedef ptr CERT_OR_CRL_BUNDLE

CERT_REQUEST_INFO	STRUC
dwVersion		dd ?
Subject			CERT_NAME_BLOB <>
SubjectPublicKeyInfo	CERT_PUBLIC_KEY_INFO <>
cAttribute		dd ?
rgAttribute		PCRYPT_ATTRIBUTE ?
CERT_REQUEST_INFO	ENDS
PCERT_REQUEST_INFO	typedef ptr CERT_REQUEST_INFO

CERT_REQUEST_V1		equ 0

CERT_KEYGEN_REQUEST_INFO  STRUC
dwVersion		dd ?
SubjectPublicKeyInfo	CERT_PUBLIC_KEY_INFO <>
pwszChallengeString	LPWSTR ?
CERT_KEYGEN_REQUEST_INFO ENDS
PCERT_KEYGEN_REQUEST_INFO typedef ptr CERT_KEYGEN_REQUEST_INFO

CERT_KEYGEN_REQUEST_V1	equ 0

CERT_SIGNED_CONTENT_INFO  STRUC
ToBeSigned		CRYPT_DER_BLOB <>
SignatureAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
Signature		CRYPT_BIT_BLOB <>
CERT_SIGNED_CONTENT_INFO ENDS
PCERT_SIGNED_CONTENT_INFO typedef ptr CERT_SIGNED_CONTENT_INFO

CTL_USAGE		STRUC
cUsageIdentifier	dd ?
rgpszUsageIdentifier	LPSTR ?
CTL_USAGE		ENDS
PCTL_USAGE		typedef ptr CTL_USAGE
CERT_ENHKEY_USAGE	typedef CTL_USAGE
PCERT_ENHKEY_USAGE	typedef ptr CERT_ENHKEY_USAGE

CTL_ENTRY		STRUC
SubjectIdentifier	CRYPT_DATA_BLOB <>
cAttribute		dd ?
rgAttribute		PCRYPT_ATTRIBUTE ?
CTL_ENTRY		ENDS
PCTL_ENTRY		typedef ptr CTL_ENTRY

CTL_INFO		STRUC
dwVersion		dd ?
SubjectUsage		CTL_USAGE <>
ListIdentifier		CRYPT_DATA_BLOB <>
SequenceNumber		CRYPT_INTEGER_BLOB <>
ThisUpdate		FILETIME <>
NextUpdate		FILETIME <>
SubjectAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
cCTLEntry		dd ?
rgCTLEntry		PCTL_ENTRY ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CTL_INFO		ENDS
PCTL_INFO		typedef ptr CTL_INFO

CTL_V1			equ 0


CRYPT_TIME_STAMP_REQUEST_INFO  STRUC
pszTimeStampAlgorithm	LPSTR ?
pszContentType		LPSTR ?
Content			CRYPT_OBJID_BLOB <>
cAttribute		dd ?
rgAttribute		PCRYPT_ATTRIBUTE ?
CRYPT_TIME_STAMP_REQUEST_INFO ENDS
PCRYPT_TIME_STAMP_REQUEST_INFO typedef ptr CRYPT_TIME_STAMP_REQUEST_INFO

CERT_ENCODING_TYPE_MASK equ 0x0000FFFF
CMSG_ENCODING_TYPE_MASK equ 0xFFFF0000
GET_CERT_ENCODING_TYPE macro X
	exitm<(X AND CERT_ENCODING_TYPE_MASK)>
	endm
GET_CMSG_ENCODING_TYPE macro X
	exitm<(X AND CMSG_ENCODING_TYPE_MASK)>
	endm

CRYPT_ASN_ENCODING	equ 0x00000001
CRYPT_NDR_ENCODING	equ 0x00000002
X509_ASN_ENCODING	equ 0x00000001
X509_NDR_ENCODING	equ 0x00000002
PKCS_7_ASN_ENCODING	equ 0x00010000
PKCS_7_NDR_ENCODING	equ 0x00020000


CryptFormatObject proto WINAPI :DWORD, :DWORD, :DWORD, :ptr, :LPCSTR, :LPBYTE, :DWORD, :ptr, :LPDWORD


CRYPT_FORMAT_STR_MULTI_LINE	    equ 0x0001
CRYPT_FORMAT_STR_NO_HEX		    equ 0x0010
CRYPT_FORMAT_SIMPLE		    equ 0x0001
CRYPT_FORMAT_X509		    equ 0x0002
CRYPT_FORMAT_OID		    equ 0x0004
CRYPT_FORMAT_RDN_SEMICOLON	    equ 0x0100
CRYPT_FORMAT_RDN_CRLF		    equ 0x0200
CRYPT_FORMAT_RDN_UNQUOTE	    equ 0x0400
CRYPT_FORMAT_RDN_REVERSE	    equ 0x0800
CRYPT_FORMAT_COMMA		    equ 0x1000
CRYPT_FORMAT_SEMICOLON		    equ CRYPT_FORMAT_RDN_SEMICOLON
CRYPT_FORMAT_CRLF		    equ CRYPT_FORMAT_RDN_CRLF

CALLBACK(PFN_CRYPT_ALLOC, :size_t)
CALLBACK(PFN_CRYPT_FREE, :ptr)

CRYPT_ENCODE_PARA	STRUC
cbSize			dd ?
pfnAlloc		PFN_CRYPT_ALLOC ?
pfnFree			PFN_CRYPT_FREE ?
CRYPT_ENCODE_PARA	ENDS
PCRYPT_ENCODE_PARA	typedef ptr CRYPT_ENCODE_PARA

CryptEncodeObjectEx proto WINAPI :DWORD, :LPCSTR, :ptr, :DWORD, :PCRYPT_ENCODE_PARA, :ptr, :ptr
CryptEncodeObject proto WINAPI :DWORD, :LPCSTR, :ptr, :LPBYTE, :LPDWORD

CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG equ 0x8
CRYPT_ENCODE_ALLOC_FLAG equ 0x8000
CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG equ CERT_RDN_ENABLE_T61_UNICODE_FLAG
CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG equ CERT_RDN_ENABLE_UTF8_UNICODE_FLAG
CRYPT_UNICODE_NAME_ENCODE_FORCE_UTF8_UNICODE_FLAG equ CERT_RDN_FORCE_UTF8_UNICODE_FLAG
CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG equ CERT_RDN_DISABLE_CHECK_TYPE_FLAG
CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG equ 0x10000
CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG equ 0x20000
CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG equ 0x40000
CRYPT_ENCODE_ENABLE_IA5CONVERSION_FLAG equ (CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG or CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG)


CRYPT_DECODE_PARA	STRUC
cbSize			dd ?
pfnAlloc		PFN_CRYPT_ALLOC ?
pfnFree			PFN_CRYPT_FREE ?
CRYPT_DECODE_PARA	ENDS
PCRYPT_DECODE_PARA	typedef ptr CRYPT_DECODE_PARA

CryptDecodeObjectEx proto WINAPI :DWORD, :LPCSTR, :ptr, :DWORD, :DWORD, :PCRYPT_DECODE_PARA, :ptr, :ptr
CryptDecodeObject proto WINAPI :DWORD, :LPCSTR, :LPBYTE, :DWORD, :DWORD, :ptr, :LPDWORD

CRYPT_DECODE_NOCOPY_FLAG equ 0x1
CRYPT_DECODE_NOCOPY_FLAG equ 0x1

CRYPT_DECODE_TO_BE_SIGNED_FLAG equ 0x2
CRYPT_DECODE_SHARE_OID_STRING_FLAG equ 0x4
CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG equ 0x8
CRYPT_DECODE_ALLOC_FLAG equ 0x8000
CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG equ CERT_RDN_DISABLE_IE4_UTF8_FLAG
CRYPT_DECODE_ENABLE_PUNYCODE_FLAG equ 0x02000000
CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG equ 0x04000000
CRYPT_DECODE_ENABLE_IA5CONVERSION_FLAG equ (CRYPT_DECODE_ENABLE_PUNYCODE_FLAG or CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG)

CRYPT_ENCODE_DECODE_NONE equ 0
X509_CERT		equ 1
X509_CERT_TO_BE_SIGNED	equ 2
X509_CERT_CRL_TO_BE_SIGNED equ 3
X509_CERT_REQUEST_TO_BE_SIGNED equ 4
X509_EXTENSIONS		equ 5
X509_NAME_VALUE		equ 6
X509_NAME		equ 7
X509_PUBLIC_KEY_INFO	equ 8

X509_AUTHORITY_KEY_ID	equ 9
X509_KEY_ATTRIBUTES	equ 10
X509_KEY_USAGE_RESTRICTION equ 11
X509_ALTERNATE_NAME	equ 12
X509_BASIC_CONSTRAINTS	equ 13
X509_KEY_USAGE		equ 14
X509_BASIC_CONSTRAINTS2 equ 15
X509_CERT_POLICIES	equ 16

PKCS_UTC_TIME		equ 17
PKCS_TIME_REQUEST	equ 18
RSA_CSP_PUBLICKEYBLOB	equ 19
X509_UNICODE_NAME	equ 20

X509_KEYGEN_REQUEST_TO_BE_SIGNED equ 21
PKCS_ATTRIBUTE		equ 22
PKCS_CONTENT_INFO_SEQUENCE_OF_ANY equ 23

X509_UNICODE_NAME_VALUE equ 24
X509_ANY_STRING		equ X509_NAME_VAUE
X509_UNICODE_ANY_STRING equ X509_UNICODE_NAME_VAUE
X509_OCTET_STRING	equ 25
X509_BITS		equ 26
X509_INTEGER		equ 27
X509_MULTI_BYTE_INTEGER equ 28
X509_ENUMERATED		equ 29
X509_CHOICE_OF_TIME	equ 30

X509_AUTHORITY_KEY_ID2	equ 31
X509_CRL_REASON_CODE	equ X509_ENUMERATED
PKCS_CONTENT_INFO	equ 33
X509_SEQUENCE_OF_ANY	equ 34
X509_CRL_DIST_POINTS	equ 35
X509_ENHANCED_KEY_USAGE equ 36
PKCS_CTL		equ 37

X509_MULTI_BYTE_UINT	equ 38
X509_DSS_PUBLICKEY	equ X509_MULTI_BYTE_UINT
X509_DSS_PARAMETERS	equ 39
X509_DSS_SIGNATURE	equ 40
PKCS_RC2_CBC_PARAMETERS equ 41
PKCS_SMIME_CAPABILITIES equ 42

X509_QC_STATEMENTS_EXT	equ 42

PKCS_RSA_PRIVATE_KEY	equ 43
PKCS_PRIVATE_KEY_INFO	equ 44
PKCS_ENCRYPTED_PRIVATE_KEY_INFO equ 45

X509_PKIX_POLICY_QUALIFIER_USERNOTICE equ 46

X509_DH_PUBLICKEY	equ X509_MULTI_BYTE_UINT
X509_DH_PARAMETERS	equ 47
PKCS_ATTRIBUTES		equ 48
PKCS_SORTED_CTL		equ 49

X509_ECC_SIGNATURE	equ 47
X942_DH_PARAMETERS	equ 50
X509_BITS_WITHOUT_TRAILING_ZEROES equ 51
X942_OTHER_INFO		equ 52

X509_CERT_PAIR		equ 53
X509_ISSUING_DIST_POINT equ 54
X509_NAME_CONSTRAINTS	equ 55
X509_POLICY_MAPPINGS	equ 56
X509_POLICY_CONSTRAINTS equ 57
X509_CROSS_CERT_DIST_POINTS equ 58

CMC_DATA		equ 59
CMC_RESPONSE		equ 60
CMC_STATUS		equ 61
CMC_ADD_EXTENSIONS	equ 62
CMC_ADD_ATTRIBUTES	equ 63

X509_CERTIFICATE_TEMPLATE equ 64

OCSP_SIGNED_REQUEST	equ 65
OCSP_REQUEST		equ 66
OCSP_RESPONSE		equ 67
OCSP_BASIC_SIGNED_RESPONSE equ 68
OCSP_BASIC_RESPONSE	equ 69

X509_LOGOTYPE_EXT	equ 70
X509_BIOMETRIC_EXT	equ 71

CNG_RSA_PUBLIC_KEY_BLOB equ 72
X509_OBJECT_IDENTIFIER	equ 73
X509_ALGORITHM_IDENTIFIER equ 74
PKCS_RSA_SSA_PSS_PARAMETERS equ 75
PKCS_RSAES_OAEP_PARAMETERS equ 76

ECC_CMS_SHARED_INFO	equ 77

TIMESTAMP_REQUEST	equ 78
TIMESTAMP_RESPONSE	equ 79
TIMESTAMP_INFO		equ 80

X509_CERT_BUNDLE	equ 81
X509_ECC_PRIVATE_KEY	equ 82
CNG_RSA_PRIVATE_KEY_BLOB equ 83
X509_SUBJECT_DIR_ATTRS	equ 84


PKCS7_SIGNER_INFO	equ 500
CMS_SIGNER_INFO		equ 501


szOID_AUTHORITY_KEY_IDENTIFIER equ <"2.5.29.1">
szOID_KEY_ATTRIBUTES	equ <"2.5.29.2">
szOID_KEY_USAGE_RESTRICTION equ <"2.5.29.4">
szOID_SUBJECT_ALT_NAME	equ <"2.5.29.7">
szOID_ISSUER_ALT_NAME	equ <"2.5.29.8">
szOID_BASIC_CONSTRAINTS equ <"2.5.29.10">
szOID_KEY_USAGE		equ <"2.5.29.15">
szOID_BASIC_CONSTRAINTS2 equ <"2.5.29.19">

szOID_CERT_POLICIES	equ <"2.5.29.32">
szOID_ANY_CERT_POLICY	equ <"2.5.29.32.0">
szOID_INHIBIT_ANY_POLICY equ <"2.5.29.54">

szOID_AUTHORITY_KEY_IDENTIFIER2 equ <"2.5.29.35">
szOID_SUBJECT_KEY_IDENTIFIER equ <"2.5.29.14">
szOID_SUBJECT_ALT_NAME2 equ <"2.5.29.17">
szOID_ISSUER_ALT_NAME2	equ <"2.5.29.18">
szOID_CRL_REASON_CODE	equ <"2.5.29.21">
szOID_CRL_DIST_POINTS	equ <"2.5.29.31">
szOID_ENHANCED_KEY_USAGE equ <"2.5.29.37">

szOID_ANY_ENHANCED_KEY_USAGE equ <"2.5.29.37.0">
szOID_CRL_NUMBER	equ <"2.5.29.20">
szOID_DELTA_CRL_INDICATOR equ <"2.5.29.27">
szOID_ISSUING_DIST_POINT equ <"2.5.29.28">
szOID_FRESHEST_CRL	equ <"2.5.29.46">
szOID_NAME_CONSTRAINTS	equ <"2.5.29.30">
szOID_POLICY_MAPPINGS	equ <"2.5.29.33">
szOID_LEGACY_POLICY_MAPPINGS equ <"2.5.29.5">
szOID_POLICY_CONSTRAINTS equ <"2.5.29.36">

szOID_RENEWAL_CERTIFICATE equ <"1.3.6.1.4.1.311.13.1">
szOID_ENROLLMENT_NAME_VALUE_PAIR equ <"1.3.6.1.4.1.311.13.2.1">
szOID_ENROLLMENT_CSP_PROVIDER equ <"1.3.6.1.4.1.311.13.2.2">
szOID_OS_VERSION	equ <"1.3.6.1.4.1.311.13.2.3">

szOID_ENROLLMENT_AGENT	equ <"1.3.6.1.4.1.311.20.2.1">

szOID_PKIX		equ <"1.3.6.1.5.5.7">
szOID_PKIX_PE		equ <"1.3.6.1.5.5.7.1">

szOID_AUTHORITY_INFO_ACCESS equ <"1.3.6.1.5.5.7.1.1">
szOID_SUBJECT_INFO_ACCESS   equ <"1.3.6.1.5.5.7.1.11">
szOID_BIOMETRIC_EXT	    equ <"1.3.6.1.5.5.7.1.2">
szOID_QC_STATEMENTS_EXT	    equ <"1.3.6.1.5.5.7.1.3">
szOID_LOGOTYPE_EXT	    equ <"1.3.6.1.5.5.7.1.12">

szOID_CERT_EXTENSIONS	equ <"1.3.6.1.4.1.311.2.1.14">
szOID_NEXT_UPDATE_LOCATION equ <"1.3.6.1.4.1.311.10.2">
szOID_REMOVE_CERTIFICATE equ <"1.3.6.1.4.1.311.10.8.1">
szOID_CROSS_CERT_DIST_POINTS equ <"1.3.6.1.4.1.311.10.9.1">

szOID_CTL		equ <"1.3.6.1.4.1.311.10.1">
szOID_SORTED_CTL	equ <"1.3.6.1.4.1.311.10.1.1">
ifndef szOID_SERIALIZED
szOID_SERIALIZED	equ <"1.3.6.1.4.1.311.10.3.3.1">
endif
ifndef szOID_NT_PRINCIPAL_NAME
szOID_NT_PRINCIPAL_NAME equ <"1.3.6.1.4.1.311.20.2.3">
endif
ifndef szOID_INTERNATIONALIZED_EMAIL_ADDRESS
szOID_INTERNATIONALIZED_EMAIL_ADDRESS equ <"1.3.6.1.4.1.311.20.2.4">
endif
ifndef szOID_PRODUCT_UPDATE
szOID_PRODUCT_UPDATE	equ <"1.3.6.1.4.1.311.31.1">
endif
szOID_ANY_APPLICATION_POLICY equ <"1.3.6.1.4.1.311.10.12.1">
szOID_AUTO_ENROLL_CTL_USAGE equ <"1.3.6.1.4.1.311.20.1">
szOID_ENROLL_CERTTYPE_EXTENSION equ <"1.3.6.1.4.1.311.20.2">
szOID_CERT_MANIFOLD	equ <"1.3.6.1.4.1.311.20.3">

ifndef szOID_CERTSRV_CA_VERSION
szOID_CERTSRV_CA_VERSION equ <"1.3.6.1.4.1.311.21.1">
endif
szOID_CERTSRV_PREVIOUS_CERT_HASH equ <"1.3.6.1.4.1.311.21.2">
szOID_CRL_VIRTUAL_BASE	equ <"1.3.6.1.4.1.311.21.3">
szOID_CRL_NEXT_PUBLISH	equ <"1.3.6.1.4.1.311.21.4">
szOID_KP_CA_EXCHANGE	equ <"1.3.6.1.4.1.311.21.5">
szOID_KP_KEY_RECOVERY_AGENT equ <"1.3.6.1.4.1.311.21.6">
szOID_CERTIFICATE_TEMPLATE equ <"1.3.6.1.4.1.311.21.7">
szOID_ENTERPRISE_OID_ROOT equ <"1.3.6.1.4.1.311.21.8">
szOID_RDN_DUMMY_SIGNER equ <"1.3.6.1.4.1.311.21.9">
szOID_APPLICATION_CERT_POLICIES equ <"1.3.6.1.4.1.311.21.10">
szOID_APPLICATION_POLICY_MAPPINGS equ <"1.3.6.1.4.1.311.21.11">

szOID_POLICY_MAPPINGS	equ <"2.5.29.5">
szOID_SUBJECT_DIR_ATTRS equ <"2.5.29.9">
szOID_PKIX_KP		equ <"1.3.6.1.5.5.7.3">
szOID_PKIX_KP_SERVER_AUTH equ <"1.3.6.1.5.5.7.3.1">
szOID_PKIX_KP_CLIENT_AUTH equ <"1.3.6.1.5.5.7.3.2">
szOID_PKIX_KP_CODE_SIGNING equ <"1.3.6.1.5.5.7.3.3">
szOID_PKIX_KP_EMAIL_PROTECTION equ <"1.3.6.1.5.5.7.3.4">
szOID_KP_CTL_USAGE_SIGNING equ <"1.3.6.1.4.1.311.10.3.1">
szOID_KP_TIME_STAMP_SIGNING equ <"1.3.6.1.4.1.311.10.3.2">
szOID_YESNO_TRUST_ATTR	equ <"1.3.6.1.4.1.311.10.4.1">

szOID_APPLICATION_POLICY_CONSTRAINTS equ <"1.3.6.1.4.1.311.21.12">

szOID_ARCHIVED_KEY_ATTR		equ <"1.3.6.1.4.1.311.21.13">
szOID_CRL_SELF_CDP		equ <"1.3.6.1.4.1.311.21.14">

szOID_REQUIRE_CERT_CHAIN_POLICY equ <"1.3.6.1.4.1.311.21.15">
szOID_ARCHIVED_KEY_CERT_HASH	equ <"1.3.6.1.4.1.311.21.16">
szOID_ISSUED_CERT_HASH		equ <"1.3.6.1.4.1.311.21.17">

szOID_DS_EMAIL_REPLICATION	equ <"1.3.6.1.4.1.311.21.19">

szOID_REQUEST_CLIENT_INFO	equ <"1.3.6.1.4.1.311.21.20">
szOID_ENCRYPTED_KEY_HASH	equ <"1.3.6.1.4.1.311.21.21">
szOID_CERTSRV_CROSSCA_VERSION	equ <"1.3.6.1.4.1.311.21.22">

szOID_NTDS_REPLICATION		equ <"1.3.6.1.4.1.311.25.1">

szOID_SUBJECT_DIR_ATTRS		equ <"2.5.29.9">
szOID_PKIX_KP			equ <"1.3.6.1.5.5.7.3">
szOID_PKIX_KP_SERVER_AUTH	equ <"1.3.6.1.5.5.7.3.1">
szOID_PKIX_KP_CLIENT_AUTH	equ <"1.3.6.1.5.5.7.3.2">
szOID_PKIX_KP_CODE_SIGNING	equ <"1.3.6.1.5.5.7.3.3">
szOID_PKIX_KP_EMAIL_PROTECTION	equ <"1.3.6.1.5.5.7.3.4">
szOID_PKIX_KP_IPSEC_END_SYSTEM	equ <"1.3.6.1.5.5.7.3.5">
szOID_PKIX_KP_IPSEC_TUNNEL	equ <"1.3.6.1.5.5.7.3.6">
szOID_PKIX_KP_IPSEC_USER	equ <"1.3.6.1.5.5.7.3.7">
szOID_PKIX_KP_TIMESTAMP_SIGNING equ <"1.3.6.1.5.5.7.3.8">
szOID_PKIX_KP_OCSP_SIGNING	equ <"1.3.6.1.5.5.7.3.9">
szOID_PKIX_OCSP_NOCHECK		equ <"1.3.6.1.5.5.7.48.1.5">
szOID_PKIX_OCSP_NONCE		equ <"1.3.6.1.5.5.7.48.1.2">

szOID_IPSEC_KP_IKE_INTERMEDIATE equ <"1.3.6.1.5.5.8.2.2">
szOID_PKINIT_KP_KDC		equ <"1.3.6.1.5.2.3.5">
szOID_KP_CTL_USAGE_SIGNING	equ <"1.3.6.1.4.1.311.10.3.1">
szOID_KP_TIME_STAMP_SIGNING	equ <"1.3.6.1.4.1.311.10.3.2">
ifndef szOID_SERVER_GATED_CRYPTO
szOID_SERVER_GATED_CRYPTO	equ <"1.3.6.1.4.1.311.10.3.3">
endif
ifndef szOID_SGC_NETSCAPE
szOID_SGC_NETSCAPE		equ <"2.16.840.1.113730.4.1">
endif
szOID_KP_EFS			equ <"1.3.6.1.4.1.311.10.3.4">
szOID_EFS_RECOVERY		equ <"1.3.6.1.4.1.311.10.3.4.1">
szOID_WHQL_CRYPTO		equ <"1.3.6.1.4.1.311.10.3.5">
szOID_NT5_CRYPTO		equ <"1.3.6.1.4.1.311.10.3.6">
szOID_OEM_WHQL_CRYPTO		equ <"1.3.6.1.4.1.311.10.3.7">
szOID_EMBEDDED_NT_CRYPTO	equ <"1.3.6.1.4.1.311.10.3.8">
szOID_ROOT_LIST_SIGNER		equ <"1.3.6.1.4.1.311.10.3.9">
szOID_KP_QUALIFIED_SUBORDINATION equ <"1.3.6.1.4.1.311.10.3.10">
szOID_KP_KEY_RECOVERY		equ <"1.3.6.1.4.1.311.10.3.11">
szOID_KP_DOCUMENT_SIGNING	equ <"1.3.6.1.4.1.311.10.3.12">
szOID_KP_LIFETIME_SIGNING	equ <"1.3.6.1.4.1.311.10.3.13">
szOID_KP_MOBILE_DEVICE_SOFTWARE equ <"1.3.6.1.4.1.311.10.3.14">
szOID_KP_SMART_DISPLAY		equ <"1.3.6.1.4.1.311.10.3.15">
szOID_KP_CSP_SIGNATURE		equ <"1.3.6.1.4.1.311.10.3.16">

ifndef szOID_DRM
szOID_DRM			equ <"1.3.6.1.4.1.311.10.5.1">
endif

ifndef szOID_DRM_INDIVIDUALIZATION
szOID_DRM_INDIVIDUALIZATION	equ <"1.3.6.1.4.1.311.10.5.2">
endif
ifndef szOID_LICENSES
szOID_LICENSES			equ <"1.3.6.1.4.1.311.10.6.1">
endif
ifndef szOID_LICENSE_SERVER
szOID_LICENSE_SERVER		equ <"1.3.6.1.4.1.311.10.6.2">
endif
ifndef szOID_KP_SMARTCARD_LOGON
szOID_KP_SMARTCARD_LOGON	equ <"1.3.6.1.4.1.311.20.2.2">
endif
szOID_KP_KERNEL_MODE_CODE_SIGNING equ <"1.3.6.1.4.1.311.61.1.1">
szOID_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING equ <"1.3.6.1.4.1.311.61.4.1">
szOID_REVOKED_LIST_SIGNER	equ <"1.3.6.1.4.1.311.10.3.19">
szOID_WINDOWS_KITS_SIGNER	equ <"1.3.6.1.4.1.311.10.3.20">
szOID_WINDOWS_RT_SIGNER		equ <"1.3.6.1.4.1.311.10.3.21">
szOID_PROTECTED_PROCESS_LIGHT_SIGNER equ <"1.3.6.1.4.1.311.10.3.22">
szOID_WINDOWS_TCB_SIGNER	equ <"1.3.6.1.4.1.311.10.3.23">
szOID_PROTECTED_PROCESS_SIGNER	equ <"1.3.6.1.4.1.311.10.3.24">
szOID_WINDOWS_THIRD_PARTY_COMPONENT_SIGNER equ <"1.3.6.1.4.1.311.10.3.25">
szOID_WINDOWS_SOFTWARE_EXTENSION_SIGNER equ <"1.3.6.1.4.1.311.10.3.26">
szOID_DISALLOWED_LIST		equ <"1.3.6.1.4.1.311.10.3.30">
szOID_SYNC_ROOT_CTL_EXT		equ <"1.3.6.1.4.1.311.10.3.50">
szOID_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING equ <"1.3.6.1.4.1.311.61.5.1">
szOID_WINDOWS_STORE_SIGNER	equ <"1.3.6.1.4.1.311.76.3.1">
szOID_DYNAMIC_CODE_GEN_SIGNER	equ <"1.3.6.1.4.1.311.76.5.1">
szOID_MICROSOFT_PUBLISHER_SIGNER equ <"1.3.6.1.4.1.311.76.8.1">

szOID_YESNO_TRUST_ATTR		equ <"1.3.6.1.4.1.311.10.4.1">
szOID_PKIX_POLICY_QUALIFIER_CPS equ <"1.3.6.1.5.5.7.2.1">
szOID_PKIX_POLICY_QUALIFIER_USERNOTICE equ <"1.3.6.1.5.5.7.2.2">
szOID_ROOT_PROGRAM_FLAGS	equ <"1.3.6.1.4.1.311.60.1.1">

CERT_ROOT_PROGRAM_FLAG_ORG	    equ 0x80
CERT_ROOT_PROGRAM_FLAG_LSC	    equ 0x40
CERT_ROOT_PROGRAM_FLAG_SUBJECT_LOGO equ 0x20
CERT_ROOT_PROGRAM_FLAG_OU	    equ 0x10
CERT_ROOT_PROGRAM_FLAG_ADDRESS	    equ 0x08

szOID_CERT_POLICIES_95_QUALIFIER1   equ <"2.16.840.1.113733.1.7.1.1">

szOID_RDN_TPM_MANUFACTURER	    equ <"2.23.133.2.1">
szOID_RDN_TPM_MODEL		    equ <"2.23.133.2.2">
szOID_RDN_TPM_VERSION		    equ <"2.23.133.2.3">

szOID_ENROLL_EK_INFO		    equ <"1.3.6.1.4.1.311.21.23">
szOID_ENROLL_ATTESTATION_STATEMENT  equ <"1.3.6.1.4.1.311.21.24">
szOID_ENROLL_KSP_NAME		    equ <"1.3.6.1.4.1.311.21.25">

szOID_ENROLL_EKPUB_CHALLENGE	    equ <"1.3.6.1.4.1.311.21.26">
szOID_ENROLL_CAXCHGCERT_HASH	    equ <"1.3.6.1.4.1.311.21.27">
szOID_ENROLL_ATTESTATION_CHALLENGE  equ <"1.3.6.1.4.1.311.21.28">
szOID_ENROLL_ENCRYPTION_ALGORITHM   equ <"1.3.6.1.4.1.311.21.29">

szOID_KP_TPM_EK_CERTIFICATE	    equ <"2.23.133.8.1">
szOID_KP_TPM_PLATFORM_CERTIFICATE   equ <"2.23.133.8.2">
szOID_KP_TPM_AIK_CERTIFICATE	    equ <"2.23.133.8.3">

szOID_ENROLL_EKVERIFYKEY	    equ <"1.3.6.1.4.1.311.21.30">
szOID_ENROLL_EKVERIFYCERT	    equ <"1.3.6.1.4.1.311.21.31">
szOID_ENROLL_EKVERIFYCREDS	    equ <"1.3.6.1.4.1.311.21.32">

szOID_ENROLL_SCEP_ERROR		    equ <"1.3.6.1.4.1.311.21.33">

szOID_ATTR_SUPPORTED_ALGORITHMS	    equ <"2.5.4.52">
szOID_ATTR_TPM_SPECIFICATION	    equ <"2.23.133.2.16">
szOID_ATTR_TPM_SECURITY_ASSERTIONS  equ <"2.23.133.2.18">


CERT_EXTENSIONS		STRUC
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CERT_EXTENSIONS		ENDS
PCERT_EXTENSIONS	typedef ptr CERT_EXTENSIONS

CERT_UNICODE_RDN_ERR_INDEX_MASK equ 0x3FF
CERT_UNICODE_RDN_ERR_INDEX_SHIFT equ 22
CERT_UNICODE_ATTR_ERR_INDEX_MASK equ 0x003F
CERT_UNICODE_ATTR_ERR_INDEX_SHIFT equ 16
CERT_UNICODE_VALUE_ERR_INDEX_MASK equ 0x0000FFFF
CERT_UNICODE_VALUE_ERR_INDEX_SHIFT equ 0

GET_CERT_UNICODE_RDN_ERR_INDEX macro X
	exitm<((X SHR CERT_UNICODE_RDN_ERR_INDEX_SHIFT) AND CERT_UNICODE_RDN_ERR_INDEX_MASK)>
	endm
GET_CERT_UNICODE_ATTR_ERR_INDEX macro X
	exitm<((X SHR CERT_UNICODE_ATTR_ERR_INDEX_SHIFT) AND CERT_UNICODE_ATTR_ERR_INDEX_MASK)>
	endm
GET_CERT_UNICODE_VALUE_ERR_INDEX macro X
	exitm<(X AND CERT_UNICODE_VAUE_ERR_INDEX_MASK)>
	endm

CERT_AUTHORITY_KEY_ID_INFO STRUC
KeyId			CRYPT_DATA_BLOB <>
CertIssuer		CERT_NAME_BLOB <>
CertSerialNumber	CRYPT_INTEGER_BLOB <>
CERT_AUTHORITY_KEY_ID_INFO ENDS
PCERT_AUTHORITY_KEY_ID_INFO typedef ptr CERT_AUTHORITY_KEY_ID_INFO

CERT_PRIVATE_KEY_VALIDITY STRUC
NotBefore		FILETIME <>
NotAfter		FILETIME <>
CERT_PRIVATE_KEY_VALIDITY ENDS
PCERT_PRIVATE_KEY_VALIDITY typedef ptr CERT_PRIVATE_KEY_VALIDITY

CERT_KEY_ATTRIBUTES_INFO  STRUC
KeyId			CRYPT_DATA_BLOB <>
IntendedKeyUsage	CRYPT_BIT_BLOB <>
pPrivateKeyUsagePeriod	PCERT_PRIVATE_KEY_VALIDITY ?
CERT_KEY_ATTRIBUTES_INFO ENDS
PCERT_KEY_ATTRIBUTES_INFO typedef ptr CERT_KEY_ATTRIBUTES_INFO

CERT_DIGITAL_SIGNATURE_KEY_USAGE equ 0x80
CERT_NON_REPUDIATION_KEY_USAGE equ 0x40
CERT_KEY_ENCIPHERMENT_KEY_USAGE equ 0x20
CERT_DATA_ENCIPHERMENT_KEY_USAGE equ 0x10
CERT_KEY_AGREEMENT_KEY_USAGE equ 0x08
CERT_KEY_CERT_SIGN_KEY_USAGE equ 0x04
CERT_OFFLINE_CRL_SIGN_KEY_USAGE equ 0x02
CERT_ENCIPHER_ONLY_KEY_USAGE equ 0x01
CERT_CRL_SIGN_KEY_USAGE equ 0x02

CERT_DECIPHER_ONLY_KEY_USAGE equ 0x80

CERT_POLICY_ID		STRUC
cCertPolicyElementId	dd ?
rgpszCertPolicyElementId LPSTR ?
CERT_POLICY_ID		ENDS
PCERT_POLICY_ID		typedef ptr CERT_POLICY_ID

CERT_KEY_USAGE_RESTRICTION_INFO	 STRUC
cCertPolicyId		dd ?
rgCertPolicyId		PCERT_POLICY_ID ?
RestrictedKeyUsage	CRYPT_BIT_BLOB <>
CERT_KEY_USAGE_RESTRICTION_INFO ENDS
PCERT_KEY_USAGE_RESTRICTION_INFO typedef ptr CERT_KEY_USAGE_RESTRICTION_INFO



CERT_ALT_NAME_ENTRY	STRUC
dwAltNameChoice		dd ?
UNION
  pwszRfc822Name	LPWSTR ?
  pwszDNSName		LPWSTR ?
  DirectoryName		CERT_NAME_BLOB <>
  pwszURL		LPWSTR ?
  IPAddress		CRYPT_DATA_BLOB <>
  pszRegisteredID	LPSTR ?
ENDS
CERT_ALT_NAME_ENTRY	ENDS
PCERT_ALT_NAME_ENTRY	typedef ptr CERT_ALT_NAME_ENTRY

CERT_ALT_NAME_OTHER_NAME equ 1
CERT_ALT_NAME_RFC822_NAME equ 2
CERT_ALT_NAME_DNS_NAME	equ 3
CERT_ALT_NAME_X400_ADDRESS equ 4
CERT_ALT_NAME_DIRECTORY_NAME equ 5
CERT_ALT_NAME_EDI_PARTY_NAME equ 6
CERT_ALT_NAME_URL	equ 7
CERT_ALT_NAME_IP_ADDRESS equ 8
CERT_ALT_NAME_REGISTERED_ID equ 9


CERT_ALT_NAME_INFO	STRUC
cAltEntry		dd ?
rgAltEntry		PCERT_ALT_NAME_ENTRY ?
CERT_ALT_NAME_INFO	ENDS
PCERT_ALT_NAME_INFO	typedef ptr CERT_ALT_NAME_INFO

CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK equ 0xFF
CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT equ 16
CERT_ALT_NAME_VALUE_ERR_INDEX_MASK equ 0x0000FFFF
CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT equ 0

GET_CERT_ALT_NAME_ENTRY_ERR_INDEX macro X
	exitm<((X SHR CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) AND CERT_AT_NAME_ENTRY_ERR_INDEX_MASK)>
	endm
GET_CERT_ALT_NAME_VALUE_ERR_INDEX macro X
	exitm<(X AND CERT_ALT_NAME_VAUE_ERR_INDEX_MASK)>
	endm


CERT_BASIC_CONSTRAINTS_INFO  STRUC
SubjectType		CRYPT_BIT_BLOB <>
fPathLenConstraint	BOOL ?
dwPathLenConstraint	dd ?
cSubtreesConstraint	dd ?
rgSubtreesConstraint	PVOID ?; CERT_NAME_BLOB ?
CERT_BASIC_CONSTRAINTS_INFO ENDS
PCERT_BASIC_CONSTRAINTS_INFO typedef ptr CERT_BASIC_CONSTRAINTS_INFO

CERT_CA_SUBJECT_FLAG	equ 0x80
CERT_END_ENTITY_SUBJECT_FLAG equ 0x40

CERT_BASIC_CONSTRAINTS2_INFO  STRUC
fCA			BOOL ?
fPathLenConstraint	BOOL ?
dwPathLenConstraint	dd ?
CERT_BASIC_CONSTRAINTS2_INFO ENDS
PCERT_BASIC_CONSTRAINTS2_INFO typedef ptr CERT_BASIC_CONSTRAINTS2_INFO


CERT_POLICY_QUALIFIER_INFO  STRUC
pszPolicyQualifierId	LPSTR ?
Qualifier		CRYPT_OBJID_BLOB <>
CERT_POLICY_QUALIFIER_INFO ENDS
PCERT_POLICY_QUALIFIER_INFO typedef ptr CERT_POLICY_QUALIFIER_INFO

CERT_POLICY_INFO	STRUC
pszPolicyIdentifier	LPSTR ?
cPolicyQualifier	dd ?
rgPolicyQualifier	PVOID ?; CERT_POLICY_QUALIFIER_INFO ?
CERT_POLICY_INFO	ENDS
PCERT_POLICY_INFO	typedef ptr CERT_POLICY_INFO

CERT_POLICIES_INFO	STRUC
cPolicyInfo		dd ?
rgPolicyInfo		PVOID ?;ptr CERT_POLICY_INFO ?
CERT_POLICIES_INFO	ENDS
PCERT_POLICIES_INFO	typedef ptr CERT_POLICIES_INFO

CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY  STRUC
pszObjId		LPSTR ?
cValue			dd ?
rgValue			PCRYPT_DER_BLOB ?
CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY ENDS
PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY typedef ptr CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY

CRYPT_CONTENT_INFO	STRUC
pszObjId		LPSTR ?
Content			CRYPT_DER_BLOB <>
CRYPT_CONTENT_INFO	ENDS
PCRYPT_CONTENT_INFO	typedef ptr CRYPT_CONTENT_INFO

CRYPT_SEQUENCE_OF_ANY	STRUC
cValue			dd ?
rgValue			PCRYPT_DER_BLOB ?
CRYPT_SEQUENCE_OF_ANY	ENDS
PCRYPT_SEQUENCE_OF_ANY	typedef ptr CRYPT_SEQUENCE_OF_ANY


CERT_AUTHORITY_KEY_ID2_INFO  STRUC
KeyId			CRYPT_DATA_BLOB <>
AuthorityCertIssuer	CERT_ALT_NAME_INFO <>
AuthorityCertSerialNumber CRYPT_INTEGER_BLOB <>
CERT_AUTHORITY_KEY_ID2_INFO ENDS
PCERT_AUTHORITY_KEY_ID2_INFO typedef ptr CERT_AUTHORITY_KEY_ID2_INFO

CERT_ACCESS_DESCRIPTION STRUC
pszAccessMethod		LPSTR ?
AccessLocation		CERT_ALT_NAME_ENTRY <>
CERT_ACCESS_DESCRIPTION ENDS
PCERT_ACCESS_DESCRIPTION typedef ptr CERT_ACCESS_DESCRIPTION


CERT_AUTHORITY_INFO_ACCESS STRUC
cAccDescr		dd ?
rgAccDescr		PCERT_ACCESS_DESCRIPTION ?
CERT_AUTHORITY_INFO_ACCESS ENDS
PCERT_AUTHORITY_INFO_ACCESS typedef ptr CERT_AUTHORITY_INFO_ACCESS
CERT_SUBJECT_INFO_ACCESS    typedef CERT_AUTHORITY_INFO_ACCESS
PCERT_SUBJECT_INFO_ACCESS   typedef ptr CERT_AUTHORITY_INFO_ACCESS


szOID_PKIX_ACC_DESCR	equ <"1.3.6.1.5.5.7.48">

szOID_PKIX_OCSP		equ <"1.3.6.1.5.5.7.48.1">
szOID_PKIX_CA_ISSUERS	equ <"1.3.6.1.5.5.7.48.2">

szOID_PKIX_TIME_STAMPING equ <"1.3.6.1.5.5.7.48.3">
szOID_PKIX_CA_REPOSITORY equ <"1.3.6.1.5.5.7.48.5">


CRL_REASON_UNSPECIFIED		equ 0
CRL_REASON_KEY_COMPROMISE	equ 1
CRL_REASON_CA_COMPROMISE	equ 2
CRL_REASON_AFFILIATION_CHANGED	equ 3
CRL_REASON_SUPERSEDED		equ 4
CRL_REASON_CESSATION_OF_OPERATION equ 5
CRL_REASON_CERTIFICATE_HOLD	equ 6
CRL_REASON_REMOVE_FROM_CRL	equ 8


CRL_DIST_POINT_NAME	STRUC
dwDistPointNameChoice	dd ?
;UNION
  FullName		CERT_ALT_NAME_INFO <>
; IssuerRDN		Not implemented
;ENDS
CRL_DIST_POINT_NAME	ENDS
PCRL_DIST_POINT_NAME	typedef ptr CRL_DIST_POINT_NAME

CRL_DIST_POINT_NO_NAME		equ 0
CRL_DIST_POINT_FULL_NAME	equ 1
CRL_DIST_POINT_ISSUER_RDN_NAME	equ 2

CRL_DIST_POINT		STRUC
DistPointName		CRL_DIST_POINT_NAME <>
ReasonFlags		CRYPT_BIT_BLOB <>
CRLIssuer		CERT_ALT_NAME_INFO <>
CRL_DIST_POINT		ENDS
PCRL_DIST_POINT		typedef ptr CRL_DIST_POINT

CRL_REASON_UNUSED_FLAG		equ 0x80
CRL_REASON_KEY_COMPROMISE_FLAG	equ 0x40
CRL_REASON_CA_COMPROMISE_FLAG	equ 0x20
CRL_REASON_AFFILIATION_CHANGED_FLAG equ 0x10
CRL_REASON_SUPERSEDED_FLAG	equ 0x08
CRL_REASON_CESSATION_OF_OPERATION_FLAG equ 0x04
CRL_REASON_CERTIFICATE_HOLD_FLAG equ 0x02

CRL_DIST_POINTS_INFO	STRUC
cDistPoint		dd ?
rgDistPoint		PCRL_DIST_POINT ?
CRL_DIST_POINTS_INFO	ENDS
PCRL_DIST_POINTS_INFO	typedef ptr CRL_DIST_POINTS_INFO

CRL_DIST_POINT_ERR_INDEX_MASK	equ 0x7F
CRL_DIST_POINT_ERR_INDEX_SHIFT	equ 24
GET_CRL_DIST_POINT_ERR_INDEX macro X
	exitm<((X SHR CRL_DIST_POINT_ERR_INDEX_SHIFT) AND CRL_DIST_POINT_ERR_INDEX_MASK)>
	endm

CRL_DIST_POINT_ERR_CRL_ISSUER_BIT equ 0x80000000
IS_CRL_DIST_POINT_ERR_CRL_ISSUER macro X
	exitm<(X AND CRL_DIST_POINT_ERR_CRL_ISSUER_BIT)>
	endm

CROSS_CERT_DIST_POINTS_INFO STRUC
dwSyncDeltaTime		dd ?
cDistPoint		dd ?
rgDistPoint		PCERT_ALT_NAME_INFO ?
CROSS_CERT_DIST_POINTS_INFO ENDS
PCROSS_CERT_DIST_POINTS_INFO typedef ptr CROSS_CERT_DIST_POINTS_INFO

CROSS_CERT_DIST_POINT_ERR_INDEX_MASK equ 0xFF
CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT equ 24
GET_CROSS_CERT_DIST_POINT_ERR_INDEX macro X
    exitm<((X shr CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT) and CROSS_CERT_DIST_POINT_ERR_INDEX_MASK)>
    endm

CERT_PAIR		STRUC
Forward			CERT_BLOB <>
Reverse			CERT_BLOB <>
CERT_PAIR		ENDS
PCERT_PAIR		typedef ptr CERT_PAIR

CRL_ISSUING_DIST_POINT	STRUC
DistPointName		CRL_DIST_POINT_NAME <>
fOnlyContainsUserCerts	BOOL ?
fOnlyContainsCACerts	BOOL ?
OnlySomeReasonFlags	CRYPT_BIT_BLOB <>
fIndirectCRL		BOOL ?
CRL_ISSUING_DIST_POINT	ENDS
PCRL_ISSUING_DIST_POINT typedef ptr CRL_ISSUING_DIST_POINT

CERT_GENERAL_SUBTREE	STRUC
Base			CERT_ALT_NAME_ENTRY <>
dwMinimum		dd ?
fMaximum		BOOL ?
dwMaximum		dd ?
CERT_GENERAL_SUBTREE	ENDS
PCERT_GENERAL_SUBTREE	typedef ptr CERT_GENERAL_SUBTREE

CERT_NAME_CONSTRAINTS_INFO STRUC
cPermittedSubtree	dd ?
rgPermittedSubtree	PCERT_GENERAL_SUBTREE ?
cExcludedSubtree	dd ?
rgExcludedSubtree	PCERT_GENERAL_SUBTREE ?
CERT_NAME_CONSTRAINTS_INFO ENDS
PCERT_NAME_CONSTRAINTS_INFO typedef ptr CERT_NAME_CONSTRAINTS_INFO

CERT_EXCLUDED_SUBTREE_BIT equ 0x80000000
IS_CERT_EXCLUDED_SUBTREE macro X
    exitm<(X and CERT_EXCLUDED_SUBTREE_BIT)>
    endm

SORTED_CTL_EXT_FLAGS_OFFSET	    equ (0*4)
SORTED_CTL_EXT_COUNT_OFFSET	    equ (1*4)
SORTED_CTL_EXT_MAX_COLLISION_OFFSET equ (2*4)
SORTED_CTL_EXT_HASH_BUCKET_OFFSET   equ (3*4)

SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG equ 0x1

CERT_DSS_PARAMETERS	STRUC
p			CRYPT_UINT_BLOB <>
q			CRYPT_UINT_BLOB <>
g			CRYPT_UINT_BLOB <>
CERT_DSS_PARAMETERS	ENDS
PCERT_DSS_PARAMETERS	typedef ptr CERT_DSS_PARAMETERS

CERT_DSS_R_LEN		equ 20
CERT_DSS_S_LEN		equ 20
CERT_DSS_SIGNATURE_LEN	equ (CERT_DSS_R_LEN + CERT_DSS_S_LEN)

CERT_MAX_ASN_ENCODED_DSS_SIGNATURE_LEN equ (2 + 2 * (2 + 20 + 1))

CERT_DH_PARAMETERS	STRUC
p			CRYPT_UINT_BLOB <>
g			CRYPT_UINT_BLOB <>
CERT_DH_PARAMETERS	ENDS
PCERT_DH_PARAMETERS	typedef ptr CERT_DH_PARAMETERS

CERT_ECC_SIGNATURE	STRUC
r			CRYPT_UINT_BLOB <>
s			CRYPT_UINT_BLOB <>
CERT_ECC_SIGNATURE	ENDS
PCERT_ECC_SIGNATURE	typedef ptr CERT_ECC_SIGNATURE

CERT_X942_DH_VALIDATION_PARAMS STRUC
seed			CRYPT_BIT_BLOB <>
pgenCounter		dd ?
CERT_X942_DH_VALIDATION_PARAMS ENDS
PCERT_X942_DH_VALIDATION_PARAMS typedef ptr CERT_X942_DH_VALIDATION_PARAMS

CERT_X942_DH_PARAMETERS STRUC
p			CRYPT_UINT_BLOB <>
g			CRYPT_UINT_BLOB <>
q			CRYPT_UINT_BLOB <>
j			CRYPT_UINT_BLOB <>
pValidationParams	PCERT_X942_DH_VALIDATION_PARAMS ?
CERT_X942_DH_PARAMETERS ENDS
PCERT_X942_DH_PARAMETERS typedef ptr CERT_X942_DH_PARAMETERS

CRYPT_RC2_CBC_PARAMETERS STRUC
dwVersion		dd ?
fIV			BOOL ?
rgbIV			db 8 dup(?)
CRYPT_RC2_CBC_PARAMETERS ENDS
PCRYPT_RC2_CBC_PARAMETERS typedef ptr CRYPT_RC2_CBC_PARAMETERS

CRYPT_X942_COUNTER_BYTE_LENGTH	    equ 4
CRYPT_X942_KEY_LENGTH_BYTE_LENGTH   equ 4
CRYPT_X942_PUB_INFO_BYTE_LENGTH	    equ (512/8)

CRYPT_X942_OTHER_INFO	STRUC
pszContentEncryptionObjId LPSTR ?
rgbCounter		db CRYPT_X942_COUNTER_BYTE_LENGTH dup(?)
rgbKeyLength		db CRYPT_X942_KEY_LENGTH_BYTE_LENGTH dup(?)
PubInfo			CRYPT_DATA_BLOB <>
CRYPT_X942_OTHER_INFO	ENDS
PCRYPT_X942_OTHER_INFO	typedef ptr CRYPT_X942_OTHER_INFO

CRYPT_ECC_CMS_SHARED_INFO_SUPPPUBINFO_BYTE_LENGTH equ 4
CRYPT_ECC_CMS_SHARED_INFO STRUC
Algorithm		CRYPT_ALGORITHM_IDENTIFIER <>
EntityUInfo		CRYPT_DATA_BLOB <>
rgbSuppPubInfo		db CRYPT_ECC_CMS_SHARED_INFO_SUPPPUBINFO_BYTE_LENGTH dup(?)
CRYPT_ECC_CMS_SHARED_INFO ENDS
PCRYPT_ECC_CMS_SHARED_INFO typedef ptr CRYPT_ECC_CMS_SHARED_INFO


CRYPT_RC2_CBC_PARAMETERS STRUC
dwVersion		dd ?
fIV			BOOL ?
rgbIV			db 8 dup(?)
CRYPT_RC2_CBC_PARAMETERS ENDS
PCRYPT_RC2_CBC_PARAMETERS typedef ptr CRYPT_RC2_CBC_PARAMETERS

CRYPT_RC2_40BIT_VERSION	 equ 160
CRYPT_RC2_56BIT_VERSION	 equ 52
CRYPT_RC2_64BIT_VERSION	 equ 120
CRYPT_RC2_128BIT_VERSION equ 58

CRYPT_RC2_40BIT_VERSION	 equ 160
CRYPT_RC2_64BIT_VERSION	 equ 120
CRYPT_RC2_128BIT_VERSION equ 58


CRYPT_SMIME_CAPABILITY	STRUC
pszObjId		LPSTR ?
Parameters		CRYPT_OBJID_BLOB <>
CRYPT_SMIME_CAPABILITY	ENDS
PCRYPT_SMIME_CAPABILITY typedef ptr CRYPT_SMIME_CAPABILITY

CRYPT_SMIME_CAPABILITIES  STRUC
cCapability		dd ?
rgCapability		PCRYPT_SMIME_CAPABILITY ?
CRYPT_SMIME_CAPABILITIES ENDS
PCRYPT_SMIME_CAPABILITIES typedef ptr CRYPT_SMIME_CAPABILITIES

CERT_QC_STATEMENT	STRUC
pszStatementId		LPSTR ?
StatementInfo		CRYPT_OBJID_BLOB <>
CERT_QC_STATEMENT	ENDS
PCERT_QC_STATEMENT	typedef ptr CERT_QC_STATEMENT

CERT_QC_STATEMENTS_EXT_INFO STRUC
cStatement		dd ?
rgStatement		PCERT_QC_STATEMENT ?
CERT_QC_STATEMENTS_EXT_INFO ENDS
PCERT_QC_STATEMENTS_EXT_INFO typedef ptr CERT_QC_STATEMENTS_EXT_INFO


szOID_QC_EU_COMPLIANCE	equ <"0.4.0.1862.1.1">
szOID_QC_SSCD		equ <"0.4.0.1862.1.4">

CRYPT_MASK_GEN_ALGORITHM STRUC
pszObjId		LPSTR ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
CRYPT_MASK_GEN_ALGORITHM ENDS
PCRYPT_MASK_GEN_ALGORITHM typedef ptr CRYPT_MASK_GEN_ALGORITHM

CRYPT_RSA_SSA_PSS_PARAMETERS STRUC
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
MaskGenAlgorithm	CRYPT_MASK_GEN_ALGORITHM <>
dwSaltLength		dd ?
dwTrailerField		dd ?
CRYPT_RSA_SSA_PSS_PARAMETERS ENDS
PCRYPT_RSA_SSA_PSS_PARAMETERS typedef ptr CRYPT_RSA_SSA_PSS_PARAMETERS

PKCS_RSA_SSA_PSS_TRAILER_FIELD_BC equ 1

CRYPT_PSOURCE_ALGORITHM STRUC
pszObjId		LPSTR ?
EncodingParameters	CRYPT_DATA_BLOB <>
CRYPT_PSOURCE_ALGORITHM ENDS
PCRYPT_PSOURCE_ALGORITHM typedef ptr CRYPT_PSOURCE_ALGORITHM

CRYPT_RSAES_OAEP_PARAMETERS STRUC
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
MaskGenAlgorithm	CRYPT_MASK_GEN_ALGORITHM <>
PSourceAlgorithm	CRYPT_PSOURCE_ALGORITHM <>
CRYPT_RSAES_OAEP_PARAMETERS ENDS
PCRYPT_RSAES_OAEP_PARAMETERS typedef ptr CRYPT_RSAES_OAEP_PARAMETERS

szOID_VERISIGN_PRIVATE_6_9		equ <"2.16.840.1.113733.1.6.9">
szOID_VERISIGN_ONSITE_JURISDICTION_HASH equ <"2.16.840.1.113733.1.6.11">
szOID_VERISIGN_BITSTRING_6_13		equ <"2.16.840.1.113733.1.6.13">
szOID_VERISIGN_ISS_STRONG_CRYPTO	equ <"2.16.840.1.113733.1.8.1">

szOIDVerisign_MessageType	equ <"2.16.840.1.113733.1.9.2">
szOIDVerisign_PkiStatus		equ <"2.16.840.1.113733.1.9.3">
szOIDVerisign_FailInfo		equ <"2.16.840.1.113733.1.9.4">

szOIDVerisign_SenderNonce	equ <"2.16.840.1.113733.1.9.5">
szOIDVerisign_RecipientNonce	equ <"2.16.840.1.113733.1.9.6">

szOIDVerisign_TransactionID	equ <"2.16.840.1.113733.1.9.7">

szOID_NETSCAPE			equ <"2.16.840.1.113730">
szOID_NETSCAPE_CERT_EXTENSION	equ <"2.16.840.1.113730.1">
szOID_NETSCAPE_CERT_TYPE	equ <"2.16.840.1.113730.1.1">
szOID_NETSCAPE_BASE_URL		equ <"2.16.840.1.113730.1.2">
szOID_NETSCAPE_REVOCATION_URL	equ <"2.16.840.1.113730.1.3">
szOID_NETSCAPE_CA_REVOCATION_URL equ <"2.16.840.1.113730.1.4">
szOID_NETSCAPE_CERT_RENEWAL_URL equ <"2.16.840.1.113730.1.7">
szOID_NETSCAPE_CA_POLICY_URL	equ <"2.16.840.1.113730.1.8">
szOID_NETSCAPE_SSL_SERVER_NAME	equ <"2.16.840.1.113730.1.12">
szOID_NETSCAPE_COMMENT		equ <"2.16.840.1.113730.1.13">

szOID_NETSCAPE_DATA_TYPE	equ <"2.16.840.1.113730.2">
szOID_NETSCAPE_CERT_SEQUENCE	equ <"2.16.840.1.113730.2.5">


NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE equ 0x80
NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE equ 0x40

NETSCAPE_SMIME_CERT_TYPE	equ 0x20
NETSCAPE_SIGN_CERT_TYPE		equ 0x10
NETSCAPE_SSL_CA_CERT_TYPE	equ 0x04
NETSCAPE_SMIME_CA_CERT_TYPE	equ 0x02
NETSCAPE_SIGN_CA_CERT_TYPE	equ 0x01

szOID_CT_PKI_DATA		equ <"1.3.6.1.5.5.7.12.2">
szOID_CT_PKI_RESPONSE		equ <"1.3.6.1.5.5.7.12.3">
szOID_PKIX_NO_SIGNATURE		equ <"1.3.6.1.5.5.7.6.2">

szOID_CMC			equ <"1.3.6.1.5.5.7.7">
szOID_CMC_STATUS_INFO		equ <"1.3.6.1.5.5.7.7.1">
szOID_CMC_IDENTIFICATION	equ <"1.3.6.1.5.5.7.7.2">
szOID_CMC_IDENTITY_PROOF	equ <"1.3.6.1.5.5.7.7.3">
szOID_CMC_DATA_RETURN		equ <"1.3.6.1.5.5.7.7.4">
szOID_CMC_TRANSACTION_ID	equ <"1.3.6.1.5.5.7.7.5">
szOID_CMC_SENDER_NONCE		equ <"1.3.6.1.5.5.7.7.6">
szOID_CMC_RECIPIENT_NONCE	equ <"1.3.6.1.5.5.7.7.7">
szOID_CMC_ADD_EXTENSIONS	equ <"1.3.6.1.5.5.7.7.8">
szOID_CMC_ENCRYPTED_POP		equ <"1.3.6.1.5.5.7.7.9">
szOID_CMC_DECRYPTED_POP		equ <"1.3.6.1.5.5.7.7.10">
szOID_CMC_LRA_POP_WITNESS	equ <"1.3.6.1.5.5.7.7.11">

szOID_CMC_GET_CERT		equ <"1.3.6.1.5.5.7.7.15">
szOID_CMC_GET_CRL		equ <"1.3.6.1.5.5.7.7.16">
szOID_CMC_REVOKE_REQUEST	equ <"1.3.6.1.5.5.7.7.17">
szOID_CMC_REG_INFO		equ <"1.3.6.1.5.5.7.7.18">
szOID_CMC_RESPONSE_INFO		equ <"1.3.6.1.5.5.7.7.19">

szOID_CMC_QUERY_PENDING		equ <"1.3.6.1.5.5.7.7.21">
szOID_CMC_ID_POP_LINK_RANDOM	equ <"1.3.6.1.5.5.7.7.22">
szOID_CMC_ID_POP_LINK_WITNESS	equ <"1.3.6.1.5.5.7.7.23">
szOID_CMC_ID_CONFIRM_CERT_ACCEPTANCE equ <"1.3.6.1.5.5.7.7.24">

szOID_CMC_ADD_ATTRIBUTES	equ <"1.3.6.1.4.1.311.10.10.1">

CMC_TAGGED_ATTRIBUTE	STRUC
dwBodyPartID		dd ?
Attribute		CRYPT_ATTRIBUTE <>
CMC_TAGGED_ATTRIBUTE	ENDS
PCMC_TAGGED_ATTRIBUTE	typedef ptr CMC_TAGGED_ATTRIBUTE

CMC_TAGGED_CERT_REQUEST STRUC
dwBodyPartID		dd ?
SignedCertRequest	CRYPT_DER_BLOB <>
CMC_TAGGED_CERT_REQUEST ENDS
PCMC_TAGGED_CERT_REQUEST typedef ptr CMC_TAGGED_CERT_REQUEST

CMC_TAGGED_REQUEST	STRUC
dwTaggedRequestChoice	dd ?
;UNION
 pTaggedCertRequest	PCMC_TAGGED_CERT_REQUEST ?
;ENDS
CMC_TAGGED_REQUEST	ENDS
PCMC_TAGGED_REQUEST	typedef ptr CMC_TAGGED_REQUEST

CMC_TAGGED_CERT_REQUEST_CHOICE equ 1

CMC_TAGGED_CONTENT_INFO STRUC
dwBodyPartID		dd ?
EncodedContentInfo	CRYPT_DER_BLOB <>
CMC_TAGGED_CONTENT_INFO ENDS
PCMC_TAGGED_CONTENT_INFO typedef ptr CMC_TAGGED_CONTENT_INFO

CMC_TAGGED_OTHER_MSG	STRUC
dwBodyPartID		dd ?
pszObjId		LPSTR ?
Value			CRYPT_OBJID_BLOB <>
CMC_TAGGED_OTHER_MSG	ENDS
PCMC_TAGGED_OTHER_MSG	typedef ptr CMC_TAGGED_OTHER_MSG

CMC_DATA_INFO		STRUC
cTaggedAttribute	dd ?
rgTaggedAttribute	PCMC_TAGGED_ATTRIBUTE ?
cTaggedRequest		dd ?
rgTaggedRequest		PCMC_TAGGED_REQUEST ?
cTaggedContentInfo	dd ?
rgTaggedContentInfo	PCMC_TAGGED_CONTENT_INFO ?
cTaggedOtherMsg		dd ?
rgTaggedOtherMsg	PCMC_TAGGED_OTHER_MSG ?
CMC_DATA_INFO		ENDS
PCMC_DATA_INFO		typedef ptr CMC_DATA_INFO

CMC_RESPONSE_INFO	STRUC
cTaggedAttribute	dd ?
rgTaggedAttribute	PCMC_TAGGED_ATTRIBUTE ?
cTaggedContentInfo	dd ?
rgTaggedContentInfo	PCMC_TAGGED_CONTENT_INFO ?
cTaggedOtherMsg		dd ?
rgTaggedOtherMsg	PCMC_TAGGED_OTHER_MSG ?
CMC_RESPONSE_INFO	ENDS
PCMC_RESPONSE_INFO	typedef ptr CMC_RESPONSE_INFO

CMC_PEND_INFO		STRUC
PendToken		CRYPT_DATA_BLOB <>
PendTime		FILETIME <>
CMC_PEND_INFO		ENDS
PCMC_PEND_INFO		typedef ptr CMC_PEND_INFO

CMC_STATUS_INFO		STRUC
dwStatus		dd ?
cBodyList		dd ?
rgdwBodyList		LPDWORD ?
pwszStatusString	LPWSTR ?
dwOtherInfoChoice	dd ?
UNION
 dwFailInfo		dd ?
 pPendInfo		PCMC_PEND_INFO ?
ENDS
CMC_STATUS_INFO		ENDS
PCMC_STATUS_INFO	typedef ptr CMC_STATUS_INFO

CMC_OTHER_INFO_NO_CHOICE   equ 0
CMC_OTHER_INFO_FAIL_CHOICE equ 1
CMC_OTHER_INFO_PEND_CHOICE equ 2

CMC_STATUS_SUCCESS	    equ 0
CMC_STATUS_FAILED	    equ 2
CMC_STATUS_PENDING	    equ 3
CMC_STATUS_NO_SUPPORT	    equ 4
CMC_STATUS_CONFIRM_REQUIRED equ 5

CMC_FAIL_BAD_ALG	    equ 0
CMC_FAIL_BAD_MESSAGE_CHECK  equ 1
CMC_FAIL_BAD_REQUEST	    equ 2
CMC_FAIL_BAD_TIME	    equ 3
CMC_FAIL_BAD_CERT_ID	    equ 4
CMC_FAIL_UNSUPORTED_EXT	    equ 5
CMC_FAIL_MUST_ARCHIVE_KEYS  equ 6
CMC_FAIL_BAD_IDENTITY	    equ 7
CMC_FAIL_POP_REQUIRED	    equ 8
CMC_FAIL_POP_FAILED	    equ 9
CMC_FAIL_NO_KEY_REUSE	    equ 10

CMC_FAIL_INTERNAL_CA_ERROR  equ 11

CMC_FAIL_TRY_LATER	    equ 12


CMC_ADD_EXTENSIONS_INFO STRUC
dwCmcDataReference	dd ?
cCertReference		dd ?
rgdwCertReference	LPDWORD ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CMC_ADD_EXTENSIONS_INFO ENDS
PCMC_ADD_EXTENSIONS_INFO typedef ptr CMC_ADD_EXTENSIONS_INFO

CMC_ADD_ATTRIBUTES_INFO STRUC
dwCmcDataReference	dd ?
cCertReference		dd ?
rgdwCertReference	LPDWORD ?
cAttribute		dd ?
rgAttribute		PCRYPT_ATTRIBUTE ?
CMC_ADD_ATTRIBUTES_INFO ENDS
PCMC_ADD_ATTRIBUTES_INFO typedef ptr CMC_ADD_ATTRIBUTES_INFO


CERT_TEMPLATE_EXT	STRUC
pszObjId		LPSTR ?
dwMajorVersion		dd ?
fMinorVersion		BOOL ?
dwMinorVersion		dd ?
CERT_TEMPLATE_EXT	ENDS
PCERT_TEMPLATE_EXT	typedef ptr CERT_TEMPLATE_EXT

CERT_HASHED_URL		STRUC
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
Hash			CRYPT_HASH_BLOB <>
pwszUrl			LPWSTR ?
CERT_HASHED_URL		ENDS
PCERT_HASHED_URL	typedef ptr CERT_HASHED_URL

CERT_LOGOTYPE_DETAILS	STRUC
pwszMimeType		LPWSTR ?
cHashedUrl		dd ?
rgHashedUrl		PCERT_HASHED_URL ?
CERT_LOGOTYPE_DETAILS	ENDS
PCERT_LOGOTYPE_DETAILS	typedef ptr CERT_LOGOTYPE_DETAILS

CERT_LOGOTYPE_REFERENCE STRUC
cHashedUrl		dd ?
rgHashedUrl		PCERT_HASHED_URL ?
CERT_LOGOTYPE_REFERENCE ENDS
PCERT_LOGOTYPE_REFERENCE typedef ptr CERT_LOGOTYPE_REFERENCE

CERT_LOGOTYPE_IMAGE_INFO STRUC
dwLogotypeImageInfoChoice dd ?
dwFileSize		dd ?
dwXSize			dd ?
dwYSize			dd ?
dwLogotypeImageResolutionChoice dd ?
UNION
 dwNumBits		dd ?
 dwTableSize		dd ?
ENDS
pwszLanguage		LPWSTR ?
CERT_LOGOTYPE_IMAGE_INFO ENDS
PCERT_LOGOTYPE_IMAGE_INFO typedef ptr CERT_LOGOTYPE_IMAGE_INFO

CERT_LOGOTYPE_GRAY_SCALE_IMAGE_INFO_CHOICE	    equ 1
CERT_LOGOTYPE_COLOR_IMAGE_INFO_CHOICE		    equ 2

CERT_LOGOTYPE_NO_IMAGE_RESOLUTION_CHOICE	    equ 0
CERT_LOGOTYPE_BITS_IMAGE_RESOLUTION_CHOICE	    equ 1
CERT_LOGOTYPE_TABLE_SIZE_IMAGE_RESOLUTION_CHOICE    equ 2

CERT_LOGOTYPE_IMAGE	STRUC
LogotypeDetails		CERT_LOGOTYPE_DETAILS <>
pLogotypeImageInfo	PCERT_LOGOTYPE_IMAGE_INFO ?
CERT_LOGOTYPE_IMAGE	ENDS
PCERT_LOGOTYPE_IMAGE	typedef ptr CERT_LOGOTYPE_IMAGE


CERT_LOGOTYPE_AUDIO_INFO STRUC
dwFileSize		dd ?
dwPlayTime		dd ?
dwChannels		dd ?
dwSampleRate		dd ?
pwszLanguage		LPWSTR ?
CERT_LOGOTYPE_AUDIO_INFO ENDS
PCERT_LOGOTYPE_AUDIO_INFO typedef ptr CERT_LOGOTYPE_AUDIO_INFO

CERT_LOGOTYPE_AUDIO	STRUC
LogotypeDetails		CERT_LOGOTYPE_DETAILS <>
pLogotypeAudioInfo	PCERT_LOGOTYPE_AUDIO_INFO ?
CERT_LOGOTYPE_AUDIO	ENDS
PCERT_LOGOTYPE_AUDIO	typedef ptr CERT_LOGOTYPE_AUDIO

CERT_LOGOTYPE_DATA	STRUC
cLogotypeImage		dd ?
rgLogotypeImage		PCERT_LOGOTYPE_IMAGE ?
cLogotypeAudio		dd ?
rgLogotypeAudio		PCERT_LOGOTYPE_AUDIO ?
CERT_LOGOTYPE_DATA	ENDS
PCERT_LOGOTYPE_DATA	typedef ptr CERT_LOGOTYPE_DATA


CERT_LOGOTYPE_INFO	STRUC
dwLogotypeInfoChoice	dd ?
UNION
 pLogotypeDirectInfo	PCERT_LOGOTYPE_DATA ?
 pLogotypeIndirectInfo	PCERT_LOGOTYPE_REFERENCE ?
ENDS
CERT_LOGOTYPE_INFO	ENDS
PCERT_LOGOTYPE_INFO	typedef ptr CERT_LOGOTYPE_INFO

CERT_LOGOTYPE_DIRECT_INFO_CHOICE    equ 1
CERT_LOGOTYPE_INDIRECT_INFO_CHOICE  equ 2

CERT_OTHER_LOGOTYPE_INFO STRUC
pszObjId		LPSTR ?
LogotypeInfo		CERT_LOGOTYPE_INFO <>
CERT_OTHER_LOGOTYPE_INFO ENDS
PCERT_OTHER_LOGOTYPE_INFO typedef ptr CERT_OTHER_LOGOTYPE_INFO

szOID_LOYALTY_OTHER_LOGOTYPE	equ <"1.3.6.1.5.5.7.20.1">
szOID_BACKGROUND_OTHER_LOGOTYPE equ <"1.3.6.1.5.5.7.20.2">

CERT_LOGOTYPE_EXT_INFO	STRUC
cCommunityLogo		dd ?
rgCommunityLogo		PCERT_LOGOTYPE_INFO ?
pIssuerLogo		PCERT_LOGOTYPE_INFO ?
pSubjectLogo		PCERT_LOGOTYPE_INFO ?
cOtherLogo		dd ?
rgOtherLogo		PCERT_OTHER_LOGOTYPE_INFO ?
CERT_LOGOTYPE_EXT_INFO	ENDS
PCERT_LOGOTYPE_EXT_INFO typedef ptr CERT_LOGOTYPE_EXT_INFO

CERT_BIOMETRIC_DATA	STRUC
dwTypeOfBiometricDataChoice dd ?
UNION
 dwPredefined		dd ?
 pszObjId		LPSTR ?
ENDS
HashedUrl		CERT_HASHED_URL <>
CERT_BIOMETRIC_DATA	ENDS
PCERT_BIOMETRIC_DATA	typedef ptr CERT_BIOMETRIC_DATA

CERT_BIOMETRIC_PREDEFINED_DATA_CHOICE	equ 1
CERT_BIOMETRIC_OID_DATA_CHOICE		equ 2

CERT_BIOMETRIC_PICTURE_TYPE		equ 0
CERT_BIOMETRIC_SIGNATURE_TYPE		equ 1


CERT_BIOMETRIC_EXT_INFO STRUC
cBiometricData		dd ?
rgBiometricData		PCERT_BIOMETRIC_DATA ?
CERT_BIOMETRIC_EXT_INFO ENDS
PCERT_BIOMETRIC_EXT_INFO typedef ptr CERT_BIOMETRIC_EXT_INFO


OCSP_SIGNATURE_INFO	STRUC
SignatureAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
Signature		CRYPT_BIT_BLOB <>
cCertEncoded		dd ?
rgCertEncoded		PCERT_BLOB ?
OCSP_SIGNATURE_INFO	ENDS
POCSP_SIGNATURE_INFO	typedef ptr OCSP_SIGNATURE_INFO

OCSP_SIGNED_REQUEST_INFO STRUC
ToBeSigned		CRYPT_DER_BLOB <>
pOptionalSignatureInfo	POCSP_SIGNATURE_INFO ?
OCSP_SIGNED_REQUEST_INFO ENDS
POCSP_SIGNED_REQUEST_INFO typedef ptr OCSP_SIGNED_REQUEST_INFO

OCSP_CERT_ID		STRUC
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
IssuerNameHash		CRYPT_HASH_BLOB <>
IssuerKeyHash		CRYPT_HASH_BLOB <>
SerialNumber		CRYPT_INTEGER_BLOB <>
OCSP_CERT_ID		ENDS
POCSP_CERT_ID		typedef ptr OCSP_CERT_ID

OCSP_REQUEST_ENTRY	STRUC
CertId			OCSP_CERT_ID <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
OCSP_REQUEST_ENTRY	ENDS
POCSP_REQUEST_ENTRY	typedef ptr OCSP_REQUEST_ENTRY

OCSP_REQUEST_INFO	STRUC
dwVersion		dd ?
pRequestorName		PCERT_ALT_NAME_ENTRY ?
cRequestEntry		dd ?
rgRequestEntry		POCSP_REQUEST_ENTRY ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
OCSP_REQUEST_INFO	ENDS
POCSP_REQUEST_INFO	typedef ptr OCSP_REQUEST_INFO

OCSP_REQUEST_V1		equ 0

OCSP_RESPONSE_INFO	STRUC
dwStatus		dd ?
pszObjId		LPSTR ?
Value			CRYPT_OBJID_BLOB <>
OCSP_RESPONSE_INFO	ENDS
POCSP_RESPONSE_INFO	typedef ptr OCSP_RESPONSE_INFO

OCSP_SUCCESSFUL_RESPONSE	    equ 0
OCSP_MALFORMED_REQUEST_RESPONSE	    equ 1
OCSP_INTERNAL_ERROR_RESPONSE	    equ 2
OCSP_TRY_LATER_RESPONSE		    equ 3
OCSP_SIG_REQUIRED_RESPONSE	    equ 5
OCSP_UNAUTHORIZED_RESPONSE	    equ 6


szOID_PKIX_OCSP_BASIC_SIGNED_RESPONSE equ <"1.3.6.1.5.5.7.48.1.1">

OCSP_BASIC_SIGNED_RESPONSE_INFO STRUC
ToBeSigned		CRYPT_DER_BLOB <>
SignatureInfo		OCSP_SIGNATURE_INFO <>
OCSP_BASIC_SIGNED_RESPONSE_INFO ENDS
POCSP_BASIC_SIGNED_RESPONSE_INFO typedef ptr OCSP_BASIC_SIGNED_RESPONSE_INFO

OCSP_BASIC_REVOKED_INFO STRUC
RevocationDate		FILETIME <>
dwCrlReasonCode		dd ?
OCSP_BASIC_REVOKED_INFO ENDS
POCSP_BASIC_REVOKED_INFO typedef ptr OCSP_BASIC_REVOKED_INFO

OCSP_BASIC_RESPONSE_ENTRY STRUC
CertId			OCSP_CERT_ID <>
dwCertStatus		dd ?
UNION
pRevokedInfo		POCSP_BASIC_REVOKED_INFO ?
ENDS
ThisUpdate		FILETIME <>
NextUpdate		FILETIME <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
OCSP_BASIC_RESPONSE_ENTRY ENDS
POCSP_BASIC_RESPONSE_ENTRY typedef ptr OCSP_BASIC_RESPONSE_ENTRY

OCSP_BASIC_GOOD_CERT_STATUS	    equ 0
OCSP_BASIC_REVOKED_CERT_STATUS	    equ 1
OCSP_BASIC_UNKNOWN_CERT_STATUS	    equ 2


OCSP_BASIC_RESPONSE_INFO STRUC
dwVersion		dd ?
dwResponderIdChoice	dd ?
UNION
ByNameResponderId	CERT_NAME_BLOB <>
ByKeyResponderId	CRYPT_HASH_BLOB <>
ENDS
ProducedAt		FILETIME <>
cResponseEntry		dd ?
rgResponseEntry		POCSP_BASIC_RESPONSE_ENTRY ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
OCSP_BASIC_RESPONSE_INFO ENDS
POCSP_BASIC_RESPONSE_INFO typedef ptr OCSP_BASIC_RESPONSE_INFO

OCSP_BASIC_RESPONSE_V1	equ 0

OCSP_BASIC_BY_NAME_RESPONDER_ID equ 1
OCSP_BASIC_BY_KEY_RESPONDER_ID	equ 2


CERT_SUPPORTED_ALGORITHM_INFO STRUC
Algorithm		CRYPT_ALGORITHM_IDENTIFIER <>
IntendedKeyUsage	CRYPT_BIT_BLOB <>
IntendedCertPolicies	CERT_POLICIES_INFO <>
CERT_SUPPORTED_ALGORITHM_INFO ENDS
PCERT_SUPPORTED_ALGORITHM_INFO typedef ptr CERT_SUPPORTED_ALGORITHM_INFO

CERT_TPM_SPECIFICATION_INFO STRUC
pwszFamily		LPWSTR ?
dwLevel			dd ?
dwRevision		dd ?
CERT_TPM_SPECIFICATION_INFO ENDS
PCERT_TPM_SPECIFICATION_INFO typedef ptr CERT_TPM_SPECIFICATION_INFO



HCRYPTOIDFUNCSET	typedef ptr
HCRYPTOIDFUNCADDR	typedef ptr

CRYPT_OID_ENCODE_OBJECT_FUNC		equ <"CryptDllEncodeObject">
CRYPT_OID_DECODE_OBJECT_FUNC		equ <"CryptDllDecodeObject">
CRYPT_OID_ENCODE_OBJECT_EX_FUNC		equ <"CryptDllEncodeObjectEx">
CRYPT_OID_DECODE_OBJECT_EX_FUNC		equ <"CryptDllDecodeObjectEx">
CRYPT_OID_CREATE_COM_OBJECT_FUNC	equ <"CryptDllCreateCOMObject">
CRYPT_OID_VERIFY_REVOCATION_FUNC	equ <"CertDllVerifyRevocation">

CRYPT_OID_VERIFY_CTL_USAGE_FUNC		equ <"CertDllVerifyCTLUsage">
CRYPT_OID_FORMAT_OBJECT_FUNC		equ <"CryptDllFormatObject">
CRYPT_OID_FIND_OID_INFO_FUNC		equ <"CryptDllFindOIDInfo">
CRYPT_OID_FIND_LOCALIZED_NAME_FUNC	equ <"CryptDllFindLocalizedName">

CRYPT_OID_REGPATH			equ <"Software\\Microsoft\\Cryptography\\OID">
CRYPT_OID_REG_ENCODING_TYPE_PREFIX	equ <"EncodingType ">
CRYPT_OID_REG_DLL_VALUE_NAME		equ <L"Dll">
CRYPT_OID_REG_FUNC_NAME_VALUE_NAME	equ <L"FuncName">
CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A	equ <"FuncName">
CRYPT_OID_REG_FLAGS_VALUE_NAME		equ <L"CryptFlags">
CRYPT_DEFAULT_OID			equ <"DEFAULT">


CRYPT_OID_FUNC_ENTRY	STRUC
pszOID			LPCSTR ?
pvFuncAddr		PVOID ?
CRYPT_OID_FUNC_ENTRY	ENDS
PCRYPT_OID_FUNC_ENTRY	typedef ptr CRYPT_OID_FUNC_ENTRY


CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG equ 1

CryptInstallOIDFunctionAddress proto WINAPI :HMODULE, :DWORD, :LPCSTR, :DWORD, :CRYPT_OID_FUNC_ENTRY, :DWORD
CryptInitOIDFunctionSet proto WINAPI :LPCSTR, :DWORD
CryptGetOIDFunctionAddress proto WINAPI :HCRYPTOIDFUNCSET, :DWORD, :LPCSTR, :DWORD, :ptr, :ptr

CRYPT_GET_INSTALLED_OID_FUNC_FLAG equ 0x1

CryptGetDefaultOIDDllList proto WINAPI :HCRYPTOIDFUNCSET, :DWORD, :LPWSTR, :LPDWORD
CryptGetDefaultOIDFunctionAddress proto WINAPI :HCRYPTOIDFUNCSET, :DWORD, :LPCWSTR, :DWORD, :ptr, :ptr
CryptFreeOIDFunctionAddress proto WINAPI :HCRYPTOIDFUNCADDR, :DWORD
CryptRegisterOIDFunction proto WINAPI :DWORD, :LPCSTR, :LPCSTR, :LPCWSTR, :LPCSTR
CryptUnregisterOIDFunction proto WINAPI :DWORD, :LPCSTR, :LPCSTR
CryptRegisterDefaultOIDFunction proto WINAPI :DWORD, :LPCSTR, :DWORD, :LPCWSTR

CRYPT_REGISTER_FIRST_INDEX equ 0
CRYPT_REGISTER_LAST_INDEX equ 0xFFFFFFFF

CryptUnregisterDefaultOIDFunction proto WINAPI :DWORD, :LPCSTR, :LPCWSTR
CryptSetOIDFunctionValue proto WINAPI :DWORD, :LPCSTR, :LPCSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
CryptGetOIDFunctionValue proto WINAPI :DWORD, :LPCSTR, :LPCSTR, :LPCWSTR, :LPDWORD, :LPBYTE, :LPDWORD

CALLBACK(PFN_CRYPT_ENUM_OID_FUNC, :DWORD, :LPCSTR, :LPCSTR, :DWORD, :DWORD, :LPCWSTR, :LPBYTE, :DWORD, :PVOID)

CryptEnumOIDFunction proto WINAPI :DWORD, :LPCSTR, :LPCSTR, :DWORD, :ptr, :PFN_CRYPT_ENUM_OID_FUNC

CRYPT_MATCH_ANY_ENCODING_TYPE equ 0xFFFFFFFF

CALG_OID_INFO_CNG_ONLY	equ 0xFFFFFFFF

CALG_OID_INFO_PARAMETERS equ 0xFFFFFFFE
IS_SPECIAL_OID_INFO_ALGID macro Algid
	exitm<(Algid GE CALG_OID_INFO_PARAMETERS)>
	endm


CRYPT_OID_INFO_HASH_PARAMETERS_ALGORITHM	equ <L"CryptOIDInfoHashParameters">
CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM		equ <L"CryptOIDInfoECCParameters">
CRYPT_OID_INFO_MGF1_PARAMETERS_ALGORITHM	equ <L"CryptOIDInfoMgf1Parameters">
CRYPT_OID_INFO_NO_SIGN_ALGORITHM		equ <L"CryptOIDInfoNoSign">
CRYPT_OID_INFO_OAEP_PARAMETERS_ALGORITHM	equ <L"CryptOIDInfoOAEPParameters">
CRYPT_OID_INFO_ECC_WRAP_PARAMETERS_ALGORITHM	equ <L"CryptOIDInfoECCWrapParameters">
CRYPT_OID_INFO_NO_PARAMETERS_ALGORITHM		equ <L"CryptOIDInfoNoParameters">


CRYPT_OID_INFO		STRUC
cbSize			dd ?
pszOID			LPCSTR ?
pwszName		LPCWSTR ?
dwGroupId		dd ?
UNION
 dwValue		dd ?
 Algid			ALG_ID ?
 dwLength		dd ?
ENDS
ExtraInfo		CRYPT_DATA_BLOB <>
ifdef CRYPT_OID_INFO_HAS_EXTRA_FIELDS
pwszCNGAlgid		LPCWSTR ?
pwszCNGExtraAlgid	LPCWSTR ?
endif
CRYPT_OID_INFO		ENDS
PCRYPT_OID_INFO		typedef ptr CRYPT_OID_INFO
PCCRYPT_OID_INFO	typedef ptr CRYPT_OID_INFO


CRYPT_HASH_ALG_OID_GROUP_ID	equ 1
CRYPT_ENCRYPT_ALG_OID_GROUP_ID	equ 2
CRYPT_PUBKEY_ALG_OID_GROUP_ID	equ 3
CRYPT_SIGN_ALG_OID_GROUP_ID	equ 4
CRYPT_RDN_ATTR_OID_GROUP_ID	equ 5
CRYPT_EXT_OR_ATTR_OID_GROUP_ID	equ 6
CRYPT_ENHKEY_USAGE_OID_GROUP_ID equ 7
CRYPT_POLICY_OID_GROUP_ID	equ 8
CRYPT_LAST_OID_GROUP_ID		equ 8

CRYPT_FIRST_ALG_OID_GROUP_ID	equ CRYPT_HASH_AG_OID_GROUP_ID
CRYPT_LAST_ALG_OID_GROUP_ID	equ CRYPT_SIGN_AG_OID_GROUP_ID


CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG equ 0x00000001
CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG equ 0x00000002
CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG	equ 0x00000004

CRYPT_OID_PUBKEY_SIGN_ONLY_FLAG		equ 0x80000000
CRYPT_OID_PUBKEY_ENCRYPT_ONLY_FLAG	equ 0x40000000


CryptFindOIDInfo proto WINAPI :DWORD, :ptr, :DWORD

CRYPT_OID_INFO_OID_KEY		equ 1
CRYPT_OID_INFO_NAME_KEY		equ 2
CRYPT_OID_INFO_ALGID_KEY	equ 3
CRYPT_OID_INFO_SIGN_KEY		equ 4
CRYPT_OID_INFO_CNG_ALGID_KEY	equ 5
CRYPT_OID_INFO_CNG_SIGN_KEY	equ 6

CRYPT_OID_INFO_OID_KEY_FLAGS_MASK	equ 0xFFFF0000
CRYPT_OID_INFO_PUBKEY_SIGN_KEY_FLAG	equ 0x80000000
CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG	equ 0x40000000

CRYPT_OID_DISABLE_SEARCH_DS_FLAG	equ 0x80000000

ifdef CRYPT_OID_INFO_HAS_EXTRA_FIELDS
CRYPT_OID_PREFER_CNG_ALGID_FLAG		equ 0x40000000
endif

CRYPT_OID_INFO_OID_GROUP_BIT_LEN_MASK	equ 0x0FFF0000
CRYPT_OID_INFO_OID_GROUP_BIT_LEN_SHIFT	equ 16

CryptRegisterOIDInfo proto WINAPI :PCCRYPT_OID_INFO, :DWORD

CRYPT_INSTALL_OID_INFO_BEFORE_FLAG equ 1

CryptUnregisterOIDInfo proto WINAPI :PCCRYPT_OID_INFO

CALLBACK(PFN_CRYPT_ENUM_OID_INFO, :PCCRYPT_OID_INFO, :ptr)

CryptEnumOIDInfo proto WINAPI :DWORD, :DWORD, :ptr, :ptr
CryptFindLocalizedName proto WINAPI :LPCWSTR

CRYPT_LOCALIZED_NAME_ENCODING_TYPE  equ 0
CRYPT_LOCALIZED_NAME_OID	    equ <"LocalizedNames">


CERT_STRONG_SIGN_SERIALIZED_INFO STRUC
dwFlags			dd ?
pwszCNGSignHashAlgids	LPWSTR ?
pwszCNGPubKeyMinBitLengths LPWSTR ?
CERT_STRONG_SIGN_SERIALIZED_INFO ENDS
PCERT_STRONG_SIGN_SERIALIZED_INFO typedef ptr CERT_STRONG_SIGN_SERIALIZED_INFO


CERT_STRONG_SIGN_ECDSA_ALGORITHM equ <L"ECDSA">

CERT_STRONG_SIGN_PARA	STRUC
cbSize			dd ?
dwInfoChoice		dd ?
UNION
pvInfo			PVOID ?
pSerializedInfo		PCERT_STRONG_SIGN_SERIALIZED_INFO ?
pszOID			LPSTR ?
ENDS
CERT_STRONG_SIGN_PARA	ENDS
PCERT_STRONG_SIGN_PARA	typedef ptr CERT_STRONG_SIGN_PARA
PCCERT_STRONG_SIGN_PARA typedef ptr CERT_STRONG_SIGN_PARA

CERT_STRONG_SIGN_SERIALIZED_INFO_CHOICE	    equ 1
CERT_STRONG_SIGN_OID_INFO_CHOICE	    equ 2
CERT_STRONG_SIGN_ENABLE_CRL_CHECK	    equ 0x1
CERT_STRONG_SIGN_ENABLE_OCSP_CHECK	    equ 0x2

szOID_CERT_STRONG_SIGN_OS_PREFIX	    equ <"1.3.6.1.4.1.311.72.1.">

szOID_CERT_STRONG_SIGN_OS_1		    equ <"1.3.6.1.4.1.311.72.1.1">
szOID_CERT_STRONG_SIGN_OS_CURRENT	    equ <szOID_CERT_STRONG_SIGN_OS_1>

szOID_CERT_STRONG_KEY_OS_PREFIX		    equ <"1.3.6.1.4.1.311.72.2.">

HCRYPTMSG		typedef ptr

szOID_PKCS_7_DATA		equ <"1.2.840.113549.1.7.1">
szOID_PKCS_7_SIGNED		equ <"1.2.840.113549.1.7.2">
szOID_PKCS_7_ENVELOPED		equ <"1.2.840.113549.1.7.3">
szOID_PKCS_7_SIGNEDANDENVELOPED equ <"1.2.840.113549.1.7.4">
szOID_PKCS_7_DIGESTED		equ <"1.2.840.113549.1.7.5">
szOID_PKCS_7_ENCRYPTED		equ <"1.2.840.113549.1.7.6">

szOID_PKCS_9_CONTENT_TYPE	equ <"1.2.840.113549.1.9.3">
szOID_PKCS_9_MESSAGE_DIGEST	equ <"1.2.840.113549.1.9.4">

CMSG_DATA			equ 1
CMSG_SIGNED			equ 2
CMSG_ENVELOPED			equ 3
CMSG_SIGNED_AND_ENVELOPED	equ 4
CMSG_HASHED			equ 5
CMSG_ENCRYPTED			equ 6

CMSG_ALL_FLAGS			equ ( NOT 0 )
CMSG_DATA_FLAG			equ (1 SHL CMSG_DATA)
CMSG_SIGNED_FLAG		equ (1 SHL CMSG_SIGNED)
CMSG_ENVELOPED_FLAG		equ (1 SHL CMSG_ENVEOPED)
CMSG_SIGNED_AND_ENVELOPED_FLAG	equ (1 SHL CMSG_SIGNED_AND_ENVEOPED)
CMSG_HASHED_FLAG		equ (1 SHL CMSG_HASHED)
CMSG_ENCRYPTED_FLAG		equ (1 SHL CMSG_ENCRYPTED)

CERT_ISSUER_SERIAL_NUMBER STRUC
Issuer			CERT_NAME_BLOB <>
SerialNumber		CRYPT_INTEGER_BLOB <>
CERT_ISSUER_SERIAL_NUMBER ENDS
PCERT_ISSUER_SERIAL_NUMBER typedef ptr CERT_ISSUER_SERIAL_NUMBER

CERT_ID			STRUC
dwIdChoice		dd ?
UNION
 IssuerSerialNumber	CERT_ISSUER_SERIAL_NUMBER <>
 KeyId			CRYPT_HASH_BLOB <>
 HashId			CRYPT_HASH_BLOB <>
ENDS
CERT_ID			ENDS
PCERT_ID		typedef ptr CERT_ID

CERT_ID_ISSUER_SERIAL_NUMBER	equ 1
CERT_ID_KEY_IDENTIFIER		equ 2
CERT_ID_SHA1_HASH		equ 3

CMSG_SIGNER_ENCODE_INFO STRUC
cbSize			dd ?
pCertInfo		PCERT_INFO ?
hCryptProv		HCRYPTPROV ?
dwKeySpec		dd ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
pvHashAuxInfo		PVOID ?
cAuthAttr		dd ?
rgAuthAttr		PCRYPT_ATTRIBUTE ?
cUnauthAttr		dd ?
rgUnauthAttr		PCRYPT_ATTRIBUTE ?
CMSG_SIGNER_ENCODE_INFO ENDS
PCMSG_SIGNER_ENCODE_INFO typedef ptr CMSG_SIGNER_ENCODE_INFO

CMSG_SIGNED_ENCODE_INFO STRUC
cbSize			dd ?
cSigners		dd ?
rgSigners		PCMSG_SIGNER_ENCODE_INFO ?
cCertEncoded		dd ?
rgCertEncoded		PCERT_BLOB ?
cCrlEncoded		dd ?
rgCrlEncoded		PCRL_BLOB ?
CMSG_SIGNED_ENCODE_INFO ENDS
PCMSG_SIGNED_ENCODE_INFO typedef ptr CMSG_SIGNED_ENCODE_INFO

CMSG_ENVELOPED_ENCODE_INFO STRUC
cbSize			dd ?
hCryptProv		HCRYPTPROV ?
ContentEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
pvEncryptionAuxInfo	PVOID ?
cRecipients		dd ?
rgpRecipients		PCERT_INFO ?
CMSG_ENVELOPED_ENCODE_INFO ENDS
PCMSG_ENVELOPED_ENCODE_INFO typedef ptr CMSG_ENVELOPED_ENCODE_INFO

CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO STRUC
cbSize			dd ?
SignedInfo		CMSG_SIGNED_ENCODE_INFO <>
EnvelopedInfo		CMSG_ENVELOPED_ENCODE_INFO <>
CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO ENDS
PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO typedef ptr CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO

CMSG_HASHED_ENCODE_INFO STRUC
cbSize			dd ?
hCryptProv		HCRYPTPROV ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
pvHashAuxInfo		PVOID ?
CMSG_HASHED_ENCODE_INFO ENDS
PCMSG_HASHED_ENCODE_INFO typedef ptr CMSG_HASHED_ENCODE_INFO

CMSG_ENCRYPTED_ENCODE_INFO STRUC
cbSize			dd ?
ContentEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
pvEncryptionAuxInfo	PVOID ?
CMSG_ENCRYPTED_ENCODE_INFO ENDS
PCMSG_ENCRYPTED_ENCODE_INFO typedef ptr CMSG_ENCRYPTED_ENCODE_INFO

;BOOL
CALLBACK(PFN_CMSG_STREAM_OUTPUT, pvArg:PVOID, pbData:LPBYTE, cbData:DWORD, fFinal:BOOL)

CMSG_INDEFINITE_LENGTH	equ (0xFFFFFFFF)

CMSG_STREAM_INFO	STRUC
cbContent		dd ?
pfnStreamOutput		PFN_CMSG_STREAM_OUTPUT ?
pvArg			PVOID ?
CMSG_STREAM_INFO	ENDS
PCMSG_STREAM_INFO	typedef ptr CMSG_STREAM_INFO

CMSG_BARE_CONTENT_FLAG			equ 0x00000001
CMSG_LENGTH_ONLY_FLAG			equ 0x00000002
CMSG_DETACHED_FLAG			equ 0x00000004
CMSG_AUTHENTICATED_ATTRIBUTES_FLAG	equ 0x00000008
CMSG_CONTENTS_OCTETS_FLAG		equ 0x00000010
CMSG_MAX_LENGTH_FLAG			equ 0x00000020

CMSG_CMS_ENCAPSULATED_CONTENT_FLAG	equ 0x00000040
CMSG_CRYPT_RELEASE_CONTEXT_FLAG		equ 0x00008000

CryptMsgOpenToEncode proto WINAPI :DWORD, :DWORD, :DWORD, :ptr, :LPSTR, :PCMSG_STREAM_INFO
CryptMsgCalculateEncodedLength proto WINAPI :DWORD, :DWORD, :DWORD, :ptr, :LPSTR, :DWORD
CryptMsgOpenToDecode proto WINAPI :DWORD, :DWORD, :DWORD, :HCRYPTPROV, :PCERT_INFO, :PCMSG_STREAM_INFO
CryptMsgClose proto WINAPI :HCRYPTMSG
CryptMsgUpdate proto WINAPI :HCRYPTMSG, :LPBYTE, :DWORD, :BOOL
CryptMsgControl proto WINAPI :HCRYPTMSG, :DWORD, :DWORD, :ptr

CMSG_CTRL_VERIFY_SIGNATURE		equ 1
CMSG_CTRL_DECRYPT			equ 2
CMSG_CTRL_VERIFY_HASH			equ 5
CMSG_CTRL_ADD_SIGNER			equ 6
CMSG_CTRL_DEL_SIGNER			equ 7
CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR	equ 8
CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR	equ 9
CMSG_CTRL_ADD_CERT			equ 10
CMSG_CTRL_DEL_CERT			equ 11
CMSG_CTRL_ADD_CRL			equ 12
CMSG_CTRL_DEL_CRL			equ 13
CMSG_CRL_COUNT_PARAM			equ 13
CMSG_CRL_PARAM				equ 14
CMSG_ENVELOPE_ALGORITHM_PARAM		equ 15
CMSG_RECIPIENT_COUNT_PARAM		equ 17
CMSG_RECIPIENT_INDEX_PARAM		equ 18
CMSG_RECIPIENT_INFO_PARAM		equ 19
CMSG_HASH_ALGORITHM_PARAM		equ 20
CMSG_HASH_DATA_PARAM			equ 21
CMSG_COMPUTED_HASH_PARAM		equ 22
CMSG_ENCRYPT_PARAM			equ 26
CMSG_ENCRYPTED_DIGEST			equ 27
CMSG_ENCODED_SIGNER			equ 28
CMSG_ENCODED_MESSAGE			equ 29
CMSG_VERSION_PARAM			equ 30
CMSG_ATTR_CERT_COUNT_PARAM		equ 31
CMSG_ATTR_CERT_PARAM			equ 32
CMSG_CMS_RECIPIENT_COUNT_PARAM		equ 33
CMSG_CMS_RECIPIENT_INDEX_PARAM		equ 34
CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM equ 35
CMSG_CMS_RECIPIENT_INFO_PARAM		equ 36
CMSG_UNPROTECTED_ATTR_PARAM		equ 37
CMSG_SIGNER_CERT_ID_PARAM		equ 38
CMSG_CMS_SIGNER_INFO_PARAM		equ 39

CMSG_SIGNER_INFO	STRUC
dwVersion		dd ?
Issuer			CERT_NAME_BLOB <>
SerialNumber		CRYPT_INTEGER_BLOB <>
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
HashEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedHash		CRYPT_DATA_BLOB <>
AuthAttrs		CRYPT_ATTRIBUTES <>
UnauthAttrs		CRYPT_ATTRIBUTES <>
CMSG_SIGNER_INFO	ENDS
PCMSG_SIGNER_INFO	typedef ptr CMSG_SIGNER_INFO


CMSG_CMS_SIGNER_INFO	STRUC
dwVersion		dd ?
SignerId		CERT_ID <>
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
HashEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedHash		CRYPT_DATA_BLOB <>
AuthAttrs		CRYPT_ATTRIBUTES <>
UnauthAttrs		CRYPT_ATTRIBUTES <>
CMSG_CMS_SIGNER_INFO	ENDS
PCMSG_CMS_SIGNER_INFO	typedef ptr CMSG_CMS_SIGNER_INFO

CMSG_ATTR		typedef CRYPT_ATTRIBUTES
PCMSG_ATTR		typedef ptr CRYPT_ATTRIBUTES

CMSG_SIGNED_DATA_V1			equ 1
CMSG_SIGNED_DATA_V3			equ 3
CMSG_SIGNED_DATA_PKCS_1_5_VERSION	equ CMSG_SIGNED_DATA_V1
CMSG_SIGNED_DATA_CMS_VERSION		equ CMSG_SIGNED_DATA_V3

CMSG_SIGNER_INFO_V1			equ 1
CMSG_SIGNER_INFO_V3			equ 3
CMSG_SIGNER_INFO_PKCS_1_5_VERSION	equ CMSG_SIGNER_INFO_V1
CMSG_SIGNER_INFO_CMS_VERSION		equ CMSG_SIGNER_INFO_V3

CMSG_HASHED_DATA_V0			equ 0
CMSG_HASHED_DATA_V2			equ 2
CMSG_HASHED_DATA_PKCS_1_5_VERSION	equ CMSG_HASHED_DATA_V0
CMSG_HASHED_DATA_CMS_VERSION		equ CMSG_HASHED_DATA_V2

CMSG_ENVELOPED_DATA_V0			equ 0
CMSG_ENVELOPED_DATA_V2			equ 2
CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION	equ CMSG_ENVELOPED_DATA_V0
CMSG_ENVELOPED_DATA_CMS_VERSION		equ CMSG_ENVELOPED_DATA_V2


CMSG_KEY_TRANS_RECIPIENT_INFO STRUC
dwVersion		dd ?
RecipientId		CERT_ID <>
KeyEncryptionAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedKey		CRYPT_DATA_BLOB <>
CMSG_KEY_TRANS_RECIPIENT_INFO ENDS
PCMSG_KEY_TRANS_RECIPIENT_INFO typedef ptr CMSG_KEY_TRANS_RECIPIENT_INFO

CMSG_RECIPIENT_ENCRYPTED_KEY_INFO STRUC
RecipientId		CERT_ID <>
EncryptedKey		CRYPT_DATA_BLOB <>
Date			FILETIME <>
pOtherAttr		PCRYPT_ATTRIBUTE_TYPE_VALUE ?
CMSG_RECIPIENT_ENCRYPTED_KEY_INFO ENDS
PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO typedef ptr CMSG_RECIPIENT_ENCRYPTED_KEY_INFO

CMSG_KEY_AGREE_RECIPIENT_INFO STRUC
dwVersion		dd ?
dwOriginatorChoice	dd ?
UNION
OriginatorCertId	CERT_ID <>
OriginatorPublicKeyInfo CERT_PUBLIC_KEY_INFO <>
ENDS
UserKeyingMaterial	CRYPT_DATA_BLOB <>
KeyEncryptionAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
cRecipientEncryptedKeys dd ?
rgpRecipientEncryptedKeys PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO ?
CMSG_KEY_AGREE_RECIPIENT_INFO ENDS
PCMSG_KEY_AGREE_RECIPIENT_INFO typedef ptr CMSG_KEY_AGREE_RECIPIENT_INFO

CMSG_KEY_AGREE_ORIGINATOR_CERT	       equ 1
CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY   equ 2

CMSG_MAIL_LIST_RECIPIENT_INFO STRUC
dwVersion		dd ?
KeyId			CRYPT_DATA_BLOB <>
KeyEncryptionAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedKey		CRYPT_DATA_BLOB <>
Date			FILETIME <>
pOtherAttr		PCRYPT_ATTRIBUTE_TYPE_VALUE ?
CMSG_MAIL_LIST_RECIPIENT_INFO ENDS
PCMSG_MAIL_LIST_RECIPIENT_INFO typedef ptr CMSG_MAIL_LIST_RECIPIENT_INFO

CMSG_CMS_RECIPIENT_INFO STRUC
dwRecipientChoice	dd ?
UNION
pKeyTrans		PCMSG_KEY_TRANS_RECIPIENT_INFO ?
pKeyAgree		PCMSG_KEY_AGREE_RECIPIENT_INFO ?
pMailList		PCMSG_MAIL_LIST_RECIPIENT_INFO ?
ENDS
CMSG_CMS_RECIPIENT_INFO ENDS
PCMSG_CMS_RECIPIENT_INFO typedef ptr CMSG_CMS_RECIPIENT_INFO


CMSG_ENVELOPED_RECIPIENT_V0		equ 0
CMSG_ENVELOPED_RECIPIENT_V2		equ 2
CMSG_ENVELOPED_RECIPIENT_V3		equ 3
CMSG_ENVELOPED_RECIPIENT_V4		equ 4
CMSG_KEY_TRANS_PKCS_1_5_VERSION		equ CMSG_ENVELOPED_RECIPIENT_V0
CMSG_KEY_TRANS_CMS_VERSION		equ CMSG_ENVELOPED_RECIPIENT_V2
CMSG_KEY_AGREE_VERSION			equ CMSG_ENVELOPED_RECIPIENT_V3
CMSG_MAIL_LIST_VERSION			equ CMSG_ENVELOPED_RECIPIENT_V4

CryptMsgControl proto WINAPI :HCRYPTMSG, :DWORD, :DWORD, :ptr

CMSG_CTRL_VERIFY_SIGNATURE	 equ 1
CMSG_CTRL_DECRYPT		 equ 2
CMSG_CTRL_VERIFY_HASH		 equ 5
CMSG_CTRL_ADD_SIGNER		 equ 6
CMSG_CTRL_DEL_SIGNER		 equ 7
CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR equ 8
CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR equ 9
CMSG_CTRL_ADD_CERT		 equ 10
CMSG_CTRL_DEL_CERT		 equ 11
CMSG_CTRL_ADD_CRL		 equ 12
CMSG_CTRL_DEL_CRL		 equ 13
CMSG_CTRL_ADD_ATTR_CERT		 equ 14
CMSG_CTRL_DEL_ATTR_CERT		 equ 15
CMSG_CTRL_KEY_TRANS_DECRYPT	 equ 16
CMSG_CTRL_KEY_AGREE_DECRYPT	 equ 17
CMSG_CTRL_MAIL_LIST_DECRYPT	 equ 18
CMSG_CTRL_VERIFY_SIGNATURE_EX	 equ 19
CMSG_CTRL_ADD_CMS_SIGNER_INFO	 equ 20
CMSG_CTRL_ENABLE_STRONG_SIGNATURE equ 21

CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA STRUC
cbSize			dd ?
hCryptProv		HCRYPTPROV_LEGACY ?
dwSignerIndex		dd ?
dwSignerType		dd ?
pvSigner		PVOID ?
CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA ENDS
PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA typedef ptr CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA

CMSG_VERIFY_SIGNER_PUBKEY	equ 1
CMSG_VERIFY_SIGNER_CERT		equ 2
CMSG_VERIFY_SIGNER_CHAIN	equ 3
CMSG_VERIFY_SIGNER_NULL		equ 4

CMSG_CTRL_DECRYPT_PARA	STRUC
cbSize			dd ?
hCryptProv		HCRYPTPROV ?
dwKeySpec		dd ?
dwRecipientIndex	dd ?
CMSG_CTRL_DECRYPT_PARA	ENDS
PCMSG_CTRL_DECRYPT_PARA typedef ptr CMSG_CTRL_DECRYPT_PARA


CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA  STRUC
cbSize			dd ?
dwSignerIndex		dd ?
blob			CRYPT_DATA_BLOB <>
CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA ENDS
PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA typedef ptr CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA


CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA  STRUC
cbSize			dd ?
dwSignerIndex		dd ?
dwUnauthAttrIndex	dd ?
CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA ENDS
PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA typedef ptr CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA


CryptMsgVerifyCountersignatureEncoded proto WINAPI :HCRYPTPROV, :DWORD, :PBYTE, :DWORD, :PBYTE, :DWORD, :PCERT_INFO
CryptMsgCountersign proto WINAPI :HCRYPTMSG, :DWORD, :DWORD, :PCMSG_SIGNER_ENCODE_INFO
CryptMsgCountersignEncoded proto WINAPI :DWORD, :PBYTE, :DWORD, :DWORD, :PCMSG_SIGNER_ENCODE_INFO, :PBYTE, :PDWORD
CryptMsgGetParam proto WINAPI :HCRYPTMSG, :DWORD, :DWORD, :ptr, :LPDWORD

CMSG_TYPE_PARAM		equ 1
CMSG_CONTENT_PARAM	equ 2
CMSG_BARE_CONTENT_PARAM equ 3
CMSG_INNER_CONTENT_TYPE_PARAM equ 4
CMSG_SIGNER_COUNT_PARAM equ 5
CMSG_SIGNER_INFO_PARAM	equ 6
CMSG_SIGNER_CERT_INFO_PARAM equ 7
CMSG_SIGNER_HASH_ALGORITHM_PARAM equ 8
CMSG_SIGNER_AUTH_ATTR_PARAM equ 9
CMSG_SIGNER_UNAUTH_ATTR_PARAM equ 10
CMSG_CERT_COUNT_PARAM	equ 11
CMSG_CERT_PARAM		equ 12
CMSG_CRL_COUNT_PARAM	equ 13
CMSG_CRL_PARAM		equ 14
CMSG_ENVELOPE_ALGORITHM_PARAM equ 15
CMSG_RECIPIENT_COUNT_PARAM equ 17
CMSG_RECIPIENT_INDEX_PARAM equ 18
CMSG_RECIPIENT_INFO_PARAM equ 19
CMSG_HASH_ALGORITHM_PARAM equ 20
CMSG_HASH_DATA_PARAM	equ 21
CMSG_COMPUTED_HASH_PARAM equ 22
CMSG_ENCRYPT_PARAM	equ 26
CMSG_ENCRYPTED_DIGEST	equ 27
CMSG_ENCODED_SIGNER	equ 28
CMSG_ENCODED_MESSAGE	equ 29


CMSG_SIGNER_INFO	STRUC
dwVersion		dd ?
Issuer			CERT_NAME_BLOB <>
SerialNumber		CRYPT_INTEGER_BLOB <>
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
HashEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
EncryptedHash		CRYPT_DATA_BLOB <>
AuthAttrs		CRYPT_ATTRIBUTES <>
UnauthAttrs		CRYPT_ATTRIBUTES <>
CMSG_SIGNER_INFO	ENDS
PCMSG_SIGNER_INFO	typedef ptr CMSG_SIGNER_INFO


CMSG_ATTR		typedef CRYPT_ATTRIBUTES
PCMSG_ATTR		typedef ptr CRYPT_ATTRIBUTES

CMSG_OID_GEN_ENCRYPT_KEY_FUNC equ <"CryptMsgDllGenEncryptKey">
CALLBACK(PFN_CMSG_GEN_ENCRYPT_KEY, :ptr HCRYPTPROV, :PCRYPT_ALGORITHM_IDENTIFIER, :PVOID, :PCERT_PUBLIC_KEY_INFO, :ptr HCRYPTKEY)
CMSG_OID_EXPORT_ENCRYPT_KEY_FUNC equ <"CryptMsgDllExportEncryptKey">
CALLBACK(PFN_CMSG_EXPORT_ENCRYPT_KEY, :HCRYPTPROV, :HCRYPTKEY, :PCERT_PUBLIC_KEY_INFO, :PBYTE, :PDWORD)
CMSG_OID_IMPORT_ENCRYPT_KEY_FUNC equ <"CryptMsgDllImportEncryptKey">
CALLBACK(PFN_CMSG_IMPORT_ENCRYPT_KEY, :HCRYPTPROV, :DWORD, :PCRYPT_ALGORITHM_IDENTIFIER, :PCRYPT_ALGORITHM_IDENTIFIER, :PBYTE, :DWORD, :ptr HCRYPTKEY)

HCERTSTORE		typedef ptr
LPHCERTSTORE		typedef ptr HCERTSTORE

CERT_CONTEXT		STRUC
dwCertEncodingType	dd ?
pbCertEncoded		LPSTR ?
cbCertEncoded		dd ?
pCertInfo		PCERT_INFO ?
hCertStore		HCERTSTORE ?
CERT_CONTEXT		ENDS
PCERT_CONTEXT		typedef ptr CERT_CONTEXT
PCCERT_CONTEXT		typedef ptr CERT_CONTEXT

CRL_CONTEXT		STRUC
dwCertEncodingType	dd ?
pbCrlEncoded		LPSTR ?
cbCrlEncoded		dd ?
pCrlInfo		PCRL_INFO ?
hCertStore		HCERTSTORE ?
CRL_CONTEXT		ENDS
PCRL_CONTEXT		typedef ptr CRL_CONTEXT
PCCRL_CONTEXT		typedef ptr CRL_CONTEXT

CTL_CONTEXT		STRUC
dwMsgAndCertEncodingType dd ?
pbCtlEncoded		LPSTR ?
cbCtlEncoded		dd ?
pCtlInfo		PCTL_INFO ?
hCertStore		HCERTSTORE ?
hCryptMsg		HCRYPTMSG ?
pbCtlContent		LPSTR ?
cbCtlContent		dd ?
CTL_CONTEXT		ENDS
PCTL_CONTEXT		typedef ptr CTL_CONTEXT
PCCTL_CONTEXT		typedef ptr CTL_CONTEXT

CERT_KEY_PROV_HANDLE_PROP_ID	equ 1
CERT_KEY_PROV_INFO_PROP_ID	equ 2
CERT_SHA1_HASH_PROP_ID		equ 3
CERT_MD5_HASH_PROP_ID		equ 4
CERT_HASH_PROP_ID		equ CERT_SHA1_HASH_PROP_ID
CERT_KEY_CONTEXT_PROP_ID	equ 5
CERT_KEY_SPEC_PROP_ID		equ 6
CERT_IE30_RESERVED_PROP_ID	equ 7
CERT_PUBKEY_HASH_RESERVED_PROP_ID equ 8
CERT_ENHKEY_USAGE_PROP_ID	equ 9
CERT_CTL_USAGE_PROP_ID		equ CERT_ENHKEY_USAGE_PROP_ID
CERT_NEXT_UPDATE_LOCATION_PROP_ID equ 10
CERT_FRIENDLY_NAME_PROP_ID	equ 11
CERT_PVK_FILE_PROP_ID		equ 12
CERT_FIRST_RESERVED_PROP_ID	equ 13

CERT_LAST_RESERVED_PROP_ID	equ 0x00007FFF
CERT_FIRST_USER_PROP_ID		equ 0x00008000
CERT_LAST_USER_PROP_ID		equ 0x0000FFFF


IS_CERT_HASH_PROP_ID macro X
	exitm<(CERT_SHA1_HASH_PROP_ID EQ (X) OR CERT_MD5_HASH_PROP_ID EQ (X))>
	endm


CRYPT_KEY_PROV_PARAM	STRUC
dwParam			dd ?
pbData			LPSTR ?
cbData			dd ?
dwFlags			dd ?
CRYPT_KEY_PROV_PARAM	ENDS
PCRYPT_KEY_PROV_PARAM	typedef ptr CRYPT_KEY_PROV_PARAM

CRYPT_KEY_PROV_INFO	STRUC
pwszContainerName	LPWSTR ?
pwszProvName		LPWSTR ?
dwProvType		dd ?
dwFlags			dd ?
cProvParam		dd ?
rgProvParam		PCRYPT_KEY_PROV_PARAM ?
dwKeySpec		dd ?
CRYPT_KEY_PROV_INFO	ENDS
PCRYPT_KEY_PROV_INFO	typedef ptr CRYPT_KEY_PROV_INFO

CERT_SET_KEY_PROV_HANDLE_PROP_ID equ 0x00000001
CERT_SET_KEY_CONTEXT_PROP_ID equ 0x00000001

CERT_KEY_CONTEXT	STRUC
cbSize			dd ?
hCryptProv		HCRYPTPROV ?
dwKeySpec		dd ?
CERT_KEY_CONTEXT	ENDS
PCERT_KEY_CONTEXT	typedef ptr CERT_KEY_CONTEXT

CERT_STORE_PROV_MSG	equ 1
CERT_STORE_PROV_MEMORY	equ 2
CERT_STORE_PROV_FILE	equ 3
CERT_STORE_PROV_REG	equ 4

CERT_STORE_PROV_PKCS7		equ 5
CERT_STORE_PROV_SERIALIZED	equ 6
CERT_STORE_PROV_FILENAME_A	equ 7
CERT_STORE_PROV_FILENAME_W	equ 8
CERT_STORE_PROV_FILENAME	equ CERT_STORE_PROV_FILENAME_W
CERT_STORE_PROV_SYSTEM_A	equ 9
CERT_STORE_PROV_SYSTEM_W	equ 10
CERT_STORE_PROV_SYSTEM		equ CERT_STORE_PROV_SYSTEM_W

sz_CERT_STORE_PROV_MEMORY	equ <"Memory">
sz_CERT_STORE_PROV_FILENAME_W	equ <"File">
sz_CERT_STORE_PROV_FILENAME	equ <sz_CERT_STORE_PROV_FILENAME_W>
sz_CERT_STORE_PROV_SYSTEM_W	equ <"System">
sz_CERT_STORE_PROV_SYSTEM	equ <sz_CERT_STORE_PROV_SYSTEM_W>
sz_CERT_STORE_PROV_PKCS7	equ <"PKCS7">
sz_CERT_STORE_PROV_SERIALIZED	equ <"Serialized">

CERT_STORE_SIGNATURE_FLAG equ 0x00000001
CERT_STORE_TIME_VALIDITY_FLAG equ 0x00000002
CERT_STORE_REVOCATION_FLAG equ 0x00000004
CERT_STORE_NO_CRL_FLAG	equ 0x00010000
CERT_STORE_NO_ISSUER_FLAG equ 0x00020000

CERT_STORE_NO_CRYPT_RELEASE_FLAG equ 0x00000001
CERT_STORE_READONLY_FLAG equ 0x00008000

CERT_SYSTEM_STORE_LOCATION_MASK equ 0x00030000
CERT_SYSTEM_STORE_CURRENT_USER equ 0x00010000
CERT_SYSTEM_STORE_LOCAL_MACHINE equ 0x00020000

CertOpenStore proto WINAPI :LPCSTR, :DWORD, :HCRYPTPROV, :DWORD, :ptr


HCERTSTOREPROV		typedef PVOID

CRYPT_OID_OPEN_STORE_PROV_FUNC equ <"CertDllOpenStoreProv">


CERT_STORE_PROV_INFO	STRUC
cbSize			dd ?
cStoreProvFunc		dd ?
rgpvStoreProvFunc	PVOID ?
hStoreProv		HCERTSTOREPROV ?
dwStoreProvFlags	dd ?
CERT_STORE_PROV_INFO	ENDS
PCERT_STORE_PROV_INFO	typedef ptr CERT_STORE_PROV_INFO

CALLBACK(PFN_CERT_DLL_OPEN_STORE_PROV_FUNC, :LPCSTR, :DWORD, :HCRYPTPROV, :DWORD, :PVOID, :HCERTSTORE, :PCERT_STORE_PROV_INFO)

CERT_STORE_PROV_CLOSE_FUNC equ 0
CERT_STORE_PROV_READ_CERT_FUNC equ 1
CERT_STORE_PROV_WRITE_CERT_FUNC equ 2
CERT_STORE_PROV_DELETE_CERT_FUNC equ 3
CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC equ 4
CERT_STORE_PROV_READ_CRL_FUNC equ 5
CERT_STORE_PROV_WRITE_CRL_FUNC equ 6
CERT_STORE_PROV_DELETE_CRL_FUNC equ 7
CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC equ 8
CERT_STORE_PROV_READ_CTL_FUNC equ 9
CERT_STORE_PROV_WRITE_CTL_FUNC equ 10
CERT_STORE_PROV_DELETE_CTL_FUNC equ 11
CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC equ 12

CALLBACK(PFN_CERT_STORE_PROV_CLOSE, :HCERTSTOREPROV, :DWORD)
CALLBACK(PFN_CERT_STORE_PROV_READ_CERT, :HCERTSTOREPROV, :PCCERT_CONTEXT, :DWORD, :ptr PCCERT_CONTEXT)

CERT_STORE_PROV_WRITE_ADD_FLAG equ 0x1

CALLBACK(PFN_CERT_STORE_PROV_WRITE_CERT, :HCERTSTOREPROV, :PCCERT_CONTEXT, :DWORD)
CALLBACK(PFN_CERT_STORE_PROV_DELETE_CERT, :HCERTSTOREPROV, :PCCERT_CONTEXT, :DWORD)
;CALLBACK(PFN_CERT_STORE_PROV_SET_CERT_PROPERTY, :HCERTSTOREPROV, :PCCERT_CONTEXT, :DWORD, :DWORD, :PVOID)
CALLBACK(PFN_CERT_STORE_PROV_READ_CRL, :HCERTSTOREPROV, :PCCRL_CONTEXT, :DWORD, :ptr PCCRL_CONTEXT)
CALLBACK(PFN_CERT_STORE_PROV_WRITE_CRL, :HCERTSTOREPROV, :PCCRL_CONTEXT, :DWORD)
CALLBACK(PFN_CERT_STORE_PROV_DELETE_CRL, :HCERTSTOREPROV, :PCCRL_CONTEXT, :DWORD)
CALLBACK(PFN_CERT_STORE_PROV_SET_CRL_PROPERTY, :HCERTSTOREPROV, :PCCRL_CONTEXT, :DWORD, :DWORD, :PVOID)
CALLBACK(PFN_CERT_STORE_PROV_READ_CTL, :HCERTSTOREPROV, :PCCTL_CONTEXT, :DWORD, :ptr PCCTL_CONTEXT)
CALLBACK(PFN_CERT_STORE_PROV_WRITE_CTL, :HCERTSTOREPROV, :PCCTL_CONTEXT, :DWORD)
CALLBACK(PFN_CERT_STORE_PROV_DELETE_CTL, :HCERTSTOREPROV, :PCCTL_CONTEXT, :DWORD)

CALLBACK(PFN_CERT_STORE_PROV_SET_CTL_PROPERTY, :HCERTSTOREPROV, :PCCTL_CONTEXT, :DWORD, :DWORD, :PVOID)

CertDuplicateStore proto WINAPI :HCERTSTORE

CERT_STORE_SAVE_AS_STORE	equ 1
CERT_STORE_SAVE_AS_PKCS7	equ 2

CERT_STORE_SAVE_TO_FILE		equ 1
CERT_STORE_SAVE_TO_MEMORY	equ 2
CERT_STORE_SAVE_TO_FILENAME_A	equ 3
CERT_STORE_SAVE_TO_FILENAME_W	equ 4
CERT_STORE_SAVE_TO_FILENAME	equ CERT_STORE_SAVE_TO_FILENAME_W

CertSaveStore proto WINAPI :HCERTSTORE, :DWORD, :DWORD, :DWORD, :ptr, :DWORD

CERT_CLOSE_STORE_FORCE_FLAG equ 0x00000001
CERT_CLOSE_STORE_CHECK_FLAG equ 0x00000002

CertCloseStore proto WINAPI :HCERTSTORE, :DWORD
CertGetSubjectCertificateFromStore proto WINAPI :HCERTSTORE, :DWORD, :PCERT_INFO
CertEnumCertificatesInStore proto WINAPI :HCERTSTORE, :PCCERT_CONTEXT
CertFindCertificateInStore proto WINAPI :HCERTSTORE, :DWORD, :DWORD, :DWORD, :ptr, :PCCERT_CONTEXT


CERT_COMPARE_MASK	equ 0xFFFF
CERT_COMPARE_SHIFT	equ 16
CERT_COMPARE_ANY	equ 0
CERT_COMPARE_SHA1_HASH	equ 1
CERT_COMPARE_NAME	equ 2
CERT_COMPARE_ATTR	equ 3
CERT_COMPARE_MD5_HASH	equ 4
CERT_COMPARE_PROPERTY	equ 5
CERT_COMPARE_PUBLIC_KEY equ 6
CERT_COMPARE_HASH	equ CERT_COMPARE_SHA1_HASH
CERT_COMPARE_NAME_STR_A equ 7
CERT_COMPARE_NAME_STR_W equ 8
CERT_COMPARE_KEY_SPEC	equ 9
CERT_COMPARE_ENHKEY_USAGE equ 10
CERT_COMPARE_CTL_USAGE	equ CERT_COMPARE_ENHKEY_USAGE

CERT_FIND_ANY		equ (CERT_COMPARE_ANY SHL CERT_COMPARE_SHIFT)
CERT_FIND_SHA1_HASH	equ (CERT_COMPARE_SHA1_HASH SHL CERT_COMPARE_SHIFT)
CERT_FIND_MD5_HASH	equ (CERT_COMPARE_MD5_HASH SHL CERT_COMPARE_SHIFT)
CERT_FIND_HASH		equ CERT_FIND_SHA1_HASH
CERT_FIND_PROPERTY	equ (CERT_COMPARE_PROPERTY SHL CERT_COMPARE_SHIFT)
CERT_FIND_PUBLIC_KEY	equ (CERT_COMPARE_PUBLIC_KEY SHL CERT_COMPARE_SHIFT)
CERT_FIND_SUBJECT_NAME	equ (CERT_COMPARE_NAME SHL CERT_COMPARE_SHIFT OR CERT_INFO_SUBJECT_FAG)
CERT_FIND_SUBJECT_ATTR	equ (CERT_COMPARE_ATTR SHL CERT_COMPARE_SHIFT OR CERT_INFO_SUBJECT_FAG)
CERT_FIND_ISSUER_NAME	equ (CERT_COMPARE_NAME SHL CERT_COMPARE_SHIFT OR CERT_INFO_ISSUER_FAG)
CERT_FIND_ISSUER_ATTR	equ (CERT_COMPARE_ATTR SHL CERT_COMPARE_SHIFT OR CERT_INFO_ISSUER_FAG)
CERT_FIND_SUBJECT_STR_A equ (CERT_COMPARE_NAME_STR_A SHL CERT_COMPARE_SHIFT OR CERT_INFO_SUBJECT_FAG)
CERT_FIND_SUBJECT_STR_W equ (CERT_COMPARE_NAME_STR_W SHL CERT_COMPARE_SHIFT OR CERT_INFO_SUBJECT_FAG)
CERT_FIND_SUBJECT_STR	equ CERT_FIND_SUBJECT_STR_W
CERT_FIND_ISSUER_STR_A	equ (CERT_COMPARE_NAME_STR_A SHL CERT_COMPARE_SHIFT OR CERT_INFO_ISSUER_FAG)
CERT_FIND_ISSUER_STR_W	equ (CERT_COMPARE_NAME_STR_W SHL CERT_COMPARE_SHIFT OR CERT_INFO_ISSUER_FAG)
CERT_FIND_ISSUER_STR	equ CERT_FIND_ISSUER_STR_W
CERT_FIND_KEY_SPEC	equ (CERT_COMPARE_KEY_SPEC SHL CERT_COMPARE_SHIFT)
CERT_FIND_ENHKEY_USAGE	equ (CERT_COMPARE_ENHKEY_USAGE SHL CERT_COMPARE_SHIFT)
CERT_FIND_CTL_USAGE	equ CERT_FIND_ENHKEY_USAGE

CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG	equ 0x1
CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG	equ 0x2
CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG	equ 0x4
CERT_FIND_NO_ENHKEY_USAGE_FLAG		equ 0x8

CERT_FIND_OPTIONAL_CTL_USAGE_FLAG	equ CERT_FIND_OPTIONAL_ENHKEY_USAGE_FAG
CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG	equ CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FAG
CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG	equ CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FAG
CERT_FIND_NO_CTL_USAGE_FLAG		equ CERT_FIND_NO_ENHKEY_USAGE_FAG

CertGetIssuerCertificateFromStore proto WINAPI :HCERTSTORE, :PCCERT_CONTEXT, :PCCERT_CONTEXT, :LPDWORD
CertVerifySubjectCertificateContext proto WINAPI :PCCERT_CONTEXT, :PCCERT_CONTEXT, :LPDWORD
CertDuplicateCertificateContext proto WINAPI :PCCERT_CONTEXT
CertCreateCertificateContext proto WINAPI :DWORD, :LPBYTE, :DWORD
CertFreeCertificateContext proto WINAPI :PCCERT_CONTEXT
CertSetCertificateContextProperty proto WINAPI :PCCERT_CONTEXT, :DWORD, :DWORD, :ptr
CertGetCertificateContextProperty proto WINAPI :PCCERT_CONTEXT, :DWORD, :ptr, :LPDWORD
CertEnumCertificateContextProperties proto WINAPI :PCCERT_CONTEXT, :DWORD
CertGetCRLFromStore proto WINAPI :HCERTSTORE, :PCCERT_CONTEXT, :PCCRL_CONTEXT, :LPDWORD
CertDuplicateCRLContext proto WINAPI :PCCRL_CONTEXT
CertCreateCRLContext proto WINAPI :DWORD, :LPBYTE, :DWORD
CertFreeCRLContext proto WINAPI :PCCRL_CONTEXT
CertSetCRLContextProperty proto WINAPI :PCCRL_CONTEXT, :DWORD, :DWORD, :ptr
CertGetCRLContextProperty proto WINAPI :PCCRL_CONTEXT, :DWORD, :ptr, :LPDWORD
CertEnumCRLContextProperties proto WINAPI :PCCRL_CONTEXT, :DWORD

CERT_STORE_ADD_NEW		equ 1
CERT_STORE_ADD_USE_EXISTING	equ 2
CERT_STORE_ADD_REPLACE_EXISTING equ 3
CERT_STORE_ADD_ALWAYS		equ 4

CertAddEncodedCertificateToStore proto WINAPI :HCERTSTORE, :DWORD, :LPBYTE, :DWORD, :DWORD, :ptr
CertAddCertificateContextToStore proto WINAPI :HCERTSTORE, :PCCERT_CONTEXT, :DWORD, :ptr

CERT_STORE_CERTIFICATE_CONTEXT equ 1
CERT_STORE_CRL_CONTEXT	equ 2
CERT_STORE_CTL_CONTEXT	equ 3

CERT_STORE_ALL_CONTEXT_FLAG equ ( NOT 0)
CERT_STORE_CERTIFICATE_CONTEXT_FLAG equ (1 SHL CERT_STORE_CERTIFICATE_CONTEXT)
CERT_STORE_CRL_CONTEXT_FLAG equ (1 SHL CERT_STORE_CRL_CONTEXT)
CERT_STORE_CTL_CONTEXT_FLAG equ (1 SHL CERT_STORE_CTL_CONTEXT)

CertAddSerializedElementToStore proto WINAPI :HCERTSTORE, :LPBYTE, :DWORD, :DWORD, :DWORD, :DWORD, :LPDWORD, :ptr
CertDeleteCertificateFromStore proto WINAPI :PCCERT_CONTEXT
CertAddEncodedCRLToStore proto WINAPI :HCERTSTORE, :DWORD, :LPBYTE, :DWORD, :DWORD, :PCCRL_CONTEXT
CertAddCRLContextToStore proto WINAPI :HCERTSTORE, :PCCRL_CONTEXT, :DWORD, :PCCRL_CONTEXT
CertDeleteCRLFromStore proto WINAPI :PCCRL_CONTEXT
CertSerializeCertificateStoreElement proto WINAPI :PCCERT_CONTEXT, :DWORD, :LPBYTE, :LPDWORD
CertSerializeCRLStoreElement proto WINAPI :PCCRL_CONTEXT, :DWORD, :LPBYTE, :LPDWORD
CertDuplicateCTLContext proto WINAPI :PCCTL_CONTEXT
CertCreateCTLContext proto WINAPI :DWORD, :LPBYTE, :DWORD
CertFreeCTLContext proto WINAPI :PCCTL_CONTEXT
CertSetCTLContextProperty proto WINAPI :PCCTL_CONTEXT, :DWORD, :DWORD, :ptr
CertGetCTLContextProperty proto WINAPI :PCCTL_CONTEXT, :DWORD, :ptr, :LPDWORD
CertEnumCTLContextProperties proto WINAPI :PCCTL_CONTEXT, :DWORD
CertEnumCTLsInStore proto WINAPI :HCERTSTORE, :PCCTL_CONTEXT
CertFindSubjectInCTL proto WINAPI :DWORD, :DWORD, :ptr, :PCCTL_CONTEXT, :DWORD

CTL_ANY_SUBJECT_TYPE	equ 1
CTL_CERT_SUBJECT_TYPE	equ 2

CTL_ANY_SUBJECT_INFO	STRUC
SubjectAlgorithm	CRYPT_ALGORITHM_IDENTIFIER <>
SubjectIdentifier	CRYPT_DATA_BLOB <>
CTL_ANY_SUBJECT_INFO	ENDS
PCTL_ANY_SUBJECT_INFO	typedef ptr CTL_ANY_SUBJECT_INFO

CertFindCTLInStore proto WINAPI :HCERTSTORE, :DWORD, :DWORD, :DWORD, :ptr, :PCCTL_CONTEXT

CTL_FIND_ANY		equ 0
CTL_FIND_SHA1_HASH	equ 1
CTL_FIND_MD5_HASH	equ 2
CTL_FIND_USAGE		equ 3
CTL_FIND_SUBJECT	equ 4

CTL_FIND_USAGE_PARA	STRUC
cbSize			dd ?
SubjectUsage		CTL_USAGE <>
ListIdentifier		CRYPT_DATA_BLOB <>
pSigner			PCERT_INFO ?
CTL_FIND_USAGE_PARA	ENDS
PCTL_FIND_USAGE_PARA	typedef ptr CTL_FIND_USAGE_PARA

CTL_FIND_NO_LIST_ID_CBDATA	equ 0xFFFFFFFF
CTL_FIND_NO_SIGNER_PTR		equ 0xFFFFFFFF

CTL_FIND_SAME_USAGE_FLAG equ 0x1


CTL_FIND_SUBJECT_PARA	STRUC
cbSize			dd ?
pUsagePara		PCTL_FIND_USAGE_PARA ?
dwSubjectType		dd ?
pvSubject		PVOID ?
CTL_FIND_SUBJECT_PARA	ENDS
PCTL_FIND_SUBJECT_PARA	typedef ptr CTL_FIND_SUBJECT_PARA


CertAddEncodedCTLToStore proto WINAPI :HCERTSTORE, :DWORD, :LPBYTE, :DWORD, :DWORD, :PCCTL_CONTEXT
CertAddCTLContextToStore proto WINAPI :HCERTSTORE, :PCCTL_CONTEXT, :DWORD, :PCCTL_CONTEXT
CertSerializeCTLStoreElement proto WINAPI :PCCTL_CONTEXT, :DWORD, :LPBYTE, :LPDWORD
CertDeleteCTLFromStore proto WINAPI :PCCTL_CONTEXT
CertGetEnhancedKeyUsage proto WINAPI :PCCERT_CONTEXT, :DWORD, :PCERT_ENHKEY_USAGE, :LPDWORD
CertSetEnhancedKeyUsage proto WINAPI :PCCERT_CONTEXT, :PCERT_ENHKEY_USAGE
CertAddEnhancedKeyUsageIdentifier proto WINAPI :PCCERT_CONTEXT, :LPCSTR
CertRemoveEnhancedKeyUsageIdentifier proto WINAPI :PCCERT_CONTEXT, :LPCSTR
CryptMsgGetAndVerifySigner proto WINAPI :HCRYPTMSG, :DWORD, :ptr, :DWORD, :PCCERT_CONTEXT, :LPDWORD

CMSG_TRUSTED_SIGNER_FLAG	equ 0x1
CMSG_SIGNER_ONLY_FLAG		equ 0x2
CMSG_USE_SIGNER_INDEX_FLAG	equ 0x4

CryptMsgSignCTL proto WINAPI :DWORD, :LPBYTE, :DWORD, :PCMSG_SIGNED_ENCODE_INFO, :DWORD, :LPBYTE, :LPDWORD
CryptMsgEncodeAndSignCTL proto WINAPI :DWORD, :PCTL_INFO, :PCMSG_SIGNED_ENCODE_INFO, :DWORD, :LPBYTE, :LPDWORD


CTL_VERIFY_USAGE_PARA	STRUC
cbSize			dd ?
ListIdentifier		CRYPT_DATA_BLOB <>
cCtlStore		dd ?
rghCtlStore		PVOID ?;HCERTSTORE ?
cSignerStore		dd ?
rghSignerStore		PVOID ?;HCERTSTORE ?
CTL_VERIFY_USAGE_PARA	ENDS
PCTL_VERIFY_USAGE_PARA	typedef ptr CTL_VERIFY_USAGE_PARA

CTL_VERIFY_USAGE_STATUS	 STRUC
cbSize			dd ?
dwError			dd ?
dwFlags			dd ?
ppCtl			PCCTL_CONTEXT ?
dwCtlEntryIndex		dd ?
ppSigner		PCCERT_CONTEXT ?
dwSignerIndex		dd ?
CTL_VERIFY_USAGE_STATUS ENDS
PCTL_VERIFY_USAGE_STATUS typedef ptr CTL_VERIFY_USAGE_STATUS

CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG	equ 0x1
CERT_VERIFY_TRUSTED_SIGNERS_FLAG	equ 0x2
CERT_VERIFY_NO_TIME_CHECK_FLAG		equ 0x4
CERT_VERIFY_ALLOW_MORE_USAGE_FLAG	equ 0x8

CERT_VERIFY_UPDATED_CTL_FLAG		equ 0x1

CertVerifyCTLUsage proto WINAPI :DWORD, :DWORD, :ptr, :PCTL_USAGE, :DWORD, :PCTL_VERIFY_USAGE_PARA, :PCTL_VERIFY_USAGE_STATUS

CERT_REVOCATION_PARA	STRUC
cbSize			dd ?
pIssuerCert		PCCERT_CONTEXT ?
cCertStore		dd ?
rgCertStore		PVOID ?;HCERTSTORE ?
CERT_REVOCATION_PARA	ENDS
PCERT_REVOCATION_PARA	typedef ptr CERT_REVOCATION_PARA

CERT_REVOCATION_STATUS	STRUC
cbSize			dd ?
dwIndex			dd ?
dwError			dd ?
dwReason		dd ?
CERT_REVOCATION_STATUS	ENDS
PCERT_REVOCATION_STATUS typedef ptr CERT_REVOCATION_STATUS

CertVerifyRevocation proto WINAPI :DWORD, :DWORD, :DWORD, :ptr, :DWORD, :PCERT_REVOCATION_PARA, :PCERT_REVOCATION_STATUS

CERT_CONTEXT_REVOCATION_TYPE equ 1
CERT_VERIFY_REV_CHAIN_FLAG equ 0x1

CertCompareIntegerBlob proto WINAPI :PCRYPT_INTEGER_BLOB, :PCRYPT_INTEGER_BLOB
CertCompareCertificate proto WINAPI :DWORD, :PCERT_INFO, :PCERT_INFO
CertCompareCertificateName proto WINAPI :DWORD, :PCERT_NAME_BLOB, :PCERT_NAME_BLOB
CertIsRDNAttrsInCertificateName proto WINAPI :DWORD, :DWORD, :PCERT_NAME_BLOB, :PCERT_RDN

CERT_UNICODE_IS_RDN_ATTRS_FLAG equ 0x1

CertComparePublicKeyInfo proto WINAPI :DWORD, :PCERT_PUBLIC_KEY_INFO, :PCERT_PUBLIC_KEY_INFO
CertGetPublicKeyLength proto WINAPI :DWORD, :PCERT_PUBLIC_KEY_INFO
CryptVerifyCertificateSignature proto WINAPI :HCRYPTPROV, :DWORD, :LPBYTE, :DWORD, :PCERT_PUBLIC_KEY_INFO

CryptHashToBeSigned proto WINAPI :HCRYPTPROV, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptHashCertificate proto WINAPI :HCRYPTPROV, :ALG_ID, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptSignCertificate proto WINAPI :HCRYPTPROV, :DWORD, :DWORD, :LPBYTE, :DWORD, :PCRYPT_ALGORITHM_IDENTIFIER, :ptr, :LPBYTE, :LPDWORD
CryptSignAndEncodeCertificate proto WINAPI :HCRYPTPROV, :DWORD, :DWORD, :LPCSTR, :ptr, :PCRYPT_ALGORITHM_IDENTIFIER, :ptr, :PBYTE, :LPDWORD
CertVerifyTimeValidity proto WINAPI :LPFILETIME, :PCERT_INFO
CertVerifyCRLTimeValidity proto WINAPI :LPFILETIME, :PCRL_INFO
CertVerifyValidityNesting proto WINAPI :PCERT_INFO, :PCERT_INFO
CertVerifyCRLRevocation proto WINAPI :DWORD, :PCERT_INFO, :DWORD, :PCRL_INFO
CertAlgIdToOID proto WINAPI :DWORD
CertOIDToAlgId proto WINAPI :LPCSTR
CertFindExtension proto WINAPI :LPCSTR, :DWORD, :CERT_EXTENSION
CertFindAttribute proto WINAPI :LPCSTR, :DWORD, :CRYPT_ATTRIBUTE
CertFindRDNAttr proto WINAPI :LPCSTR, :PCERT_NAME_INFO
CertGetIntendedKeyUsage proto WINAPI :DWORD, :PCERT_INFO, :LPBYTE, :DWORD
CryptExportPublicKeyInfo proto WINAPI :HCRYPTPROV, :DWORD, :DWORD, :PCERT_PUBLIC_KEY_INFO, :LPDWORD

CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC equ <"CryptDllExportPublicKeyInfoEx">

CryptExportPublicKeyInfoEx proto WINAPI :HCRYPTPROV, :DWORD, :DWORD, :LPSTR, :DWORD, :ptr, :PCERT_PUBLIC_KEY_INFO, :LPDWORD
CryptImportPublicKeyInfo proto WINAPI :HCRYPTPROV, :DWORD, :PCERT_PUBLIC_KEY_INFO, :ptr

CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC equ <"CryptDllImportPublicKeyInfoEx">

CryptImportPublicKeyInfoEx proto WINAPI :HCRYPTPROV, :DWORD, :PCERT_PUBLIC_KEY_INFO, :ALG_ID, :DWORD, :ptr, :ptr
CryptHashPublicKeyInfo proto WINAPI :HCRYPTPROV, :ALG_ID, :DWORD, :DWORD, :PCERT_PUBLIC_KEY_INFO, :LPBYTE, :LPDWORD
CertRDNValueToStrA proto WINAPI :DWORD, :PCERT_RDN_VALUE_BLOB, :LPSTR, :DWORD
CertRDNValueToStrW proto WINAPI :DWORD, :PCERT_RDN_VALUE_BLOB, :LPWSTR, :DWORD
ifdef _UNICODE
CertRDNValueToStr	equ <CertRDNValueToStrW>
else
CertRDNValueToStr	equ <CertRDNValueToStrA>
endif
CertNameToStrA proto WINAPI :DWORD, :PCERT_NAME_BLOB, :DWORD, :LPSTR, :DWORD
CertNameToStrW proto WINAPI :DWORD, :PCERT_NAME_BLOB, :DWORD, :LPWSTR, :DWORD
ifdef _UNICODE
CertNameToStr		equ <CertNameToStrW>
else
CertNameToStr		equ <CertNameToStrA>
endif

CERT_SIMPLE_NAME_STR	equ 1
CERT_OID_NAME_STR	equ 2
CERT_X500_NAME_STR	equ 3

CERT_NAME_STR_SEMICOLON_FLAG	equ 0x40000000
CERT_NAME_STR_NO_PLUS_FLAG	equ 0x20000000
CERT_NAME_STR_NO_QUOTING_FLAG	equ 0x10000000
CERT_NAME_STR_CRLF_FLAG		equ 0x08000000
CERT_NAME_STR_COMMA_FLAG	equ 0x04000000

CertStrToNameA proto WINAPI :DWORD, :LPCSTR, :DWORD, :ptr, :LPBYTE, :LPDWORD, :LPCSTR
CertStrToNameW proto WINAPI :DWORD, :LPCWSTR, :DWORD, :ptr, :LPBYTE, :LPDWORD, :LPCWSTR
ifdef _UNICODE
CertStrToName		equ <CertStrToNameW>
else
CertStrToName		equ <CertStrToNameA>
endif

CALLBACK(PFN_CRYPT_GET_SIGNER_CERTIFICATE, :PVOID, :DWORD, :PCERT_INFO, :HCERTSTORE)

CRYPT_SIGN_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgEncodingType	dd ?
pSigningCert		PCCERT_CONTEXT ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
pvHashAuxInfo		PVOID ?
cMsgCert		dd ?
rgpMsgCert		PCCERT_CONTEXT ?
cMsgCrl			dd ?
rgpMsgCrl		PCCRL_CONTEXT ?
cAuthAttr		dd ?
rgAuthAttr		PCRYPT_ATTRIBUTE ?
cUnauthAttr		dd ?
rgUnauthAttr		PCRYPT_ATTRIBUTE ?
dwFlags			dd ?
dwInnerContentType	dd ?
CRYPT_SIGN_MESSAGE_PARA ENDS
PCRYPT_SIGN_MESSAGE_PARA typedef ptr CRYPT_SIGN_MESSAGE_PARA

CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG equ 0x1

CRYPT_VERIFY_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgAndCertEncodingType dd ?
hCryptProv		HCRYPTPROV ?
pfnGetSignerCertificate PFN_CRYPT_GET_SIGNER_CERTIFICATE ?
pvGetArg		PVOID ?
CRYPT_VERIFY_MESSAGE_PARA ENDS
PCRYPT_VERIFY_MESSAGE_PARA typedef ptr CRYPT_VERIFY_MESSAGE_PARA

CRYPT_ENCRYPT_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgEncodingType	dd ?
hCryptProv		HCRYPTPROV ?
ContentEncryptionAlgorithm CRYPT_ALGORITHM_IDENTIFIER <>
pvEncryptionAuxInfo	PVOID ?
dwFlags			dd ?
dwInnerContentType	dd ?
CRYPT_ENCRYPT_MESSAGE_PARA ENDS
PCRYPT_ENCRYPT_MESSAGE_PARA typedef ptr CRYPT_ENCRYPT_MESSAGE_PARA

CRYPT_DECRYPT_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgAndCertEncodingType dd ?
cCertStore		dd ?
rghCertStore		PVOID ?;HCERTSTORE ?
CRYPT_DECRYPT_MESSAGE_PARA ENDS
PCRYPT_DECRYPT_MESSAGE_PARA typedef ptr CRYPT_DECRYPT_MESSAGE_PARA

CRYPT_HASH_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgEncodingType	dd ?
hCryptProv		HCRYPTPROV ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
pvHashAuxInfo		PVOID ?
CRYPT_HASH_MESSAGE_PARA ENDS
PCRYPT_HASH_MESSAGE_PARA typedef ptr CRYPT_HASH_MESSAGE_PARA

CRYPT_KEY_SIGN_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgAndCertEncodingType dd ?
hCryptProv		HCRYPTPROV ?
dwKeySpec		dd ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
pvHashAuxInfo		PVOID ?
PubKeyAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
CRYPT_KEY_SIGN_MESSAGE_PARA ENDS
PCRYPT_KEY_SIGN_MESSAGE_PARA typedef ptr CRYPT_KEY_SIGN_MESSAGE_PARA

CRYPT_KEY_VERIFY_MESSAGE_PARA STRUC
cbSize			dd ?
dwMsgEncodingType	dd ?
hCryptProv		HCRYPTPROV ?
CRYPT_KEY_VERIFY_MESSAGE_PARA ENDS
PCRYPT_KEY_VERIFY_MESSAGE_PARA typedef ptr CRYPT_KEY_VERIFY_MESSAGE_PARA

CryptSignMessage proto WINAPI :ptr, :BOOL, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptVerifyMessageSignature proto WINAPI :ptr, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD, :PCCERT_CONTEXT
CryptGetMessageSignerCount proto WINAPI :DWORD, :LPBYTE, :DWORD
CryptGetMessageCertificates proto WINAPI :DWORD, :HCRYPTPROV, :DWORD, :LPBYTE, :DWORD
CryptVerifyDetachedMessageSignature proto WINAPI :ptr, :DWORD, :LPBYTE, :DWORD, :DWORD, :LPBYTE, :DWORD, :ptr
CryptEncryptMessage proto WINAPI :ptr, :DWORD, :PCCERT_CONTEXT, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptDecryptMessage proto WINAPI :ptr, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD, :PCCERT_CONTEXT
CryptSignAndEncryptMessage proto WINAPI :ptr, :ptr, :DWORD, :ptr, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptDecryptAndVerifyMessageSignature proto WINAPI :ptr, :ptr, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD, :ptr, :ptr
CryptDecodeMessage proto WINAPI :DWORD, :ptr, :ptr, :DWORD, :LPBYTE, :DWORD, :DWORD, :LPDWORD, :LPDWORD, :LPBYTE, :LPDWORD, :ptr, :ptr
CryptHashMessage proto WINAPI :ptr, :BOOL, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD, :LPBYTE, :LPDWORD
CryptVerifyMessageHash proto WINAPI :ptr, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD, :LPBYTE, :LPDWORD
CryptVerifyDetachedMessageHash proto WINAPI :ptr, :LPBYTE, :DWORD, :DWORD, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptSignMessageWithKey proto WINAPI :ptr, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CryptVerifyMessageSignatureWithKey proto WINAPI :ptr, :ptr, :LPBYTE, :DWORD, :LPBYTE, :LPDWORD
CertOpenSystemStoreA proto WINAPI :HCRYPTPROV, :LPCSTR
CertOpenSystemStoreW proto WINAPI :HCRYPTPROV, :LPCWSTR
ifdef _UNICODE
CertOpenSystemStore	equ <CertOpenSystemStoreW>
else
CertOpenSystemStore	equ <CertOpenSystemStoreA>
endif

CertAddEncodedCertificateToSystemStoreA proto WINAPI :LPCSTR, :LPBYTE, :DWORD
CertAddEncodedCertificateToSystemStoreW proto WINAPI :LPCWSTR, :LPBYTE, :DWORD
ifdef _UNICODE
CertAddEncodedCertificateToSystemStore equ <CertAddEncodedCertificateToSystemStoreW>
else
CertAddEncodedCertificateToSystemStore equ <CertAddEncodedCertificateToSystemStoreA>
endif


CERT_CHAIN		STRUC
cCerts			dd ?
certs			PCERT_BLOB ?
keyLocatorInfo		CRYPT_KEY_PROV_INFO <>
CERT_CHAIN		ENDS
PCERT_CHAIN		typedef ptr CERT_CHAIN

FindCertsByIssuer proto WINAPI :PCERT_CHAIN, :LPDWORD, :LPDWORD, :LPBYTE, :DWORD, :LPCWSTR, :DWORD
CryptQueryObject proto WINAPI :DWORD, :ptr, :DWORD, :DWORD, :DWORD, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr

CERT_QUERY_OBJECT_FILE	equ 0x00000001
CERT_QUERY_OBJECT_BLOB	equ 0x00000002

CERT_QUERY_CONTENT_CERT equ 1
CERT_QUERY_CONTENT_CTL	equ 2
CERT_QUERY_CONTENT_CRL	equ 3
CERT_QUERY_CONTENT_SERIALIZED_STORE equ 4
CERT_QUERY_CONTENT_SERIALIZED_CERT equ 5
CERT_QUERY_CONTENT_SERIALIZED_CTL equ 6
CERT_QUERY_CONTENT_SERIALIZED_CRL equ 7
CERT_QUERY_CONTENT_PKCS7_SIGNED equ 8
CERT_QUERY_CONTENT_PKCS7_UNSIGNED equ 9
CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED equ 10
CERT_QUERY_CONTENT_PKCS10 equ 11
CERT_QUERY_CONTENT_PFX	equ 12
CERT_QUERY_CONTENT_CERT_PAIR equ 13
CERT_QUERY_CONTENT_PFX_AND_LOAD equ 14

CERT_QUERY_CONTENT_FLAG_CERT equ (1 SHL CERT_QUERY_CONTENT_CERT)
CERT_QUERY_CONTENT_FLAG_CTL equ (1 SHL CERT_QUERY_CONTENT_CTL)
CERT_QUERY_CONTENT_FLAG_CRL equ (1 SHL CERT_QUERY_CONTENT_CRL)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE equ (1 SHL CERT_QUERY_CONTENT_SERIALIZED_STORE)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT equ (1 SHL CERT_QUERY_CONTENT_SERIALIZED_CERT)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL equ (1 SHL CERT_QUERY_CONTENT_SERIALIZED_CTL)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL equ (1 SHL CERT_QUERY_CONTENT_SERIALIZED_CRL)
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED equ (1 SHL CERT_QUERY_CONTENT_PKCS7_SIGNED)
CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED equ (1 SHL CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED equ (1 SHL CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
CERT_QUERY_CONTENT_FLAG_PKCS10 equ (1 SHL CERT_QUERY_CONTENT_PKCS10)
CERT_QUERY_CONTENT_FLAG_PFX equ (1 SHL CERT_QUERY_CONTENT_PFX)
CERT_QUERY_CONTENT_FLAG_CERT_PAIR equ (1 SHL CERT_QUERY_CONTENT_CERT_PAIR)
CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD equ (1 SHL CERT_QUERY_CONTENT_PFX_AND_LOAD)
CERT_QUERY_CONTENT_FLAG_ALL equ (CERT_QUERY_CONTENT_FLAG_CERT OR CERT_QUERY_CONTENT_FLAG_CTL OR CERT_QUERY_CONTENT_FLAG_CRL OR CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE OR CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT OR CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL OR CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL OR CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED OR CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED OR CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED OR CERT_QUERY_CONTENT_FLAG_PKCS10 OR CERT_QUERY_CONTENT_FLAG_PFX OR CERT_QUERY_CONTENT_FLAG_CERT_PAIR)

CERT_QUERY_FORMAT_BINARY equ 1
CERT_QUERY_FORMAT_BASE64_ENCODED equ 2

CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED equ 3
CERT_QUERY_FORMAT_FLAG_BINARY equ (1 SHL CERT_QUERY_FORMAT_BINARY)
CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED equ (1 SHL CERT_QUERY_FORMAT_BASE64_ENCODED)
CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED equ (1 SHL CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
CERT_QUERY_FORMAT_FLAG_ALL equ (CERT_QUERY_FORMAT_FLAG_BINARY OR CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED OR CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)

CryptMemAlloc proto WINAPI :ULONG
CryptMemRealloc proto WINAPI :ptr, :ULONG
CryptMemFree proto WINAPI :ptr

HCRYPTASYNC		typedef HANDLE
PHCRYPTASYNC		typedef ptr HCRYPTASYNC

CALLBACK(PFN_CRYPT_ASYNC_PARAM_FREE_FUNC, :LPSTR, :ptr)

CryptCreateAsyncHandle proto WINAPI :DWORD, :PHCRYPTASYNC
CryptSetAsyncParam proto WINAPI :HCRYPTASYNC, :LPSTR, :ptr, :PFN_CRYPT_ASYNC_PARAM_FREE_FUNC
CryptGetAsyncParam proto WINAPI :HCRYPTASYNC, :LPSTR, :ptr, :ptr
CryptCloseAsyncHandle proto WINAPI :HCRYPTASYNC

CRYPT_BLOB_ARRAY	STRUC
cBlob			dd ?
rgBlob			PCRYPT_DATA_BLOB ?
CRYPT_BLOB_ARRAY	ENDS
PCRYPT_BLOB_ARRAY	typedef ptr CRYPT_BLOB_ARRAY

CRYPT_CREDENTIALS	STRUC
cbSize			dd ?
pszCredentialsOid	LPCSTR ?
pvCredentials		LPVOID ?
CRYPT_CREDENTIALS	ENDS
PCRYPT_CREDENTIALS	typedef ptr CRYPT_CREDENTIALS

CREDENTIAL_OID_PASSWORD_CREDENTIALS_A equ 1
CREDENTIAL_OID_PASSWORD_CREDENTIALS_W equ 2

ifdef _UNICODE
CREDENTIAL_OID_PASSWORD_CREDENTIALS equ <CREDENTIAL_OID_PASSWORD_CREDENTIALS_W>
else
CREDENTIAL_OID_PASSWORD_CREDENTIALS equ <CREDENTIAL_OID_PASSWORD_CREDENTIALS_A>
endif

CRYPT_PASSWORD_CREDENTIALSA  STRUC
cbSize			dd ?
pszUsername		LPSTR ?
pszPassword		LPSTR ?
CRYPT_PASSWORD_CREDENTIALSA ENDS
PCRYPT_PASSWORD_CREDENTIALSA typedef ptr CRYPT_PASSWORD_CREDENTIALSA
CRYPT_PASSWORD_CREDENTIALSW  STRUC
cbSize			dd ?
pszUsername		LPWSTR ?
pszPassword		LPWSTR ?
CRYPT_PASSWORD_CREDENTIALSW ENDS
PCRYPT_PASSWORD_CREDENTIALSW typedef ptr CRYPT_PASSWORD_CREDENTIALSW
ifdef _UNICODE
CRYPT_PASSWORD_CREDENTIALS typedef CRYPT_PASSWORD_CREDENTIALSW
PCRYPT_PASSWORD_CREDENTIALS typedef PCRYPT_PASSWORD_CREDENTIALSW
else
CRYPT_PASSWORD_CREDENTIALS typedef CRYPT_PASSWORD_CREDENTIALSA
PCRYPT_PASSWORD_CREDENTIALS typedef PCRYPT_PASSWORD_CREDENTIALSA
endif

SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC equ <"SchemeDllRetrieveEncodedObject">
SCHEME_OID_RETRIEVE_ENCODED_OBJECTW_FUNC equ <"SchemeDllRetrieveEncodedObjectW">

CALLBACK(PFN_FREE_ENCODED_OBJECT_FUNC, :LPCSTR, :PCRYPT_BLOB_ARRAY, :LPVOID)

CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC equ <"ContextDllCreateObjectContext">

CONTEXT_OID_CERTIFICATE equ 1
CONTEXT_OID_CRL		equ 2
CONTEXT_OID_CTL		equ 3
CONTEXT_OID_PKCS7	equ 4
CONTEXT_OID_CAPI2_ANY	equ 5
CONTEXT_OID_OCSP_RESP	equ 6

CRYPT_RETRIEVE_MULTIPLE_OBJECTS equ 0x00000001
CRYPT_CACHE_ONLY_RETRIEVAL equ 0x00000002
CRYPT_WIRE_ONLY_RETRIEVAL equ 0x00000004
CRYPT_DONT_CACHE_RESULT equ 0x00000008
CRYPT_ASYNC_RETRIEVAL	equ 0x00000010
CRYPT_STICKY_CACHE_RETRIEVAL equ 0x00001000
CRYPT_LDAP_SCOPE_BASE_ONLY_RETRIEVAL equ 0x00002000
CRYPT_OFFLINE_CHECK_RETRIEVAL equ 0x00004000

CRYPT_LDAP_INSERT_ENTRY_ATTRIBUTE equ 0x00008000
CRYPT_LDAP_SIGN_RETRIEVAL equ 0x00010000
CRYPT_NO_AUTH_RETRIEVAL equ 0x00020000
CRYPT_LDAP_AREC_EXCLUSIVE_RETRIEVAL equ 0x00040000
CRYPT_AIA_RETRIEVAL	equ 0x00080000
CRYPT_HTTP_POST_RETRIEVAL equ 0x00100000
CRYPT_PROXY_CACHE_RETRIEVAL equ 0x00200000
CRYPT_NOT_MODIFIED_RETRIEVAL equ 0x00400000

CRYPT_VERIFY_CONTEXT_SIGNATURE equ 0x00000020
CRYPT_VERIFY_DATA_HASH	equ 0x00000040

CRYPT_KEEP_TIME_VALID	equ 0x00000080
CRYPT_DONT_VERIFY_SIGNATURE equ 0x00000100
CRYPT_DONT_CHECK_TIME_VALIDITY equ 0x00000200

CRYPT_CHECK_FRESHNESS_TIME_VALIDITY equ 0x00000400
CRYPT_ACCUMULATIVE_TIMEOUT equ 0x00000800
CRYPT_OCSP_ONLY_RETRIEVAL equ 0x01000000

CRYPTNET_URL_CACHE_PRE_FETCH_INFO STRUC
cbSize			dd ?
dwObjectType		dd ?
dwError			dd ?
dwReserved		dd ?
ThisUpdateTime		FILETIME <>
NextUpdateTime		FILETIME <>
PublishTime		FILETIME <>
CRYPTNET_URL_CACHE_PRE_FETCH_INFO ENDS
PCRYPTNET_URL_CACHE_PRE_FETCH_INFO typedef ptr CRYPTNET_URL_CACHE_PRE_FETCH_INFO

CRYPTNET_URL_CACHE_PRE_FETCH_NONE equ 0
CRYPTNET_URL_CACHE_PRE_FETCH_BLOB equ 1
CRYPTNET_URL_CACHE_PRE_FETCH_CRL equ 2
CRYPTNET_URL_CACHE_PRE_FETCH_OCSP equ 3
CRYPTNET_URL_CACHE_PRE_FETCH_AUTOROOT_CAB equ 5

CRYPTNET_URL_CACHE_FLUSH_INFO  STRUC
cbSize			dd ?
dwExemptSeconds		dd ?
ExpireTime		FILETIME <>
CRYPTNET_URL_CACHE_FLUSH_INFO ENDS
PCRYPTNET_URL_CACHE_FLUSH_INFO typedef ptr CRYPTNET_URL_CACHE_FLUSH_INFO

CRYPTNET_URL_CACHE_DEFAULT_FLUSH equ 0
CRYPTNET_URL_CACHE_DISABLE_FLUSH equ 0xFFFFFFFF

CRYPTNET_URL_CACHE_RESPONSE_INFO  STRUC
cbSize			dd ?
wResponseType		dw ?
wResponseFlags		dw ?
LastModifiedTime	FILETIME <>
dwMaxAge		dd ?
pwszETag		LPCWSTR ?
dwProxyId		dd ?
CRYPTNET_URL_CACHE_RESPONSE_INFO ENDS
PCRYPTNET_URL_CACHE_RESPONSE_INFO typedef ptr CRYPTNET_URL_CACHE_RESPONSE_INFO


CRYPTNET_URL_CACHE_RESPONSE_NONE equ 0
CRYPTNET_URL_CACHE_RESPONSE_HTTP equ 1

CRYPTNET_URL_CACHE_RESPONSE_VALIDATED equ 0x8000

CRYPT_RETRIEVE_AUX_INFO	 STRUC
cbSize			dd ?
pLastSyncTime		LPFILETIME ?
dwMaxUrlRetrievalByteCount dd ?
pPreFetchInfo		PCRYPTNET_URL_CACHE_PRE_FETCH_INFO ?
pFlushInfo		PCRYPTNET_URL_CACHE_FLUSH_INFO ?
ppResponseInfo		PVOID ? ;LPPCRYPTNET_URL_CACHE_RESPONSE_INFO ?
pwszCacheFileNamePrefix LPWSTR ?
pftCacheResync		LPFILETIME ?
fProxyCacheRetrieval	BOOL ?
dwHttpStatusCode	dd ?
CRYPT_RETRIEVE_AUX_INFO ENDS
PCRYPT_RETRIEVE_AUX_INFO typedef ptr CRYPT_RETRIEVE_AUX_INFO

CryptRetrieveObjectByUrlA proto WINAPI :LPCSTR, :LPCSTR, :DWORD, :DWORD, :ptr, :HCRYPTASYNC, :ptr, :ptr, :ptr
CryptRetrieveObjectByUrlW proto WINAPI :LPCWSTR, :LPCSTR, :DWORD, :DWORD, :ptr,:HCRYPTASYNC, :ptr, :ptr,:ptr

ifdef _UNICODE
CryptRetrieveObjectByUrl equ <CryptRetrieveObjectByUrlW>
else
CryptRetrieveObjectByUrl equ <CryptRetrieveObjectByUrlA>
endif

CALLBACK(PFN_CRYPT_CANCEL_RETRIEVAL, :DWORD, :ptr)

CryptInstallCancelRetrieval proto WINAPI :PFN_CRYPT_CANCEL_RETRIEVAL, :ptr, :DWORD, :ptr
CryptUninstallCancelRetrieval proto WINAPI :DWORD, :ptr
CryptCancelAsyncRetrieval proto WINAPI :HCRYPTASYNC

CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION equ 1

CALLBACK(PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC, :LPVOID, :DWORD, :LPCSTR, :LPSTR, :LPVOID)

CRYPT_ASYNC_RETRIEVAL_COMPLETION  STRUC
pfnCompletion		PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC ?
pvCompletion		LPVOID ?
CRYPT_ASYNC_RETRIEVAL_COMPLETION ENDS
PCRYPT_ASYNC_RETRIEVAL_COMPLETION typedef ptr CRYPT_ASYNC_RETRIEVAL_COMPLETION

CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL equ 2

CALLBACK(PFN_CANCEL_ASYNC_RETRIEVAL_FUNC, :HCRYPTASYNC)

CRYPT_GET_URL_FROM_PROPERTY equ 0x00000001
CRYPT_GET_URL_FROM_EXTENSION equ 0x00000002
CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE equ 0x00000004
CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE equ 0x00000008

CRYPT_URL_ARRAY		STRUC
cUrl			dd ?
rgwszUrl		PVOID ?
CRYPT_URL_ARRAY		ENDS
PCRYPT_URL_ARRAY	typedef ptr CRYPT_URL_ARRAY

CRYPT_URL_INFO		STRUC
cbSize			dd ?
dwSyncDeltaTime		dd ?
cGroup			dd ?
rgcGroupEntry		LPDWORD ?
CRYPT_URL_INFO		ENDS
PCRYPT_URL_INFO		typedef ptr CRYPT_URL_INFO

CryptGetObjectUrl proto WINAPI :LPCSTR, :ptr, :DWORD, :PCRYPT_URL_ARRAY, :ptr, :PCRYPT_URL_INFO, :ptr, :ptr

URL_OID_GET_OBJECT_URL_FUNC equ <"UrlDllGetObjectUrl">

URL_OID_CERTIFICATE_ISSUER equ 1
URL_OID_CERTIFICATE_CRL_DIST_POINT equ 2
URL_OID_CTL_ISSUER	equ 3
URL_OID_CTL_NEXT_UPDATE equ 4
URL_OID_CRL_ISSUER	equ 5
URL_OID_CERTIFICATE_FRESHEST_CRL equ 6
URL_OID_CRL_FRESHEST_CRL equ 7
URL_OID_CROSS_CERT_DIST_POINT equ 8
URL_OID_CERTIFICATE_OCSP equ 9
URL_OID_CERTIFICATE_OCSP_AND_CRL_DIST_POINT equ 10
URL_OID_CERTIFICATE_CRL_DIST_POINT_AND_OCSP equ 11
URL_OID_CROSS_CERT_SUBJECT_INFO_ACCESS equ 12
URL_OID_CERTIFICATE_ONLY_OCSP equ 13

CERT_CRL_CONTEXT_PAIR	STRUC
pCertContext		PCCERT_CONTEXT ?
pCrlContext		PCCRL_CONTEXT ?
CERT_CRL_CONTEXT_PAIR	ENDS
PCERT_CRL_CONTEXT_PAIR	typedef ptr CERT_CRL_CONTEXT_PAIR
PCCERT_CRL_CONTEXT_PAIR typedef ptr CERT_CRL_CONTEXT_PAIR

CRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO STRUC
cbSize			dd ?
iDeltaCrlIndicator	SINT ?
pftCacheResync		LPFILETIME ?
pLastSyncTime		LPFILETIME ?
pMaxAgeTime		LPFILETIME ?
pChainPara		PVOID ? ;PCERT_REVOCATION_CHAIN_PARA ?
pDeltaCrlIndicator	PCRYPT_INTEGER_BLOB ?
CRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO ENDS
PCRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO typedef ptr CRYPT_GET_TIME_VALID_OBJECT_EXTRA_INFO

CryptGetTimeValidObject proto WINAPI :LPCSTR,  :ptr, :ptr, :ptr, :DWORD, :DWORD, :ptr, :ptr, :ptr

TIME_VALID_OID_GET_OBJECT_FUNC equ <"TimeValidDllGetObject">

TIME_VALID_OID_GET_CTL	equ 1
TIME_VALID_OID_GET_CRL	equ 2
TIME_VALID_OID_GET_CRL_FROM_CERT equ 3

TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CERT equ 4
TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CRL equ 5

CryptFlushTimeValidObject proto WINAPI :LPCSTR, :ptr, :ptr, :DWORD, :ptr

TIME_VALID_OID_FLUSH_OBJECT_FUNC equ <"TimeValidDllFlushObject">

TIME_VALID_OID_FLUSH_CTL equ 1
TIME_VALID_OID_FLUSH_CRL equ 2
TIME_VALID_OID_FLUSH_CRL_FROM_CERT equ 3

TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CERT equ 4
TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CRL equ 5

CRYPTPROTECT_PROMPTSTRUCT STRUC
cbSize			dd ?
dwPromptFlags		dd ?
hwndApp			HWND ?
szPrompt		LPCWSTR ?
CRYPTPROTECT_PROMPTSTRUCT ENDS
PCRYPTPROTECT_PROMPTSTRUCT typedef ptr CRYPTPROTECT_PROMPTSTRUCT


CRYPTPROTECT_DEFAULT_PROVIDER equ <{ 0xdf9d8cd0, 0x1501, 0x11d1, {0x8c, 0x7a, 0x00, 0xc0, 0x4f, 0xc2, 0x97, 0xeb} }>

CRYPTPROTECT_PROMPT_ON_UNPROTECT equ 0x1
CRYPTPROTECT_PROMPT_ON_PROTECT equ 0x2
CRYPTPROTECT_PROMPT_RESERVED equ 0x04
CRYPTPROTECT_PROMPT_STRONG equ 0x08
CRYPTPROTECT_PROMPT_REQUIRE_STRONG equ 0x10
CRYPTPROTECT_UI_FORBIDDEN equ 0x1
CRYPTPROTECT_LOCAL_MACHINE equ 0x4
CRYPTPROTECT_CRED_SYNC	equ 0x8
CRYPTPROTECT_AUDIT	equ 0x10
CRYPTPROTECT_NO_RECOVERY equ 0x20
CRYPTPROTECT_VERIFY_PROTECTION equ 0x40
CRYPTPROTECT_CRED_REGENERATE equ 0x80
CRYPTPROTECT_FIRST_RESERVED_FLAGVAL equ 0x0FFFFFFF
CRYPTPROTECT_LAST_RESERVED_FLAGVAL equ 0xFFFFFFFF

CryptProtectData proto WINAPI :ptr, :LPCWSTR, :ptr, :ptr, :ptr, :DWORD, :ptr
CryptUnprotectData proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :DWORD, :ptr

;if (NTDDI_VERSION GE NTDDI_WINLH)
CryptUpdateProtectedState proto WINAPI :PSID, :LPCWSTR, :DWORD, :ptr, :ptr
;endif

CRYPTPROTECTMEMORY_BLOCK_SIZE equ 16
CRYPTPROTECTMEMORY_SAME_PROCESS equ 0x00
CRYPTPROTECTMEMORY_CROSS_PROCESS equ 0x01
CRYPTPROTECTMEMORY_SAME_LOGON equ 0x02

CryptProtectMemory proto WINAPI :ptr, :DWORD, :DWORD
CryptUnprotectMemory proto WINAPI :ptr, :DWORD, :DWORD

HCRYPTPROV_OR_NCRYPT_KEY_HANDLE typedef ULONG_PTR

CertCreateSelfSignCertificate proto WINAPI :HCRYPTPROV_OR_NCRYPT_KEY_HANDLE, :ptr, :DWORD, :ptr, :ptr, :ptr, :ptr, :ptr
CERT_CREATE_SELFSIGN_NO_SIGN equ 1
CERT_CREATE_SELFSIGN_NO_KEY_INFO equ 2

CryptGetKeyIdentifierProperty proto WINAPI :ptr, :DWORD, :DWORD, :LPCWSTR, :ptr, :ptr, :ptr

CRYPT_KEYID_MACHINE_FLAG equ 0x00000020
CRYPT_KEYID_ALLOC_FLAG	equ 0x00008000

CryptSetKeyIdentifierProperty proto WINAPI :ptr, :DWORD, :DWORD, :LPCWSTR, :ptr, :ptr

CRYPT_KEYID_DELETE_FLAG equ 0x00000010
CRYPT_KEYID_SET_NEW_FLAG equ 0x00002000

CALLBACK(PFN_CRYPT_ENUM_KEYID_PROP, :ptr, :DWORD, :ptr, :ptr, :DWORD, :ptr, :ptr)

CryptEnumKeyIdentifierProperties proto WINAPI :ptr, :DWORD, :DWORD, :LPCWSTR, :ptr, :ptr, :ptr
CryptCreateKeyIdentifierFromCSP proto WINAPI :DWORD, :LPCSTR, :ptr, :DWORD, :DWORD, :ptr, :ptr, :ptr

CERT_CHAIN_CONFIG_REGPATH equ <L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CertDllCreateCertificateChainEngine\\Config">
CERT_CHAIN_MAX_URL_RETRIEVAL_BYTE_COUNT_VALUE_NAME equ <L"MaxUrlRetrievalByteCount">
CERT_CHAIN_MAX_URL_RETRIEVAL_BYTE_COUNT_DEFAULT equ (100*1024*1024)

CERT_CHAIN_CACHE_RESYNC_FILETIME_VALUE_NAME equ <L"ChainCacheResyncFiletime">

CERT_CHAIN_DISABLE_MANDATORY_BASIC_CONSTRAINTS_VALUE_NAME equ <L"DisableMandatoryBasicConstraints">
CERT_CHAIN_DISABLE_CA_NAME_CONSTRAINTS_VALUE_NAME equ <L"DisableCANameConstraints">
CERT_CHAIN_DISABLE_UNSUPPORTED_CRITICAL_EXTENSIONS_VALUE_NAME equ <L"DisableUnsupportedCriticalExtensions">

CERT_CHAIN_MAX_AIA_URL_COUNT_IN_CERT_VALUE_NAME equ <L"MaxAIAUrlCountInCert">
CERT_CHAIN_MAX_AIA_URL_COUNT_IN_CERT_DEFAULT equ 5

CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_COUNT_PER_CHAIN_VALUE_NAME equ <L"MaxAIAUrlRetrievalCountPerChain">
CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_COUNT_PER_CHAIN_DEFAULT equ 3

CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_BYTE_COUNT_VALUE_NAME equ <L"MaxAIAUrlRetrievalByteCount">
CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_BYTE_COUNT_DEFAULT equ 100000

CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_CERT_COUNT_VALUE_NAME equ <L"MaxAIAUrlRetrievalCertCount">
CERT_CHAIN_MAX_AIA_URL_RETRIEVAL_CERT_COUNT_DEFAULT equ 10

CERT_CHAIN_OCSP_VALIDITY_SECONDS_VALUE_NAME equ <L"OcspValiditySeconds">
CERT_CHAIN_OCSP_VALIDITY_SECONDS_DEFAULT equ (12 * 60 * 60)


CERT_SRV_OCSP_RESP_MIN_VALIDITY_SECONDS_VALUE_NAME equ <L"SrvOcspRespMinValiditySeconds">
CERT_SRV_OCSP_RESP_MIN_VALIDITY_SECONDS_DEFAULT equ (10 * 60)

CERT_SRV_OCSP_RESP_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME equ <L"SrvOcspRespUrlRetrievalTimeoutMilliseconds">
CERT_SRV_OCSP_RESP_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT equ (15 * 1000)

CERT_SRV_OCSP_RESP_MAX_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME equ <L"SrvOcspRespMaxBeforeNextUpdateSeconds">
CERT_SRV_OCSP_RESP_MAX_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT equ (4 * 60 * 60)

CERT_SRV_OCSP_RESP_MIN_BEFORE_NEXT_UPDATE_SECONDS_VALUE_NAME equ <L"SrvOcspRespMinBeforeNextUpdateSeconds">
CERT_SRV_OCSP_RESP_MIN_BEFORE_NEXT_UPDATE_SECONDS_DEFAULT equ (2 * 60)

CERT_SRV_OCSP_RESP_MIN_AFTER_NEXT_UPDATE_SECONDS_VALUE_NAME equ <L"SrvOcspRespMinAfterNextUpdateSeconds">
CERT_SRV_OCSP_RESP_MIN_AFTER_NEXT_UPDATE_SECONDS_DEFAULT equ (1 * 60)


CRYPTNET_MAX_CACHED_OCSP_PER_CRL_COUNT_VALUE_NAME equ <L"CryptnetMaxCachedOcspPerCrlCount">
CRYPTNET_MAX_CACHED_OCSP_PER_CRL_COUNT_DEFAULT equ 500

CRYPTNET_OCSP_AFTER_CRL_DISABLE equ 0xFFFFFFFF

CRYPTNET_URL_CACHE_DEFAULT_FLUSH_EXEMPT_SECONDS_VALUE_NAME equ <L"CryptnetDefaultFlushExemptSeconds">
CRYPTNET_URL_CACHE_DEFAULT_FLUSH_EXEMPT_SECONDS_DEFAULT equ (28 * 24 * 60 * 60)

CRYPTNET_PRE_FETCH_MIN_MAX_AGE_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchMinMaxAgeSeconds">
CRYPTNET_PRE_FETCH_MIN_MAX_AGE_SECONDS_DEFAULT equ (1 * 60 * 60)

CRYPTNET_PRE_FETCH_MAX_MAX_AGE_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchMaxMaxAgeSeconds">
CRYPTNET_PRE_FETCH_MAX_MAX_AGE_SECONDS_DEFAULT equ (14 * 24 * 60 * 60)


CRYPTNET_PRE_FETCH_AFTER_PUBLISH_PRE_FETCH_DIVISOR_VALUE_NAME equ <L"CryptnetPreFetchAfterPublishPreFetchDivisor">
CRYPTNET_PRE_FETCH_AFTER_PUBLISH_PRE_FETCH_DIVISOR_DEFAULT equ 10

CRYPTNET_PRE_FETCH_BEFORE_NEXT_UPDATE_PRE_FETCH_DIVISOR_VALUE_NAME equ <L"CryptnetPreFetchBeforeNextUpdatePreFetchDivisor">
CRYPTNET_PRE_FETCH_BEFORE_NEXT_UPDATE_PRE_FETCH_DIVISOR_DEFAULT equ 20

CRYPTNET_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchMinBeforeNextUpdatePreFetchSeconds">
CRYPTNET_PRE_FETCH_MIN_BEFORE_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT equ (1 * 60 * 60)

CRYPTNET_PRE_FETCH_VALIDITY_PERIOD_AFTER_NEXT_UPDATE_PRE_FETCH_DIVISOR_VALUE_NAME equ <L"CryptnetPreFetchValidityPeriodAfterNextUpdatePreFetchDivisor">
CRYPTNET_PRE_FETCH_VALIDITY_PERIOD_AFTER_NEXT_UPDATE_PRE_FETCH_DIVISOR_DEFAULT equ 10

CRYPTNET_PRE_FETCH_MAX_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchMaxAfterNextUpdatePreFetchPeriodSeconds">
CRYPTNET_PRE_FETCH_MAX_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT equ (4 * 60 * 60)

CRYPTNET_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchMinAfterNextUpdatePreFetchPeriodSeconds">
CRYPTNET_PRE_FETCH_MIN_AFTER_NEXT_UPDATE_PRE_FETCH_PERIOD_SECONDS_DEFAULT equ (30 * 60)

CRYPTNET_PRE_FETCH_AFTER_CURRENT_TIME_PRE_FETCH_PERIOD_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchAfterCurrentTimePreFetchPeriodSeconds">
CRYPTNET_PRE_FETCH_AFTER_CURRENT_TIME_PRE_FETCH_PERIOD_SECONDS_DEFAULT equ (30 * 60)

CRYPTNET_PRE_FETCH_TRIGGER_PERIOD_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchTriggerPeriodSeconds">
CRYPTNET_PRE_FETCH_TRIGGER_PERIOD_SECONDS_DEFAULT equ (10 * 60)

CRYPTNET_PRE_FETCH_TRIGGER_DISABLE equ 0xFFFFFFFF

CRYPTNET_PRE_FETCH_SCAN_AFTER_TRIGGER_DELAY_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchScanAfterTriggerDelaySeconds">
CRYPTNET_PRE_FETCH_SCAN_AFTER_TRIGGER_DELAY_SECONDS_DEFAULT equ 30

CRYPTNET_PRE_FETCH_RETRIEVAL_TIMEOUT_SECONDS_VALUE_NAME equ <L"CryptnetPreFetchRetrievalTimeoutSeconds">
CRYPTNET_PRE_FETCH_RETRIEVAL_TIMEOUT_SECONDS_DEFAULT equ (5 * 60)

CERT_GROUP_POLICY_CHAIN_CONFIG_REGPATH equ <L"\\ChainEngine\\Config">
CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH equ <L"\\ChainEngine\\Config">

CERT_CHAIN_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME equ <L"ChainUrlRetrievalTimeoutMilliseconds">
CERT_CHAIN_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT equ (15 * 1000)

CERT_CHAIN_REV_ACCUMULATIVE_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_VALUE_NAME equ <L"ChainRevAccumulativeUrlRetrievalTimeoutMilliseconds">
CERT_CHAIN_REV_ACCUMULATIVE_URL_RETRIEVAL_TIMEOUT_MILLISECONDS_DEFAULT equ (20 * 1000)

CERT_RETR_BEHAVIOR_INET_AUTH_VALUE_NAME equ <L"EnableInetUnknownAuth">
CERT_RETR_BEHAVIOR_INET_STATUS_VALUE_NAME equ <L"EnableInetLocal">
CERT_RETR_BEHAVIOR_FILE_VALUE_NAME equ <L"AllowFileUrlScheme">
CERT_RETR_BEHAVIOR_LDAP_VALUE_NAME equ <L"DisableLDAPSignAndEncrypt">

CRYPTNET_CACHED_OCSP_SWITCH_TO_CRL_COUNT_VALUE_NAME equ <L"CryptnetCachedOcspSwitchToCrlCount">
CRYPTNET_CACHED_OCSP_SWITCH_TO_CRL_COUNT_DEFAULT equ 50

CRYPTNET_CRL_BEFORE_OCSP_ENABLE equ 0xFFFFFFFF

CERT_CHAIN_DISABLE_AIA_URL_RETRIEVAL_VALUE_NAME equ <L"DisableAIAUrlRetrieval">

CERT_CHAIN_OPTIONS_VALUE_NAME equ <L"Options">
CERT_CHAIN_OPTION_DISABLE_AIA_URL_RETRIEVAL equ 0x2
CERT_CHAIN_OPTION_ENABLE_SIA_URL_RETRIEVAL equ 0x4

CERT_CHAIN_CROSS_CERT_DOWNLOAD_INTERVAL_HOURS_VALUE_NAME equ <L"CrossCertDownloadIntervalHours">
CERT_CHAIN_CROSS_CERT_DOWNLOAD_INTERVAL_HOURS_DEFAULT equ (24 * 7)

CERT_CHAIN_CRL_VALIDITY_EXT_PERIOD_HOURS_VALUE_NAME equ <L"CRLValidityExtensionPeriod">
CERT_CHAIN_CRL_VALIDITY_EXT_PERIOD_HOURS_DEFAULT equ 12

HCERTCHAINENGINE	typedef HANDLE

HCCE_CURRENT_USER	equ (NULL)
HCCE_LOCAL_MACHINE	equ (0x1)



CERT_CHAIN_CACHE_END_CERT equ 0x00000001
CERT_CHAIN_THREAD_STORE_SYNC equ 0x00000002
CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL equ 0x00000004
CERT_CHAIN_USE_LOCAL_MACHINE_STORE equ 0x00000008
CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE equ 0x00000010
CERT_CHAIN_ENABLE_SHARE_STORE equ 0x00000020

CERT_CHAIN_ENGINE_CONFIG  STRUC
cbSize			dd ?
hRestrictedRoot		HCERTSTORE ?
hRestrictedTrust	HCERTSTORE ?
hRestrictedOther	HCERTSTORE ?
cAdditionalStore	dd ?
rghAdditionalStore	PVOID ?
dwFlags			dd ?
dwUrlRetrievalTimeout	dd ?
MaximumCachedCertificates dd ?
CycleDetectionModulus	dd ?
if (NTDDI_VERSION GE NTDDI_WIN7)
hExclusiveRoot		HCERTSTORE ?
hExclusiveTrustedPeople HCERTSTORE ?
endif
CERT_CHAIN_ENGINE_CONFIG ENDS
PCERT_CHAIN_ENGINE_CONFIG typedef ptr CERT_CHAIN_ENGINE_CONFIG

CertCreateCertificateChainEngine proto WINAPI :PCERT_CHAIN_ENGINE_CONFIG, :ptr
CertFreeCertificateChainEngine proto WINAPI :HCERTCHAINENGINE
CertResyncCertificateChainEngine proto WINAPI :HCERTCHAINENGINE

CERT_TRUST_STATUS	STRUC
dwErrorStatus		dd ?
dwInfoStatus		dd ?
CERT_TRUST_STATUS	ENDS
PCERT_TRUST_STATUS	typedef ptr CERT_TRUST_STATUS


CERT_TRUST_NO_ERROR	equ 0x00000000
CERT_TRUST_IS_NOT_TIME_VALID equ 0x00000001
CERT_TRUST_IS_NOT_TIME_NESTED equ 0x00000002
CERT_TRUST_IS_REVOKED	equ 0x00000004
CERT_TRUST_IS_NOT_SIGNATURE_VALID equ 0x00000008
CERT_TRUST_IS_NOT_VALID_FOR_USAGE equ 0x00000010
CERT_TRUST_IS_UNTRUSTED_ROOT equ 0x00000020
CERT_TRUST_REVOCATION_STATUS_UNKNOWN equ 0x00000040
CERT_TRUST_IS_CYCLIC	equ 0x00000080
CERT_TRUST_INVALID_EXTENSION equ 0x00000100
CERT_TRUST_INVALID_POLICY_CONSTRAINTS equ 0x00000200
CERT_TRUST_INVALID_BASIC_CONSTRAINTS equ 0x00000400
CERT_TRUST_INVALID_NAME_CONSTRAINTS equ 0x00000800
CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT equ 0x00001000
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT equ 0x00002000
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT equ 0x00004000
CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT equ 0x00008000
CERT_TRUST_IS_OFFLINE_REVOCATION equ 0x01000000
CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY equ 0x02000000
CERT_TRUST_IS_EXPLICIT_DISTRUST equ 0x04000000
CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT equ 0x08000000
CERT_TRUST_IS_PARTIAL_CHAIN equ 0x00010000
CERT_TRUST_CTL_IS_NOT_TIME_VALID equ 0x00020000
CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID equ 0x00040000
CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE equ 0x00080000
CERT_TRUST_HAS_EXACT_MATCH_ISSUER equ 0x00000001
CERT_TRUST_HAS_KEY_MATCH_ISSUER equ 0x00000002
CERT_TRUST_HAS_NAME_MATCH_ISSUER equ 0x00000004
CERT_TRUST_IS_SELF_SIGNED equ 0x00000008
CERT_TRUST_HAS_PREFERRED_ISSUER equ 0x00000100
CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY equ 0x00000200
CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS equ 0x00000400
CERT_TRUST_IS_PEER_TRUSTED equ 0x00000800
CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED equ 0x00001000
CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE equ 0x00002000
CERT_TRUST_IS_COMPLEX_CHAIN equ 0x00010000

CERT_REVOCATION_INFO	STRUC
cbSize			dd ?
dwRevocationResult	dd ?
pszRevocationOid	LPCSTR ?
pvOidSpecificInfo	LPVOID ?
fHasFreshnessTime	BOOL ?
dwFreshnessTime		dd ?
pCrlInfo		PVOID ?;PCERT_REVOCATION_CRL_INFO ?
CERT_REVOCATION_INFO	ENDS
PCERT_REVOCATION_INFO	typedef ptr CERT_REVOCATION_INFO

CERT_TRUST_LIST_INFO	STRUC
cbSize			dd ?
pCtlEntry		PCTL_ENTRY ?
pCtlContext		PCCTL_CONTEXT ?
CERT_TRUST_LIST_INFO	ENDS
PCERT_TRUST_LIST_INFO	typedef ptr CERT_TRUST_LIST_INFO

CERT_CHAIN_ELEMENT	STRUC
cbSize			dd ?
pCertContext		PCCERT_CONTEXT ?
TrustStatus		CERT_TRUST_STATUS <>
pRevocationInfo		PCERT_REVOCATION_INFO ?
pIssuanceUsage		PCERT_ENHKEY_USAGE ?
pApplicationUsage	PCERT_ENHKEY_USAGE ?
pwszExtendedErrorInfo	LPCWSTR ?
CERT_CHAIN_ELEMENT	ENDS
PCERT_CHAIN_ELEMENT	typedef ptr CERT_CHAIN_ELEMENT
PCCERT_CHAIN_ELEMENT	typedef ptr CERT_CHAIN_ELEMENT

CERT_SIMPLE_CHAIN	STRUC
cbSize			dd ?
TrustStatus		CERT_TRUST_STATUS <>
cElement		dd ?
rgpElement		PVOID ?;CERT_CHAIN_ELEMENT ?
pTrustListInfo		PCERT_TRUST_LIST_INFO ?
fHasRevocationFreshnessTime BOOL ?
dwRevocationFreshnessTime dd ?
CERT_SIMPLE_CHAIN	ENDS
PCERT_SIMPLE_CHAIN	typedef ptr CERT_SIMPLE_CHAIN
PCCERT_SIMPLE_CHAIN	typedef ptr CERT_SIMPLE_CHAIN

CERT_CHAIN_CONTEXT	STRUC
cbSize			dd ?
TrustStatus		CERT_TRUST_STATUS <>
cChain			dd ?
rgpChain		PVOID ?
cLowerQualityChainContext dd ?
rgpLowerQualityChainContext PVOID ?
fHasRevocationFreshnessTime BOOL ?
dwRevocationFreshnessTime dd ?
dwCreateFlags		dd ?
ChainId			GUID <>
CERT_CHAIN_CONTEXT	ENDS
PCERT_CHAIN_CONTEXT	typedef CERT_CHAIN_CONTEXT
PCCERT_CHAIN_CONTEXT	typedef ptr CERT_CHAIN_CONTEXT

USAGE_MATCH_TYPE_AND	equ 0x00000000
USAGE_MATCH_TYPE_OR	equ 0x00000001

CERT_USAGE_MATCH	STRUC
dwType			dd ?
Usage			CERT_ENHKEY_USAGE <>
CERT_USAGE_MATCH	ENDS
PCERT_USAGE_MATCH	typedef ptr CERT_USAGE_MATCH

CTL_USAGE_MATCH		STRUC
dwType			dd ?
Usage			CTL_USAGE <>
CTL_USAGE_MATCH		ENDS
PCTL_USAGE_MATCH	typedef ptr CTL_USAGE_MATCH

CERT_CHAIN_PARA		STRUC
cbSize			dd ?
RequestedUsage		CERT_USAGE_MATCH <>
ifdef CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
RequestedIssuancePolicy CERT_USAGE_MATCH <>
dwUrlRetrievalTimeout	dd ?
fCheckRevocationFreshnessTime BOOL ?
dwRevocationFreshnessTime dd ?
pftCacheResync		LPFILETIME ?
endif
CERT_CHAIN_PARA		ENDS
PCERT_CHAIN_PARA	typedef ptr CERT_CHAIN_PARA

CERT_CHAIN_REVOCATION_CHECK_END_CERT equ 0x10000000
CERT_CHAIN_REVOCATION_CHECK_CHAIN equ 0x20000000
CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT equ 0x40000000
CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY equ 0x80000000
CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT equ 0x08000000

CERT_CHAIN_REVOCATION_CHECK_OCSP_CERT equ 0x04000000

CERT_CHAIN_DISABLE_PASS1_QUALITY_FILTERING equ 0x00000040
CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS equ 0x00000080
CERT_CHAIN_DISABLE_AUTH_ROOT_AUTO_UPDATE equ 0x00000100

CERT_CHAIN_TIMESTAMP_TIME equ 0x00000200

CERT_CHAIN_ENABLE_PEER_TRUST equ 0x00000400
CERT_CHAIN_DISABLE_MY_PEER_TRUST equ 0x00000800

CertGetCertificateChain proto WINAPI :HCERTCHAINENGINE, :PCCERT_CONTEXT, :LPFILETIME, :HCERTSTORE, :ptr, :DWORD, :ptr, :ptr
CertFreeCertificateChain proto WINAPI :PCCERT_CHAIN_CONTEXT
CertDuplicateCertificateChain proto WINAPI :PCCERT_CHAIN_CONTEXT

CERT_REVOCATION_CHAIN_PARA STRUC
cbSize			dd ?
hChainEngine		HCERTCHAINENGINE ?
hAdditionalStore	HCERTSTORE ?
dwChainFlags		dd ?
dwUrlRetrievalTimeout	dd ?
pftCurrentTime		LPFILETIME ?
pftCacheResync		LPFILETIME ?
cbMaxUrlRetrievalByteCount dd ?
CERT_REVOCATION_CHAIN_PARA ENDS

REVOCATION_OID_CRL_REVOCATION equ 1

CRL_REVOCATION_INFO	STRUC
pCrlEntry		PCRL_ENTRY ?
pCrlContext		PCCRL_CONTEXT ?
pCrlIssuerChain		PCCERT_CHAIN_CONTEXT ?
CRL_REVOCATION_INFO	ENDS
PCRL_REVOCATION_INFO	typedef ptr CRL_REVOCATION_INFO

CertFindChainInStore proto WINAPI :HCERTSTORE, :DWORD, :DWORD, :DWORD, :ptr, :ptr

CERT_CHAIN_FIND_BY_ISSUER equ 1

CALLBACK(PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK, :PCCERT_CONTEXT, :ptr)

CERT_CHAIN_FIND_BY_ISSUER_PARA STRUC
cbSize			dd ?
pszUsageIdentifier	LPCSTR ?
dwKeySpec		dd ?
dwAcquirePrivateKeyFlags dd ?
cIssuer			dd ?
rgIssuer		PCERT_NAME_BLOB ?
pfnFindCallback		PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK ?
pvFindArg		PVOID ?
ifdef CERT_CHAIN_FIND_BY_ISSUER_PARA_HAS_EXTRA_FIELDS
pdwIssuerChainIndex	LPDWORD ?
pdwIssuerElementIndex	LPDWORD ?
endif
CERT_CHAIN_FIND_BY_ISSUER_PARA ENDS
PCERT_CHAIN_FIND_BY_ISSUER_PARA typedef ptr CERT_CHAIN_FIND_BY_ISSUER_PARA
CERT_CHAIN_FIND_ISSUER_PARA typedef CERT_CHAIN_FIND_BY_ISSUER_PARA
PCERT_CHAIN_FIND_ISSUER_PARA typedef ptr CERT_CHAIN_FIND_ISSUER_PARA

CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG equ 0x0001
CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG equ 0x0002
CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG equ 0x0004
CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG equ 0x0008
CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG equ 0x4000
CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG equ 0x8000

CERT_CHAIN_POLICY_PARA	STRUC
cbSize			dd ?
dwFlags			dd ?
pvExtraPolicyPara	PVOID ?
CERT_CHAIN_POLICY_PARA	ENDS
PCERT_CHAIN_POLICY_PARA typedef ptr CERT_CHAIN_POLICY_PARA

CERT_CHAIN_POLICY_STATUS  STRUC
cbSize			dd ?
dwError			dd ?
lChainIndex		LONG ?
lElementIndex		LONG ?
pvExtraPolicyStatus	PVOID ?
CERT_CHAIN_POLICY_STATUS ENDS
PCERT_CHAIN_POLICY_STATUS typedef ptr CERT_CHAIN_POLICY_STATUS

CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG equ 0x00000001
CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG equ 0x00000002
CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG equ 0x00000004
CERT_CHAIN_POLICY_IGNORE_INVALID_BASIC_CONSTRAINTS_FLAG equ 0x00000008

CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS equ (CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG OR CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG OR CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG)

CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG equ 0x00000010
CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG equ 0x00000020
CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG equ 0x00000040
CERT_CHAIN_POLICY_IGNORE_INVALID_POLICY_FLAG equ 0x00000080

CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG equ 0x00000100
CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG equ 0x00000200
CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG equ 0x00000400
CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG equ 0x00000800

CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS equ (CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG OR CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG OR CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG OR CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG)

CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG equ 0x00008000
CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG equ 0x00004000

CERT_CHAIN_POLICY_IGNORE_NOT_SUPPORTED_CRITICAL_EXT_FLAG equ 0x00002000
CERT_CHAIN_POLICY_IGNORE_PEER_TRUST_FLAG equ 0x00001000

CertVerifyCertificateChainPolicy proto WINAPI :LPCSTR, :ptr, :ptr, :ptr

CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC equ <"CertDllVerifyCertificateChainPolicy">


CERT_CHAIN_POLICY_BASE			equ 1
CERT_CHAIN_POLICY_AUTHENTICODE		equ 2
CERT_CHAIN_POLICY_AUTHENTICODE_TS	equ 3
CERT_CHAIN_POLICY_SSL			equ 4
CERT_CHAIN_POLICY_BASIC_CONSTRAINTS	equ 5
CERT_CHAIN_POLICY_NT_AUTH		equ 6
CERT_CHAIN_POLICY_MICROSOFT_ROOT	equ 7
CERT_CHAIN_POLICY_EV			equ 8


AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA  STRUC
cbSize			dd ?
dwRegPolicySettings	dd ?
pSignerInfo		PCMSG_SIGNER_INFO ?
AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA ENDS

AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS  STRUC
cbSize			dd ?
fCommercial		BOOL ?
AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS ENDS

AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA  STRUC
cbSize			dd ?
dwRegPolicySettings	dd ?
fCommercial		BOOL ?
AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA ENDS

HTTPSPolicyCallbackData STRUC
UNION
 cbStruct		dd ?
 cbSize			dd ?
ENDS
dwAuthType		dd ?
AUTHTYPE_CLIENT		equ 1
AUTHTYPE_SERVER		equ 2
fdwChecks		dd ?
pwszServerName		LPWSTR ?
HTTPSPolicyCallbackData ENDS
PHTTPSPolicyCallbackData typedef ptr HTTPSPolicyCallbackData
PSSL_EXTRA_CERT_CHAIN_POLICY_PARA typedef HTTPSPolicyCallbackData
LPSSL_EXTRA_CERT_CHAIN_POLICY_PARA typedef ptr HTTPSPolicyCallbackData

BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG equ 0x80000000
BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG equ 0x40000000

MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG equ 0x00010000

EV_EXTRA_CERT_CHAIN_POLICY_PARA	 STRUC
cbSize			dd ?
dwRootProgramQualifierFlags dd ?
EV_EXTRA_CERT_CHAIN_POLICY_PARA ENDS

EV_EXTRA_CERT_CHAIN_POLICY_STATUS  STRUC
cbSize			dd ?
dwQualifiers		dd ?
dwIssuanceUsageIndex	dd ?
EV_EXTRA_CERT_CHAIN_POLICY_STATUS ENDS
PEV_EXTRA_CERT_CHAIN_POLICY_STATUS typedef ptr EV_EXTRA_CERT_CHAIN_POLICY_STATUS

CryptStringToBinaryA proto WINAPI :LPCSTR, :DWORD, :DWORD, :ptr, :ptr, :ptr, :ptr
CryptStringToBinaryW proto WINAPI :LPCWSTR, :DWORD, :DWORD, :ptr, :ptr, :ptr, :ptr
ifdef _UNICODE
CryptStringToBinary	equ <CryptStringToBinaryW>
else
CryptStringToBinary	equ <CryptStringToBinaryA>
endif

CryptBinaryToStringA proto WINAPI :ptr, :DWORD, :DWORD, :LPSTR, :ptr
CryptBinaryToStringW proto WINAPI :ptr, :DWORD, :DWORD, :LPWSTR, :ptr
ifdef _UNICODE
CryptBinaryToString	equ <CryptBinaryToStringW>
else
CryptBinaryToString	equ <CryptBinaryToStringA>
endif

CRYPT_STRING_BASE64HEADER equ 0x00000000
CRYPT_STRING_BASE64	equ 0x00000001
CRYPT_STRING_BINARY	equ 0x00000002
CRYPT_STRING_BASE64REQUESTHEADER equ 0x00000003
CRYPT_STRING_HEX	equ 0x00000004
CRYPT_STRING_HEXASCII	equ 0x00000005
CRYPT_STRING_BASE64_ANY equ 0x00000006
CRYPT_STRING_ANY	equ 0x00000007
CRYPT_STRING_HEX_ANY	equ 0x00000008
CRYPT_STRING_BASE64X509CRLHEADER equ 0x00000009
CRYPT_STRING_HEXADDR	equ 0x0000000a
CRYPT_STRING_HEXASCIIADDR equ 0x0000000b
CRYPT_STRING_HEXRAW	equ 0x0000000c

CRYPT_STRING_HASHDATA	equ 0x10000000
CRYPT_STRING_STRICT	equ 0x20000000
CRYPT_STRING_NOCRLF	equ 0x40000000
CRYPT_STRING_NOCR	equ 0x80000000

szOID_PKCS_12_PbeIds	equ <"1.2.840.113549.1.12.1">
szOID_PKCS_12_pbeWithSHA1And128BitRC4 equ <"1.2.840.113549.1.12.1.1">
szOID_PKCS_12_pbeWithSHA1And40BitRC4 equ <"1.2.840.113549.1.12.1.2">
szOID_PKCS_12_pbeWithSHA1And3KeyTripleDES equ <"1.2.840.113549.1.12.1.3">
szOID_PKCS_12_pbeWithSHA1And2KeyTripleDES equ <"1.2.840.113549.1.12.1.4">
szOID_PKCS_12_pbeWithSHA1And128BitRC2 equ <"1.2.840.113549.1.12.1.5">
szOID_PKCS_12_pbeWithSHA1And40BitRC2 equ <"1.2.840.113549.1.12.1.6">


CRYPT_PKCS12_PBE_PARAMS STRUC
iIterations		SINT ?
cbSalt			ULONG ?
CRYPT_PKCS12_PBE_PARAMS ENDS

PFXImportCertStore proto WINAPI :ptr, :LPCWSTR, :DWORD

CRYPT_USER_KEYSET	equ 0x00001000
PKCS12_PREFER_CNG_KSP	equ 0x00000100
PKCS12_ALWAYS_CNG_KSP	equ 0x00000200
PKCS12_ALLOW_OVERWRITE_KEY equ 0x00004000
PKCS12_NO_PERSIST_KEY	equ 0x00008000
PKCS12_IMPORT_RESERVED_MASK equ 0xffff0000

PFXIsPFXBlob proto WINAPI :ptr
PFXVerifyPassword proto WINAPI :ptr, :LPCWSTR, :DWORD
PFXExportCertStoreEx proto WINAPI :HCERTSTORE, :ptr, :LPCWSTR, :ptr, :DWORD

REPORT_NO_PRIVATE_KEY	equ 0x0001
REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY equ 0x0002
EXPORT_PRIVATE_KEYS	equ 0x0004
PKCS12_INCLUDE_EXTENDED_PROPERTIES equ 0x0010
PKCS12_EXPORT_RESERVED_MASK equ 0xffff0000

PFXExportCertStore proto WINAPI :HCERTSTORE, :ptr, :LPCWSTR, :DWORD

if 0;(NTDDI_VERSION GE NTDDI_WINLH)

HCERT_SERVER_OCSP_RESPONSE typedef ptr

CertOpenServerOcspResponse proto WINAPI :PCCERT_CHAIN_CONTEXT, :DWORD, :ptr
CertAddRefServerOcspResponse proto WINAPI :HCERT_SERVER_OCSP_RESPONSE
CertCloseServerOcspResponse proto WINAPI :HCERT_SERVER_OCSP_RESPONSE, :DWORD

CERT_SERVER_OCSP_RESPONSE_CONTEXT STRUC
cbSize			dd ?
pbEncodedOcspResponse	LPBYTE ?
cbEncodedOcspResponse	dd ?
CERT_SERVER_OCSP_RESPONSE_CONTEXT ENDS
PCCERT_SERVER_OCSP_RESPONSE_CONTEXT typedef ptr CERT_SERVER_OCSP_RESPONSE_CONTEXT

CertGetServerOcspResponseContext proto WINAPI :HCERT_SERVER_OCSP_RESPONSE, :DWORD, :ptr
CertAddRefServerOcspResponseContext proto WINAPI :PCCERT_SERVER_OCSP_RESPONSE_CONTEXT
CertFreeServerOcspResponseContext proto WINAPI :PCCERT_SERVER_OCSP_RESPONSE_CONTEXT

endif

CertRetrieveLogoOrBiometricInfo proto WINAPI :PCCERT_CONTEXT, :LPCSTR, :DWORD, :DWORD, :DWORD, :ptr, :ptr, :ptr, :ptr

CERT_RETRIEVE_ISSUER_LOGO equ 1
CERT_RETRIEVE_SUBJECT_LOGO equ 2
CERT_RETRIEVE_COMMUNITY_LOGO equ 3

CERT_RETRIEVE_BIOMETRIC_PREDEFINED_BASE_TYPE equ 1000

CERT_RETRIEVE_BIOMETRIC_PICTURE_TYPE equ (CERT_RETRIEVE_BIOMETRIC_PREDEFINED_BASE_TYPE + CERT_BIOMETRIC_PICTURE_TYPE)
CERT_RETRIEVE_BIOMETRIC_SIGNATURE_TYPE equ (CERT_RETRIEVE_BIOMETRIC_PREDEFINED_BASE_TYPE + CERT_BIOMETRIC_SIGNATURE_TYPE)

if (NTDDI_VERSION GE NTDDI_WIN7)

CERT_SELECT_CHAIN_PARA	STRUC
hChainEngine		HCERTCHAINENGINE ?
pTime			LPFILETIME ?
hAdditionalStore	HCERTSTORE ?
pChainPara		PCERT_CHAIN_PARA ?
dwFlags			dd ?
CERT_SELECT_CHAIN_PARA	ENDS
PCERT_SELECT_CHAIN_PARA typedef ptr CERT_SELECT_CHAIN_PARA
PCCERT_SELECT_CHAIN_PARA typedef ptr CERT_SELECT_CHAIN_PARA

CERT_SELECT_MAX_PARA	equ 500

CERT_SELECT_CRITERIA	STRUC
dwType			dd ?
cPara			dd ?
ppPara			PVOID ?
CERT_SELECT_CRITERIA	ENDS
PCERT_SELECT_CRITERIA	typedef ptr CERT_SELECT_CRITERIA
PCCERT_SELECT_CRITERIA	typedef ptr CERT_SELECT_CRITERIA

CERT_SELECT_BY_ENHKEY_USAGE	equ 1
CERT_SELECT_BY_KEY_USAGE	equ 2
CERT_SELECT_BY_POLICY_OID	equ 3
CERT_SELECT_BY_PROV_NAME	equ 4
CERT_SELECT_BY_EXTENSION	equ 5
CERT_SELECT_BY_SUBJECT_HOST_NAME equ 6
CERT_SELECT_BY_ISSUER_ATTR	equ 7
CERT_SELECT_BY_SUBJECT_ATTR	equ 8
CERT_SELECT_BY_ISSUER_NAME	equ 9
CERT_SELECT_BY_PUBLIC_KEY	equ 10
CERT_SELECT_BY_TLS_SIGNATURES	equ 11

CERT_SELECT_LAST	equ CERT_SELECT_BY_TLS_SIGNATURES
CERT_SELECT_MAX		equ (CERT_SELECT_LAST * 3)

CERT_SELECT_ALLOW_EXPIRED equ 0x00000001
CERT_SELECT_TRUSTED_ROOT equ 0x00000002
CERT_SELECT_DISALLOW_SELFSIGNED equ 0x00000004
CERT_SELECT_HAS_PRIVATE_KEY equ 0x00000008
CERT_SELECT_HAS_KEY_FOR_SIGNATURE equ 0x00000010
CERT_SELECT_HAS_KEY_FOR_KEY_EXCHANGE equ 0x00000020
CERT_SELECT_HARDWARE_ONLY equ 0x00000040
CERT_SELECT_ALLOW_DUPLICATES equ 0x00000080

CertSelectCertificateChains proto WINAPI :LPCGUID, :DWORD, :ptr, :DWORD, :ptr, :HCERTSTORE, :PDWORD, :ptr
CertFreeCertificateChainList proto WINAPI :ptr

endif

if (NTDDI_VERSION GE NTDDI_WIN7)

TIMESTAMP_VERSION	equ 1

CRYPT_TIMESTAMP_REQUEST STRUC
dwVersion		dd ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
HashedMessage		CRYPT_DER_BLOB <>
pszTSAPolicyId		LPSTR ?
Nonce			CRYPT_INTEGER_BLOB <>
fCertReq		BOOL ?
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CRYPT_TIMESTAMP_REQUEST ENDS
PCRYPT_TIMESTAMP_REQUEST typedef ptr CRYPT_TIMESTAMP_REQUEST

CRYPT_TIMESTAMP_RESPONSE STRUC
dwStatus		dd ?
cFreeText		dd ?
rgFreeText		LPWSTR ?
FailureInfo		CRYPT_BIT_BLOB <>
ContentInfo		CRYPT_DER_BLOB <>
CRYPT_TIMESTAMP_RESPONSE ENDS
PCRYPT_TIMESTAMP_RESPONSE typedef ptr CRYPT_TIMESTAMP_RESPONSE

TIMESTAMP_STATUS_GRANTED equ 0
TIMESTAMP_STATUS_GRANTED_WITH_MODS equ 1
TIMESTAMP_STATUS_REJECTED equ 2
TIMESTAMP_STATUS_WAITING equ 3
TIMESTAMP_STATUS_REVOCATION_WARNING equ 4
TIMESTAMP_STATUS_REVOKED equ 5

TIMESTAMP_FAILURE_BAD_ALG equ 0
TIMESTAMP_FAILURE_BAD_REQUEST equ 2
TIMESTAMP_FAILURE_BAD_FORMAT equ 5
TIMESTAMP_FAILURE_TIME_NOT_AVAILABLE equ 14
TIMESTAMP_FAILURE_POLICY_NOT_SUPPORTED equ 15
TIMESTAMP_FAILURE_EXTENSION_NOT_SUPPORTED equ 16
TIMESTAMP_FAILURE_INFO_NOT_AVAILABLE equ 17
TIMESTAMP_FAILURE_SYSTEM_FAILURE equ 25

CRYPT_TIMESTAMP_ACCURACY STRUC
dwSeconds		dd ?
dwMillis		dd ?
dwMicros		dd ?
CRYPT_TIMESTAMP_ACCURACY ENDS
PCRYPT_TIMESTAMP_ACCURACY typedef ptr CRYPT_TIMESTAMP_ACCURACY

CRYPT_TIMESTAMP_INFO	STRUC
dwVersion		dd ?
pszTSAPolicyId		LPSTR ?
HashAlgorithm		CRYPT_ALGORITHM_IDENTIFIER <>
HashedMessage		CRYPT_DER_BLOB <>
SerialNumber		CRYPT_INTEGER_BLOB <>
ftTime			FILETIME <>
pvAccuracy		PCRYPT_TIMESTAMP_ACCURACY ?
fOrdering		BOOL ?
Nonce			CRYPT_DER_BLOB <>
Tsa			CRYPT_DER_BLOB <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CRYPT_TIMESTAMP_INFO	ENDS
PCRYPT_TIMESTAMP_INFO	typedef ptr CRYPT_TIMESTAMP_INFO

CRYPT_TIMESTAMP_CONTEXT STRUC
cbEncoded		dd ?
pbEncoded		LPBYTE ?
pTimeStamp		PCRYPT_TIMESTAMP_INFO ?
CRYPT_TIMESTAMP_CONTEXT ENDS
PCRYPT_TIMESTAMP_CONTEXT typedef ptr CRYPT_TIMESTAMP_CONTEXT

CRYPT_TIMESTAMP_PARA	STRUC
pszTSAPolicyId		LPCSTR ?
fRequestCerts		BOOL ?
Nonce			CRYPT_INTEGER_BLOB <>
cExtension		dd ?
rgExtension		PCERT_EXTENSION ?
CRYPT_TIMESTAMP_PARA	ENDS
PCRYPT_TIMESTAMP_PARA	typedef ptr CRYPT_TIMESTAMP_PARA

CryptRetrieveTimeStamp proto WINAPI :LPCWSTR, :DWORD, :DWORD, :LPCSTR, :ptr, :ptr, :DWORD, :ptr, :ptr, :ptr

TIMESTAMP_DONT_HASH_DATA equ 0x00000001
TIMESTAMP_VERIFY_CONTEXT_SIGNATURE equ 0x00000020
TIMESTAMP_NO_AUTH_RETRIEVAL equ 0x00020000

CryptVerifyTimeStampSignature proto WINAPI :ptr, :DWORD, :ptr, :DWORD, :HCERTSTORE, :ptr, :ptr, :ptr

if (NTDDI_VERSION GE NTDDI_WIN8)

CRYPT_OBJECT_LOCATOR_SPN_NAME_TYPE		     equ 1
CRYPT_OBJECT_LOCATOR_LAST_RESERVED_NAME_TYPE	     equ 32
CRYPT_OBJECT_LOCATOR_FIRST_RESERVED_USER_NAME_TYPE   equ 33
CRYPT_OBJECT_LOCATOR_LAST_RESERVED_USER_NAME_TYPE    equ 0x0000FFFF

SSL_OBJECT_LOCATOR_PFX_FUNC		       equ <"SslObjectLocatorInitializePfx">
SSL_OBJECT_LOCATOR_ISSUER_LIST_FUNC	       equ <"SslObjectLocatorInitializeIssuerList">
SSL_OBJECT_LOCATOR_CERT_VALIDATION_CONFIG_FUNC equ <"SslObjectLocatorInitializeCertValidationConfig">

CRYPT_OBJECT_LOCATOR_RELEASE_SYSTEM_SHUTDOWN   equ 1
CRYPT_OBJECT_LOCATOR_RELEASE_SERVICE_STOP      equ 2
CRYPT_OBJECT_LOCATOR_RELEASE_PROCESS_EXIT      equ 3
CRYPT_OBJECT_LOCATOR_RELEASE_DLL_UNLOAD	       equ 4


CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FLUSH, :ptr, :ptr, :DWORD)
CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_GET, :ptr, :ptr, :DWORD, :ptr, :ptr, :ptr, :ptr, :ptr)
CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_RELEASE, :DWORD, :LPVOID)
CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_PASSWORD, :LPVOID, :PCWSTR)
CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE, :LPVOID, :PBYTE)
CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_IDENTIFIER, :LPVOID, :PCRYPT_DATA_BLOB)

CRYPT_OBJECT_LOCATOR_PROVIDER_TABLE STRUC
cbSize			dd ?
pfnGet			PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_GET ?
pfnRelease		PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_RELEASE ?
pfnFreePassword		PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_PASSWORD ?
pfnFree			PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE ?
pfnFreeIdentifier	PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_FREE_IDENTIFIER ?
CRYPT_OBJECT_LOCATOR_PROVIDER_TABLE ENDS
PCRYPT_OBJECT_LOCATOR_PROVIDER_TABLE typedef ptr CRYPT_OBJECT_LOCATOR_PROVIDER_TABLE

CALLBACK(PFN_CRYPT_OBJECT_LOCATOR_PROVIDER_INITIALIZE, :ptr, :ptr, :ptr, :ptr, :ptr)

endif ;; (NTDDI_VERSION GE NTDDI_WIN8)

endif ;; (NTDDI_VERSION GE NTDDI_WIN7)

endif ;; !defined(_DDK_DRIVER_)

endif ;; WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

ifndef _WINCRYPT_NO_DPAPI
include dpapi.inc
endif
endif
