#ifndef _CRYPTUIAPI_H
#define _CRYPTUIAPI_H

/* Cryptographic UI API definitions */

#include <wincrypt.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <pshpack8.h>

#define CRYPTUI_SELECT_ISSUEDTO_COLUMN  0x000000001
#define CRYPTUI_SELECT_ISSUEDBY_COLUMN  0x000000002
#define CRYPTUI_SELECT_INTENDEDUSE_COLUMN  0x000000004
#define CRYPTUI_SELECT_FRIENDLYNAME_COLUMN  0x000000008
#define CRYPTUI_SELECT_LOCATION_COLUMN  0x000000010
#define CRYPTUI_SELECT_EXPIRATION_COLUMN  0x000000020

#define CRYPTUI_CERT_MGR_TAB_MASK  0x0000000F
#define CRYPTUI_CERT_MGR_PUBLISHER_TAB  0x00000004
#define CRYPTUI_CERT_MGR_SINGLE_TAB_FLAG  0x00008000

#define CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE  0x01
#define CRYPTUI_WIZ_DIGITAL_SIGN_PVK_PROV  0x02

#define CRYPTUI_WIZ_DIGITAL_SIGN_COMMERCIAL  0x0001
#define CRYPTUI_WIZ_DIGITAL_SIGN_INDIVIDUAL  0x0002

#define CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_FILE  0x01
#define CRYPTUI_WIZ_DIGITAL_SIGN_SUBJECT_BLOB  0x02

#define CRYPTUI_WIZ_DIGITAL_SIGN_CERT  0x01
#define CRYPTUI_WIZ_DIGITAL_SIGN_STORE  0x02
#define CRYPTUI_WIZ_DIGITAL_SIGN_PVK  0x03

#define CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN  0x00000001
#define CRYPTUI_WIZ_DIGITAL_SIGN_ADD_CHAIN_NO_ROOT  0x00000002

#define CRYPTUI_WIZ_NO_UI  0x0001

#if __POCC__ >= 290
#pragma warn(push)
#pragma warn(disable:2198)  /* Nameless field is not standard */
#endif

typedef BOOL (WINAPI *PFNCFILTERPROC)(PCCERT_CONTEXT,BOOL*,void*);

typedef struct _CRYPTUI_CERT_MGR_STRUCT {
    DWORD dwSize;
    HWND hwndParent;
    DWORD dwFlags;
    LPCWSTR pwszTitle;
    LPCSTR pszInitUsageOID;
} CRYPTUI_CERT_MGR_STRUCT, *PCRYPTUI_CERT_MGR_STRUCT;
typedef const CRYPTUI_CERT_MGR_STRUCT *PCCRYPTUI_CERT_MGR_STRUCT;

BOOL WINAPI CryptUIDlgCertMgr(PCCRYPTUI_CERT_MGR_STRUCT);

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO {
    DWORD dwSize;
    GUID *pGuidSubject;
    DWORD cbBlob;
    BYTE *pbBlob;
    LPCWSTR pwszDisplayName;
} CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO {
    DWORD dwSize;
    DWORD cCertStore;
    HCERTSTORE *rghCertStore;
    PFNCFILTERPROC pFilterCallback;
    void *pvCallbackData;
} CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO {
    DWORD dwSize;
    LPWSTR pwszPvkFileName;
    LPWSTR pwszProvName;
    DWORD dwProvType;
} CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO {
    DWORD dwSize;
    LPWSTR pwszSigningCertFileName;
    DWORD dwPvkChoice;
    union {
        PCCRYPTUI_WIZ_DIGITAL_SIGN_PVK_FILE_INFO pPvkFileInfo;
        PCRYPT_KEY_PROV_INFO pPvkProvInfo;
    };
} CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO {
    DWORD dwSize;
    DWORD dwAttrFlags;
    LPCWSTR pwszDescription;
    LPCWSTR pwszMoreInfoLocation;
    LPCSTR pszHashAlg;
    LPCWSTR pwszSigningCertDisplayString;
    HCERTSTORE hAdditionalCertStore;
    PCRYPT_ATTRIBUTES psAuthenticated;
    PCRYPT_ATTRIBUTES psUnauthenticated;
} CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_INFO {
    DWORD dwSize;
    DWORD dwSubjectChoice;
    union {
        LPCWSTR pwszFileName;
        PCCRYPTUI_WIZ_DIGITAL_SIGN_BLOB_INFO pSignBlobInfo;
    };
    DWORD dwSigningCertChoice;
    union {
        PCCERT_CONTEXT pSigningCertContext;
        PCCRYPTUI_WIZ_DIGITAL_SIGN_STORE_INFO pSigningCertStore;
        PCCRYPTUI_WIZ_DIGITAL_SIGN_CERT_PVK_INFO pSigningCertPvkInfo;
    };
    LPCWSTR pwszTimestampURL;
    DWORD dwAdditionalCertChoice;
    PCCRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO pSignExtInfo;
} CRYPTUI_WIZ_DIGITAL_SIGN_INFO, *PCRYPTUI_WIZ_DIGITAL_SIGN_INFO;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_INFO *PCCRYPTUI_WIZ_DIGITAL_SIGN_INFO;

typedef struct _CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT {
    DWORD dwSize;
    DWORD cbBlob;
    BYTE *pbBlob;
} CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT, *PCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT;
typedef const CRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT *PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT;

#if __POCC__ >= 290
#pragma warn(pop)
#endif

BOOL WINAPI CryptUIDlgViewContext(DWORD,const void*,HWND,LPCWSTR,DWORD,void*);
PCCERT_CONTEXT WINAPI CryptUIDlgSelectCertificateFromStore(HCERTSTORE,HWND,LPCWSTR,LPCWSTR,DWORD,DWORD,void*);

BOOL WINAPI CryptUIWizDigitalSign(DWORD,HWND,LPCWSTR,PCCRYPTUI_WIZ_DIGITAL_SIGN_INFO,PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT*);
BOOL WINAPI CryptUIWizFreeDigitalSignContext(PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT);

#include <poppack.h>

#ifdef __cplusplus
}
#endif

#endif /* _CRYPTUIAPI_H */
