ifndef __BCRYPT_H__
define __BCRYPT_H__

include winapifamily.inc

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

.pragma comment(lib, bcrypt)

ifndef _NTDEF_
NTSTATUS	typedef LONG
PNTSTATUS	typedef ptr NTSTATUS
endif

ifndef BCRYPT_SUCCESS
BCRYPT_SUCCESS macro Status
	exitm<((Status) GE 0)>
	endm
endif

BCRYPT_OBJECT_ALIGNMENT equ 16

BCRYPT_STRUCT_ALIGNMENT equ 1

BCRYPT_KDF_HASH		equ <L"HASH">
BCRYPT_KDF_HMAC		equ <L"HMAC">
BCRYPT_KDF_TLS_PRF	equ <L"TLS_PRF">
BCRYPT_KDF_SP80056A_CONCAT equ <L"SP800_56A_CONCAT">

KDF_HASH_ALGORITHM	equ 0x0
KDF_SECRET_PREPEND	equ 0x1
KDF_SECRET_APPEND	equ 0x2
KDF_HMAC_KEY		equ 0x3
KDF_TLS_PRF_LABEL	equ 0x4
KDF_TLS_PRF_SEED	equ 0x5
KDF_SECRET_HANDLE	equ 0x6
KDF_TLS_PRF_PROTOCOL	equ 0x7
KDF_ALGORITHMID		equ 0x8
KDF_PARTYUINFO		equ 0x9
KDF_PARTYVINFO		equ <0xA>
KDF_SUPPPUBINFO		equ 0xB
KDF_SUPPPRIVINFO	equ 0xC
KDF_LABEL		equ 0xD
KDF_CONTEXT		equ 0xE
KDF_SALT		equ 0xF
KDF_ITERATION_COUNT	equ 0x10
KDF_GENERIC_PARAMETER	equ 0x11
KDF_KEYBITLENGTH	equ 0x12

KDF_USE_SECRET_AS_HMAC_KEY_FLAG equ 0x1

BCRYPT_KEY_LENGTHS_STRUCT STRUC
dwMinLength		ULONG ?
dwMaxLength		ULONG ?
dwIncrement		ULONG ?
BCRYPT_KEY_LENGTHS_STRUCT ENDS

BCRYPT_AUTH_TAG_LENGTHS_STRUCT typedef BCRYPT_KEY_LENGTHS_STRUCT

BCRYPT_OID		STRUC
cbOID			ULONG ?
pbOID			PUCHAR ?
BCRYPT_OID		ENDS
LPBCRYPT_OID		typedef ptr BCRYPT_OID

BCRYPT_OID_LIST		STRUC
dwOIDCount		ULONG ?
pOIDs			LPBCRYPT_OID ?
BCRYPT_OID_LIST		ENDS

BCRYPT_PKCS1_PADDING_INFO STRUC
pszAlgId		LPCWSTR ?
BCRYPT_PKCS1_PADDING_INFO ENDS

BCRYPT_PSS_PADDING_INFO STRUC
pszAlgId		LPCWSTR ?
cbSalt			ULONG ?
BCRYPT_PSS_PADDING_INFO ENDS

BCRYPT_OAEP_PADDING_INFO STRUC
pszAlgId		LPCWSTR ?
pbLabel			PUCHAR ?
cbLabel			ULONG ?
BCRYPT_OAEP_PADDING_INFO ENDS

BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION equ 1

BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG equ 0x00000001
BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG equ 0x00000002

BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO STRUC
cbSize			ULONG ?
dwInfoVersion		ULONG ?
pbNonce			PUCHAR ?
cbNonce			ULONG ?
pbAuthData		PUCHAR ?
cbAuthData		ULONG ?
pbTag			PUCHAR ?
cbTag			ULONG ?
pbMacContext		PUCHAR ?
cbMacContext		ULONG ?
cbAAD			ULONG ?
cbData			ULONGLONG ?
dwFlags			ULONG ?
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO ENDS
PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO typedef ptr BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO

BCRYPT_INIT_AUTH_MODE_INFO macro _AUTH_INFO_STRUCT_
	exitm<.err>
	endm

BCRYPT_OPAQUE_KEY_BLOB	equ <L"OpaqueKeyBlob">
BCRYPT_KEY_DATA_BLOB	equ <L"KeyDataBlob">
BCRYPT_AES_WRAP_KEY_BLOB equ <L"Rfc3565KeyWrapBlob">

BCRYPT_OBJECT_LENGTH	equ <L"ObjectLength">
BCRYPT_ALGORITHM_NAME	equ <L"AlgorithmName">
BCRYPT_PROVIDER_HANDLE	equ <L"ProviderHandle">
BCRYPT_CHAINING_MODE	equ <L"ChainingMode">
BCRYPT_BLOCK_LENGTH	equ <L"BlockLength">
BCRYPT_KEY_LENGTH	equ <L"KeyLength">
BCRYPT_KEY_OBJECT_LENGTH equ <L"KeyObjectLength">
BCRYPT_KEY_STRENGTH	equ <L"KeyStrength">
BCRYPT_KEY_LENGTHS	equ <L"KeyLengths">
BCRYPT_BLOCK_SIZE_LIST	equ <L"BlockSizeList">
BCRYPT_EFFECTIVE_KEY_LENGTH equ <L"EffectiveKeyLength">
BCRYPT_HASH_LENGTH	equ <L"HashDigestLength">
BCRYPT_HASH_OID_LIST	equ <L"HashOIDList">
BCRYPT_PADDING_SCHEMES	equ <L"PaddingSchemes">
BCRYPT_SIGNATURE_LENGTH equ <L"SignatureLength">
BCRYPT_HASH_BLOCK_LENGTH equ <L"HashBlockLength">
BCRYPT_AUTH_TAG_LENGTH	equ <L"AuthTagLength">
BCRYPT_PRIMITIVE_TYPE	equ <L"PrimitiveType">
BCRYPT_IS_KEYED_HASH	equ <L"IsKeyedHash">
BCRYPT_IS_REUSABLE_HASH equ <L"IsReusableHash">
BCRYPT_MESSAGE_BLOCK_LENGTH equ <L"MessageBlockLength">

BCRYPT_PCP_PLATFORM_TYPE_PROPERTY equ <L"PCP_PLATFORM_TYPE">
BCRYPT_PCP_PROVIDER_VERSION_PROPERTY equ <L"PCP_PROVIDER_VERSION">

if (NTDDI_VERSION GT NTDDI_WINBLUE OR (NTDDI_VERSION EQ NTDDI_WINBLUE AND defined(WINBLUE_KBSPRING14)))
BCRYPT_MULTI_OBJECT_LENGTH equ <L"MultiObjectLength">
endif

BCRYPT_INITIALIZATION_VECTOR equ <L"IV">

BCRYPT_CHAIN_MODE_NA	equ <L"ChainingModeN/A">
BCRYPT_CHAIN_MODE_CBC	equ <L"ChainingModeCBC">
BCRYPT_CHAIN_MODE_ECB	equ <L"ChainingModeECB">
BCRYPT_CHAIN_MODE_CFB	equ <L"ChainingModeCFB">
BCRYPT_CHAIN_MODE_CCM	equ <L"ChainingModeCCM">
BCRYPT_CHAIN_MODE_GCM	equ <L"ChainingModeGCM">

BCRYPT_SUPPORTED_PAD_ROUTER equ 0x00000001
BCRYPT_SUPPORTED_PAD_PKCS1_ENC equ 0x00000002
BCRYPT_SUPPORTED_PAD_PKCS1_SIG equ 0x00000004
BCRYPT_SUPPORTED_PAD_OAEP equ 0x00000008
BCRYPT_SUPPORTED_PAD_PSS equ 0x00000010

BCRYPT_PROV_DISPATCH	equ 0x00000001

BCRYPT_BLOCK_PADDING	equ 0x00000001

BCRYPT_PAD_NONE		equ 0x00000001
BCRYPT_PAD_PKCS1	equ 0x00000002
BCRYPT_PAD_OAEP		equ 0x00000004
BCRYPT_PAD_PSS		equ 0x00000008
if (NTDDI_VERSION GE NTDDI_WINBLUE)
BCRYPT_PAD_PKCS1__HASH_OID equ 0x00000010
endif

BCRYPTBUFFER_VERSION	equ 0

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

BCryptBuffer		STRUC
cbBuffer		ULONG ?
BufferType		ULONG ?
pvBuffer		PVOID ?
BCryptBuffer		ENDS
PBCryptBuffer		typedef ptr BCryptBuffer

BCryptBufferDesc	STRUC
ulVersion		ULONG ?
cBuffers		ULONG ?
pBuffers		PBCryptBuffer ?
BCryptBufferDesc	ENDS
 PBCryptBufferDesc	typedef ptr BCryptBufferDesc

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

BCRYPT_HANDLE		typedef PVOID
BCRYPT_ALG_HANDLE	typedef PVOID
BCRYPT_KEY_HANDLE	typedef PVOID
BCRYPT_HASH_HANDLE	typedef PVOID
BCRYPT_SECRET_HANDLE	typedef PVOID

BCRYPT_PUBLIC_KEY_BLOB	equ <L"PUBLICBLOB">
BCRYPT_PRIVATE_KEY_BLOB equ <L"PRIVATEBLOB">

BCRYPT_KEY_BLOB		STRUC
Magic			ULONG ?
BCRYPT_KEY_BLOB		ENDS

BCRYPT_RSAPUBLIC_BLOB	equ <L"RSAPUBLICBLOB">
BCRYPT_RSAPRIVATE_BLOB	equ <L"RSAPRIVATEBLOB">
LEGACY_RSAPUBLIC_BLOB	equ <L"CAPIPUBLICBLOB">
LEGACY_RSAPRIVATE_BLOB	equ <L"CAPIPRIVATEBLOB">

BCRYPT_RSAPUBLIC_MAGIC	equ 0x31415352	;; RSA1
BCRYPT_RSAPRIVATE_MAGIC equ 0x32415352	;; RSA2

BCRYPT_RSAKEY_BLOB	STRUC
Magic			ULONG ?
BitLength		ULONG ?
cbPublicExp		ULONG ?
cbModulus		ULONG ?
cbPrime1		ULONG ?
cbPrime2		ULONG ?
BCRYPT_RSAKEY_BLOB	ENDS

BCRYPT_RSAFULLPRIVATE_BLOB equ <L"RSAFULLPRIVATEBLOB">

BCRYPT_RSAFULLPRIVATE_MAGIC equ 0x33415352  ;; RSA3

BCRYPT_GLOBAL_PARAMETERS equ <L"SecretAgreementParam">
BCRYPT_PRIVATE_KEY	equ <L"PrivKeyVal">

BCRYPT_ECCPUBLIC_BLOB	equ <L"ECCPUBLICBLOB">
BCRYPT_ECCPRIVATE_BLOB	equ <L"ECCPRIVATEBLOB">

BCRYPT_ECDH_PUBLIC_P256_MAGIC equ 0x314B4345  ;; ECK1
BCRYPT_ECDH_PRIVATE_P256_MAGIC equ 0x324B4345  ;; ECK2
BCRYPT_ECDH_PUBLIC_P384_MAGIC equ 0x334B4345  ;; ECK3
BCRYPT_ECDH_PRIVATE_P384_MAGIC equ 0x344B4345  ;; ECK4
BCRYPT_ECDH_PUBLIC_P521_MAGIC equ 0x354B4345  ;; ECK5
BCRYPT_ECDH_PRIVATE_P521_MAGIC equ 0x364B4345  ;; ECK6

BCRYPT_ECDSA_PUBLIC_P256_MAGIC equ 0x31534345  ;; ECS1
BCRYPT_ECDSA_PRIVATE_P256_MAGIC equ 0x32534345	;; ECS2
BCRYPT_ECDSA_PUBLIC_P384_MAGIC equ 0x33534345  ;; ECS3
BCRYPT_ECDSA_PRIVATE_P384_MAGIC equ 0x34534345	;; ECS4
BCRYPT_ECDSA_PUBLIC_P521_MAGIC equ 0x35534345  ;; ECS5
BCRYPT_ECDSA_PRIVATE_P521_MAGIC equ 0x36534345	;; ECS6

BCRYPT_ECCKEY_BLOB	STRUC
dwMagic			ULONG ?
cbKey			ULONG ?
BCRYPT_ECCKEY_BLOB	ENDS
PBCRYPT_ECCKEY_BLOB	typedef ptr BCRYPT_ECCKEY_BLOB

BCRYPT_DH_PUBLIC_BLOB	equ <L"DHPUBLICBLOB">
BCRYPT_DH_PRIVATE_BLOB	equ <L"DHPRIVATEBLOB">
LEGACY_DH_PUBLIC_BLOB	equ <L"CAPIDHPUBLICBLOB">
LEGACY_DH_PRIVATE_BLOB	equ <L"CAPIDHPRIVATEBLOB">

BCRYPT_DH_PUBLIC_MAGIC	equ 0x42504844	;; DHPB
BCRYPT_DH_PRIVATE_MAGIC equ 0x56504844	;; DHPV

BCRYPT_DH_KEY_BLOB	STRUC
dwMagic			ULONG ?
cbKey			ULONG ?
BCRYPT_DH_KEY_BLOB	ENDS
PBCRYPT_DH_KEY_BLOB	typedef ptr BCRYPT_DH_KEY_BLOB

BCRYPT_DH_PARAMETERS	equ <L"DHParameters">

BCRYPT_DH_PARAMETERS_MAGIC equ 0x4d504844  ;; DHPM

BCRYPT_DH_PARAMETER_HEADER STRUC
cbLength		ULONG ?
dwMagic			ULONG ?
cbKeyLength		ULONG ?
BCRYPT_DH_PARAMETER_HEADER ENDS


BCRYPT_DSA_PUBLIC_BLOB	equ <L"DSAPUBLICBLOB">
BCRYPT_DSA_PRIVATE_BLOB equ <L"DSAPRIVATEBLOB">
LEGACY_DSA_PUBLIC_BLOB	equ <L"CAPIDSAPUBLICBLOB">
LEGACY_DSA_PRIVATE_BLOB equ <L"CAPIDSAPRIVATEBLOB">
LEGACY_DSA_V2_PUBLIC_BLOB equ <L"V2CAPIDSAPUBLICBLOB">
LEGACY_DSA_V2_PRIVATE_BLOB equ <L"V2CAPIDSAPRIVATEBLOB">

BCRYPT_DSA_PUBLIC_MAGIC equ 0x42505344	;; DSPB
BCRYPT_DSA_PRIVATE_MAGIC equ 0x56505344	 ;; DSPV
BCRYPT_DSA_PUBLIC_MAGIC_V2 equ 0x32425044  ;; DPB2
BCRYPT_DSA_PRIVATE_MAGIC_V2 equ 0x32565044  ;; DPV2

BCRYPT_DSA_KEY_BLOB	STRUC
dwMagic			ULONG ?
cbKey			ULONG ?
Count			UCHAR 4 dup(?)
Seed			UCHAR 20 dup(?)
q			UCHAR 20 dup(?)
BCRYPT_DSA_KEY_BLOB	ENDS
PBCRYPT_DSA_KEY_BLOB	typedef ptr BCRYPT_DSA_KEY_BLOB

.enum HASHALGORITHM_ENUM {
    DSA_HASH_ALGORITHM_SHA1,
    DSA_HASH_ALGORITHM_SHA256,
    DSA_HASH_ALGORITHM_SHA512
    }

.enum DSAFIPSVERSION_ENUM {
    DSA_FIPS186_2,
    DSA_FIPS186_3
    }

BCRYPT_DSA_KEY_BLOB_V2	STRUC
dwMagic			ULONG ?
cbKey			ULONG ?
hashAlgorithm		HASHALGORITHM_ENUM ?
standardVersion		DSAFIPSVERSION_ENUM ?
cbSeedLength		ULONG ?
cbGroupSize		ULONG ?
Count			UCHAR 4 dup(?)
BCRYPT_DSA_KEY_BLOB_V2	ENDS
PBCRYPT_DSA_KEY_BLOB_V2 typedef ptr BCRYPT_DSA_KEY_BLOB_V2

BCRYPT_KEY_DATA_BLOB_HEADER STRUC
dwMagic			ULONG ?
dwVersion		ULONG ?
cbKeyData		ULONG ?
BCRYPT_KEY_DATA_BLOB_HEADER ENDS
PBCRYPT_KEY_DATA_BLOB_HEADER typedef ptr BCRYPT_KEY_DATA_BLOB_HEADER

BCRYPT_KEY_DATA_BLOB_MAGIC equ 0x4d42444b ;;Key Data Blob Magic (KDBM)
BCRYPT_KEY_DATA_BLOB_VERSION1 equ 0x1
BCRYPT_DSA_PARAMETERS	equ <L"DSAParameters">
BCRYPT_DSA_PARAMETERS_MAGIC equ 0x4d505344  ;; DSPM
BCRYPT_DSA_PARAMETERS_MAGIC_V2 equ 0x324d5044  ;; DPM2

BCRYPT_DSA_PARAMETER_HEADER STRUC
cbLength		ULONG ?
dwMagic			ULONG ?
cbKeyLength		ULONG ?
Count			UCHAR 4 dup(?)
Seed			UCHAR 20 dup(?)
q			UCHAR 20 dup(?)
BCRYPT_DSA_PARAMETER_HEADER ENDS

BCRYPT_DSA_PARAMETER_HEADER_V2 STRUC
cbLength		ULONG ?
dwMagic			ULONG ?
cbKeyLength		ULONG ?
hashAlgorithm		HASHALGORITHM_ENUM ?
standardVersion		DSAFIPSVERSION_ENUM ?
cbSeedLength		ULONG ?
cbGroupSize		ULONG ?
Count			UCHAR 4 dup(?)
BCRYPT_DSA_PARAMETER_HEADER_V2 ENDS

.enum BCRYPT_HASH_OPERATION_TYPE {
    BCRYPT_HASH_OPERATION_HASH_DATA = 1,
    BCRYPT_HASH_OPERATION_FINISH_HASH = 2,
    }

BCRYPT_MULTI_HASH_OPERATION  STRUC
iHash			ULONG ?
hashOperation		BCRYPT_HASH_OPERATION_TYPE ?
pbBuffer		PUCHAR ?
cbBuffer		ULONG ?
BCRYPT_MULTI_HASH_OPERATION ENDS

.enum BCRYPT_MULTI_OPERATION_TYPE {
    BCRYPT_OPERATION_TYPE_HASH = 1,
    }

BCRYPT_MULTI_OBJECT_LENGTH_STRUCT STRUC
cbPerObject		ULONG ?
cbPerElement		ULONG ?
BCRYPT_MULTI_OBJECT_LENGTH_STRUCT ENDS

MS_PRIMITIVE_PROVIDER	equ <L"Microsoft Primitive Provider">
MS_PLATFORM_CRYPTO_PROVIDER equ <L"Microsoft Platform Crypto Provider">

BCRYPT_RSA_ALGORITHM	equ <L"RSA">
BCRYPT_RSA_SIGN_ALGORITHM equ <L"RSA_SIGN">
BCRYPT_DH_ALGORITHM	equ <L"DH">
BCRYPT_DSA_ALGORITHM	equ <L"DSA">
BCRYPT_RC2_ALGORITHM	equ <L"RC2">
BCRYPT_RC4_ALGORITHM	equ <L"RC4">
BCRYPT_AES_ALGORITHM	equ <L"AES">
BCRYPT_DES_ALGORITHM	equ <L"DES">
BCRYPT_DESX_ALGORITHM	equ <L"DESX">
BCRYPT_3DES_ALGORITHM	equ <L"3DES">
BCRYPT_3DES_112_ALGORITHM equ <L"3DES_112">
BCRYPT_MD2_ALGORITHM	equ <L"MD2">
BCRYPT_MD4_ALGORITHM	equ <L"MD4">
BCRYPT_MD5_ALGORITHM	equ <L"MD5">
BCRYPT_SHA1_ALGORITHM	equ <L"SHA1">
BCRYPT_SHA256_ALGORITHM equ <L"SHA256">
BCRYPT_SHA384_ALGORITHM equ <L"SHA384">
BCRYPT_SHA512_ALGORITHM equ <L"SHA512">
BCRYPT_AES_GMAC_ALGORITHM equ <L"AES-GMAC">
BCRYPT_AES_CMAC_ALGORITHM equ <L"AES-CMAC">
BCRYPT_ECDSA_P256_ALGORITHM equ <L"ECDSA_P256">
BCRYPT_ECDSA_P384_ALGORITHM equ <L"ECDSA_P384">
BCRYPT_ECDSA_P521_ALGORITHM equ <L"ECDSA_P521">
BCRYPT_ECDH_P256_ALGORITHM equ <L"ECDH_P256">
BCRYPT_ECDH_P384_ALGORITHM equ <L"ECDH_P384">
BCRYPT_ECDH_P521_ALGORITHM equ <L"ECDH_P521">
BCRYPT_RNG_ALGORITHM	equ <L"RNG">
BCRYPT_RNG_FIPS186_DSA_ALGORITHM equ <L"FIPS186DSARNG">
BCRYPT_RNG_DUAL_EC_ALGORITHM equ <L"DUALECRNG">
BCRYPT_SP800108_CTR_HMAC_ALGORITHM equ <L"SP800_108_CTR_HMAC">
BCRYPT_SP80056A_CONCAT_ALGORITHM equ <L"SP800_56A_CONCAT">
BCRYPT_PBKDF2_ALGORITHM equ <L"PBKDF2">
BCRYPT_CAPI_KDF_ALGORITHM equ <L"CAPI_KDF">

BCRYPT_CIPHER_INTERFACE equ 0x00000001
BCRYPT_HASH_INTERFACE	equ 0x00000002
BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE equ 0x00000003
BCRYPT_SECRET_AGREEMENT_INTERFACE equ 0x00000004
BCRYPT_SIGNATURE_INTERFACE equ 0x00000005
BCRYPT_RNG_INTERFACE	equ 0x00000006
BCRYPT_KEY_DERIVATION_INTERFACE equ 0x00000007

BCRYPT_ALG_HANDLE_HMAC_FLAG equ 0x00000008
BCRYPT_CAPI_AES_FLAG	equ 0x00000010
BCRYPT_HASH_REUSABLE_FLAG equ 0x00000020

if (NTDDI_VERSION GT NTDDI_WINBLUE OR (NTDDI_VERSION EQ NTDDI_WINBLUE AND defined(WINBLUE_KBSPRING14)))
BCRYPT_MULTI_FLAG	equ 0x00000040
endif

BCRYPT_BUFFERS_LOCKED_FLAG equ 0x00000040
if (NTDDI_VERSION GE NTDDI_WINBLUE)
BCRYPT_EXTENDED_KEYSIZE equ 0x00000080
endif

BCryptOpenAlgorithmProvider proto WINAPI :ptr, :LPCWSTR, :LPCWSTR, :ULONG

BCRYPT_CIPHER_OPERATION equ 0x00000001
BCRYPT_HASH_OPERATION	equ 0x00000002
BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION equ 0x00000004
BCRYPT_SECRET_AGREEMENT_OPERATION equ 0x00000008
BCRYPT_SIGNATURE_OPERATION equ 0x00000010
BCRYPT_RNG_OPERATION	equ 0x00000020
BCRYPT_KEY_DERIVATION_OPERATION equ 0x00000040

BCRYPT_ALGORITHM_IDENTIFIER STRUC
pszName			LPWSTR ?
dwClass			ULONG ?
dwFlags			ULONG ?
BCRYPT_ALGORITHM_IDENTIFIER ENDS

BCryptEnumAlgorithms proto WINAPI :ULONG, :ptr, :ptr, :ULONG

BCRYPT_PROVIDER_NAME	STRUC
pszProviderName		LPWSTR ?
BCRYPT_PROVIDER_NAME	ENDS

BCryptEnumProviders proto WINAPI :LPCWSTR, :ptr, :ptr, :ULONG

BCRYPT_PUBLIC_KEY_FLAG	equ 0x00000001
BCRYPT_PRIVATE_KEY_FLAG equ 0x00000002

BCryptGetProperty proto WINAPI :BCRYPT_HANDLE, :LPCWSTR, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptSetProperty proto WINAPI :BCRYPT_HANDLE, :LPCWSTR, :PUCHAR, :ULONG, :ULONG
BCryptCloseAlgorithmProvider proto WINAPI :BCRYPT_ALG_HANDLE, :ULONG
BCryptFreeBuffer proto WINAPI :ptr
BCryptGenerateSymmetricKey proto WINAPI :BCRYPT_ALG_HANDLE, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONG
BCryptGenerateKeyPair proto WINAPI :BCRYPT_ALG_HANDLE, :ptr, :ULONG, :ULONG
BCryptEncrypt proto WINAPI :BCRYPT_KEY_HANDLE, :PUCHAR, :ULONG, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptDecrypt proto WINAPI :BCRYPT_KEY_HANDLE, :PUCHAR, :ULONG, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptExportKey proto WINAPI :BCRYPT_KEY_HANDLE, :BCRYPT_KEY_HANDLE, :LPCWSTR, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptImportKey proto WINAPI :BCRYPT_ALG_HANDLE, :BCRYPT_KEY_HANDLE, :LPCWSTR, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONG

BCRYPT_NO_KEY_VALIDATION equ 0x00000008

BCryptImportKeyPair proto WINAPI :BCRYPT_ALG_HANDLE, :BCRYPT_KEY_HANDLE, :LPCWSTR, :ptr, :PUCHAR, :ULONG, :ULONG
BCryptDuplicateKey proto WINAPI :BCRYPT_KEY_HANDLE, :ptr, :PUCHAR, :ULONG, :ULONG
BCryptFinalizeKeyPair proto WINAPI :BCRYPT_KEY_HANDLE, :ULONG
BCryptDestroyKey proto WINAPI :BCRYPT_KEY_HANDLE
BCryptDestroySecret proto WINAPI :BCRYPT_SECRET_HANDLE
BCryptSignHash proto WINAPI :BCRYPT_KEY_HANDLE, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptVerifySignature proto WINAPI :BCRYPT_KEY_HANDLE, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONG
BCryptSecretAgreement proto WINAPI :BCRYPT_KEY_HANDLE, :BCRYPT_KEY_HANDLE, :ptr, :ULONG
BCryptDeriveKey proto WINAPI :BCRYPT_SECRET_HANDLE, :LPCWSTR, :ptr, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptKeyDerivation proto WINAPI :BCRYPT_KEY_HANDLE, :ptr, :PUCHAR, :ULONG, :ptr, :ULONG
BCryptCreateHash proto WINAPI :BCRYPT_ALG_HANDLE, :ptr, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONG
BCryptHashData proto WINAPI :BCRYPT_HASH_HANDLE, :PUCHAR, :ULONG, :ULONG
BCryptFinishHash proto WINAPI :BCRYPT_HASH_HANDLE, :PUCHAR, :ULONG, :ULONG
if (NTDDI_VERSION GT NTDDI_WINBLUE OR (NTDDI_VERSION EQ NTDDI_WINBLUE AND defined(WINBLUE_KBSPRING14)))
BCryptCreateMultiHash proto WINAPI :BCRYPT_ALG_HANDLE, :ptr, :ULONG, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONG
BCryptProcessMultiOperations proto WINAPI :BCRYPT_HANDLE, :BCRYPT_MULTI_OPERATION_TYPE, :ptr, :ULONG, :ULONG
endif
BCryptDuplicateHash proto WINAPI :BCRYPT_HASH_HANDLE, :ptr, :PUCHAR, :ULONG, :ULONG
BCryptDestroyHash proto WINAPI :BCRYPT_HASH_HANDLE

BCRYPT_RNG_USE_ENTROPY_IN_BUFFER equ 0x00000001
BCRYPT_USE_SYSTEM_PREFERRED_RNG equ 0x00000002

BCryptGenRandom proto WINAPI :BCRYPT_ALG_HANDLE, :PUCHAR, :ULONG, :ULONG
BCryptDeriveKeyCapi proto WINAPI :BCRYPT_HASH_HANDLE, :BCRYPT_ALG_HANDLE, :PUCHAR, :ULONG, :ULONG
BCryptDeriveKeyPBKDF2 proto WINAPI :BCRYPT_ALG_HANDLE, :PUCHAR, :ULONG, :PUCHAR, :ULONG, :ULONGLONG, :PUCHAR, :ULONG, :ULONG

BCRYPT_INTERFACE_VERSION STRUC
MajorVersion		USHORT ?
MinorVersion		USHORT ?
BCRYPT_INTERFACE_VERSION ENDS
PBCRYPT_INTERFACE_VERSION typedef ptr BCRYPT_INTERFACE_VERSION

BCRYPT_MAKE_INTERFACE_VERSION macro major,minor
	exitm<(major or (minor shl 16))>
	endm

BCRYPT_IS_INTERFACE_VERSION_COMPATIBLE macro loader, provider
	exitm<(loader.MajorVersion LE provider.MajorVersion)>
	endm


BCRYPT_CIPHER_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)
BCRYPT_HASH_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)

if (NTDDI_VERSION GT NTDDI_WINBLUE OR (NTDDI_VERSION EQ NTDDI_WINBLUE AND defined(WINBLUE_KBSPRING14)))
BCRYPT_HASH_INTERFACE_MAJORVERSION_2 equ 2
BCRYPT_HASH_INTERFACE_VERSION_2 equ BCRYPT_MAKE_INTERFACE_VERSION(BCRYPT_HASH_INTERFACE_MAJORVERSION_2,0)
endif

BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)
BCRYPT_SECRET_AGREEMENT_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)
BCRYPT_SIGNATURE_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)
BCRYPT_RNG_INTERFACE_VERSION_1 equ BCRYPT_MAKE_INTERFACE_VERSION(1,0)

CRYPT_MIN_DEPENDENCIES	equ (0x00000001)
CRYPT_PROCESS_ISOLATE	equ (0x00010000)

CRYPT_UM		equ (0x00000001)
CRYPT_KM		equ (0x00000002)
CRYPT_MM		equ (0x00000003)
CRYPT_ANY		equ (0x00000004)

CRYPT_OVERWRITE		equ (0x00000001)
CRYPT_LOCAL		equ (0x00000001)
CRYPT_DOMAIN		equ (0x00000002)
CRYPT_EXCLUSIVE		equ (0x00000001)
CRYPT_OVERRIDE		equ (0x00010000)
CRYPT_ALL_FUNCTIONS	equ (0x00000001)
CRYPT_ALL_PROVIDERS	equ (0x00000002)
CRYPT_PRIORITY_TOP	equ (0x00000000)
CRYPT_PRIORITY_BOTTOM	equ (0xFFFFFFFF)
CRYPT_DEFAULT_CONTEXT	equ <L"Default">

CRYPT_INTERFACE_REG	STRUC
dwInterface		ULONG ?
dwFlags			ULONG ?
cFunctions		ULONG ?
rgpszFunctions		LPWSTR ?
CRYPT_INTERFACE_REG	ENDS
PCRYPT_INTERFACE_REG	typedef ptr CRYPT_INTERFACE_REG

CRYPT_IMAGE_REG		STRUC
pszImage		PWSTR ?
cInterfaces		ULONG ?
rgpInterfaces		PCRYPT_INTERFACE_REG ?
CRYPT_IMAGE_REG		ENDS
PCRYPT_IMAGE_REG	typedef ptr CRYPT_IMAGE_REG

CRYPT_PROVIDER_REG	STRUC
cAliases		ULONG ?
rgpszAliases		LPWSTR ?
pUM			PCRYPT_IMAGE_REG ?
pKM			PCRYPT_IMAGE_REG ?
CRYPT_PROVIDER_REG	ENDS
PCRYPT_PROVIDER_REG	typedef ptr CRYPT_PROVIDER_REG

CRYPT_PROVIDERS		STRUC
cProviders		ULONG ?
rgpszProviders		LPWSTR ?
CRYPT_PROVIDERS		ENDS
PCRYPT_PROVIDERS	typedef ptr CRYPT_PROVIDERS

CRYPT_CONTEXT_CONFIG	STRUC
dwFlags			ULONG ?
dwReserved		ULONG ?
CRYPT_CONTEXT_CONFIG	ENDS
PCRYPT_CONTEXT_CONFIG	typedef ptr CRYPT_CONTEXT_CONFIG

CRYPT_CONTEXT_FUNCTION_CONFIG STRUC
dwFlags			ULONG ?
dwReserved		ULONG ?
CRYPT_CONTEXT_FUNCTION_CONFIG ENDS
PCRYPT_CONTEXT_FUNCTION_CONFIG typedef ptr CRYPT_CONTEXT_FUNCTION_CONFIG

CRYPT_CONTEXTS		STRUC
cContexts		ULONG ?
rgpszContexts		LPWSTR ?
CRYPT_CONTEXTS		ENDS
PCRYPT_CONTEXTS		typedef ptr CRYPT_CONTEXTS

CRYPT_CONTEXT_FUNCTIONS STRUC
cFunctions		ULONG ?
rgpszFunctions		LPWSTR ?
CRYPT_CONTEXT_FUNCTIONS ENDS
PCRYPT_CONTEXT_FUNCTIONS typedef ptr CRYPT_CONTEXT_FUNCTIONS

CRYPT_CONTEXT_FUNCTION_PROVIDERS STRUC
cProviders		ULONG ?
rgpszProviders		LPWSTR ?
CRYPT_CONTEXT_FUNCTION_PROVIDERS ENDS
PCRYPT_CONTEXT_FUNCTION_PROVIDERS typedef ptr CRYPT_CONTEXT_FUNCTION_PROVIDERS

CRYPT_PROPERTY_REF	STRUC
pszProperty		PWSTR ?
cbValue			ULONG ?
pbValue			PUCHAR ?
CRYPT_PROPERTY_REF	ENDS
PCRYPT_PROPERTY_REF	typedef ptr CRYPT_PROPERTY_REF

CRYPT_IMAGE_REF		STRUC
pszImage		PWSTR ?
dwFlags			ULONG ?
CRYPT_IMAGE_REF		ENDS
PCRYPT_IMAGE_REF	typedef ptr CRYPT_IMAGE_REF

CRYPT_PROVIDER_REF	STRUC
dwInterface		ULONG ?
pszFunction		PWSTR ?
pszProvider		PWSTR ?
cProperties		ULONG ?
rgpProperties		PCRYPT_PROPERTY_REF ?
pUM			PCRYPT_IMAGE_REF ?
pKM			PCRYPT_IMAGE_REF ?
CRYPT_PROVIDER_REF	ENDS
PCRYPT_PROVIDER_REF	typedef ptr CRYPT_PROVIDER_REF

CRYPT_PROVIDER_REFS	STRUC
cProviders		ULONG ?
rgpProviders		PCRYPT_PROVIDER_REF ?
CRYPT_PROVIDER_REFS	ENDS
PCRYPT_PROVIDER_REFS	typedef ptr CRYPT_PROVIDER_REFS

ifndef KERNEL_MODE_CNG

BCryptQueryProviderRegistration proto WINAPI :LPCWSTR, :ULONG, :ULONG, :ptr, :ptr
BCryptEnumRegisteredProviders proto WINAPI :ptr, :ptr
BCryptCreateContext proto WINAPI :ULONG, :LPCWSTR, :PCRYPT_CONTEXT_CONFIG
BCryptDeleteContext proto WINAPI :ULONG, :LPCWSTR
BCryptEnumContexts proto WINAPI :ULONG, :ptr, :ptr
BCryptConfigureContext proto WINAPI :ULONG, :LPCWSTR, :PCRYPT_CONTEXT_CONFIG
BCryptQueryContextConfiguration proto WINAPI :ULONG, :LPCWSTR, :ptr, :ptr
BCryptAddContextFunction proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :ULONG
BCryptRemoveContextFunction proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR
BCryptEnumContextFunctions proto WINAPI :ULONG, :LPCWSTR, :ULONG, :ptr, :ptr
BCryptConfigureContextFunction proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :PCRYPT_CONTEXT_FUNCTION_CONFIG
BCryptQueryContextFunctionConfiguration proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :ptr, :ptr
BCryptEnumContextFunctionProviders proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :ptr, :ptr
BCryptSetContextFunctionProperty proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :LPCWSTR, :ULONG, :PUCHAR
BCryptQueryContextFunctionProperty proto WINAPI :ULONG, :LPCWSTR, :ULONG, :LPCWSTR, :LPCWSTR, :ptr, :ptr

endif ;; ifndef KERNEL_MODE_CNG

ifdef KERNEL_MODE_CNG
BCryptRegisterConfigChangeNotify proto WINAPI :PRKEVENT
else
BCryptRegisterConfigChangeNotify proto WINAPI :ptr
endif
ifdef KERNEL_MODE_CNG
BCryptUnregisterConfigChangeNotify proto WINAPI :PRKEVENT
else
BCryptUnregisterConfigChangeNotify proto WINAPI :HANDLE
endif
BCryptResolveProviders proto WINAPI :LPCWSTR, :ULONG, :LPCWSTR, :LPCWSTR, :ULONG, :ULONG, :ptr, :ptr
BCryptGetFipsAlgorithmMode proto WINAPI :ptr
endif
endif
