BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(
    __in HANDLE hFile,
    __inout DWORD *pcbHash,
    _Out_opt_ BYTE *pbHash,
    __in DWORD dwFlags);


BOOL CryptCATAdminCalcHashFromFileHandle2(
  HCATADMIN hCatAdmin,
  HANDLE    hFile,
  DWORD     *pcbHash,
  BYTE      *pbHash,
  DWORD     dwFlags
);

HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(
    __in HCATADMIN hCatAdmin,
    __in BYTE *pbHash,
    __in DWORD cbHash,
    __in DWORD dwFlags,
    __inout HCATINFO *phPrevCatInfo);

BOOL WINAPI CryptCATAdminAcquireContext(
  _Out_       HCATADMIN *phCatAdmin,
  _In_        GUID      *pgSubsystem,
  _In_        DWORD     dwFlags
);

BOOL CryptCATAdminAcquireContext2(
  HCATADMIN               *phCatAdmin,
  GUID              *pgSubsystem,
  PCWSTR                  pwszHashAlgorithm,
  PCCERT_STRONG_SIGN_PARA pStrongHashPolicy,
  DWORD                   dwFlags
);

BOOL WINAPI CryptCATCatalogInfoFromContext(
  _In_    HCATINFO     hCatInfo,
  _Inout_ CATALOG_INFO *psCatInfo,
  _In_    DWORD        dwFlags
);


BOOL WINAPI CryptCATAdminReleaseCatalogContext(
  _In_ HCATADMIN hCatAdmin,
  _In_ HCATINFO  hCatInfo,
  _In_ DWORD     dwFlags
);

BOOL WINAPI CryptCATAdminReleaseContext(
  _In_ HCATADMIN hCatAdmin,
  _In_ DWORD     dwFlags
);

CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo(
  _In_ HANDLE         hCatalog,
  _In_ CRYPTCATMEMBER *pCatMember,
  _In_ LPWSTR         pwszReferenceTag
);

CRYPTCATMEMBER* WINAPI CryptCATGetMemberInfo(
  _In_ HANDLE hCatalog,
  _In_ LPWSTR pwszReferenceTag
);

CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo(
  _In_ HANDLE         hCatalog,
  _In_ CRYPTCATMEMBER *pCatMember,
  _In_ LPWSTR         pwszReferenceTag
);

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateCatAttr(
  _In_ HANDLE            hCatalog,
  _In_ CRYPTCATATTRIBUTE *pPrevAttr
);

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateAttr(
  _In_ HANDLE            hCatalog,
  _In_ CRYPTCATMEMBER    *pCatMember,
  _In_ CRYPTCATATTRIBUTE *pPrevAttr
);

CRYPTCATMEMBER* WINAPI CryptCATEnumerateMember(
  _In_ HANDLE         hCatalog,
  _In_ CRYPTCATMEMBER *pPrevMember
);

BOOL WINAPI CryptQueryObject(
  _In_        DWORD      dwObjectType,
  _In_        VOID       *pvObject,
  _In_        DWORD      dwExpectedContentTypeFlags,
  _In_        DWORD      dwExpectedFormatTypeFlags,
  _In_        DWORD      dwFlags,
  _Out_       DWORD      *pdwMsgAndCertEncodingType,
  _Out_       DWORD      *pdwContentType,
  _Out_       DWORD      *pdwFormatType,
  _Out_       HCERTSTORE *phCertStore,
  _Out_       HCRYPTMSG  *phMsg,
  _Out_       PVOID       *ppvContext
);

BOOL WINAPI CryptMsgGetParam(
  _In_    HCRYPTMSG hCryptMsg,
  _In_    DWORD     dwParamType,
  _In_    DWORD     dwIndex,
  _Out_   VOID      *pvData,
  _Inout_ DWORD     *pcbData
);


BOOL WINAPI CryptDecodeObject(
  _In_          DWORD  dwCertEncodingType,
  _In_          LPCSTR lpszStructType,
  _In_          BYTE   *pbEncoded,
  _In_          DWORD  cbEncoded,
  _In_          DWORD  dwFlags,
  _Out_         VOID   *pvStructInfo,
  _Inout_       DWORD  *pcbStructInfo
);


PCCERT_CONTEXT WINAPI CertFindCertificateInStore(
  _In_       HCERTSTORE     hCertStore,
  _In_       DWORD          dwCertEncodingType,
  _In_       DWORD          dwFindFlags,
  _In_       DWORD          dwFindType,
  _In_       VOID           *pvFindPara,
  _In_       PCCERT_CONTEXT pPrevCertContext
);

DWORD WINAPI CertGetNameStringA(
  _In_  PCCERT_CONTEXT pCertContext,
  _In_  DWORD          dwType,
  _In_  DWORD          dwFlags,
  _In_  VOID           *pvTypePara,
  _Out_ LPCSTR         pszNameString,
  _In_  DWORD          cchNameString
);

DWORD WINAPI CertGetNameStringW(
  _In_  PCCERT_CONTEXT pCertContext,
  _In_  DWORD          dwType,
  _In_  DWORD          dwFlags,
  _In_  VOID           *pvTypePara,
  _Out_ LPWSTR         pszNameString,
  _In_  DWORD          cchNameString
);


BOOL WINAPI CertGetCertificateChain(
  _In_opt_ HCERTCHAINENGINE     hChainEngine,
  _In_     PCCERT_CONTEXT       pCertContext,
  _In_opt_ LPFILETIME           pTime,
  _In_     HCERTSTORE           hAdditionalStore,
  _In_     PCERT_CHAIN_PARA     pChainPara,
  _In_     DWORD                dwFlags,
  _In_     LPVOID               pvReserved,
  _Out_    PCCERT_CHAIN_CONTEXT *ppChainContext
);

PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(
  _In_opt_ HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProvOrNCryptKey,
  _In_     PCERT_NAME_BLOB                 pSubjectIssuerBlob,
  _In_     DWORD                           dwFlags,
  _In_opt_ PCRYPT_KEY_PROV_INFO            pKeyProvInfo,
  _In_opt_ PCRYPT_ALGORITHM_IDENTIFIER     pSignatureAlgorithm,
  _In_opt_ PSYSTEMTIME                     pStartTime,
  _In_opt_ PSYSTEMTIME                     pEndTime,
  _In_opt_ PCERT_EXTENSIONS                pExtensions
);


BOOL WINAPI CertStrToNameA(
  _In_      DWORD   dwCertEncodingType,
  _In_      LPCSTR  pszX500,
  _In_      DWORD   dwStrType,
  _In_opt_  VOID    *pvReserved,
  _Out_     BYTE    *pbEncoded,
  _Inout_   DWORD   *pcbEncoded,
  _Out_opt_ LPCSTR *ppszError
);

BOOL WINAPI CertStrToNameW(
  _In_      DWORD   dwCertEncodingType,
  _In_      LPWSTR  pszX500,
  _In_      DWORD   dwStrType,
  _In_opt_  VOID    *pvReserved,
  _Out_     BYTE    *pbEncoded,
  _Inout_   DWORD   *pcbEncoded,
  _Out_opt_ LPWSTR *ppszError
);

HCERTSTORE WINAPI CertOpenStore(
  _In_       LPCSTR            lpszStoreProvider,
  _In_       DWORD             dwMsgAndCertEncodingType,
  _In_       HCRYPTPROV_LEGACY hCryptProv,
  _In_       DWORD             dwFlags,
  _In_       VOID              *pvPara
);

BOOL WINAPI CertAddCertificateContextToStore(
  _In_      HCERTSTORE     hCertStore,
  _In_      PCCERT_CONTEXT pCertContext,
  _In_      DWORD          dwAddDisposition,
  _Out_opt_ PCCERT_CONTEXT *ppStoreContext
);

BOOL WINAPI CertFreeCertificateContext(
  _In_ PCCERT_CONTEXT pCertContext
);


BOOL WINAPI PFXExportCertStoreEx(
  _In_    HCERTSTORE      hStore,
  _Inout_ CRYPT_DATA_BLOB *pPFX,
  _In_    LPCWSTR         szPassword,
  _In_    VOID            *pvPara,
  _In_    DWORD           dwFlags
);

HCERTSTORE WINAPI PFXImportCertStore(
  _In_ CRYPT_DATA_BLOB *pPFX,
  _In_ LPCWSTR         szPassword,
  _In_ DWORD           dwFlags
);


BOOL WINAPI CryptGenKey(
  _In_  HCRYPTPROV hProv,
  _In_  ALG_ID     Algid,
  _In_  DWORD      dwFlags,
  _Out_ HCRYPTKEY  *phKey
);

BOOL WINAPI CryptDestroyKey(
  _In_ HCRYPTKEY hKey
);

BOOL WINAPI CryptAcquireContextA(
  _Out_ HCRYPTPROV *phProv,
  _In_  LPCSTR    pszContainer,
  _In_  LPCSTR    pszProvider,
  _In_  DWORD      dwProvType,
  _In_  DWORD      dwFlags
);

BOOL WINAPI CryptAcquireContextW(
  _Out_ HCRYPTPROV *phProv,
  _In_  LPWSTR    pszContainer,
  _In_  LPWSTR    pszProvider,
  _In_  DWORD      dwProvType,
  _In_  DWORD      dwFlags
);


BOOL WINAPI CryptReleaseContext(
  _In_ HCRYPTPROV hProv,
  _In_ DWORD      dwFlags
);


BOOL CryptCreateHash(
  HCRYPTPROV hProv,
  ALG_ID     Algid,
  HCRYPTKEY  hKey,
  DWORD      dwFlags,
  HCRYPTHASH *phHash
);

BOOL CryptHashData(
  HCRYPTHASH hHash,
  BYTE *pbData,
  DWORD      dwDataLen,
  DWORD      dwFlags
);

BOOL CryptGetHashParam(
  HCRYPTHASH hHash,
  DWORD      dwParam,
  BYTE       *pbData,
  DWORD      *pdwDataLen,
  DWORD      dwFlags
);

BOOL CryptVerifySignatureA(
  HCRYPTHASH hHash,
  BYTE *pbSignature,
  DWORD      dwSigLen,
  HCRYPTKEY  hPubKey,
  LPCSTR     szDescription,
  DWORD      dwFlags
);

BOOL CryptVerifySignatureW(
  HCRYPTHASH hHash,
  BYTE *pbSignature,
  DWORD      dwSigLen,
  HCRYPTKEY  hPubKey,
  LPCWSTR    szDescription,
  DWORD      dwFlags
);

BOOL CryptSignHashA(
  HCRYPTHASH hHash,
  DWORD      dwKeySpec,
  LPCSTR     szDescription,
  DWORD      dwFlags,
  BYTE       *pbSignature,
  DWORD      *pdwSigLen
);


BOOL CryptSignHashW(
  HCRYPTHASH hHash,
  DWORD      dwKeySpec,
  LPCWSTR    szDescription,
  DWORD      dwFlags,
  BYTE       *pbSignature,
  DWORD      *pdwSigLen
);

BOOL CryptDestroyHash(
  HCRYPTHASH hHash
);

BOOL CryptEncrypt(
  HCRYPTKEY  hKey,
  HCRYPTHASH hHash,
  BOOL       Final,
  DWORD      dwFlags,
  BYTE       *pbData,
  DWORD      *pdwDataLen,
  DWORD      dwBufLen
);

BOOL CryptDecrypt(
  HCRYPTKEY  hKey,
  HCRYPTHASH hHash,
  BOOL       Final,
  DWORD      dwFlags,
  BYTE       *pbData,
  DWORD      *pdwDataLen
);

BOOL CryptDeriveKey(
  HCRYPTPROV hProv,
  ALG_ID     Algid,
  HCRYPTHASH hBaseData,
  DWORD      dwFlags,
  HCRYPTKEY  *phKey
);

BOOL WINAPI CryptExportKey(
  _In_    HCRYPTKEY hKey,
  _In_    HCRYPTKEY hExpKey,
  _In_    DWORD     dwBlobType,
  _In_    DWORD     dwFlags,
  _Out_   BYTE      *pbData,
  _Inout_ DWORD     *pdwDataLen
);

BOOL CryptImportKey(
  HCRYPTPROV hProv,
  BYTE *pbData,
  DWORD      dwDataLen,
  HCRYPTKEY  hPubKey,
  DWORD      dwFlags,
  HCRYPTKEY  *phKey
);

BOOL WINAPI CertGetCertificateContextProperty(
  _In_    PCCERT_CONTEXT pCertContext,
  _In_    DWORD          dwPropId,
  _Out_   VOID           *pvData,
  _Inout_ DWORD          *pcbData
);

DWORD WINAPI CertEnumCertificateContextProperties(
  _In_ PCCERT_CONTEXT pCertContext,
  _In_ DWORD          dwPropId
);

BOOL WINAPI CryptEncryptMessage(
  _In_          PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
  _In_          DWORD                       cRecipientCert,
  _In_          PCCERT_CONTEXT              *rgpRecipientCert,
  _In_          BYTE                        *pbToBeEncrypted,
  _In_          DWORD                       cbToBeEncrypted,
  _Out_         BYTE                        *pbEncryptedBlob,
  _Inout_       DWORD                       *pcbEncryptedBlob
);

BOOL WINAPI CryptDecryptMessage(
  _In_              PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
  _In_              BYTE                        *pbEncryptedBlob,
  _In_              DWORD                       cbEncryptedBlob,
  _Out_opt_         BYTE                        *pbDecrypted,
  _Inout_opt_       DWORD                       *pcbDecrypted,
  _Out_opt_         PCCERT_CONTEXT              *ppXchgCert
);

BOOL WINAPI CryptAcquireCertificatePrivateKey(
  _In_     PCCERT_CONTEXT                  pCert,
  _In_     DWORD                           dwFlags,
  _In_opt_ VOID                            *pvParameters,
  _Out_    HCRYPTPROV_OR_NCRYPT_KEY_HANDLE *phCryptProvOrNCryptKey,
  _Out_    DWORD                           *pdwKeySpec,
  _Out_    BOOL                            *pfCallerFreeProvOrNCryptKey
);


PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
  _In_ PCCERT_CONTEXT pCertContext
);


PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(
  _In_ HCERTSTORE     hCertStore,
  _In_ PCCERT_CONTEXT pPrevCertContext
);

BOOL WINAPI CryptEncodeObjectEx(
  _In_          DWORD              dwCertEncodingType,
  _In_          LPCSTR             lpszStructType,
  _In_          VOID               *pvStructInfo,
  _In_          DWORD              dwFlags,
  _In_          PCRYPT_ENCODE_PARA pEncodePara,
  _Out_         VOID               *pvEncoded,
  _Inout_       DWORD              *pcbEncoded
);

PCCERT_CONTEXT WINAPI CertCreateCertificateContext(
  _In_       DWORD dwCertEncodingType,
  _In_       BYTE  *pbCertEncoded,
  _In_       DWORD cbCertEncoded
);

BOOL WINAPI CertCompareCertificate(
  _In_ DWORD      dwCertEncodingType,
  _In_ PCERT_INFO pCertId1,
  _In_ PCERT_INFO pCertId2
);

PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(
  _In_ HCERTSTORE    hCertStore,
  _In_ PCCTL_CONTEXT pPrevCtlContext
);

PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(
  _In_ PCCTL_CONTEXT pCtlContext
);

BOOL WINAPI CertFreeCTLContext(
  _In_ PCCTL_CONTEXT pCtlContext
);


BOOL WINAPI CryptUIDlgViewContext(
  _In_       DWORD   dwContextType,
  _In_       PVOID   pvContext,
  _In_       HWND    hwnd,
  _In_       LPCWSTR pwszTitle,
  _In_       DWORD   dwFlags,
  _In_       PVOID   pvReserved
);

BOOL WINAPI CryptMsgVerifyCountersignatureEncoded(
  _In_ HCRYPTPROV_LEGACY hCryptProv,
  _In_ DWORD             dwEncodingType,
  _In_ PBYTE             pbSignerInfo,
  _In_ DWORD             cbSignerInfo,
  _In_ PBYTE             pbSignerInfoCountersignature,
  _In_ DWORD             cbSignerInfoCountersignature,
  _In_ PCERT_INFO        pciCountersigner
);

BOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx(
  _In_opt_   HCRYPTPROV_LEGACY hCryptProv,
  _In_       DWORD             dwEncodingType,
  _In_       PBYTE             pbSignerInfo,
  _In_       DWORD             cbSignerInfo,
  _In_       PBYTE             pbSignerInfoCountersignature,
  _In_       DWORD             cbSignerInfoCountersignature,
  _In_       DWORD             dwSignerType,
  _In_       PVOID             pvSigner,
  _Reserved_ DWORD             dwFlags,
  _Reserved_ PVOID             pvExtra
);

BOOL WINAPI CryptHashCertificate(
  _In_          HCRYPTPROV_LEGACY hCryptProv,
  _In_          ALG_ID            Algid,
  _In_          DWORD             dwFlags,
  _In_          BYTE              *pbEncoded,
  _In_          DWORD             cbEncoded,
  _Out_         BYTE              *pbComputedHash,
  _Inout_       DWORD             *pcbComputedHash
);


BOOL CryptSignMessage(
  PCRYPT_SIGN_MESSAGE_PARA pSignPara,
  BOOL                     fDetachedSignature,
  DWORD                    cToBeSigned,
  PBYTE                 *rgpbToBeSigned,
  DWORD                 *rgcbToBeSigned,
  BYTE                     *pbSignedBlob,
  DWORD                    *pcbSignedBlob
);


BOOL CryptSignAndEncryptMessage(
  PCRYPT_SIGN_MESSAGE_PARA    pSignPara,
  PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
  DWORD                       cRecipientCert,
  PCCERT_CONTEXT           *rgpRecipientCert,
  BYTE                  *pbToBeSignedAndEncrypted,
  DWORD                       cbToBeSignedAndEncrypted,
  BYTE                        *pbSignedAndEncryptedBlob,
  DWORD                       *pcbSignedAndEncryptedBlob
);

BOOL CryptVerifyMessageSignature(
  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
  DWORD                      dwSignerIndex,
  BYTE                 *pbSignedBlob,
  DWORD                      cbSignedBlob,
  BYTE                       *pbDecoded,
  DWORD                      *pcbDecoded,
  PCCERT_CONTEXT             *ppSignerCert
);

BOOL CryptVerifyMessageSignatureWithKey(
  PCRYPT_KEY_VERIFY_MESSAGE_PARA pVerifyPara,
  PCERT_PUBLIC_KEY_INFO          pPublicKeyInfo,
  BYTE                     *pbSignedBlob,
  DWORD                          cbSignedBlob,
  BYTE                           *pbDecoded,
  DWORD                          *pcbDecoded
);


BOOL CryptVerifyMessageHash(
  PCRYPT_HASH_MESSAGE_PARA pHashPara,
  BYTE                     *pbHashedBlob,
  DWORD                    cbHashedBlob,
  BYTE                     *pbToBeHashed,
  DWORD                    *pcbToBeHashed,
  BYTE                     *pbComputedHash,
  DWORD                    *pcbComputedHash
);



PCCERT_CONTEXT PfnCryptGetSignerCertificate(
  PVOID pvGetArg,
  DWORD dwCertEncodingType,
  PCERT_INFO pSignerId,
  HCERTSTORE hMsgCertStore
);


BOOL CryptEncrypt(
  HCRYPTKEY  hKey,
  HCRYPTHASH hHash,
  BOOL       Final,
  DWORD      dwFlags,
  BYTE       *pbData,
  DWORD      *pdwDataLen,
  DWORD      dwBufLen
);


BOOL CryptDecrypt(
  HCRYPTKEY  hKey,
  HCRYPTHASH hHash,
  BOOL       Final,
  DWORD      dwFlags,
  BYTE       *pbData,
  DWORD      *pdwDataLen
);

HCRYPTMSG CryptMsgOpenToEncode(
  DWORD             dwMsgEncodingType,
  DWORD             dwFlags,
  DWORD             dwMsgType,
  PVOID             pvMsgEncodeInfo,
  LPSTR             pszInnerContentObjID,
  PCMSG_STREAM_INFO pStreamInfo
);

HCRYPTMSG CryptMsgOpenToDecode(
  DWORD             dwMsgEncodingType,
  DWORD             dwFlags,
  DWORD             dwMsgType,
  HCRYPTPROV_LEGACY hCryptProv,
  PCERT_INFO        pRecipientInfo,
  PCMSG_STREAM_INFO pStreamInfo
);

BOOL CryptMsgUpdate(
  HCRYPTMSG  hCryptMsg,
  BYTE      *pbData,
  DWORD      cbData,
  BOOL       fFinal
);

BOOL CryptMsgControl(
  HCRYPTMSG  hCryptMsg,
  DWORD      dwFlags,
  DWORD      dwCtrlType,
  PVOID      pvCtrlPara
);

BOOL CryptMsgClose(
  HCRYPTMSG hCryptMsg
);

BOOL CryptEnumOIDFunction(
  DWORD                   dwEncodingType,
  LPCSTR                  pszFuncName,
  LPCSTR                  pszOID,
  DWORD                   dwFlags,
  PVOID                   pvArg,
  PFN_CRYPT_ENUM_OID_FUNC pfnEnumOIDFunc
);


BOOL CryptGetOIDFunctionValue(
  DWORD   dwEncodingType,
  LPCSTR  pszFuncName,
  LPCSTR  pszOID,
  LPCWSTR pwszValueName,
  DWORD   *pdwValueType,
  BYTE    *pbValueData,
  DWORD   *pcbValueData
);

BOOL CertCloseStore(
  HCERTSTORE hCertStore,
  DWORD      dwFlags
);