cryptdlg.h 10.8 KB
Newer Older
Juan Lang's avatar
Juan Lang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
/*
 * Copyright (C) 2008 Juan Lang
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
#ifndef __CRYPTDLG_H__
#define __CRYPTDLG_H__

#include <prsht.h>

#ifdef __cplusplus
extern "C" {
#endif

#define CRYPTDLG_FLAGS_MASK         0xff000000
#define CRYPTDLG_REVOCATION_DEFAULT 0x00000000
#define CRYPTDLG_REVOCATION_ONLINE  0x80000000
#define CRYPTDLG_REVOCATION_CACHE   0x40000000
#define CRYPTDLG_REVOCATION_NONE    0x20000000

#define CRYPTDLG_POLICY_MASK          0x0000ffff
#define POLICY_IGNORE_NON_CRITICAL_BC 0x00000001

#define CRYPTDLG_ACTION_MASK             0xffff0000
#define ACTION_REVOCATION_DEFAULT_ONLINE 0x00010000
#define ACTION_REVOCATION_DEFAULT_CACHE  0x00020000

typedef BOOL (WINAPI *PFNCMFILTERPROC)(PCCERT_CONTEXT, DWORD, DWORD, DWORD);

#define CERT_DISPWELL_SELECT                 1
#define CERT_DISPWELL_TRUST_CA_CERT          2
#define CERT_DISPWELL_TRUST_LEAF_CERT        3
#define CERT_DISPWELL_TRUST_ADD_CA_CERT      4
#define CERT_DISPWELL_TRUST_ADD_LEAF_CERT    5
#define CERT_DISPWELL_DISTRUST_CA_CERT       6
#define CERT_DISPWELL_DISTRUST_LEAF_CERT     7
#define CERT_DISPWELL_DISTRUST_ADD_CA_CERT   8
#define CERT_DISPWELL_DISTRUST_ADD_LEAF_CERT 9

typedef UINT (WINAPI *PFNCMHOOKPROC)(HWND, UINT, WPARAM, LPARAM);

#define CSS_SELECTCERT_MASK      0x00ffffff
#define CSS_HIDE_PROPERTIES      0x00000001
#define CSS_ENABLEHOOK           0x00000002
#define CSS_ALLOWMULTISELECT     0x00000004
#define CSS_SHOW_HELP            0x00000010
#define CSS_ENABLETEMPLATE       0x00000020
#define CSS_ENABLETEMPLATEHANDLE 0x00000040

#define SELCERT_OK         IDOK
#define SELCERT_CANCEL     IDCANCEL
#define SELCERT_PROPERTIES 100
#define SELCERT_FINEPRINT  101
#define SELCERT_CERTLIST   102
#define SELCERT_HELP       IDHELP
#define SELCERT_ISSUED_TO  103
#define SELCERT_VALIDITY   104
#define SELCERT_ALGORITHM  105
#define SELCERT_SERIAL_NUM 106
#define SELCERT_THUMBPRINT 107

typedef struct tagCSSA
{
    DWORD           dwSize;
    HWND            hwndParent;
    HINSTANCE       hInstance;
    LPCSTR          pTemplateName;
    DWORD           dwFlags;
    LPCSTR          szTitle;
    DWORD           cCertStore;
    HCERTSTORE     *arrayCertStore;
    LPCSTR          szPurposeOid;
    DWORD           cCertContext;
    PCCERT_CONTEXT *arrayCertContext;
    DWORD           lCustData;
    PFNCMHOOKPROC   pfnHook;
    PFNCMFILTERPROC pfnFilter;
    LPCSTR          szHelpFileName;
    DWORD           dwHelpId;
    HCRYPTPROV      hprov;
} CERT_SELECT_STRUCT_A, *PCERT_SELECT_STRUCT_A;

typedef struct tagCSSW
{
    DWORD           dwSize;
    HWND            hwndParent;
    HINSTANCE       hInstance;
    LPCWSTR         pTemplateName;
    DWORD           dwFlags;
    LPCWSTR         szTitle;
    DWORD           cCertStore;
    HCERTSTORE     *arrayCertStore;
    LPCSTR          szPurposeOid;
    DWORD           cCertContext;
    PCCERT_CONTEXT *arrayCertContext;
    DWORD           lCustData;
    PFNCMHOOKPROC   pfnHook;
    PFNCMFILTERPROC pfnFilter;
    LPCWSTR         szHelpFileName;
    DWORD           dwHelpId;
    HCRYPTPROV      hprov;
} CERT_SELECT_STRUCT_W, *PCERT_SELECT_STRUCT_W;

#define CERT_SELECT_STRUCT WINELIB_NAME_AW(CERT_SELECT_STRUCT_)

BOOL WINAPI CertSelectCertificateA(PCERT_SELECT_STRUCT_A pCertSelectInfo);
BOOL WINAPI CertSelectCertificateW(PCERT_SELECT_STRUCT_W pCertSelectInfo);
#define CertSelectCertificate WINELIB_NAME_AW(CertSelectCertificate)

#define CM_VIEWFLAGS_MASK       0x00ffffff
#define CM_ENABLEHOOK           0x00000001
#define CM_SHOW_HELP            0x00000002
#define CM_SHOW_HELPICON        0x00000004
#define CM_ENABLETEMPLATE       0x00000008
#define CM_HIDE_ADVANCEPAGE     0x00000010
#define CM_HIDE_TRUSTPAGE       0x00000020
#define CM_NO_NAMECHANGE        0x00000040
#define CM_NO_EDITTRUST         0x00000080
#define CM_HIDE_DETAILPAGE      0x00000100
#define CM_ADD_CERT_STORES      0x00000200
#define CERTVIEW_CRYPTUI_LPARAM 0x00800000

typedef struct tagCERT_VIEWPROPERTIES_STRUCT_A
{
    DWORD           dwSize;
    HWND            hwndParent;
    HINSTANCE       hInstance;
    DWORD           dwFlags;
    LPCSTR          szTitle;
    PCCERT_CONTEXT  pCertContext;
    LPSTR          *arrayPurposes;
    DWORD           cArrayPurposes;
    DWORD           cRootStores;
    HCERTSTORE     *rghstoreRoots;
    DWORD           cStores;
    HCERTSTORE     *rghstoreCAs;
    DWORD           cTrustStores;
    HCERTSTORE     *rghstoreTrust;
    HCRYPTPROV      hprov;
    DWORD           lCustData;
    DWORD           dwPad;
    LPCSTR          szHelpFileName;
    DWORD           dwHelpId;
    DWORD           nStartPage;
    DWORD           cArrayPropSheetPages;
    /* FIXME: PSDK declares arrayPropSheetPages as a PROPSHEETPAGE *, which we
     * don't allow in our own headers.  It's probably wrong, but we're not
     * compatible.
     */
    PROPSHEETPAGEA *arrayPropSheetPages;
} CERT_VIEWPROPERTIES_STRUCT_A, *PCERT_VIEWPROPERTIES_STRUCT_A;

typedef struct tagCERT_VIEWPROPERTIES_STRUCT_W
{
    DWORD           dwSize;
    HWND            hwndParent;
    HINSTANCE       hInstance;
    DWORD           dwFlags;
    LPCWSTR         szTitle;
    PCCERT_CONTEXT  pCertContext;
    LPSTR          *arrayPurposes;
    DWORD           cArrayPurposes;
    DWORD           cRootStores;
    HCERTSTORE     *rghstoreRoots;
    DWORD           cStores;
    HCERTSTORE     *rghstoreCAs;
    DWORD           cTrustStores;
    HCERTSTORE     *rghstoreTrust;
    HCRYPTPROV      hprov;
    DWORD           lCustData;
    DWORD           dwPad;
    LPCWSTR         szHelpFileName;
    DWORD           dwHelpId;
    DWORD           nStartPage;
    DWORD           cArrayPropSheetPages;
    /* FIXME: PSDK declares arrayPropSheetPages as a PROPSHEETPAGE *, which we
     * don't allow in our own headers.  It's probably wrong, but we're not
     * compatible.
     */
    PROPSHEETPAGEW *arrayPropSheetPages;
} CERT_VIEWPROPERTIES_STRUCT_W, *PCERT_VIEWPROPERTIES_STRUCT_W;

#define CERT_VIEWPROPERTIES_STRUCT WINELIB_NAME_AW(CERT_VIEWPROPERTIES_STRUCT_)
#define PCERT_VIEWPROPERTIES_STRUCT \
 WINELIB_NAME_AW(PCERT_VIEWPROPERTIES_STRUCT_)

BOOL WINAPI CertViewPropertiesA(PCERT_VIEWPROPERTIES_STRUCT_A pCertViewInfo);
BOOL WINAPI CertViewPropertiesW(PCERT_VIEWPROPERTIES_STRUCT_W pCertViewInfo);
#define CertViewProperties WINELIB_NAME_AW(CertViewProperties)

#define CERT_FILTER_OP_EXISTS     1
#define CERT_FILTER_OP_NOT_EXISTS 2
#define CERT_FILTER_OP_EQUALITY   3

typedef struct tagCMOID
{
    LPCSTR szExtensionOID;
    DWORD  dwTestOperation;
    LPBYTE pbTestData;
    DWORD  cbTestData;
} CERT_FILTER_EXTENSION_MATCH;

#define CERT_FILTER_INCLUDE_V1_CERTS  0x0001
#define CERT_FILTER_VALID_TIME_RANGE  0x0002
#define CERT_FILTER_VALID_SIGNATURE   0x0004
#define CERT_FILTER_LEAF_CERTS_ONLY   0x0008
#define CERT_FILTER_ISSUER_CERTS_ONLY 0x0010
#define CERT_FILTER_KEY_EXISTS        0x0020

typedef struct tagCMFLTR
{
    DWORD                        dwSize;
    DWORD                        cExtensionChecks;
    CERT_FILTER_EXTENSION_MATCH *arrayExtensionChecks;
    DWORD                        dwCheckingFlags;
} CERT_FILTER_DATA;

DWORD WINAPI GetFriendlyNameOfCertA(PCCERT_CONTEXT pccert, LPSTR pchBuffer,
 DWORD cchBuffer);
DWORD WINAPI GetFriendlyNameOfCertW(PCCERT_CONTEXT pccert, LPWSTR pchBuffer,
 DWORD cchBuffer);
#define GetFriendlyNameOfCert WINELIB_NAME_AW(GetFriendlyNameOfCert)

#define CERT_CERTIFICATE_ACTION_VERIFY \
 { 0x7801ebd0, 0xcf4b, 0x11d0, { 0x85,0x1f,0x00,0x60,0x97,0x93,0x87,0xea }}
#define szCERT_CERTIFICATE_ACTION_VERIFY \
 "{7801ebd0-cf4b-11d0-851f-0060979387ea}"

typedef HRESULT (WINAPI *PFNTRUSTHELPER)(PCCERT_CONTEXT, DWORD, BOOL, LPBYTE);

#define CERT_VALIDITY_MASK_VALIDITY              0x0000ffff
#define CERT_VALIDITY_BEFORE_START               0x00000001
#define CERT_VALIDITY_AFTER_END                  0x00000002
#define CERT_VALIDITY_SIGNATURE_FAILS            0x00000004
#define CERT_VALIDITY_CERTIFICATE_REVOKED        0x00000008
#define CERT_VALIDITY_KEY_USAGE_EXT_FAILURE      0x00000010
#define CERT_VALIDITY_EXTENDED_USAGE_FAILURE     0x00000020
#define CERT_VALIDITY_NAME_CONSTRAINTS_FAILURE   0x00000040
#define CERT_VALIDITY_UNKNOWN_CRITICAL_EXTENSION 0x00000080
#define CERT_VALIDITY_ISSUER_INVALID             0x00000100
#define CERT_VALIDITY_OTHER_EXTENSION_FAILURE    0x00000200
#define CERT_VALIDITY_PERIOD_NESTING_FAILURE     0x00000400
#define CERT_VALIDITY_OTHER_ERROR                0x00000800

#define CERT_VALIDITY_MASK_TRUST                 0xffff0000
#define CERT_VALIDITY_EXPLICITLY_DISTRUSTED      0x01000000
#define CERT_VALIDITY_ISSUER_DISTRUST            0x02000000
#define CERT_VALIDITY_NO_ISSUER_CERT_FOUND       0x10000000
#define CERT_VALIDITY_NO_CRL_FOUND               0x20000000
#define CERT_VALIDITY_CRL_OUT_OF_DATE            0x40000000
#define CERT_VALIDITY_NO_TRUST_DATA              0x80000000

#define CERT_TRUST_MASK                0x00ffffff
#define CERT_TRUST_DO_FULL_SEARCH      0x00000001
#define CERT_TRUST_PERMIT_MISSING_CRLS 0x00000002
#define CERT_TRUST_DO_FULL_TRUST       0x00000005
#define CERT_TRUST_ADD_CERT_STORES     CM_ADD_CERT_STORES

typedef struct _CERT_VERIFY_CERTIFICATE_TRUST
{
    DWORD            cbSize;
    PCCERT_CONTEXT   pccert;
    DWORD            dwFlags;
    DWORD            dwIgnoreErr;
    DWORD           *pdwErrors;
    LPSTR            pszUsageOid;
    HCRYPTPROV       hprov;
    DWORD            cRootStores;
    HCERTSTORE       rghstoreRoots;
    DWORD            cStores;
    HCERTSTORE      *rghstoreCAs;
    DWORD            cTrustStores;
    HCERTSTORE      *rghstoreTrust;
    DWORD            lCustData;
    PFNTRUSTHELPER   pfnTrustHelper;
    DWORD           *pcchain;
    PCCERT_CONTEXT **prgChain;
    DWORD          **prgdwErrors;
    DATA_BLOB      **prgpbTrustInfo;
} CERT_VERIFY_CERTIFICATE_TRUST, *PCERT_VERIFY_CERTIFICATE_TRUST;

#define CTL_MODIFY_REQUEST_ADD_NOT_TRUSTED 1
#define CTL_MODIFY_REQUEST_REMOVE          2
#define CTL_MODIFY_REQUEST_ADD_TRUSTED     3

typedef struct _CTL_MODIFY_REQUEST
{
    PCCERT_CONTEXT pccert;
    DWORD          dwOperation;
    DWORD          dwError;
} CTL_MODIFY_REQUEST, *PCTL_MODIFY_REQUEST;

HRESULT WINAPI CertModifyCertificatesToTrust(int cCertStore,
 PCTL_MODIFY_REQUEST rgCerts, LPCSTR szPurpose, HWND hwnd,
 HCERTSTORE hcertstoreTrust);

#ifdef __cplusplus
}
#endif

#endif