oledb32: Implement conversions to DBTYPE_WSTR.
[wine] / include / wincrypt.h
1 /*
2  * Copyright (C) 2002 Travis Michielsen
3  * Copyright (C) 2004-2005 Juan Lang
4  * Copyright (C) 2007 Vijay Kiran Kamuju
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_WINCRYPT_H
22 #define __WINE_WINCRYPT_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #include <bcrypt.h>
29 /* FIXME: #include <ncrypt.h> */
30
31 #ifdef _ADVAPI32_
32 # define WINADVAPI
33 #else
34 # define WINADVAPI DECLSPEC_IMPORT
35 #endif
36
37 /* some typedefs for function parameters */
38 typedef unsigned int ALG_ID;
39 typedef ULONG_PTR HCRYPTPROV;
40 typedef ULONG_PTR HCRYPTPROV_OR_NCRYPT_KEY_HANDLE;
41 typedef ULONG_PTR HCRYPTPROV_LEGACY;
42 typedef ULONG_PTR HCRYPTKEY;
43 typedef ULONG_PTR HCRYPTHASH;
44 typedef void *HCERTSTORE;
45 typedef void *HCRYPTMSG;
46 typedef void *HCERTSTOREPROV;
47 typedef void *HCRYPTOIDFUNCSET;
48 typedef void *HCRYPTOIDFUNCADDR;
49 typedef void *HCRYPTDEFAULTCONTEXT;
50
51 /* CSP Structs */
52
53 typedef struct _PROV_ENUMALGS {
54   ALG_ID aiAlgid;
55   DWORD  dwBitLen;
56   DWORD  dwNameLen;
57   CHAR   szName[20];
58 } PROV_ENUMALGS;
59
60 typedef struct _PROV_ENUMALGS_EX {
61   ALG_ID aiAlgid;
62   DWORD  dwDefaultLen;
63   DWORD  dwMinLen;
64   DWORD  dwMaxLen;
65   DWORD  dwProtocols;
66   DWORD  dwNameLen;
67   CHAR   szName[20];
68   DWORD  dwLongNameLen;
69   CHAR   szLongName[40];
70 } PROV_ENUMALGS_EX;
71
72 #define SCHANNEL_MAC_KEY 0
73 #define SCHANNEL_ENC_KEY 1
74
75 typedef struct _SCHANNEL_ALG {
76   DWORD  dwUse;
77   ALG_ID Algid;
78   DWORD  cBits;
79   DWORD  dwFlags;
80   DWORD  dwReserved;
81 } SCHANNEL_ALG, *PSCHANNEL_ALG;
82
83 typedef struct _HMAC_INFO {
84   ALG_ID HashAlgid;
85   BYTE*  pbInnerString;
86   DWORD  cbInnerString;
87   BYTE*  pbOuterString;
88   DWORD  cbOuterString;
89 } HMAC_INFO, *PHMAC_INFO;
90                 
91 typedef struct _CRYPTOAPI_BLOB {
92   DWORD    cbData;
93   BYTE*    pbData;
94 } CRYPT_INTEGER_BLOB,  *PCRYPT_INTEGER_BLOB,
95   CRYPT_UINT_BLOB,     *PCRYPT_UINT_BLOB,
96   CRYPT_OBJID_BLOB,    *PCRYPT_OBJID_BLOB,
97   CERT_NAME_BLOB,      *PCERT_NAME_BLOB,
98   CERT_RDN_VALUE_BLOB, *PCERT_RDN_VALUE_BLOB,
99   CERT_BLOB,           *PCERT_BLOB,
100   CRL_BLOB,            *PCRL_BLOB,
101   DATA_BLOB,           *PDATA_BLOB,
102   CRYPT_DATA_BLOB,     *PCRYPT_DATA_BLOB,
103   CRYPT_HASH_BLOB,     *PCRYPT_HASH_BLOB,
104   CRYPT_DIGEST_BLOB,   *PCRYPT_DIGEST_BLOB,
105   CRYPT_DER_BLOB,      *PCRYPT_DER_BLOB,
106   CRYPT_ATTR_BLOB,     *PCRYPT_ATTR_BLOB;
107
108 typedef struct _CRYPTPROTECT_PROMPTSTRUCT{
109   DWORD   cbSize;
110   DWORD   dwPromptFlags;
111   HWND    hwndApp;
112   LPCWSTR szPrompt;
113 } CRYPTPROTECT_PROMPTSTRUCT, *PCRYPTPROTECT_PROMPTSTRUCT;
114
115 typedef struct _CRYPT_ALGORITHM_IDENTIFIER {
116   LPSTR            pszObjId;
117   CRYPT_OBJID_BLOB Parameters;
118 } CRYPT_ALGORITHM_IDENTIFIER, *PCRYPT_ALGORITHM_IDENTIFIER;
119
120 typedef struct _CRYPT_ATTRIBUTE_TYPE_VALUE {
121   LPSTR               pszObjId;
122   CRYPT_OBJID_BLOB    Value;
123 } CRYPT_ATTRIBUTE_TYPE_VALUE, *PCRYPT_ATTRIBUTE_TYPE_VALUE;
124
125 typedef struct _PUBLICKEYSTRUC {
126     BYTE   bType;
127     BYTE   bVersion;
128     WORD   reserved;
129     ALG_ID aiKeyAlg;
130 } BLOBHEADER, PUBLICKEYSTRUC;
131
132 typedef struct _RSAPUBKEY {
133     DWORD   magic;
134     DWORD   bitlen;
135     DWORD   pubexp;
136 } RSAPUBKEY;
137
138 typedef struct _PUBKEY {
139     DWORD   magic;
140     DWORD   bitlen;
141 } DHPUBKEY, DSSPUBKEY, KEAPUBKEY, TEKPUBKEY;
142
143 typedef struct _DSSSEED {
144     DWORD   counter;
145     BYTE    seed[20];
146 } DSSSEED;
147
148 typedef struct _PUBKEYVER3 {
149     DWORD   magic;
150     DWORD   bitlenP;
151     DWORD   bitlenQ;
152     DWORD   bitlenJ;
153     DSSSEED DSSSeed;
154 } DHPUBKEY_VER3, DSSPUBKEY_VER3;
155
156 typedef struct _PRIVKEYVER3 {
157     DWORD   magic;
158     DWORD   bitlenP;
159     DWORD   bitlenQ;
160     DWORD   bitlenJ;
161     DWORD   bitlenX;
162     DSSSEED DSSSeed;
163 } DHPRIVKEY_VER3, DSSPRIVKEY_VER3;
164
165 typedef struct _KEY_TYPE_SUBTYPE {
166     DWORD   dwKeySpec;
167     GUID    Type;
168     GUID    SubType;
169 } KEY_TYPE_SUBTYPE, *PKEY_TYPE_SUBTYPE;
170
171 typedef struct _CERT_FORTEZZA_DATA_PROP {
172     unsigned char   SerialNumber[8];
173     int             CertIndex;
174     unsigned char   CertLabel[36];
175 } CERT_FORTEZZA_DATA_PROP;
176
177 typedef struct _CMS_DH_KEY_INFO {
178     DWORD             dwVersion;
179     ALG_ID            Algid;
180     LPSTR             pszContentEncObjId;
181     CRYPT_DATA_BLOB   PubInfo;
182     void              *pReserved;
183 } CMS_DH_KEY_INFO, *PCMS_DH_KEY_INFO;
184
185 typedef struct _CRYPT_BIT_BLOB {
186     DWORD cbData;
187     BYTE  *pbData;
188     DWORD cUnusedBits;
189 } CRYPT_BIT_BLOB, *PCRYPT_BIT_BLOB;
190
191 typedef struct _CRYPT_KEY_PROV_PARAM {
192     DWORD dwParam;
193     BYTE *pbData;
194     DWORD cbData;
195     DWORD dwFlags;
196 } CRYPT_KEY_PROV_PARAM, *PCRYPT_KEY_PROV_PARAM;
197
198 typedef struct _CRYPT_KEY_PROV_INFO {
199     LPWSTR                pwszContainerName;
200     LPWSTR                pwszProvName;
201     DWORD                 dwProvType;
202     DWORD                 dwFlags;
203     DWORD                 cProvParam;
204     PCRYPT_KEY_PROV_PARAM rgProvParam;
205     DWORD                 dwKeySpec;
206 } CRYPT_KEY_PROV_INFO, *PCRYPT_KEY_PROV_INFO;
207
208 typedef struct _CERT_KEY_CONTEXT {
209     DWORD      cbSize;
210     HCRYPTPROV hCryptProv;
211     DWORD      dwKeySpec;
212 } CERT_KEY_CONTEXT, *PCERT_KEY_CONTEXT;
213
214 typedef struct _CERT_PUBLIC_KEY_INFO {
215     CRYPT_ALGORITHM_IDENTIFIER Algorithm;
216     CRYPT_BIT_BLOB             PublicKey;
217 } CERT_PUBLIC_KEY_INFO, *PCERT_PUBLIC_KEY_INFO;
218
219 typedef struct _CERT_EXTENSION {
220     LPSTR               pszObjId;
221     BOOL                fCritical;
222     CRYPT_OBJID_BLOB    Value;
223 } CERT_EXTENSION, *PCERT_EXTENSION;
224
225 typedef struct _CERT_EXTENSIONS {
226     DWORD           cExtension;
227     PCERT_EXTENSION rgExtension;
228 } CERT_EXTENSIONS, *PCERT_EXTENSIONS;
229
230 typedef struct _CERT_INFO {
231     DWORD                      dwVersion;
232     CRYPT_INTEGER_BLOB         SerialNumber;
233     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
234     CERT_NAME_BLOB             Issuer;
235     FILETIME                   NotBefore;
236     FILETIME                   NotAfter;
237     CERT_NAME_BLOB             Subject;
238     CERT_PUBLIC_KEY_INFO       SubjectPublicKeyInfo;
239     CRYPT_BIT_BLOB             IssuerUniqueId;
240     CRYPT_BIT_BLOB             SubjectUniqueId;
241     DWORD                      cExtension;
242     PCERT_EXTENSION            rgExtension;
243 } CERT_INFO, *PCERT_INFO;
244
245 typedef struct _CERT_RDN_ATTR {
246     LPSTR               pszObjId;
247     DWORD               dwValueType;
248     CERT_RDN_VALUE_BLOB Value;
249 } CERT_RDN_ATTR, *PCERT_RDN_ATTR;
250
251 typedef struct _CERT_RDN {
252     DWORD          cRDNAttr;
253     PCERT_RDN_ATTR rgRDNAttr;
254 } CERT_RDN, *PCERT_RDN;
255
256 typedef struct _CERT_NAME_INFO {
257     DWORD     cRDN;
258     PCERT_RDN rgRDN;
259 } CERT_NAME_INFO, *PCERT_NAME_INFO;
260
261 typedef struct _CERT_NAME_VALUE {
262     DWORD               dwValueType;
263     CERT_RDN_VALUE_BLOB Value;
264 } CERT_NAME_VALUE, *PCERT_NAME_VALUE;
265
266 typedef struct _CERT_ENCRYPTED_PRIVATE_KEY_INFO {
267     CRYPT_ALGORITHM_IDENTIFIER EncryptionAlgorithm;
268     CRYPT_DATA_BLOB            EncryptedPrivateKey;
269 } CERT_ENCRYPTED_PRIVATE_KEY_INFO, *PCERT_ENCRYPTED_PRIVATE_KEY_INFO;
270
271 typedef struct _CERT_AUTHORITY_KEY_ID_INFO {
272     CRYPT_DATA_BLOB    KeyId;
273     CERT_NAME_BLOB     CertIssuer;
274     CRYPT_INTEGER_BLOB CertSerialNumber;
275 } CERT_AUTHORITY_KEY_ID_INFO, *PCERT_AUTHORITY_KEY_ID_INFO;
276
277 typedef struct _CERT_PRIVATE_KEY_VALIDITY {
278     FILETIME NotBefore;
279     FILETIME NotAfter;
280 } CERT_PRIVATE_KEY_VALIDITY, *PCERT_PRIVATE_KEY_VALIDITY;
281
282 typedef struct _CERT_KEY_ATTRIBUTES_INFO {
283     CRYPT_DATA_BLOB            KeyId;
284     CRYPT_BIT_BLOB             IntendedKeyUsage;
285     PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod;
286 } CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO;
287
288 /* byte 0 */
289 #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80
290 #define CERT_NON_REPUDIATION_KEY_USAGE   0x40
291 #define CERT_KEY_ENCIPHERMENT_KEY_USAGE  0x20
292 #define CERT_DATA_ENCIPHERMENT_KEY_USAGE 0x10
293 #define CERT_KEY_AGREEMENT_KEY_USAGE     0x08
294 #define CERT_KEY_CERT_SIGN_KEY_USAGE     0x04
295 #define CERT_OFFLINE_CRL_SIGN_KEY_USAGE  0x02
296 #define CERT_CRL_SIGN_KEY_USAGE          0x02
297 #define CERT_ENCIPHER_ONLY_KEY_USAGE     0x01
298 /* byte 1 */
299 #define CERT_DECIPHER_ONLY_KEY_USAGE     0x80
300
301 typedef struct _CERT_POLICY_ID {
302     DWORD  cCertPolicyElementId;
303     LPSTR *rgbszCertPolicyElementId;
304 } CERT_POLICY_ID, *PCERT_POLICY_ID;
305
306 typedef struct _CERT_KEY_USAGE_RESTRICTION_INFO {
307     DWORD           cCertPolicyId;
308     PCERT_POLICY_ID rgCertPolicyId;
309     CRYPT_BIT_BLOB  RestrictedKeyUsage;
310 } CERT_KEY_USAGE_RESTRICTION_INFO, *PCERT_KEY_USAGE_RESTRICTION_INFO;
311
312 typedef struct _CERT_OTHER_NAME {
313     LPSTR            pszObjId;
314     CRYPT_OBJID_BLOB Value;
315 } CERT_OTHER_NAME, *PCERT_OTHER_NAME;
316
317 typedef struct _CERT_ALT_NAME_ENTRY {
318     DWORD dwAltNameChoice;
319     union {
320         PCERT_OTHER_NAME pOtherName;
321         LPWSTR           pwszRfc822Name;
322         LPWSTR           pwszDNSName;
323         CERT_NAME_BLOB   DirectoryName;
324         LPWSTR           pwszURL;
325         CRYPT_DATA_BLOB  IPAddress;
326         LPSTR            pszRegisteredID;
327     } DUMMYUNIONNAME;
328 } CERT_ALT_NAME_ENTRY, *PCERT_ALT_NAME_ENTRY;
329
330 #define CERT_ALT_NAME_OTHER_NAME     1
331 #define CERT_ALT_NAME_RFC822_NAME    2
332 #define CERT_ALT_NAME_DNS_NAME       3
333 #define CERT_ALT_NAME_X400_ADDRESS   4
334 #define CERT_ALT_NAME_DIRECTORY_NAME 5
335 #define CERT_ALT_NAME_EDI_PARTY_NAME 6
336 #define CERT_ALT_NAME_URL            7
337 #define CERT_ALT_NAME_IP_ADDRESS     8
338 #define CERT_ALT_NAME_REGISTERED_ID  9
339
340 typedef struct _CERT_ALT_NAME_INFO {
341     DWORD                cAltEntry;
342     PCERT_ALT_NAME_ENTRY rgAltEntry;
343 } CERT_ALT_NAME_INFO, *PCERT_ALT_NAME_INFO;
344
345 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK  0xff
346 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT 16
347 #define CERT_ALT_NAME_VALUE_ERR_INDEX_MASK  0x0000ffff
348 #define CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT 0
349 #define GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(x) \
350  (((x) >> CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) & \
351   CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK)
352 #define GET_CERT_ALT_NAME_VALUE_ERR_INDEX(x) \
353  ((x) & CERT_ALT_NAME_VALUE_ERR_INDEX_MASK)
354
355 typedef struct _CERT_BASIC_CONSTRAINTS_INFO {
356     CRYPT_BIT_BLOB  SubjectType;
357     BOOL            fPathLenConstraint;
358     DWORD           dwPathLenConstraint;
359     DWORD           cSubtreesConstraint;
360     CERT_NAME_BLOB *rgSubtreesConstraint;
361 } CERT_BASIC_CONSTRAINTS_INFO, *PCERT_BASIC_CONSTRAINTS_INFO;
362
363 #define CERT_CA_SUBJECT_FLAG         0x80
364 #define CERT_END_ENTITY_SUBJECT_FLAG 0x40
365
366 typedef struct _CERT_BASIC_CONSTRAINTS2_INFO {
367     BOOL  fCA;
368     BOOL  fPathLenConstraint;
369     DWORD dwPathLenConstraint;
370 } CERT_BASIC_CONSTRAINTS2_INFO, *PCERT_BASIC_CONSTRAINTS2_INFO;
371
372 typedef struct _CERT_POLICY_QUALIFIER_INFO {
373     LPSTR            pszPolicyQualifierId;
374     CRYPT_OBJID_BLOB Qualifier;
375 } CERT_POLICY_QUALIFIER_INFO, *PCERT_POLICY_QUALIFIER_INFO;
376
377 typedef struct _CERT_POLICY_INFO {
378     LPSTR                       pszPolicyIdentifier;
379     DWORD                       cPolicyQualifier;
380     CERT_POLICY_QUALIFIER_INFO *rgPolicyQualifier;
381 } CERT_POLICY_INFO, *PCERT_POLICY_INFO;
382
383 typedef struct _CERT_POLICIES_INFO {
384     DWORD             cPolicyInfo;
385     CERT_POLICY_INFO *rgPolicyInfo;
386 } CERT_POLICIES_INFO, *PCERT_POLICIES_INFO;
387
388 typedef struct _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE {
389     LPSTR pszOrganization;
390     DWORD cNoticeNumbers;
391     int  *rgNoticeNumbers;
392 } CERT_POLICY_QUALIFIER_NOTICE_REFERENCE,
393  *PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
394
395 typedef struct _CERT_POLICY_QUALIFIER_USER_NOTICE {
396     CERT_POLICY_QUALIFIER_NOTICE_REFERENCE *pNoticeReference;
397     LPWSTR                                  pszDisplayText;
398 } CERT_POLICY_QUALIFIER_USER_NOTICE, *PCERT_POLICY_QUALIFIER_USER_NOTICE;
399
400 typedef struct _CPS_URLS {
401     LPWSTR                      pszURL;
402     CRYPT_ALGORITHM_IDENTIFIER *pAlgorithm;
403     CRYPT_DATA_BLOB            *pDigest;
404 } CPS_URLS, *PCPS_URLS;
405
406 typedef struct _CERT_POLICY95_QUALIFIER1 {
407     LPWSTR    pszPracticesReference;
408     LPSTR     pszNoticeIdentifier;
409     LPSTR     pszNSINoticeIdentifier;
410     DWORD     cCPSURLs;
411     CPS_URLS *rgCPSURLs;
412 } CERT_POLICY95_QUALIFIER1, *PCERT_POLICY95_QUALIFIER1;
413
414 typedef struct _CERT_POLICY_MAPPING {
415     LPSTR pszIssuerDomainPolicy;
416     LPSTR pszSubjectDomainPolicy;
417 } CERT_POLICY_MAPPING, *PCERT_POLICY_MAPPING;
418
419 typedef struct _CERT_POLICY_MAPPINGS_INFO {
420     DWORD                cPolicyMapping;
421     PCERT_POLICY_MAPPING rgPolicyMapping;
422 } CERT_POLICY_MAPPINGS_INFO, *PCERT_POLICY_MAPPINGS_INFO;
423
424 typedef struct _CERT_POLICY_CONSTRAINTS_INFO {
425     BOOL  fRequireExplicitPolicy;
426     DWORD dwRequireExplicitPolicySkipCerts;
427     BOOL  fInhibitPolicyMapping;
428     DWORD dwInhibitPolicyMappingSkipCerts;
429 } CERT_POLICY_CONSTRAINTS_INFO, *PCERT_POLICY_CONSTRAINTS_INFO;
430
431 typedef struct _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY {
432     LPSTR           pszObjId;
433     DWORD           cValue;
434     PCRYPT_DER_BLOB rgValue;
435 } CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY, *PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
436
437 typedef struct _CRYPT_CONTENT_INFO {
438     LPSTR          pszObjId;
439     CRYPT_DER_BLOB Content;
440 } CRYPT_CONTENT_INFO, *PCRYPT_CONTENT_INFO;
441
442 typedef struct _CRYPT_SEQUENCE_OF_ANY {
443     DWORD           cValue;
444     PCRYPT_DER_BLOB rgValue;
445 } CRYPT_SEQUENCE_OF_ANY, *PCRYPT_SEQUENCE_OF_ANY;
446
447 typedef struct _CERT_AUTHORITY_KEY_ID2_INFO {
448     CRYPT_DATA_BLOB    KeyId;
449     CERT_ALT_NAME_INFO AuthorityCertIssuer;
450     CRYPT_INTEGER_BLOB AuthorityCertSerialNumber;
451 } CERT_AUTHORITY_KEY_ID2_INFO, *PCERT_AUTHORITY_KEY_ID2_INFO;
452
453 typedef struct _CERT_ACCESS_DESCRIPTION {
454     LPSTR               pszAccessMethod;
455     CERT_ALT_NAME_ENTRY AccessLocation;
456 } CERT_ACCESS_DESCRIPTION, *PCERT_ACCESS_DESCRIPTION;
457
458 typedef struct _CERT_AUTHORITY_INFO_ACCESS {
459     DWORD                    cAccDescr;
460     PCERT_ACCESS_DESCRIPTION rgAccDescr;
461 } CERT_AUTHORITY_INFO_ACCESS, *PCERT_AUTHORITY_INFO_ACCESS;
462
463 typedef struct _CERT_CONTEXT {
464     DWORD      dwCertEncodingType;
465     BYTE       *pbCertEncoded;
466     DWORD      cbCertEncoded;
467     PCERT_INFO pCertInfo;
468     HCERTSTORE hCertStore;
469 } CERT_CONTEXT, *PCERT_CONTEXT;
470 typedef const CERT_CONTEXT *PCCERT_CONTEXT;
471
472 typedef struct _CRL_ENTRY {
473     CRYPT_INTEGER_BLOB SerialNumber;
474     FILETIME           RevocationDate;
475     DWORD              cExtension;
476     PCERT_EXTENSION    rgExtension;
477 } CRL_ENTRY, *PCRL_ENTRY;
478
479 typedef struct _CRL_INFO {
480     DWORD           dwVersion;
481     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
482     CERT_NAME_BLOB  Issuer;
483     FILETIME        ThisUpdate;
484     FILETIME        NextUpdate;
485     DWORD           cCRLEntry;
486     PCRL_ENTRY      rgCRLEntry;
487     DWORD           cExtension;
488     PCERT_EXTENSION rgExtension;
489 } CRL_INFO, *PCRL_INFO;
490
491 typedef struct _CRL_DIST_POINT_NAME {
492     DWORD dwDistPointNameChoice;
493     union {
494         CERT_ALT_NAME_INFO FullName;
495     } DUMMYUNIONNAME;
496 } CRL_DIST_POINT_NAME, *PCRL_DIST_POINT_NAME;
497
498 #define CRL_DIST_POINT_NO_NAME         0
499 #define CRL_DIST_POINT_FULL_NAME       1
500 #define CRL_DIST_POINT_ISSUER_RDN_NAME 2
501
502 typedef struct _CRL_DIST_POINT {
503     CRL_DIST_POINT_NAME DistPointName;
504     CRYPT_BIT_BLOB      ReasonFlags;
505     CERT_ALT_NAME_INFO  CRLIssuer;
506 } CRL_DIST_POINT, *PCRL_DIST_POINT;
507
508 #define CRL_REASON_UNUSED_FLAG                 0x80
509 #define CRL_REASON_KEY_COMPROMISE_FLAG         0x40
510 #define CRL_REASON_CA_COMPROMISE_FLAG          0x20
511 #define CRL_REASON_AFFILIATION_CHANGED_FLAG    0x10
512 #define CRL_REASON_SUPERSEDED_FLAG             0x08
513 #define CRL_REASON_CESSATION_OF_OPERATION_FLAG 0x04
514 #define CRL_REASON_CERTIFICATE_HOLD_FLAG       0x02
515
516 typedef struct _CRL_DIST_POINTS_INFO {
517     DWORD           cDistPoint;
518     PCRL_DIST_POINT rgDistPoint;
519 } CRL_DIST_POINTS_INFO, *PCRL_DIST_POINTS_INFO;
520
521 #define CRL_DIST_POINT_ERR_INDEX_MASK  0x7f
522 #define CRL_DIST_POINT_ERR_INDEX_SHIFT 24
523 #define GET_CRL_DIST_POINT_ERR_INDEX(x) \
524  (((x) >> CRL_DIST_POINT_ERR_INDEX_SHIFT) & CRL_DIST_POINT_ERR_INDEX_MASK)
525
526 #define CRL_DIST_POINT_ERR_CRL_ISSUER_BIT 0x80000000L
527 #define IS_CRL_DIST_POINT_ERR_CRL_ISSUER(x) \
528  ((x) & CRL_DIST_POINT_ERR_CRL_ISSUER_BIT)
529
530 typedef struct _CROSS_CERT_DIST_POINTS_INFO {
531     DWORD               dwSyncDeltaTime;
532     DWORD               cDistPoint;
533     PCERT_ALT_NAME_INFO rgDistPoint;
534 } CROSS_CERT_DIST_POINTS_INFO, *PCROSS_CERT_DIST_POINTS_INFO;
535
536 #define CROSS_CERT_DIST_POINT_ERR_INDEX_MASK  0xff
537 #define CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT 24
538 #define GET_CROSS_CERT_DIST_POINT_ERR_INDEX(x) \
539  (((x) >> CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT) & \
540  CROSS_CERT_DIST_POINT_ERR_INDEX_MASK)
541
542 typedef struct _CERT_PAIR {
543     CERT_BLOB Forward;
544     CERT_BLOB Reverse;
545 } CERT_PAIR, *PCERT_PAIR;
546
547 typedef struct _CRL_ISSUING_DIST_POINT {
548     CRL_DIST_POINT_NAME DistPointName;
549     BOOL                fOnlyContainsUserCerts;
550     BOOL                fOnlyContainsCACerts;
551     CRYPT_BIT_BLOB      OnlySomeReasonFlags;
552     BOOL                fIndirectCRL;
553 } CRL_ISSUING_DIST_POINT, *PCRL_ISSUING_DIST_POINT;
554
555 typedef struct _CERT_GENERAL_SUBTREE {
556     CERT_ALT_NAME_ENTRY Base;
557     DWORD               dwMinimum;
558     BOOL                fMaximum;
559     DWORD               dwMaximum;
560 } CERT_GENERAL_SUBTREE, *PCERT_GENERAL_SUBTREE;
561
562 typedef struct _CERT_NAME_CONSTRAINTS_INFO {
563     DWORD                 cPermittedSubtree;
564     PCERT_GENERAL_SUBTREE rgPermittedSubtree;
565     DWORD                 cExcludedSubtree;
566     PCERT_GENERAL_SUBTREE rgExcludedSubtree;
567 } CERT_NAME_CONSTRAINTS_INFO, *PCERT_NAME_CONSTRAINTS_INFO;
568
569 #define CERT_EXCLUDED_SUBTREE_BIT 0x80000000L
570 #define IS_CERT_EXCLUDED_SUBTREE(x) ((x) & CERT_EXCLUDED_SUBTREE_BIT)
571
572 typedef struct _CRYPT_ATTRIBUTE {
573     LPSTR            pszObjId;
574     DWORD            cValue;
575     PCRYPT_DATA_BLOB rgValue;
576 } CRYPT_ATTRIBUTE, *PCRYPT_ATTRIBUTE;
577
578 typedef struct _CRYPT_ATTRIBUTES {
579     DWORD            cAttr;
580     PCRYPT_ATTRIBUTE rgAttr;
581 } CRYPT_ATTRIBUTES, *PCRYPT_ATTRIBUTES;
582
583 typedef struct _CERT_REQUEST_INFO {
584     DWORD                dwVersion;
585     CERT_NAME_BLOB       Subject;
586     CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
587     DWORD                cAttribute;
588     PCRYPT_ATTRIBUTE     rgAttribute;
589 } CERT_REQUEST_INFO, *PCERT_REQUEST_INFO;
590
591 typedef struct _CERT_KEYGEN_REQUEST_INFO {
592     DWORD                dwVersion;
593     CERT_PUBLIC_KEY_INFO SubjectPubliceKeyInfo;
594     LPWSTR               pwszChallengeString;
595 } CERT_KEYGEN_REQUEST_INFO, *PCERT_KEYGEN_REQUEST_INFO;
596
597 typedef struct _CERT_SIGNED_CONTENT_INFO {
598     CRYPT_DER_BLOB             ToBeSigned;
599     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
600     CRYPT_BIT_BLOB             Signature;
601 } CERT_SIGNED_CONTENT_INFO, *PCERT_SIGNED_CONTENT_INFO;
602
603 typedef struct _CRL_CONTEXT {
604     DWORD      dwCertEncodingType;
605     BYTE      *pbCrlEncoded;
606     DWORD      cbCrlEncoded;
607     PCRL_INFO  pCrlInfo;
608     HCERTSTORE hCertStore;
609 } CRL_CONTEXT, *PCRL_CONTEXT;
610 typedef const CRL_CONTEXT *PCCRL_CONTEXT;
611
612 #define SORTED_CTL_EXT_FLAGS_OFFSET                (0*4)
613 #define SORTED_CTL_EXT_COUNT_OFFSET                (1*4)
614 #define SORTED_CTL_EXT_MAX_COLLISION_OFFSET        (2*4)
615 #define SORTED_CTL_EXT_HASH_BUCKET_OFFSET          (3*4)
616
617 #define SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG    0x1
618
619 typedef struct _CERT_DSS_PARAMETERS {
620     CRYPT_UINT_BLOB    p;
621     CRYPT_UINT_BLOB    q;
622     CRYPT_UINT_BLOB    g;
623 } CERT_DSS_PARAMETERS, *PCERT_DSS_PARAMETERS;
624
625 #define CERT_DSS_R_LEN            20
626 #define CERT_DSS_S_LEN            20
627 #define CERT_DSS_SIGNATURE_LEN    (CERT_DSS_R_LEN + CERT_DSS_S_LEN)
628
629 #define CERT_MAX_ENCODED_DSS_SIGNATURE_LEN    (2 + 2*(2 + 20 +1))
630
631 typedef struct _CERT_DH_PARAMETERS {
632     CRYPT_UINT_BLOB    p;
633     CRYPT_UINT_BLOB    g;
634 } CERT_DH_PARAMETERS, *PCERT_DH_PARAMETERS;
635
636 typedef struct _CERT_X942_DH_VALIDATION_PARAMS {
637     CRYPT_BIT_BLOB     seed;
638     DWORD              pgenCounter;
639 } CERT_X942_DH_VALIDATION_PARAMS, *PCERT_X942_DH_VALIDATION_PARAMS;
640
641 typedef struct _CERT_X942_DH_PARAMETERS {
642     CRYPT_UINT_BLOB                    p;
643     CRYPT_UINT_BLOB                    g;
644     CRYPT_UINT_BLOB                    q;
645     CRYPT_UINT_BLOB                    j;
646     PCERT_X942_DH_VALIDATION_PARAMS    pValidationParams;
647 } CERT_X942_DH_PARAMETERS, *PCERT_X942_DH_PARAMETERS;
648
649 #define CRYPT_X942_COUNTER_BYTE_LENGTH        4
650 #define CRYPT_X942_KEY_LENGTH_BYTE_LENGTH     4
651 #define CRYPT_X942_PUB_INFO_BYTE_LENGTH       (512/8)
652
653 typedef struct _CRYPT_X942_OTHER_INFO {
654     LPSTR              pszContentEncryptionObjId;
655     BYTE               rgbCounter[CRYPT_X942_COUNTER_BYTE_LENGTH];
656     BYTE               rgbKeyLength[CRYPT_X942_KEY_LENGTH_BYTE_LENGTH];
657     CRYPT_DATA_BLOB    PubInfo;
658 } CRYPT_X942_OTHER_INFO, *PCRYPT_X942_OTHER_INFO;
659
660 typedef struct _CRYPT_RC2_CBC_PARAMETERS {
661     DWORD    dwVersion;
662     BOOL     fIV;
663     BYTE     rgbIV[4];
664 } CRYPT_RC2_CBC_PARAMETERS, *PCRYPT_RC2_CBC_PARAMETERS;
665
666 #define CRYPT_RC2_40BIT_VERSION    160
667 #define CRYPT_RC2_56BIT_VERSION    52
668 #define CRYPT_RC2_64BIT_VERSION    120
669 #define CRYPT_RC2_128BIT_VERSION   58
670
671 typedef struct _CRYPT_SMIME_CAPABILITY {
672     LPSTR               pszObjId;
673     CRYPT_OBJID_BLOB    Parameters;
674 } CRYPT_SMIME_CAPABILITY, *PCRYPT_SMIME_CAPABILITY;
675
676 typedef struct _CRYPT_SMIME_CAPABILITIES {
677     DWORD                   cCapability;
678     PCRYPT_SMIME_CAPABILITY rgCapability;
679 } CRYPT_SMIME_CAPABILITIES, *PCRYPT_SMIME_CAPABILITIES;
680
681 typedef struct _VTableProvStruc {
682     DWORD    Version;
683     FARPROC  pFuncVerifyImage;
684     FARPROC  pFuncReturnhWnd;
685     DWORD    dwProvType;
686     BYTE    *pbContextInfo;
687     DWORD    cbContextInfo;
688     LPSTR    pszProvName;
689 } VTableProvStruc, *PVTableProvStruc;
690
691 typedef struct _CERT_PRIVATE_KEY_INFO {
692     DWORD                      Version;
693     CRYPT_ALGORITHM_IDENTIFIER Algorithm;
694     CRYPT_DER_BLOB             PrivateKey;
695     PCRYPT_ATTRIBUTES          pAttributes;
696 } CERT_PRIVATE_KEY_INFO, *PCERT_PRIVATE_KEY_INFO;
697
698 typedef struct _CTL_USAGE {
699     DWORD  cUsageIdentifier;
700     LPSTR *rgpszUsageIdentifier;
701 } CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE;
702
703 typedef struct _CTL_ENTRY {
704     CRYPT_DATA_BLOB  SubjectIdentifier;
705     DWORD            cAttribute;
706     PCRYPT_ATTRIBUTE rgAttribute;
707 } CTL_ENTRY, *PCTL_ENTRY;
708
709 typedef struct _CTL_INFO {
710     DWORD                      dwVersion;
711     CTL_USAGE                  SubjectUsage;
712     CRYPT_DATA_BLOB            ListIdentifier;
713     CRYPT_INTEGER_BLOB         SequenceNumber;
714     FILETIME                   ThisUpdate;
715     FILETIME                   NextUpdate;
716     CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm;
717     DWORD                      cCTLEntry;
718     PCTL_ENTRY                 rgCTLEntry;
719     DWORD                      cExtension;
720     PCERT_EXTENSION            rgExtension;
721 } CTL_INFO, *PCTL_INFO;
722
723 typedef struct _CTL_CONTEXT {
724     DWORD      dwMsgAndCertEncodingType;
725     BYTE      *pbCtlEncoded;
726     DWORD      cbCtlEncoded;
727     PCTL_INFO  pCtlInfo;
728     HCERTSTORE hCertStore;
729     HCRYPTMSG  hCryptMsg;
730     BYTE      *pbCtlContext;
731     DWORD      cbCtlContext;
732 } CTL_CONTEXT, *PCTL_CONTEXT;
733 typedef const CTL_CONTEXT *PCCTL_CONTEXT;
734
735 typedef struct _CRYPT_TIME_STAMP_REQUEST_INFO {
736     LPSTR            pszTimeStampAlgorithm;
737     LPSTR            pszContentType;
738     CRYPT_OBJID_BLOB Content;
739     DWORD            cAttribute;
740     PCRYPT_ATTRIBUTE rgAttribute;
741 } CRYPT_TIME_STAMP_REQUEST_INFO, *PCRYPT_TIME_STAMP_REQUEST_INFO;
742
743 typedef struct _CRYPT_ENROLLMENT_NAME_VALUE_PAIR {
744     LPWSTR pwszName;
745     LPWSTR pwszValue;
746 } CRYPT_ENROLLMENT_NAME_VALUE_PAIR, *PCRYPT_ENROLLMENT_NAME_VALUE_PAIR;
747
748 typedef struct _CMSG_SIGNER_INFO {
749     DWORD                      dwVersion;
750     CERT_NAME_BLOB             Issuer;
751     CRYPT_INTEGER_BLOB         SerialNumber;
752     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
753     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
754     CRYPT_DATA_BLOB            EncryptedHash;
755     CRYPT_ATTRIBUTES           AuthAttrs;
756     CRYPT_ATTRIBUTES           UnauthAttrs;
757 } CMSG_SIGNER_INFO, *PCMSG_SIGNER_INFO;
758
759 #define CMSG_VERIFY_SIGNER_PUBKEY 1
760 #define CMSG_VERIFY_SIGNER_CERT   2
761 #define CMSG_VERIFY_SIGNER_CHAIN  3
762 #define CMSG_VERIFY_SIGNER_NULL   4
763
764 typedef struct _CERT_REVOCATION_CRL_INFO {
765     DWORD         cbSize;
766     PCCRL_CONTEXT pBaseCrlContext;
767     PCCRL_CONTEXT pDeltaCrlContext;
768     PCRL_ENTRY    pCrlEntry;
769     BOOL          fDeltaCrlEntry;
770 } CERT_REVOCATION_CRL_INFO, *PCERT_REVOCATION_CRL_INFO;
771
772 typedef struct _CERT_REVOCATION_INFO {
773     DWORD                     cbSize;
774     DWORD                     dwRevocationResult;
775     LPCSTR                    pszRevocationOid;
776     LPVOID                    pvOidSpecificInfo;
777     BOOL                      fHasFreshnessTime;
778     DWORD                     dwFreshnessTime;
779     PCERT_REVOCATION_CRL_INFO pCrlInfo;
780 } CERT_REVOCATION_INFO, *PCERT_REVOCATION_INFO;
781
782 typedef struct _CERT_REVOCATION_PARA {
783     DWORD                     cbSize;
784     PCCERT_CONTEXT            pIssuerCert;
785     DWORD                     cCertStore;
786     HCERTSTORE               *rgCertStore;
787     HCERTSTORE                hCrlStore;
788     LPFILETIME                pftTimeToUse;
789 #ifdef CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS
790     DWORD                     dwUrlRetrievalTimeout;
791     BOOL                      fCheckFreshnessTime;
792     DWORD                     dwFreshnessTime;
793     LPFILETIME                pftCurrentTime;
794     PCERT_REVOCATION_CRL_INFO pCrlInfo;
795 #endif
796 } CERT_REVOCATION_PARA, *PCERT_REVOCATION_PARA;
797
798 #define CERT_CONTEXT_REVOCATION_TYPE 1
799 #define CERT_VERIFY_REV_CHAIN_FLAG                0x00000001
800 #define CERT_VERIFY_CACHE_ONLY_BASED_REVOCATION   0x00000002
801 #define CERT_VERIFY_REV_ACCUMULATIVE_TIMEOUT_FLAG 0x00000004
802
803 typedef struct _CTL_VERIFY_USAGE_PARA {
804     DWORD           cbSize;
805     CRYPT_DATA_BLOB ListIdentifier;
806     DWORD           cCtlStore;
807     HCERTSTORE     *rghCtlStore;
808     DWORD           cSignerStore;
809     HCERTSTORE     *rghSignerStore;
810 } CTL_VERIFY_USAGE_PARA, *PCTL_VERIFY_USAGE_PARA;
811
812 typedef struct _CTL_VERIFY_USAGE_STATUS {
813     DWORD           cbSize;
814     DWORD           dwError;
815     DWORD           dwFlags;
816     PCCTL_CONTEXT  *ppCtl;
817     DWORD           dwCtlEntryIndex;
818     PCCERT_CONTEXT *ppSigner;
819     DWORD           dwSignerIndex;
820 } CTL_VERIFY_USAGE_STATUS, *PCTL_VERIFY_USAGE_STATUS;
821
822 #define CERT_VERIFY_INHIBIT_CTL_UPDATE_FLAG 0x1
823 #define CERT_VERIFY_TRUSTED_SIGNERS_FLAG    0x2
824 #define CERT_VERIFY_NO_TIME_CHECK_FLAG      0x4
825 #define CERT_VERIFY_ALLOW_MORE_USAGE_FLAG   0x8
826 #define CERT_VERIFY_UPDATED_CTL_FLAG        0x1
827
828 typedef struct _CERT_REVOCATION_STATUS {
829     DWORD cbSize;
830     DWORD dwIndex;
831     DWORD dwError;
832     DWORD dwReason;
833     BOOL  fHasFreshnessTime;
834     DWORD dwFreshnessTime;
835 } CERT_REVOCATION_STATUS, *PCERT_REVOCATION_STATUS;
836
837 typedef struct _CERT_TRUST_LIST_INFO {
838     DWORD         cbSize;
839     PCTL_ENTRY    pCtlEntry;
840     PCCTL_CONTEXT pCtlContext;
841 } CERT_TRUST_LIST_INFO, *PCERT_TRUST_LIST_INFO;
842
843 #define CERT_TRUST_NO_ERROR                          0x00000000
844 #define CERT_TRUST_IS_NOT_TIME_VALID                 0x00000001
845 #define CERT_TRUST_IS_NOT_TIME_NESTED                0x00000002
846 #define CERT_TRUST_IS_REVOKED                        0x00000004
847 #define CERT_TRUST_IS_NOT_SIGNATURE_VALID            0x00000008
848 #define CERT_TRUST_IS_NOT_VALID_FOR_USAGE            0x00000010
849 #define CERT_TRUST_IS_UNTRUSTED_ROOT                 0x00000020
850 #define CERT_TRUST_REVOCATION_STATUS_UNKNOWN         0x00000040
851 #define CERT_TRUST_IS_CYCLIC                         0x00000080
852 #define CERT_TRUST_INVALID_EXTENSION                 0x00000100
853 #define CERT_TRUST_INVALID_POLICY_CONSTRAINTS        0x00000200
854 #define CERT_TRUST_INVALID_BASIC_CONSTRAINTS         0x00000400
855 #define CERT_TRUST_INVALID_NAME_CONSTRAINTS          0x00000800
856 #define CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT 0x00001000
857 #define CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT   0x00002000
858 #define CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT 0x00004000
859 #define CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT      0x00008000
860 #define CERT_TRUST_IS_OFFLINE_REVOCATION             0x01000000
861 #define CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY          0x02000000
862
863 #define CERT_TRUST_IS_PARTIAL_CHAIN                  0x00010000
864 #define CERT_TRUST_CTL_IS_NOT_TIME_VALID             0x00020000
865 #define CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID        0x00040000
866 #define CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE        0x00080000
867
868 #define CERT_TRUST_HAS_EXACT_MATCH_ISSUER            0x00000001
869 #define CERT_TRUST_HAS_KEY_MATCH_ISSUER              0x00000002
870 #define CERT_TRUST_HAS_NAME_MATCH_ISSUER             0x00000004
871 #define CERT_TRUST_IS_SELF_SIGNED                    0x00000008
872
873 #define CERT_TRUST_HAS_PREFERRED_ISSUER              0x00000100
874 #define CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY         0x00000200
875 #define CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS        0x00000400
876
877 #define CERT_TRUST_IS_COMPLEX_CHAIN                  0x00010000
878
879 typedef struct _CERT_TRUST_STATUS {
880     DWORD dwErrorStatus;
881     DWORD dwInfoStatus;
882 } CERT_TRUST_STATUS, *PCERT_TRUST_STATUS;
883
884 typedef struct _CERT_CHAIN_ELEMENT {
885     DWORD                 cbSize;
886     PCCERT_CONTEXT        pCertContext;
887     CERT_TRUST_STATUS     TrustStatus;
888     PCERT_REVOCATION_INFO pRevocationInfo;
889     PCERT_ENHKEY_USAGE    pIssuanceUsage;
890     PCERT_ENHKEY_USAGE    pApplicationUsage;
891     LPCWSTR               pwszExtendedErrorInfo;
892 } CERT_CHAIN_ELEMENT, *PCERT_CHAIN_ELEMENT;
893
894 typedef struct _CERT_SIMPLE_CHAIN {
895     DWORD                 cbSize;
896     CERT_TRUST_STATUS     TrustStatus;
897     DWORD                 cElement;
898     PCERT_CHAIN_ELEMENT  *rgpElement;
899     PCERT_TRUST_LIST_INFO pTrustListInfo;
900     BOOL                  fHasRevocationFreshnessTime;
901     DWORD                 dwRevocationFreshnessTime;
902 } CERT_SIMPLE_CHAIN, *PCERT_SIMPLE_CHAIN;
903
904 typedef struct _CERT_CHAIN_CONTEXT CERT_CHAIN_CONTEXT, *PCERT_CHAIN_CONTEXT;
905 typedef const CERT_CHAIN_CONTEXT *PCCERT_CHAIN_CONTEXT;
906
907 struct _CERT_CHAIN_CONTEXT {
908     DWORD                 cbSize;
909     CERT_TRUST_STATUS     TrustStatus;
910     DWORD                 cChain;
911     PCERT_SIMPLE_CHAIN   *rgpChain;
912     DWORD                 cLowerQualityChainContext;
913     PCCERT_CHAIN_CONTEXT *rgpLowerQualityChainContext;
914     BOOL                  fHasRevocationFreshnessTime;
915     DWORD                 dwRevocationFreshnessTime;
916 };
917
918 typedef struct _CERT_CHAIN_POLICY_PARA {
919     DWORD cbSize;
920     DWORD dwFlags;
921     void *pvExtraPolicyPara;
922 } CERT_CHAIN_POLICY_PARA, *PCERT_CHAIN_POLICY_PARA;
923
924 typedef struct _CERT_CHAIN_POLICY_STATUS {
925     DWORD cbSize;
926     DWORD dwError;
927     LONG  lChainIndex;
928     LONG  lElementIndex;
929     void *pvExtraPolicyStatus;
930 } CERT_CHAIN_POLICY_STATUS, *PCERT_CHAIN_POLICY_STATUS;
931
932 #define CERT_CHAIN_POLICY_BASE              ((LPCSTR)1)
933 #define CERT_CHAIN_POLICY_AUTHENTICODE      ((LPCSTR)2)
934 #define CERT_CHAIN_POLICY_AUTHENTICODE_TS   ((LPCSTR)3)
935 #define CERT_CHAIN_POLICY_SSL               ((LPCSTR)4)
936 #define CERT_CHAIN_POLICY_BASIC_CONSTRAINTS ((LPCSTR)5)
937 #define CERT_CHAIN_POLICY_NT_AUTH           ((LPCSTR)6)
938 #define CERT_CHAIN_POLICY_MICROSOFT_ROOT    ((LPCSTR)7)
939
940 #define CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG            0x00000001
941 #define CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG        0x00000002
942 #define CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG           0x00000004
943 #define CERT_CHAIN_POLICY_IGNORE_INVALID_BASIC_CONSTRAINTS_FLAG 0x00000008
944
945 #define CERT_CHAIN_POLICY_IGNORE_ALL_NOT_TIME_VALID_FLAGS ( \
946  CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG \
947  CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG \
948  CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG )
949
950 #define CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG                 0x00000010
951 #define CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG               0x00000020
952 #define CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG              0x00000040
953 #define CERT_CHAIN_POLICY_IGNORE_INVALID_POLICY_FLAG            0x00000080
954
955 #define CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG           0x00000100
956 #define CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG    0x00000200
957 #define CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG            0x00000400
958 #define CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG          0x00000800
959
960 #define CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS ( \
961  CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG \
962  CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG \
963  CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG \
964  CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG )
965
966 #define CERT_CHAIN_POLICY_TRUST_TESTROOT_FLAG                   0x00004000
967 #define CERT_CHAIN_POLICY_ALLOW_TESTROOT_FLAG                   0x00008000
968 #define MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG  0x00010000
969
970 typedef struct _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA {
971     DWORD             cbSize;
972     DWORD             dwRegPolicySettings;
973     PCMSG_SIGNER_INFO pSignerInfo;
974 } AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA,
975  *PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_PARA;
976
977 typedef struct _AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS {
978     DWORD cbSize;
979     BOOL  fCommercial;
980 } AUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS,
981  *PAUTHENTICODE_EXTRA_CERT_CHAIN_POLICY_STATUS;
982
983 typedef struct _AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA {
984     DWORD cbSize;
985     DWORD dwRegPolicySettings;
986     BOOL  fCommercial;
987 } AUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA,
988  *PAUTHENTICODE_TS_EXTRA_CERT_CHAIN_POLICY_PARA;
989
990 typedef struct _HTTPSPolicyCallbackData {
991     union {
992         DWORD cbStruct;
993         DWORD cbSize;
994     } DUMMYUNIONNAME;
995     DWORD  dwAuthType;
996     DWORD  fdwChecks;
997     WCHAR *pwszServerName;
998 } HTTPSPolicyCallbackData, *PHTTPSPolicyCallbackData,
999  SSL_EXTRA_CERT_CHAIN_POLICY_PARA, *PSSL_EXTRA_CERT_CHAIN_POLICY_PARA;
1000
1001 /* Values for HTTPSPolicyCallbackData's dwAuthType */
1002 #define AUTHTYPE_CLIENT 1
1003 #define AUTHTYPE_SERVER 2
1004 /* Values for HTTPSPolicyCallbackData's fdwChecks are defined in wininet.h */
1005
1006 #define BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_CA_FLAG         0x80000000
1007 #define BASIC_CONSTRAINTS_CERT_CHAIN_POLICY_END_ENTITY_FLAG 0x40000000
1008
1009 #define MICROSOFT_ROOT_CERT_CHAIN_POLICY_ENABLE_TEST_ROOT_FLAG 0x00010000
1010
1011 #define USAGE_MATCH_TYPE_AND 0x00000000
1012 #define USAGE_MATCH_TYPE_OR  0x00000001
1013
1014 typedef struct _CERT_USAGE_MATCH {
1015     DWORD             dwType;
1016     CERT_ENHKEY_USAGE Usage;
1017 } CERT_USAGE_MATCH, *PCERT_USAGE_MATCH;
1018
1019 typedef struct _CTL_USAGE_MATCH {
1020     DWORD     dwType;
1021     CTL_USAGE Usage;
1022 } CTL_USAGE_MATCH, *PCTL_USAGE_MATCH;
1023
1024 #define CERT_CHAIN_REVOCATION_CHECK_END_CERT           0x10000000
1025 #define CERT_CHAIN_REVOCATION_CHECK_CHAIN              0x20000000
1026 #define CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x40000000
1027 #define CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY         0x80000000
1028
1029 #define CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT     0x08000000
1030
1031 #define CERT_CHAIN_DISABLE_PASS1_QUALITY_FILTERING     0x00000040
1032 #define CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS       0x00000080
1033 #define CERT_CHAIN_DISABLE_AUTH_ROOT_AUTO_UPDATE       0x00000100
1034 #define CERT_CHAIN_TIMESTAMP_TIME                      0x00000200
1035
1036 typedef struct _CERT_CHAIN_PARA {
1037     DWORD            cbSize;
1038     CERT_USAGE_MATCH RequestedUsage;
1039 #ifdef CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
1040     CERT_USAGE_MATCH RequestedIssuancePolicy;
1041     DWORD            dwUrlRetrievalTimeout;
1042     BOOL             fCheckRevocationFreshnessTime;
1043     DWORD            dwRevocationFreshnessTime;
1044     LPFILETIME       pftCacheResync;
1045 #endif
1046 } CERT_CHAIN_PARA, *PCERT_CHAIN_PARA;
1047
1048 typedef struct _CERT_SYSTEM_STORE_INFO {
1049     DWORD cbSize;
1050 } CERT_SYSTEM_STORE_INFO, *PCERT_SYSTEM_STORE_INFO;
1051
1052 typedef struct _CERT_PHYSICAL_STORE_INFO {
1053     DWORD           cbSize;
1054     LPSTR           pszOpenStoreProvider;
1055     DWORD           dwOpenEncodingType;
1056     DWORD           dwOpenFlags;
1057     CRYPT_DATA_BLOB OpenParameters;
1058     DWORD           dwFlags;
1059     DWORD           dwPriority;
1060 } CERT_PHYSICAL_STORE_INFO, *PCERT_PHYSICAL_STORE_INFO;
1061
1062 typedef struct _CERT_SYSTEM_STORE_RELOCATE_PARA {
1063     union {
1064         HKEY  hKeyBase;
1065         VOID *pvBase;
1066     } DUMMYUNIONNAME;
1067     union {
1068         void   *pvSystemStore;
1069         LPCSTR  pszSystemStore;
1070         LPCWSTR pwszSystemStore;
1071     } DUMMYUNIONNAME2;
1072 } CERT_SYSTEM_STORE_RELOCATE_PARA, *PCERT_SYSTEM_STORE_RELOCATE_PARA;
1073
1074 typedef BOOL (WINAPI *PFN_CERT_ENUM_SYSTEM_STORE_LOCATION)(
1075  LPCWSTR pwszStoreLocation, DWORD dwFlags, void *pvReserved, void *pvArg);
1076
1077 typedef BOOL (WINAPI *PFN_CERT_ENUM_SYSTEM_STORE)(const void *pvSystemStore,
1078  DWORD dwFlags, PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved,
1079  void *pvArg);
1080
1081 typedef BOOL (WINAPI *PFN_CERT_ENUM_PHYSICAL_STORE)(const void *pvSystemStore,
1082  DWORD dwFlags, LPCWSTR pwszStoreName, PCERT_PHYSICAL_STORE_INFO pStoreInfo,
1083  void *pvReserved, void *pvArg);
1084
1085 /* Encode/decode object */
1086 typedef LPVOID (__WINE_ALLOC_SIZE(1) WINAPI *PFN_CRYPT_ALLOC)(size_t cbsize);
1087 typedef VOID   (WINAPI *PFN_CRYPT_FREE)(LPVOID pv);
1088
1089 typedef struct _CRYPT_ENCODE_PARA {
1090     DWORD           cbSize;
1091     PFN_CRYPT_ALLOC pfnAlloc;
1092     PFN_CRYPT_FREE  pfnFree;
1093 } CRYPT_ENCODE_PARA, *PCRYPT_ENCODE_PARA;
1094
1095 typedef struct _CRYPT_DECODE_PARA {
1096     DWORD           cbSize;
1097     PFN_CRYPT_ALLOC pfnAlloc;
1098     PFN_CRYPT_FREE  pfnFree;
1099 } CRYPT_DECODE_PARA, *PCRYPT_DECODE_PARA;
1100
1101 typedef struct _CERT_STORE_PROV_INFO {
1102     DWORD             cbSize;
1103     DWORD             cStoreProvFunc;
1104     void            **rgpvStoreProvFunc;
1105     HCERTSTOREPROV    hStoreProv;
1106     DWORD             dwStoreProvFlags;
1107     HCRYPTOIDFUNCADDR hStoreProvFuncAddr2;
1108 } CERT_STORE_PROV_INFO, *PCERT_STORE_PROV_INFO;
1109
1110 typedef BOOL (WINAPI *PFN_CERT_DLL_OPEN_STORE_PROV_FUNC)(
1111  LPCSTR lpszStoreProvider, DWORD dwEncodingType, HCRYPTPROV_LEGACY hCryptProv,
1112  DWORD dwFlags, const void *pvPara, HCERTSTORE hCertStore,
1113  PCERT_STORE_PROV_INFO pStoreProvInfo);
1114
1115 typedef void (WINAPI *PFN_CERT_STORE_PROV_CLOSE)(HCERTSTOREPROV hStoreProv,
1116  DWORD dwFlags);
1117
1118 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CERT)(HCERTSTOREPROV hStoreProv,
1119  PCCERT_CONTEXT pStoreCertContext, DWORD dwFlags,
1120  PCCERT_CONTEXT *ppProvCertContext);
1121
1122 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CERT)(HCERTSTOREPROV hStoreProv,
1123  PCCERT_CONTEXT pCertContext, DWORD dwFlags);
1124
1125 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CERT)(
1126  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwFlags);
1127
1128 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CERT_PROPERTY)(
1129  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwPropId,
1130  DWORD dwFlags, const void *pvData);
1131
1132 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CRL)(HCERTSTOREPROV hStoreProv,
1133  PCCRL_CONTEXT pStoreCrlContext, DWORD dwFlags,
1134  PCCRL_CONTEXT *ppProvCrlContext);
1135
1136 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CRL)(HCERTSTOREPROV hStoreProv,
1137  PCCRL_CONTEXT pCrlContext, DWORD dwFlags);
1138
1139 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CRL)(HCERTSTOREPROV hStoreProv,
1140  PCCRL_CONTEXT pCrlContext, DWORD dwFlags);
1141
1142 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CRL_PROPERTY)(
1143  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext, DWORD dwPropId,
1144  DWORD dwFlags, const void *pvData);
1145
1146 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CTL)(HCERTSTOREPROV hStoreProv,
1147  PCCTL_CONTEXT pStoreCtlContext, DWORD dwFlags,
1148  PCCTL_CONTEXT *ppProvCtlContext);
1149
1150 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CTL)(HCERTSTOREPROV hStoreProv,
1151  PCCTL_CONTEXT pCtlContext, DWORD dwFlags);
1152
1153 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CTL)(
1154  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwFlags);
1155
1156 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CTL_PROPERTY)(
1157  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwPropId,
1158  DWORD dwFlags, const void *pvData);
1159
1160 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_CONTROL)(HCERTSTOREPROV hStoreProv,
1161  DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara);
1162
1163 typedef struct _CERT_STORE_PROV_FIND_INFO {
1164     DWORD       cbSize;
1165     DWORD       dwMsgAndCertEncodingType;
1166     DWORD       dwFindFlags;
1167     DWORD       dwFindType;
1168     const void *pvFindPara;
1169 } CERT_STORE_PROV_FIND_INFO, *PCERT_STORE_PROV_FIND_INFO;
1170 typedef const CERT_STORE_PROV_FIND_INFO CCERT_STORE_PROV_FIND_INFO,
1171  *PCCERT_STORE_PROV_FIND_INFO;
1172
1173 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CERT)(HCERTSTOREPROV hStoreProv,
1174  PCCERT_STORE_PROV_FIND_INFO pFindInfo, PCCERT_CONTEXT pPrevCertContext,
1175  DWORD dwFlags, void **ppvStoreProvFindInfo, PCCERT_CONTEXT *ppProvCertContext);
1176
1177 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CERT)(
1178  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext,
1179  void *pvStoreProvFindInfo, DWORD dwFlags);
1180
1181 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CERT_PROPERTY)(
1182  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwPropId,
1183  DWORD dwFlags, void *pvData, DWORD *pcbData);
1184
1185 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CRL)(HCERTSTOREPROV hStoreProv,
1186  PCCERT_STORE_PROV_FIND_INFO pFindInfo, PCCRL_CONTEXT pPrevCrlContext,
1187  DWORD dwFlags, void **ppvStoreProvFindInfo, PCCRL_CONTEXT *ppProvCrlContext);
1188
1189 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CRL)(
1190  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext,
1191  void *pvStoreProvFindInfo, DWORD dwFlags);
1192
1193 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CRL_PROPERTY)(
1194  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext, DWORD dwPropId,
1195  DWORD dwFlags, void *pvData, DWORD *pcbData);
1196
1197 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CTL)(HCERTSTOREPROV hStoreProv,
1198  PCCTL_CONTEXT pCtlContext, void *pvStoreProvFindInfo, DWORD dwFlags);
1199
1200 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CTL_PROPERTY)(
1201  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwPropId,
1202  DWORD dwFlags, void *pvData);
1203
1204 typedef struct _CERT_CREATE_CONTEXT_PARA {
1205     DWORD          cbSize;
1206     PFN_CRYPT_FREE pfnFree;
1207     void          *pvFree;
1208 } CERT_CREATE_CONTEXT_PARA, *PCERT_CREATE_CONTEXT_PARA;
1209
1210 typedef struct _CRYPT_OID_FUNC_ENTRY {
1211     LPCSTR pszOID;
1212     void  *pvFuncAddr;
1213 } CRYPT_OID_FUNC_ENTRY, *PCRYPT_OID_FUNC_ENTRY;
1214
1215 typedef BOOL (WINAPI *PFN_CRYPT_ENUM_OID_FUNC)(DWORD dwEncodingType,
1216  LPCSTR pszFuncName, LPCSTR pszOID, DWORD cValue, const DWORD rgdwValueType[],
1217  LPCWSTR const rgpwszValueName[], const BYTE * const rgpbValueData[],
1218  const DWORD rgcbValueData[], void *pvArg);
1219
1220 #define CRYPT_MATCH_ANY_ENCODING_TYPE 0xffffffff
1221
1222 typedef struct _CRYPT_OID_INFO {
1223     DWORD   cbSize;
1224     LPCSTR  pszOID;
1225     LPCWSTR pwszName;
1226     DWORD   dwGroupId;
1227     union {
1228         DWORD  dwValue;
1229         ALG_ID Algid;
1230         DWORD  dwLength;
1231     } DUMMYUNIONNAME;
1232     CRYPT_DATA_BLOB ExtraInfo;
1233 } CRYPT_OID_INFO, *PCRYPT_OID_INFO;
1234 typedef const CRYPT_OID_INFO CCRYPT_OID_INFO, *PCCRYPT_OID_INFO;
1235
1236 typedef BOOL (WINAPI *PFN_CRYPT_ENUM_OID_INFO)(PCCRYPT_OID_INFO pInfo,
1237  void *pvArg);
1238
1239 typedef struct _CRYPT_SIGN_MESSAGE_PARA {
1240     DWORD                      cbSize;
1241     DWORD                      dwMsgEncodingType;
1242     PCCERT_CONTEXT             pSigningCert;
1243     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
1244     void *                     pvHashAuxInfo;
1245     DWORD                      cMsgCert;
1246     PCCERT_CONTEXT            *rgpMsgCert;
1247     DWORD                      cMsgCrl;
1248     PCCRL_CONTEXT             *rgpMsgCrl;
1249     DWORD                      cAuthAttr;
1250     PCRYPT_ATTRIBUTE           rgAuthAttr;
1251     DWORD                      cUnauthAttr;
1252     PCRYPT_ATTRIBUTE           rgUnauthAttr;
1253     DWORD                      dwFlags;
1254     DWORD                      dwInnerContentType;
1255 #ifdef CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS
1256     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
1257     void *                     pvHashEncryptionAuxInfo;
1258 #endif
1259 } CRYPT_SIGN_MESSAGE_PARA, *PCRYPT_SIGN_MESSAGE_PARA;
1260
1261 #define CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG         0x00000001
1262 #define CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG 0x00000002
1263 #define CRYPT_MESSAGE_KEYID_SIGNER_FLAG             0x00000004
1264 #define CRYPT_MESSAGE_SILENT_KEYSET_FLAG            0x00000008
1265
1266 typedef PCCERT_CONTEXT (WINAPI *PFN_CRYPT_GET_SIGNER_CERTIFICATE)(void *pvArg,
1267  DWORD dwCertEncodingType, PCERT_INFO pSignerId, HCERTSTORE hMsgCertStore);
1268
1269 typedef struct _CRYPT_VERIFY_MESSAGE_PARA {
1270     DWORD                            cbSize;
1271     DWORD                            dwMsgAndCertEncodingType;
1272     HCRYPTPROV_LEGACY                hCryptProv;
1273     PFN_CRYPT_GET_SIGNER_CERTIFICATE pfnGetSignerCertificate;
1274     void *                           pvGetArg;
1275 } CRYPT_VERIFY_MESSAGE_PARA, *PCRYPT_VERIFY_MESSAGE_PARA;
1276
1277 typedef struct _CRYPT_ENCRYPT_MESSAGE_PARA {
1278     DWORD                      cbSize;
1279     DWORD                      dwMsgEncodingType;
1280     HCRYPTPROV_LEGACY          hCryptProv;
1281     CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
1282     void *                     pvEncryptionAuxInfo;
1283     DWORD                      dwFlags;
1284     DWORD                      dwInnerContentType;
1285 } CRYPT_ENCRYPT_MESSAGE_PARA, *PCRYPT_ENCRYPT_MESSAGE_PARA;
1286
1287 #define CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG 0x00000004
1288
1289 typedef struct _CRYPT_DECRYPT_MESSAGE_PARA {
1290     DWORD       cbSize;
1291     DWORD       dwMsgAndCertEncodingType;
1292     DWORD       cCertStore;
1293     HCERTSTORE *rghCertStore;
1294 #ifdef CRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS
1295     DWORD       dwFlags;
1296 #endif
1297 } CRYPT_DECRYPT_MESSAGE_PARA, *PCRYPT_DECRYPT_MESSAGE_PARA;
1298
1299 typedef struct _CRYPT_HASH_MESSAGE_PARA {
1300     DWORD                      cbSize;
1301     DWORD                      dwMsgEncodingType;
1302     HCRYPTPROV_LEGACY          hCryptProv;
1303     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
1304     void *                     pvHashAuxInfo;
1305 } CRYPT_HASH_MESSAGE_PARA, *PCRYPT_HASH_MESSAGE_PARA;
1306
1307 typedef struct _CRYPT_KEY_SIGN_MESSAGE_PARA {
1308     DWORD                      cbSize;
1309     DWORD                      dwMsgAndCertEncodingType;
1310     HCRYPTPROV                 hCryptProv;
1311     DWORD                      dwKeySpec;
1312     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
1313     void *                     pvHashAuxInfo;
1314 } CRYPT_KEY_SIGN_MESSAGE_PARA, *PCRYPT_KEY_SIGN_MESSAGE_PARA;
1315
1316 typedef struct _CRYPT_KEY_VERIFY_MESSAGE_PARA {
1317     DWORD      cbSize;
1318     DWORD      dwMsgEncodingType;
1319     HCRYPTPROV_LEGACY hCryptProv;
1320 } CRYPT_KEY_VERIFY_MESSAGE_PARA, *PCRYPT_KEY_VERIFY_MESSAGE_PARA;
1321
1322 typedef struct _CRYPT_URL_ARRAY {
1323     DWORD   cUrl;
1324     LPWSTR *rgwszUrl;
1325 } CRYPT_URL_ARRAY, *PCRYPT_URL_ARRAY;
1326
1327 typedef struct _CRYPT_URL_INFO {
1328     DWORD  cbSize;
1329     DWORD  dwSyncDeltaTime;
1330     DWORD  cGroup;
1331     DWORD *rgcGroupEntry;
1332 } CRYPT_URL_INFO, *PCRYPT_URL_INFO;
1333
1334 #define URL_OID_CERTIFICATE_ISSUER         ((LPCSTR)1)
1335 #define URL_OID_CERTIFICATE_CRL_DIST_POINT ((LPCSTR)2)
1336 #define URL_OID_CTL_ISSUER                 ((LPCSTR)3)
1337 #define URL_OID_CTL_NEXT_UPDATE            ((LPCSTR)4)
1338 #define URL_OID_CRL_ISSUER                 ((LPCSTR)5)
1339 #define URL_OID_CERTIFICATE_FRESHEST_CRL   ((LPCSTR)6)
1340 #define URL_OID_CRL_FRESHEST_CRL           ((LPCSTR)7)
1341 #define URL_OID_CROSS_CERT_DIST_POINT      ((LPCSTR)8)
1342
1343 #define URL_OID_GET_OBJECT_URL_FUNC "UrlDllGetObjectUrl"
1344
1345 typedef HANDLE HCRYPTASYNC, *PHCRYPTASYNC;
1346
1347 typedef void (WINAPI *PFN_CRYPT_ASYNC_PARAM_FREE_FUNC)(LPSTR pszParamOid,
1348  LPVOID pvParam);
1349
1350 #define CRYPT_PARAM_ASYNC_RETRIEVAL_COMPLETION ((LPCSTR)1)
1351 #define CRYPT_PARAM_CANCEL_ASYNC_RETRIEVAL     ((LPCSTR)2)
1352
1353 typedef void (WINAPI *PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC)(
1354  void *pvCompletion, DWORD dwCompletionCode, LPCSTR pszURL, LPSTR pszObjectOid,
1355  void *pvObject);
1356
1357 typedef struct _CRYPT_ASYNC_RETRIEVAL_COMPLETION
1358 {
1359     PFN_CRYPT_ASYNC_RETRIEVAL_COMPLETION_FUNC pfnCompletion;
1360     void                                     *pvCompletion;
1361 } CRYPT_ASYNC_RETRIEVAL_COMPLETION, *PCRYPT_ASYNC_RETRIEVAL_COMPLETION;
1362
1363 typedef BOOL (WINAPI *PFN_CANCEL_ASYNC_RETRIEVAL_FUNC)(
1364  HCRYPTASYNC hAsyncRetrieve);
1365
1366 typedef struct _CRYPT_BLOB_ARRAY
1367 {
1368     DWORD            cBlob;
1369     PCRYPT_DATA_BLOB rgBlob;
1370 } CRYPT_BLOB_ARRAY, *PCRYPT_BLOB_ARRAY;
1371
1372 typedef struct _CRYPT_CREDENTIALS {
1373     DWORD  cbSize;
1374     LPCSTR pszCredentialsOid;
1375     LPVOID pvCredentials;
1376 } CRYPT_CREDENTIALS, *PCRYPT_CREDENTIALS;
1377
1378 #define CREDENTIAL_OID_PASSWORD_CREDENTIALS_A ((LPCSTR)1)
1379 #define CREDENTIAL_OID_PASSWORD_CREDENTIALS_W ((LPCSTR)2)
1380 #define CREDENTIAL_OID_PASSWORD_CREDENTIALS \
1381  WINELIB_NAME_AW(CREDENTIAL_OID_PASSWORD_CREDENTIALS_)
1382
1383 typedef struct _CRYPT_PASSWORD_CREDENTIALSA {
1384     DWORD cbSize;
1385     LPSTR pszUsername;
1386     LPSTR pszPassword;
1387 } CRYPT_PASSWORD_CREDENTIALSA, *PCRYPT_PASSWORD_CREDENTIALSA;
1388
1389 typedef struct _CRYPT_PASSWORD_CREDENTIALSW {
1390     DWORD  cbSize;
1391     LPWSTR pszUsername;
1392     LPWSTR pszPassword;
1393 } CRYPT_PASSWORD_CREDENTIALSW, *PCRYPT_PASSWORD_CREDENTIALSW;
1394 #define CRYPT_PASSWORD_CREDENTIALS WINELIB_NAME_AW(CRYPT_PASSWORD_CREDENTIALS)
1395 #define PCRYPT_PASSWORD_CREDENTIALS WINELIB_NAME_AW(PCRYPT_PASSWORD_CREDENTIALS)
1396
1397 typedef struct _CRYPT_RETRIEVE_AUX_INFO {
1398     DWORD     cbSize;
1399     FILETIME *pLastSyncTime;
1400     DWORD     dwMaxUrlRetrievalByteCount;
1401 } CRYPT_RETRIEVE_AUX_INFO, *PCRYPT_RETRIEVE_AUX_INFO;
1402
1403 typedef void (WINAPI *PFN_FREE_ENCODED_OBJECT_FUNC)(LPCSTR pszObjectOid,
1404  PCRYPT_BLOB_ARRAY pObject, void *pvFreeContext);
1405
1406 #define SCHEME_OID_RETRIEVE_ENCODED_OBJECT_FUNC \
1407  "SchemeDllRetrieveEncodedObject"
1408 #define SCHEME_OID_RETRIEVE_ENCODED_OBJECTW_FUNC \
1409  "SchemeDllRetrieveEncodedObjectW"
1410 /* The signature of SchemeDllRetrieveEncodedObjectW is:
1411 BOOL WINAPI SchemeDllRetrieveEncodedObjectW(LPCWSTR pwszUrl,
1412  LPCSTR pszObjectOid, DWORD dwRetrievalFlags, DWORD dwTimeout,
1413  PCRYPT_BLOB_ARRAY pObject, PFN_FREE_ENCODED_OBJECT_FUNC *ppfnFreeObject,
1414  void **ppvFreeContext, HCRYPTASYNC hAsyncRetrieve,
1415  PCRYPT_CREDENTIALS pCredentials, PCRYPT_RETRIEVE_AUX_INFO pAuxInfo);
1416  */
1417
1418 #define CONTEXT_OID_CREATE_OBJECT_CONTEXT_FUNC "ContextDllCreateObjectContext"
1419 /* The signature of ContextDllCreateObjectContext is:
1420 BOOL WINAPI ContextDllCreateObjectContext(LPCSTR pszObjectOid,
1421  DWORD dwRetrievalFlags, PCRYPT_BLOB_ARRAY pObject, void **ppvContxt);
1422  */
1423
1424 #define CONTEXT_OID_CERTIFICATE ((LPCSTR)1)
1425 #define CONTEXT_OID_CRL         ((LPCSTR)2)
1426 #define CONTEXT_OID_CTL         ((LPCSTR)3)
1427 #define CONTEXT_OID_PKCS7       ((LPCSTR)4)
1428 #define CONTEXT_OID_CAPI2_ANY   ((LPCSTR)5)
1429
1430 #define CRYPT_RETRIEVE_MULTIPLE_OBJECTS      0x00000001
1431 #define CRYPT_CACHE_ONLY_RETRIEVAL           0x00000002
1432 #define CRYPT_WIRE_ONLY_RETRIEVAL            0x00000004
1433 #define CRYPT_DONT_CACHE_RESULT              0x00000008
1434 #define CRYPT_ASYNC_RETRIEVAL                0x00000010
1435 #define CRYPT_STICKY_CACHE_RETRIEVAL         0x00001000
1436 #define CRYPT_LDAP_SCOPE_BASE_ONLY_RETRIEVAL 0x00002000
1437 #define CRYPT_OFFLINE_CHECK_RETRIEVAL        0x00004000
1438 #define CRYPT_LDAP_INSERT_ENTRY_ATTRIBUTE    0x00008000
1439 #define CRYPT_LDAP_SIGN_RETRIEVAL            0x00010000
1440 #define CRYPT_NO_AUTH_RETRIEVAL              0x00020000
1441 #define CRYPT_LDAP_AREC_EXCLUSIVE_RETRIEVAL  0x00040000
1442 #define CRYPT_AIA_RETRIEVAL                  0x00080000
1443
1444 #define CRYPT_VERIFY_CONTEXT_SIGNATURE      0x00000020
1445 #define CRYPT_VERIFY_DATA_HASH              0x00000040
1446 #define CRYPT_KEEP_TIME_VALID               0x00000080
1447 #define CRYPT_DONT_VERIFY_SIGNATURE         0x00000100
1448 #define CRYPT_DONT_CHECK_TIME_VALIDITY      0x00000200
1449 #define CRYPT_CHECK_FRESHNESS_TIME_VALIDITY 0x00000400
1450 #define CRYPT_ACCUMULATIVE_TIMEOUT          0x00000800
1451
1452 typedef BOOL (WINAPI *PFN_CRYPT_CANCEL_RETRIEVAL)(DWORD dwFlags, void *pvArg);
1453
1454 typedef struct _CERT_CRL_CONTEXT_PAIR
1455 {
1456     PCCERT_CONTEXT pCertContext;
1457     PCCRL_CONTEXT  pCrlContext;
1458 } CERT_CRL_CONTEXT_PAIR, *PCERT_CRL_CONTEXT_PAIR;
1459 typedef const CERT_CRL_CONTEXT_PAIR *PCCERT_CRL_CONTEXT_PAIR;
1460
1461 #define TIME_VALID_OID_GET_OBJECT_FUNC   "TimeValidDllGetObject"
1462
1463 #define TIME_VALID_OID_GET_CTL                    ((LPCSTR)1)
1464 #define TIME_VALID_OID_GET_CRL                    ((LPCSTR)2)
1465 #define TIME_VALID_OID_GET_CRL_FROM_CERT          ((LPCSTR)3)
1466 #define TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CERT ((LPCSTR)4)
1467 #define TIME_VALID_OID_GET_FRESHEST_CRL_FROM_CRL  ((LPCSTR)5)
1468
1469 #define TIME_VALID_OID_FLUSH_OBJECT_FUNC "TimeValidDllFlushObject"
1470
1471 #define TIME_VALID_OID_FLUSH_CTL                    ((LPCSTR)1)
1472 #define TIME_VALID_OID_FLUSH_CRL                    ((LPCSTR)2)
1473 #define TIME_VALID_OID_FLUSH_CRL_FROM_CERT          ((LPCSTR)3)
1474 #define TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CERT ((LPCSTR)4)
1475 #define TIME_VALID_OID_FLUSH_FRESHEST_CRL_FROM_CRL  ((LPCSTR)5)
1476
1477 /* OID group IDs */
1478 #define CRYPT_HASH_ALG_OID_GROUP_ID     1
1479 #define CRYPT_ENCRYPT_ALG_OID_GROUP_ID  2
1480 #define CRYPT_PUBKEY_ALG_OID_GROUP_ID   3
1481 #define CRYPT_SIGN_ALG_OID_GROUP_ID     4
1482 #define CRYPT_RDN_ATTR_OID_GROUP_ID     5
1483 #define CRYPT_EXT_OR_ATTR_OID_GROUP_ID  6
1484 #define CRYPT_ENHKEY_USAGE_OID_GROUP_ID 7
1485 #define CRYPT_POLICY_OID_GROUP_ID       8
1486 #define CRYPT_TEMPLATE_OID_GROUP_ID     9
1487 #define CRYPT_LAST_OID_GROUP_ID         9
1488
1489 #define CRYPT_FIRST_ALG_OID_GROUP_ID CRYPT_HASH_ALG_OID_GROUP_ID
1490 #define CRYPT_LAST_ALG_OID_GROUP_ID  CRYPT_SIGN_ALG_OID_GROUP_ID
1491
1492 #define CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG  0x1
1493 #define CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG 0x2
1494 #define CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG    0x4
1495
1496 #define CRYPT_OID_INFO_OID_KEY   1
1497 #define CRYPT_OID_INFO_NAME_KEY  2
1498 #define CRYPT_OID_INFO_ALGID_KEY 3
1499 #define CRYPT_OID_INFO_SIGN_KEY  4
1500
1501 /* Algorithm IDs */
1502
1503 #define GET_ALG_CLASS(x)                (x & (7 << 13))
1504 #define GET_ALG_TYPE(x)                 (x & (15 << 9))
1505 #define GET_ALG_SID(x)                  (x & (511))
1506
1507 /* Algorithm Classes */
1508 #define ALG_CLASS_ANY                   (0)
1509 #define ALG_CLASS_SIGNATURE             (1 << 13)
1510 #define ALG_CLASS_MSG_ENCRYPT           (2 << 13)
1511 #define ALG_CLASS_DATA_ENCRYPT          (3 << 13)
1512 #define ALG_CLASS_HASH                  (4 << 13)
1513 #define ALG_CLASS_KEY_EXCHANGE          (5 << 13)
1514 #define ALG_CLASS_ALL                   (7 << 13)
1515 /* Algorithm types */
1516 #define ALG_TYPE_ANY                    (0)
1517 #define ALG_TYPE_DSS                    (1 << 9)
1518 #define ALG_TYPE_RSA                    (2 << 9)
1519 #define ALG_TYPE_BLOCK                  (3 << 9)
1520 #define ALG_TYPE_STREAM                 (4 << 9)
1521 #define ALG_TYPE_DH                     (5 << 9)
1522 #define ALG_TYPE_SECURECHANNEL          (6 << 9)
1523
1524 /* SIDs */
1525 #define ALG_SID_ANY                     (0)
1526 /* RSA SIDs */
1527 #define ALG_SID_RSA_ANY                 0
1528 #define ALG_SID_RSA_PKCS                1
1529 #define ALG_SID_RSA_MSATWORK            2
1530 #define ALG_SID_RSA_ENTRUST             3
1531 #define ALG_SID_RSA_PGP                 4
1532 /* DSS SIDs */
1533 #define ALG_SID_DSS_ANY                 0
1534 #define ALG_SID_DSS_PKCS                1
1535 #define ALG_SID_DSS_DMS                 2
1536
1537 /* DES SIDs */
1538 #define ALG_SID_DES                     1
1539 #define ALG_SID_3DES                    3
1540 #define ALG_SID_DESX                    4
1541 #define ALG_SID_IDEA                    5
1542 #define ALG_SID_CAST                    6
1543 #define ALG_SID_SAFERSK64               7
1544 #define ALG_SID_SAFERSK128              8
1545 #define ALG_SID_3DES_112                9
1546 #define ALG_SID_CYLINK_MEK             12
1547 #define ALG_SID_RC5                    13
1548 #define ALG_SID_AES_128                14
1549 #define ALG_SID_AES_192                15
1550 #define ALG_SID_AES_256                16
1551 #define ALG_SID_AES                    17
1552 /* Diffie-Hellmans SIDs */
1553 #define ALG_SID_DH_SANDF                1
1554 #define ALG_SID_DH_EPHEM                2
1555 #define ALG_SID_AGREED_KEY_ANY          3
1556 #define ALG_SID_KEA                     4
1557 /* RC2 SIDs */
1558 #define ALG_SID_RC4                     1
1559 #define ALG_SID_RC2                     2
1560 #define ALG_SID_SEAL                    2
1561 /* Hash SIDs */
1562 #define ALG_SID_MD2                     1
1563 #define ALG_SID_MD4                     2
1564 #define ALG_SID_MD5                     3
1565 #define ALG_SID_SHA                     4
1566 #define ALG_SID_SHA1                    ALG_SID_SHA
1567 #define ALG_SID_MAC                     5
1568 #define ALG_SID_RIPEMD                  6
1569 #define ALG_SID_RIPEMD160               7
1570 #define ALG_SID_SSL3SHAMD5              8
1571 #define ALG_SID_HMAC                    9
1572 #define ALG_SID_TLS1PRF                10
1573 #define ALG_SID_HASH_REPLACE_OWF       11
1574 #define ALG_SID_SHA_256                12
1575 #define ALG_SID_SHA_384                13
1576 #define ALG_SID_SHA_512                14
1577 /* SCHANNEL SIDs */
1578 #define ALG_SID_SSL3_MASTER             1
1579 #define ALG_SID_SCHANNEL_MASTER_HASH    2
1580 #define ALG_SID_SCHANNEL_MAC_KEY        3
1581 #define ALG_SID_PCT1_MASTER             4
1582 #define ALG_SID_SSL2_MASTER             5
1583 #define ALG_SID_TLS1_MASTER             6
1584 #define ALG_SID_SCHANNEL_ENC_KEY        7
1585 #define ALG_SID_EXAMPLE                80
1586
1587 /* Algorithm Definitions */
1588 #define CALG_MD2                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD2)
1589 #define CALG_MD4                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD4)
1590 #define CALG_MD5                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD5)
1591 #define CALG_SHA                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SHA)
1592 #define CALG_SHA1 CALG_SHA
1593 #define CALG_MAC                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MAC)
1594 #define CALG_SSL3_SHAMD5          (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SSL3SHAMD5)
1595 #define CALG_HMAC                 (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_HMAC)
1596 #define CALG_TLS1PRF              (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_TLS1PRF)
1597 #define CALG_HASH_REPLACE_OWF     (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_HASH_REPLACE_OWF)
1598 #define CALG_SHA_256              (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SHA_256)
1599 #define CALG_SHA_384              (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SHA_384)
1600 #define CALG_SHA_512              (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SHA_512)
1601 #define CALG_RSA_SIGN             (ALG_CLASS_SIGNATURE    | ALG_TYPE_RSA           | ALG_SID_RSA_ANY)
1602 #define CALG_DSS_SIGN             (ALG_CLASS_SIGNATURE    | ALG_TYPE_DSS           | ALG_SID_DSS_ANY)
1603 #define CALG_NO_SIGN              (ALG_CLASS_SIGNATURE    | ALG_TYPE_ANY           | ALG_SID_ANY)
1604 #define CALG_DH_SF                (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH            | ALG_SID_DH_SANDF)
1605 #define CALG_DH_EPHEM             (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH            | ALG_SID_DH_EPHEM)
1606 #define CALG_RSA_KEYX             (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA           | ALG_SID_RSA_ANY)
1607 #define CALG_DES                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_DES)
1608 #define CALG_RC2                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_RC2)
1609 #define CALG_3DES                 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_3DES)
1610 #define CALG_3DES_112             (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_3DES_112)
1611 #define CALG_AES_128              (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_AES_128)
1612 #define CALG_AES_192              (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_AES_192)
1613 #define CALG_AES_256              (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_AES_256)
1614 #define CALG_AES                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_AES)
1615 #define CALG_RC4                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM        | ALG_SID_RC4)
1616 #define CALG_SEAL                 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM        | ALG_SID_SEAL)
1617 #define CALG_RC5                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM        | ALG_SID_RC5)
1618 #define CALG_SSL3_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL3_MASTER)
1619 #define CALG_SCHANNEL_MASTER_HASH (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MASTER_HASH)
1620 #define CALG_SCHANNEL_MAC_KEY     (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MAC_KEY)
1621 #define CALG_SCHANNEL_ENC_KEY     (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_ENC_KEY)
1622 #define CALG_PCT1_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_PCT1_MASTER)
1623 #define CALG_SSL2_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL2_MASTER)
1624 #define CALG_TLS1_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_TLS1_MASTER)
1625
1626
1627 /* Protocol Flags */
1628 #define CRYPT_FLAG_PCT1    0x0001
1629 #define CRYPT_FLAG_SSL2    0x0002
1630 #define CRYPT_FLAG_SSL3    0x0004
1631 #define CRYPT_FLAG_TLS1    0x0008
1632 #define CRYPT_FLAG_IPSEC   0x0010
1633 #define CRYPT_FLAG_SIGNING 0x0020
1634
1635 /* Provider names */
1636 #define MS_DEF_PROV_A                            "Microsoft Base Cryptographic Provider v1.0"
1637 #if defined(__GNUC__)
1638 # define MS_DEF_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1639         'B','a','s','e',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1640         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 }
1641 #elif defined(_MSC_VER)
1642 # define MS_DEF_PROV_W      L"Microsoft Base Cryptographic Provider v1.0"
1643 #else
1644 static const WCHAR MS_DEF_PROV_W[] =             { 'M','i','c','r','o','s','o','f','t',' ',
1645         'B','a','s','e',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1646         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 };
1647 #endif
1648 #define MS_DEF_PROV                              WINELIB_NAME_AW(MS_DEF_PROV_)
1649
1650 #define MS_ENHANCED_PROV_A                       "Microsoft Enhanced Cryptographic Provider v1.0"
1651 #if defined(__GNUC__)
1652 # define MS_ENHANCED_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1653         'E','n','h','a','n','c','e','d',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1654         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 }
1655 #elif defined(_MSC_VER)
1656 # define MS_ENHANCED_PROV_W     L"Microsoft Enhanced Cryptographic Provider v1.0"
1657 #else
1658 static const WCHAR MS_ENHANCED_PROV_W[] =        { 'M','i','c','r','o','s','o','f','t',' ',
1659         'E','n','h','a','n','c','e','d',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1660         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 };
1661 #endif
1662 #define MS_ENHANCED_PROV                         WINELIB_NAME_AW(MS_ENHANCED_PROV_)
1663
1664 #define MS_STRONG_PROV_A                         "Microsoft Strong Cryptographic Provider"
1665 #if defined(__GNUC__)
1666 # define MS_STRONG_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1667         'S','t','r','o','n','g',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1668         'P','r','o','v','i','d','e','r',0 }
1669 #elif defined(_MSC_VER)
1670 # define MS_STRONG_PROV_W     L"Microsoft Strong Cryptographic Provider"
1671 #else
1672 static const WCHAR MS_STRONG_PROV_W[] =          { 'M','i','c','r','o','s','o','f','t',' ',
1673         'S','t','r','o','n','g',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1674         'P','r','o','v','i','d','e','r',0 };
1675 #endif
1676 #define MS_STRONG_PROV                           WINELIB_NAME_AW(MS_STRONG_PROV_)
1677
1678 #define MS_DEF_RSA_SIG_PROV_A                    "Microsoft RSA Signature Cryptographic Provider"
1679 #if defined(__GNUC__)
1680 # define MS_DEF_RSA_SIG_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1681         'R','S','A',' ','S','i','g','n','a','t','u','r','e',' ', \
1682         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1683 #elif defined(_MSC_VER)
1684 # define MS_DEF_RSA_SIG_PROV_W      L"Microsoft RSA Signature Cryptographic Provider"
1685 #else
1686 static const WCHAR MS_DEF_RSA_SIG_PROV_W[] =     { 'M','i','c','r','o','s','o','f','t',' ',
1687         'R','S','A',' ','S','i','g','n','a','t','u','r','e',' ',
1688         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1689 #endif
1690 #define MS_DEF_RSA_SIG_PROV                      WINELIB_NAME_AW(MS_DEF_RSA_SIG_PROV_)
1691
1692 #define MS_DEF_RSA_SCHANNEL_PROV_A               "Microsoft RSA SChannel Cryptographic Provider"
1693 #if defined(__GNUC__)
1694 # define MS_DEF_RSA_SCHANNEL_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1695         'R','S','A',' ','S','C','h','a','n','n','e','l',' ', \
1696         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1697 #elif defined(_MSC_VER)
1698 # define MS_DEF_RSA_SCHANNEL_PROV_W     L"Microsoft RSA SChannel Cryptographic Provider"
1699 #else
1700 static const WCHAR MS_DEF_RSA_SCHANNEL_PROV_W[] = { 'M','i','c','r','o','s','o','f','t',' ',
1701         'R','S','A',' ','S','C','h','a','n','n','e','l',' ',
1702         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1703 #endif
1704 #define MS_DEF_RSA_SCHANNEL_PROV                 WINELIB_NAME_AW(MS_DEF_RSA_SCHANNEL_PROV_)
1705
1706 #define MS_DEF_DSS_PROV_A                        "Microsoft Base DSS Cryptographic Provider"
1707 #if defined(__GNUC__)
1708 # define MS_DEF_DSS_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1709         'B','a','s','e',' ','D','S','S',' ', \
1710         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1711 #elif defined(_MSC_VER)
1712 # define MS_DEF_DSS_PROV_W     L"Microsoft Base DSS Cryptographic Provider"
1713 #else
1714 static const WCHAR MS_DEF_DSS_PROV_W[] =         { 'M','i','c','r','o','s','o','f','t',' ',
1715         'B','a','s','e',' ','D','S','S',' ',
1716         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1717 #endif
1718 #define MS_DEF_DSS_PROV                          WINELIB_NAME_AW(MS_DEF_DSS_PROV_)
1719
1720 #define MS_DEF_DSS_DH_PROV_A                     "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
1721 #if defined(__GNUC__)
1722 # define MS_DEF_DSS_DH_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1723         'B','a','s','e',' ','D','S','S',' ','a','n','d',' ', \
1724         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ', \
1725         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1726 #elif defined(_MSC_VER)
1727 # define MS_DEF_DSS_DH_PROV_W     L"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
1728 #else
1729 static const WCHAR MS_DEF_DSS_DH_PROV_W[] =      { 'M','i','c','r','o','s','o','f','t',' ',
1730         'B','a','s','e',' ','D','S','S',' ','a','n','d',' ',
1731         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ',
1732         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1733 #endif
1734 #define MS_DEF_DSS_DH_PROV                       WINELIB_NAME_AW(MS_DEF_DSS_DH_PROV_)
1735
1736 #define MS_ENH_DSS_DH_PROV_A                     "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"
1737 #if defined(__GNUC__)
1738 # define MS_ENH_DSS_DH_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1739         'E','n','h','a','n','c','e','d',' ','D','S','S',' ','a','n','d',' ', \
1740         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ', \
1741         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1742 #elif defined(_MSC_VER)
1743 # define MS_ENH_DSS_DH_PROV_W     L"Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"
1744 #else
1745 static const WCHAR MS_ENH_DSS_DH_PROV_W[] =      { 'M','i','c','r','o','s','o','f','t',' ',
1746         'E','n','h','a','n','c','e','d',' ','D','S','S',' ','a','n','d',' ',
1747         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ',
1748         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1749 #endif
1750 #define MS_ENH_DSS_DH_PROV                       WINELIB_NAME_AW(MS_ENH_DSS_DH_PROV_)
1751
1752 #define MS_DEF_DH_SCHANNEL_PROV_A                "Microsoft DH SChannel Cryptographic Provider"
1753 #if defined(__GNUC__)
1754 # define MS_DEF_DH_SCHANNEL_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1755         'D','H',' ','S','C','h','a','n','n','e','l',' ', \
1756         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1757 #elif defined(_MSC_VER)
1758 # define MS_DEF_DH_SCHANNEL_PROV_W     L"Microsoft DH SChannel Cryptographic Provider"
1759 #else
1760 static const WCHAR MS_DEF_DH_SCHANNEL_PROV_W[] = { 'M','i','c','r','o','s','o','f','t',' ',
1761         'D','H',' ','S','C','h','a','n','n','e','l',' ',
1762         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1763 #endif
1764 #define MS_DEF_DH_SCHANNEL_PROV                  WINELIB_NAME_AW(MS_DEF_DH_SCHANNEL_PROV_)
1765
1766 #define MS_SCARD_PROV_A                          "Microsoft Base Smart Card Cryptographic Provider"
1767 #if defined(__GNUC__)
1768 # define MS_SCARD_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1769         'B','a','s','e',' ','S','m','a','r','t',' ','C','a','r','d',' ', \
1770         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1771 #elif defined(_MSC_VER)
1772 # define MS_SCARD_PROV_W     L"Microsoft Base Smart Card Cryptographic Provider"
1773 #else
1774 static const WCHAR MS_SCARD_PROV_W[] =           { 'M','i','c','r','o','s','o','f','t',' ',
1775         'B','a','s','e',' ','S','m','a','r','t',' ','C','a','r','d',' ',
1776         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1777 #endif
1778 #define MS_SCARD_PROV                            WINELIB_NAME_AW(MS_SCARD_PROV_)
1779
1780 #define MS_ENH_RSA_AES_PROV_A                          "Microsoft Enhanced RSA and AES Cryptographic Provider"
1781 #if defined(__GNUC__)
1782 # define MS_ENH_RSA_AES_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1783         'E','n','h','a','n','c','e','d',' ','R','S','A',' ','a','n','d',' ','A','E','S',' ',\
1784         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1785 #elif defined(_MSC_VER)
1786 # define MS_ENH_RSA_AES_PROV_W     L"Microsoft Enhanced RSA and AES Cryptographic Provider"
1787 #else
1788 static const WCHAR MS_ENH_RSA_AES_PROV_W[] =           { 'M','i','c','r','o','s','o','f','t',' ',
1789         'E','n','h','a','n','c','e','d',' ','R','S','A',' ','a','n','d',' ','A','E','S',' ',
1790         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1791 #endif
1792 #define MS_ENH_RSA_AES_PROV                            WINELIB_NAME_AW(MS_ENH_RSA_AES_PROV_)
1793
1794 /* Key Specs*/
1795 #define AT_KEYEXCHANGE          1
1796 #define AT_SIGNATURE            2
1797
1798 /* Provider Types */
1799 #define PROV_RSA_FULL             1
1800 #define PROV_RSA_SIG              2
1801 #define PROV_DSS                  3
1802 #define PROV_FORTEZZA             4
1803 #define PROV_MS_EXCHANGE          5
1804 #define PROV_SSL                  6
1805 #define PROV_RSA_SCHANNEL         12
1806 #define PROV_DSS_DH               13
1807 #define PROV_EC_ECDSA_SIG         14
1808 #define PROV_EC_ECNRA_SIG         15
1809 #define PROV_EC_ECDSA_FULL        16
1810 #define PROV_EC_ECNRA_FULL        17
1811 #define PROV_DH_SCHANNEL          18
1812 #define PROV_SPYRUS_LYNKS         20
1813 #define PROV_RNG                  21
1814 #define PROV_INTEL_SEC            22
1815 #define PROV_REPLACE_OWF          23
1816 #define PROV_RSA_AES              24
1817
1818 /* FLAGS Section */
1819
1820 #define CRYPT_FIRST             1
1821 #define CRYPT_NEXT              2
1822
1823 #define CRYPT_IMPL_HARDWARE     1
1824 #define CRYPT_IMPL_SOFTWARE     2
1825 #define CRYPT_IMPL_MIXED        3
1826 #define CRYPT_IMPL_UNKNOWN      4
1827
1828 /* CryptAcquireContext */
1829 #define CRYPT_VERIFYCONTEXT       0xF0000000
1830 #define CRYPT_NEWKEYSET           0x00000008
1831 #define CRYPT_DELETEKEYSET        0x00000010
1832 #define CRYPT_MACHINE_KEYSET      0x00000020
1833 #define CRYPT_SILENT              0x00000040
1834
1835 /* Crypt{Get|Set}Provider */
1836 #define CRYPT_MACHINE_DEFAULT     0x00000001
1837 #define CRYPT_USER_DEFAULT        0x00000002
1838 #define CRYPT_DELETE_DEFAULT      0x00000004
1839
1840 /* Crypt{Get/Set}ProvParam */
1841 #define PP_CLIENT_HWND          1
1842 #define PP_ENUMALGS             1
1843 #define PP_ENUMCONTAINERS       2
1844 #define PP_IMPTYPE              3
1845 #define PP_NAME                 4
1846 #define PP_VERSION              5
1847 #define PP_CONTAINER            6
1848 #define PP_CHANGE_PASSWORD      7
1849 #define PP_KEYSET_SEC_DESCR     8
1850 #define PP_KEY_TYPE_SUBTYPE     10
1851 #define PP_CONTEXT_INFO         11
1852 #define PP_KEYEXCHANGE_KEYSIZE  12
1853 #define PP_SIGNATURE_KEYSIZE    13
1854 #define PP_KEYEXCHANGE_ALG      14
1855 #define PP_SIGNATURE_ALG        15
1856 #define PP_PROVTYPE             16
1857 #define PP_KEYSTORAGE           17
1858 #define PP_SYM_KEYSIZE          19
1859 #define PP_SESSION_KEYSIZE      20
1860 #define PP_UI_PROMPT            21
1861 #define PP_ENUMALGS_EX          22
1862 #define PP_DELETEKEY            24
1863 #define PP_ENUMMANDROOTS        25
1864 #define PP_ENUMELECTROOTS       26
1865 #define PP_KEYSET_TYPE          27
1866 #define PP_ADMIN_PIN            31
1867 #define PP_KEYEXCHANGE_PIN      32
1868 #define PP_SIGNATURE_PIN        33
1869 #define PP_SIG_KEYSIZE_INC      34
1870 #define PP_KEYX_KEYSIZE_INC     35
1871 #define PP_UNIQUE_CONTAINER     36
1872 #define PP_SGC_INFO             37
1873 #define PP_USE_HARDWARE_RNG     38
1874 #define PP_KEYSPEC              39
1875 #define PP_ENUMEX_SIGNING_PROT  40
1876 #define PP_CRYPT_COUNT_KEY_USE  41
1877 #define PP_USER_CERTSTORE       42
1878 #define PP_SMARTCARD_READER     43
1879 #define PP_SMARTCARD_GUID       45
1880 #define PP_ROOT_CERTSTORE       46
1881
1882 /* Values returned by CryptGetProvParam of PP_KEYSTORAGE */
1883 #define CRYPT_SEC_DESCR         0x00000001
1884 #define CRYPT_PSTORE            0x00000002
1885 #define CRYPT_UI_PROMPT         0x00000004
1886
1887 /* Crypt{Get/Set}KeyParam */
1888 #define KP_IV                   1
1889 #define KP_SALT                 2
1890 #define KP_PADDING              3
1891 #define KP_MODE                 4
1892 #define KP_MODE_BITS            5
1893 #define KP_PERMISSIONS          6
1894 #define KP_ALGID                7
1895 #define KP_BLOCKLEN             8
1896 #define KP_KEYLEN               9
1897 #define KP_SALT_EX              10
1898 #define KP_P                    11
1899 #define KP_G                    12
1900 #define KP_Q                    13
1901 #define KP_X                    14
1902 #define KP_Y                    15
1903 #define KP_RA                   16
1904 #define KP_RB                   17
1905 #define KP_INFO                 18
1906 #define KP_EFFECTIVE_KEYLEN     19
1907 #define KP_SCHANNEL_ALG         20
1908 #define KP_CLIENT_RANDOM        21
1909 #define KP_SERVER_RANDOM        22
1910 #define KP_RP                   23
1911 #define KP_PRECOMP_MD5          24
1912 #define KP_PRECOMP_SHA          25
1913 #define KP_CERTIFICATE          26
1914 #define KP_CLEAR_KEY            27
1915 #define KP_PUB_EX_LEN           28
1916 #define KP_PUB_EX_VAL           29
1917 #define KP_KEYVAL               30
1918 #define KP_ADMIN_PIN            31
1919 #define KP_KEYEXCHANGE_PIN      32
1920 #define KP_SIGNATURE_PIN        33
1921 #define KP_PREHASH              34
1922 #define KP_ROUNDS               35
1923 #define KP_OAEP_PARAMS          36
1924 #define KP_CMS_KEY_INFO         37
1925 #define KP_CMS_DH_KEY_INFO      38
1926 #define KP_PUB_PARAMS           39
1927 #define KP_VERIFY_PARAMS        40
1928 #define KP_HIGHEST_VERSION      41
1929 #define KP_GET_USE_COUNT        42
1930
1931 /* Values for KP_PADDING */
1932 #define PKCS5_PADDING  1
1933 #define RANDOM_PADDING 2
1934 #define ZERO_PADDING   3
1935
1936 /* CryptSignHash/CryptVerifySignature */
1937 #define CRYPT_NOHASHOID         0x00000001
1938 #define CRYPT_TYPE2_FORMAT      0x00000002
1939 #define CRYPT_X931_FORMAT       0x00000004
1940
1941 /* Crypt{Get,Set}HashParam */
1942 #define HP_ALGID                0x0001
1943 #define HP_HASHVAL              0x0002
1944 #define HP_HASHSIZE             0x0004
1945 #define HP_HMAC_INFO            0x0005
1946 #define HP_TLS1PRF_LABEL        0x0006
1947 #define HP_TLS1PRF_SEED         0x0007
1948
1949 /* Crypt{Get,Set}KeyParam */
1950 #define CRYPT_MODE_CBC          1
1951 #define CRYPT_MODE_ECB          2
1952 #define CRYPT_MODE_OFB          3
1953 #define CRYPT_MODE_CFB          4
1954
1955 #define CRYPT_ENCRYPT           0x0001 
1956 #define CRYPT_DECRYPT           0x0002
1957 #define CRYPT_EXPORT            0x0004
1958 #define CRYPT_READ              0x0008
1959 #define CRYPT_WRITE             0x0010
1960 #define CRYPT_MAC               0x0020
1961 #define CRYPT_EXPORT_KEY        0x0040
1962 #define CRYPT_IMPORT_KEY        0x0080
1963 #define CRYPT_ARCHIVE           0x0100
1964
1965 /* Crypt*Key */
1966 #define CRYPT_EXPORTABLE        0x00000001
1967 #define CRYPT_USER_PROTECTED    0x00000002
1968 #define CRYPT_CREATE_SALT       0x00000004
1969 #define CRYPT_UPDATE_KEY        0x00000008
1970 #define CRYPT_NO_SALT           0x00000010
1971 #define CRYPT_PREGEN            0x00000040
1972 #define CRYPT_SERVER            0x00000400
1973 #define CRYPT_ARCHIVABLE        0x00004000
1974
1975 /* CryptExportKey */
1976 #define CRYPT_SSL2_FALLBACK     0x00000002
1977 #define CRYPT_DESTROYKEY        0x00000004
1978 #define CRYPT_OAEP              0x00000040
1979
1980 /* CryptHashSessionKey */
1981 #define CRYPT_LITTLE_ENDIAN     0x00000001
1982
1983 /* Crypt{Protect,Unprotect}Data PROMPTSTRUCT flags */
1984 #define CRYPTPROTECT_PROMPT_ON_PROTECT    0x0001
1985 #define CRYPTPROTECT_PROMPT_ON_UNPROTECT  0x0002
1986 /* Crypt{Protect,Unprotect}Data flags */
1987 #define CRYPTPROTECT_UI_FORBIDDEN       0x0001
1988 #define CRYPTPROTECT_LOCAL_MACHINE      0x0004
1989 #define CRYPTPROTECT_AUDIT              0x0010
1990 #define CRYPTPROTECT_VERIFY_PROTECTION  0x0040
1991
1992 /* Blob Types */
1993 #define SIMPLEBLOB              0x1
1994 #define PUBLICKEYBLOB           0x6
1995 #define PRIVATEKEYBLOB          0x7
1996 #define PLAINTEXTKEYBLOB        0x8
1997 #define OPAQUEKEYBLOB           0x9
1998 #define PUBLICKEYBLOBEX         0xA
1999 #define SYMMETRICWRAPKEYBLOB    0xB
2000
2001 #define CUR_BLOB_VERSION        2
2002
2003 /* cert store provider types */
2004 #define CERT_STORE_PROV_MSG                  ((LPCSTR)1)
2005 #define CERT_STORE_PROV_MEMORY               ((LPCSTR)2)
2006 #define CERT_STORE_PROV_FILE                 ((LPCSTR)3)
2007 #define CERT_STORE_PROV_REG                  ((LPCSTR)4)
2008 #define CERT_STORE_PROV_PKCS7                ((LPCSTR)5)
2009 #define CERT_STORE_PROV_SERIALIZED           ((LPCSTR)6)
2010 #define CERT_STORE_PROV_FILENAME_A           ((LPCSTR)7)
2011 #define CERT_STORE_PROV_FILENAME_W           ((LPCSTR)8)
2012 #define CERT_STORE_PROV_SYSTEM_A             ((LPCSTR)9)
2013 #define CERT_STORE_PROV_SYSTEM_W             ((LPCSTR)10)
2014 #define CERT_STORE_PROV_SYSTEM               CERT_STORE_PROV_SYSTEM_W
2015 #define CERT_STORE_PROV_COLLECTION           ((LPCSTR)11)
2016 #define CERT_STORE_PROV_SYSTEM_REGISTRY_A    ((LPCSTR)12)
2017 #define CERT_STORE_PROV_SYSTEM_REGISTRY_W    ((LPCSTR)13)
2018 #define CERT_STORE_PROV_SYSTEM_REGISTRY      CERT_STORE_PROV_SYSTEM_REGISTRY_W
2019 #define CERT_STORE_PROV_PHYSICAL_W           ((LPCSTR)14)
2020 #define CERT_STORE_PROV_PHYSICAL             CERT_STORE_PROV_PHYSICAL_W
2021 #define CERT_STORE_PROV_SMART_CARD_W         ((LPCSTR)15)
2022 #define CERT_STORE_PROV_SMART_CARD           CERT_STORE_PROV_SMART_CARD_W
2023 #define CERT_STORE_PROV_LDAP_W               ((LPCSTR)16)
2024 #define CERT_STORE_PROV_LDAP                 CERT_STORE_PROV_LDAP_W
2025
2026 #define sz_CERT_STORE_PROV_MEMORY            "Memory"
2027 #define sz_CERT_STORE_PROV_FILENAME_W        "File"
2028 #define sz_CERT_STORE_PROV_FILENAME          sz_CERT_STORE_PROV_FILENAME_W
2029 #define sz_CERT_STORE_PROV_SYSTEM_W          "System"
2030 #define sz_CERT_STORE_PROV_SYSTEM            sz_CERT_STORE_PROV_SYSTEM_W
2031 #define sz_CERT_STORE_PROV_PKCS7             "PKCS7"
2032 #define sz_CERT_STORE_PROV_SERIALIZED        "Serialized"
2033 #define sz_CERT_STORE_PROV_COLLECTION        "Collection"
2034 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W "SystemRegistry"
2035 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY   sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W
2036 #define sz_CERT_STORE_PROV_PHYSICAL_W        "Physical"
2037 #define sz_CERT_STORE_PROV_PHYSICAL          sz_CERT_STORE_PROV_PHYSICAL_W
2038 #define sz_CERT_STORE_PROV_SMART_CARD_W      "SmartCard"
2039 #define sz_CERT_STORE_PROV_SMART_CARD        sz_CERT_STORE_PROV_SMART_CARD_W
2040 #define sz_CERT_STORE_PROV_LDAP_W            "Ldap"
2041 #define sz_CERT_STORE_PROV_LDAP              sz_CERT_STORE_PROV_LDAP_W
2042
2043 /* types for CertOpenStore dwEncodingType */
2044 #define CERT_ENCODING_TYPE_MASK 0x0000ffff
2045 #define CMSG_ENCODING_TYPE_MASK 0xffff0000
2046 #define GET_CERT_ENCODING_TYPE(x) ((x) & CERT_ENCODING_TYPE_MASK)
2047 #define GET_CMSG_ENCODING_TYPE(x) ((x) & CMSG_ENCODING_TYPE_MASK)
2048
2049 #define CRYPT_ASN_ENCODING  0x00000001
2050 #define CRYPT_NDR_ENCODING  0x00000002
2051 #define X509_ASN_ENCODING   0x00000001
2052 #define X509_NDR_ENCODING   0x00000002
2053 #define PKCS_7_ASN_ENCODING 0x00010000
2054 #define PKCS_7_NDR_ENCODING 0x00020000
2055
2056 /* system store locations */
2057 #define CERT_SYSTEM_STORE_LOCATION_MASK  0x00ff0000
2058 #define CERT_SYSTEM_STORE_LOCATION_SHIFT 16
2059
2060 /* system store location ids */
2061 /* hkcu */
2062 #define CERT_SYSTEM_STORE_CURRENT_USER_ID               1
2063 /* hklm */
2064 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ID              2
2065 /* hklm\Software\Microsoft\Cryptography\Services */
2066 #define CERT_SYSTEM_STORE_CURRENT_SERVICE_ID            4
2067 #define CERT_SYSTEM_STORE_SERVICES_ID                   5
2068 /* HKEY_USERS */
2069 #define CERT_SYSTEM_STORE_USERS_ID                      6
2070 /* hkcu\Software\Policies\Microsoft\SystemCertificates */
2071 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID  7
2072 /* hklm\Software\Policies\Microsoft\SystemCertificates */
2073 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID 8
2074 /* hklm\Software\Microsoft\EnterpriseCertificates */
2075 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID   9
2076
2077 /* system store location values */
2078 #define CERT_SYSTEM_STORE_CURRENT_USER \
2079  (CERT_SYSTEM_STORE_CURRENT_USER_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2080 #define CERT_SYSTEM_STORE_LOCAL_MACHINE \
2081  (CERT_SYSTEM_STORE_LOCAL_MACHINE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2082 #define CERT_SYSTEM_STORE_CURRENT_SERVICE \
2083  (CERT_SYSTEM_STORE_CURRENT_SERVICE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2084 #define CERT_SYSTEM_STORE_SERVICES \
2085  (CERT_SYSTEM_STORE_SERVICES_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2086 #define CERT_SYSTEM_STORE_USERS \
2087  (CERT_SYSTEM_STORE_USERS_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2088 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY \
2089  (CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2090 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY \
2091  (CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2092 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE \
2093  (CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
2094
2095 #if defined(__GNUC__)
2096 #define CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH (const WCHAR[])\
2097  {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t',\
2098   '\\','S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',\
2099   0 }
2100 #define CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH (const WCHAR[])\
2101  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',\
2102   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',\
2103   't','i','f','i','c','a','t','e','s',0 }
2104 #elif defined(_MSC_VER)
2105 #define CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH \
2106  L"Software\\Microsoft\\SystemCertificates"
2107 #define CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH \
2108  L"Software\\Policies\\Microsoft\\SystemCertificates"
2109 #else
2110 static const WCHAR CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH[] = 
2111  {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
2112   'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',0 };
2113 static const WCHAR CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH[] = 
2114  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
2115   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',
2116   't','i','f','i','c','a','t','e','s',0 };
2117 #endif
2118
2119 #if defined(__GNUC__)
2120 #define CERT_EFSBLOB_REGPATH (const WCHAR[])\
2121 {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',\
2122  'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',\
2123  't','i','f','i','c','a','t','e','s','\\','E','F','S',0 }
2124 #define CERT_EFSBLOB_VALUE_NAME (const WCHAR[]) {'E','F','S','B','l','o','b',0 }
2125 #elif defined(_MSC_VER)
2126 #define CERT_EFSBLOB_REGPATH CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"\\EFS"
2127 #define CERT_EFSBLOB_VALUE_NAME L"EFSBlob"
2128 #else
2129 static const WCHAR CERT_EFSBLOB_REGPATH[] =
2130  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
2131   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',
2132   't','i','f','i','c','a','t','e','s','\\','E','F','S',0 };
2133 static const CERT_EFSBLOB_VALUE_NAME[] = { 'E','F','S','B','l','o','b',0 };
2134 #endif
2135
2136 #if defined(__GNUC__)
2137 #define CERT_PROT_ROOT_FLAGS_REGPATH (const WCHAR[])\
2138 {'\\','R','o','o','t','\\','P','r','o','t','e','c','t','e','d','R','o','o','t',\
2139  's',0 }
2140 #define CERT_PROT_ROOT_FLAGS_VALUE_NAME (const WCHAR[])\
2141 {'F','l','a','g','s',0 }
2142 #elif defined(_MSC_VER)
2143 #define CERT_PROT_ROOT_FLAGS_REGPATH L"\\Root\\ProtectedRoots"
2144 #define CERT_PROT_ROOT_FLAGS_VALUE_NAME L"Flags"
2145 #else
2146 static const WCHAR CERT_PROT_ROOT_FLAGS_REGPATH[] =
2147  { '\\','R','o','o','t','\\','P','r','o','t','e','c','t','e','d','R','o','o',
2148    't','s',0 };
2149 static const WCHAR CERT_PROT_ROOT_FLAGS_VALUE_NAME[] = {'F','l','a','g','s',0 };
2150 #endif
2151
2152 #define CERT_PROT_ROOT_DISABLE_CURRENT_USER_FLAG                0x01
2153 #define CERT_PROT_ROOT_INHIBIT_ADD_AT_INIT_FLAG                 0x02
2154 #define CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG                    0x04
2155 #define CERT_PROT_ROOT_DISABLE_LM_AUTH_FLAG                     0x08
2156 #define CERT_PROT_ROOT_DISABLE_NT_AUTH_REQUIRED_FLAG            0x10
2157 #define CERT_PROT_ROOT_DISABLE_NOT_DEFINED_NAME_CONSTRAINT_FLAG 0x20
2158
2159 #if defined(__GNUC__)
2160 #define CERT_TRUST_PUB_SAFER_GROUP_POLICY_REGPATH (const WCHAR[])\
2161 {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',\
2162  'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',\
2163  't','i','f','i','c','a','t','e','s','\\','T','r','u','s','t','e','d',\
2164  'P','u','b','l','i','s','h','e','r','\\','S','a','f','e','r',0 }
2165 #elif defined(_MSC_VER)
2166 #define CERT_TRUST_PUB_SAFER_GROUP_POLICY_REGPATH \
2167  CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH L"\\TrustedPublisher\\Safer"
2168 #else
2169 static const WCHAR CERT_TRUST_PUB_SAFER_GROUP_POLICY_REGPATH[] =
2170  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
2171   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',
2172   't','i','f','i','c','a','t','e','s','\\','T','r','u','s','t','e','d',
2173   'P','u','b','l','i','s','h','e','r','\\','S','a','f','e','r',0 };
2174 #endif
2175
2176 #if defined(__GNUC__)
2177 #define CERT_TRUST_PUB_SAFER_LOCAL_MACHINE_REGPATH (const WCHAR[])\
2178 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',\
2179  'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s','\\',\
2180  'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',\
2181  'S','a','f','e','r',0 }
2182 #define CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME (const WCHAR[])\
2183 {'A','u','t','h','e','n','t','i','c','o','d','e','F','l','a','g','s',0 };
2184 #elif defined(_MSC_VER)
2185 #define CERT_TRUST_PUB_SAFER_LOCAL_MACHINE_REGPATH \
2186  CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH L"\\TrustedPublisher\\Safer"
2187 #define CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME L"AuthenticodeFlags"
2188 #else
2189 static const WCHAR CERT_TRUST_PUB_SAFER_LOCAL_MACHINE_REGPATH[] =
2190  {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
2191   'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s','\\',
2192   'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
2193   'S','a','f','e','r',0 };
2194 static const WCHAR CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME[] =
2195  { 'A','u','t','h','e','n','t','i','c','o','d','e','F','l','a','g','s',0 };
2196 #endif
2197
2198 #define CERT_TRUST_PUB_ALLOW_END_USER_TRUST         0x00000000
2199 #define CERT_TRUST_PUB_ALLOW_MACHINE_ADMIN_TRUST    0x00000001
2200 #define CERT_TRUST_PUB_ALLOW_ENTERPRISE_ADMIN_TRUST 0x00000002
2201 #define CERT_TRUST_PUB_ALLOW_TRUST_MASK             0x00000003
2202 #define CERT_TRUST_PUB_CHECK_PUBLISHER_REV_FLAG     0x00000100
2203 #define CERT_TRUST_PUB_CHECK_TIMESTAMP_REV_FLAG     0x00000200
2204
2205 /* flags for CertOpenStore dwFlags */
2206 #define CERT_STORE_NO_CRYPT_RELEASE_FLAG            0x00000001
2207 #define CERT_STORE_SET_LOCALIZED_NAME_FLAG          0x00000002
2208 #define CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG 0x00000004
2209 #define CERT_STORE_DELETE_FLAG                      0x00000010
2210 #define CERT_STORE_UNSAFE_PHYSICAL_FLAG             0x00000020
2211 #define CERT_STORE_SHARE_STORE_FLAG                 0x00000040
2212 #define CERT_STORE_SHARE_CONTEXT_FLAG               0x00000080
2213 #define CERT_STORE_MANIFOLD_FLAG                    0x00000100
2214 #define CERT_STORE_ENUM_ARCHIVED_FLAG               0x00000200
2215 #define CERT_STORE_UPDATE_KEYID_FLAG                0x00000400
2216 #define CERT_STORE_BACKUP_RESTORE_FLAG              0x00000800
2217 #define CERT_STORE_MAXIMUM_ALLOWED_FLAG             0x00001000
2218 #define CERT_STORE_CREATE_NEW_FLAG                  0x00002000
2219 #define CERT_STORE_OPEN_EXISTING_FLAG               0x00004000
2220 #define CERT_STORE_READONLY_FLAG                    0x00008000
2221
2222 #define CERT_REGISTRY_STORE_REMOTE_FLAG      0x00010000
2223 #define CERT_REGISTRY_STORE_SERIALIZED_FLAG  0x00020000
2224 #define CERT_REGISTRY_STORE_ROAMING_FLAG     0x00040000
2225 #define CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG 0x00080000
2226 #define CERT_REGISTRY_STORE_LM_GPT_FLAG      0x01000000
2227 #define CERT_REGISTRY_STORE_CLIENT_GPT_FLAG  0x80000000
2228
2229 #define CERT_FILE_STORE_COMMIT_ENABLE_FLAG 0x00010000
2230
2231 /* CertCloseStore dwFlags */
2232 #define CERT_CLOSE_STORE_FORCE_FLAG 0x00000001
2233 #define CERT_CLOSE_STORE_CHECK_FLAG 0x00000002
2234
2235 /* dwAddDisposition */
2236 #define CERT_STORE_ADD_NEW                                 1
2237 #define CERT_STORE_ADD_USE_EXISTING                        2
2238 #define CERT_STORE_ADD_REPLACE_EXISTING                    3
2239 #define CERT_STORE_ADD_ALWAYS                              4
2240 #define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES 5
2241 #define CERT_STORE_ADD_NEWER                               6
2242 #define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES            7
2243
2244 /* Installable OID function defs */
2245 #define CRYPT_OID_OPEN_STORE_PROV_FUNC     "CertDllOpenStoreProv"
2246 #define CRYPT_OID_ENCODE_OBJECT_FUNC       "CryptDllEncodeObject"
2247 #define CRYPT_OID_DECODE_OBJECT_FUNC       "CryptDllDecodeObject"
2248 #define CRYPT_OID_ENCODE_OBJECT_EX_FUNC    "CryptDllEncodeObjectEx"
2249 #define CRYPT_OID_DECODE_OBJECT_EX_FUNC    "CryptDllDecodeObjectEx"
2250 #define CRYPT_OID_CREATE_COM_OBJECT_FUNC   "CryptDllCreateComObject"
2251 #define CRYPT_OID_VERIFY_REVOCATION_FUNC   "CertDllVerifyRevocation"
2252 #define CRYPT_OID_VERIFY_CTL_USAGE_FUNC    "CertDllVerifyCTLUsage"
2253 #define CRYPT_OID_FORMAT_OBJECT_FUNC       "CryptDllFormatObject"
2254 #define CRYPT_OID_FIND_OID_INFO_FUNC       "CryptDllFindOIDInfo"
2255 #define CRYPT_OID_FIND_LOCALIZED_NAME_FUNC "CryptDllFindLocalizedName"
2256 #define CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC  "CryptDllExportPublicKeyInfoEx"
2257 #define CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC  "CryptDllImportPublicKeyInfoEx"
2258 #define CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC "CryptDllExportPrivateKeyInfoEx"
2259 #define CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC "CryptDllImportPrivateKeyInfoEx"
2260 #define CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC \
2261  "CertDllVerifyCertificateChainPolicy"
2262 #define URL_OID_GET_OBJECT_URL_FUNC    "UrlDllGetObjectUrl"
2263 #define TIME_VALID_OID_GET_OBJECT_FUNC "TimeValidDllGetObject"
2264
2265 #define CRYPT_OID_REGPATH "Software\\Microsoft\\Cryptography\\OID"
2266 #define CRYPT_OID_REG_ENCODING_TYPE_PREFIX "EncodingType "
2267 #if defined(__GNUC__)
2268 # define CRYPT_OID_REG_DLL_VALUE_NAME (const WCHAR []){ 'D','l','l',0 }
2269 # define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME \
2270  (const WCHAR []){ 'F','u','n','c','N','a','m','e',0 }
2271 # define CRYPT_OID_REG_FLAGS_VALUE_NAME \
2272  (const WCHAR []){ 'C','r','y','p','t','F','l','a','g','s',0 }
2273 #elif defined(_MSC_VER)
2274 # define CRYPT_OID_REG_DLL_VALUE_NAME       L"Dll"
2275 # define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME L"FuncName"
2276 # define CRYPT_OID_REG_FLAGS_VALUE_NAME     L"CryptFlags"
2277 #else
2278 static const WCHAR CRYPT_OID_REG_DLL_VALUE_NAME[] = { 'D','l','l',0 };
2279 static const WCHAR CRYPT_OID_REG_FUNC_NAME_VALUE_NAME[] =
2280  { 'F','u','n','c','N','a','m','e',0 };
2281 static const WCHAR CRYPT_OID_REG_FLAGS_VALUE_NAME[] =
2282  { 'C','r','y','p','t','F','l','a','g','s',0 };
2283 #endif
2284 #define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A "FuncName"
2285 #define CRYPT_DEFAULT_OID                    "DEFAULT"
2286
2287 #define CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG 1
2288
2289 #define CRYPT_GET_INSTALLED_OID_FUNC_FLAG  0x1
2290
2291 #define CRYPT_REGISTER_FIRST_INDEX 0
2292 #define CRYPT_REGISTER_LAST_INDEX  0xffffffff
2293
2294 /* values for CERT_STORE_PROV_INFO's dwStoreProvFlags */
2295 #define CERT_STORE_PROV_EXTERNAL_FLAG        0x1
2296 #define CERT_STORE_PROV_DELETED_FLAG         0x2
2297 #define CERT_STORE_PROV_NO_PERSIST_FLAG      0x4
2298 #define CERT_STORE_PROV_SYSTEM_STORE_FLAG    0x8
2299 #define CERT_STORE_PROV_LM_SYSTEM_STORE_FLAG 0x10
2300
2301 /* function indices */
2302 #define CERT_STORE_PROV_CLOSE_FUNC             0
2303 #define CERT_STORE_PROV_READ_CERT_FUNC         1
2304 #define CERT_STORE_PROV_WRITE_CERT_FUNC        2
2305 #define CERT_STORE_PROV_DELETE_CERT_FUNC       3
2306 #define CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC 4
2307 #define CERT_STORE_PROV_READ_CRL_FUNC          5
2308 #define CERT_STORE_PROV_WRITE_CRL_FUNC         6
2309 #define CERT_STORE_PROV_DELETE_CRL_FUNC        7
2310 #define CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC  8
2311 #define CERT_STORE_PROV_READ_CTL_FUNC          9
2312 #define CERT_STORE_PROV_WRITE_CTL_FUNC         10
2313 #define CERT_STORE_PROV_DELETE_CTL_FUNC        11
2314 #define CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC  12
2315 #define CERT_STORE_PROV_CONTROL_FUNC           13
2316 #define CERT_STORE_PROV_FIND_CERT_FUNC         14
2317 #define CERT_STORE_PROV_FREE_FIND_CERT_FUNC    15
2318 #define CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC 16
2319 #define CERT_STORE_PROV_FIND_CRL_FUNC          17
2320 #define CERT_STORE_PROV_FREE_FIND_CRL_FUNC     18
2321 #define CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC  19
2322 #define CERT_STORE_PROV_FIND_CTL_FUNC          20
2323 #define CERT_STORE_PROV_FREE_FIND_CTL_FUNC     21
2324 #define CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC  22
2325
2326 /* physical store dwFlags, also used by CertAddStoreToCollection as
2327  * dwUpdateFlags
2328  */
2329 #define CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG                  0x1
2330 #define CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG                0x2
2331 #define CERT_PHYSICAL_STORE_REMOVE_OPEN_DISABLE_FLAG         0x4
2332 #define CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG 0x8
2333
2334 /* dwFlag values for CertEnumPhysicalStore callback */
2335 #define CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG 0x1
2336
2337 /* predefined store names */
2338 #if defined(__GNUC__)
2339 # define CERT_PHYSICAL_STORE_DEFAULT_NAME (const WCHAR[])\
2340  {'.','D','e','f','a','u','l','t','0'}
2341 # define CERT_PHYSICAL_STORE_GROUP_POLICY_NAME (const WCHAR[])\
2342  {'.','G','r','o','u','p','P','o','l','i','c','y',0}
2343 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME (const WCHAR[])\
2344  {'.','L','o','c','a','l','M','a','c','h','i','n','e',0}
2345 # define CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME (const WCHAR[])\
2346  {'.','U','s','e','r','C','e','r','t','i','f','i','c','a','t','e',0}
2347 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME (const WCHAR[])\
2348  {'.','L','o','c','a','l','M','a','c','h','i','n','e','G','r','o','u','p',\
2349  'P','o','l','i','c','y',0}
2350 # define CERT_PHYSICAL_STORE_ENTERPRISE_NAME (const WCHAR[])\
2351  {'.','E','n','t','e','r','p','r','i','s','e',0}
2352 # define CERT_PHYSICAL_STORE_AUTH_ROOT_NAME (const WCHAR[])\
2353  {'.','A','u','t','h','R','o','o','t',0}
2354 #elif defined(_MSC_VER)
2355 # define CERT_PHYSICAL_STORE_DEFAULT_NAME \
2356  L".Default"
2357 # define CERT_PHYSICAL_STORE_GROUP_POLICY_NAME \
2358  L".GroupPolicy"
2359 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME \
2360  L".LocalMachine"
2361 # define CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME \
2362  L".UserCertificate"
2363 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME \
2364  L".LocalMachineGroupPolicy"
2365 # define CERT_PHYSICAL_STORE_ENTERPRISE_NAME \
2366  L".Enterprise"
2367 # define CERT_PHYSICAL_STORE_AUTH_ROOT_NAME \
2368  L".AuthRoot"
2369 #else
2370 static const WCHAR CERT_PHYSICAL_STORE_DEFAULT_NAME[] = 
2371  {'.','D','e','f','a','u','l','t','0'};
2372 static const WCHAR CERT_PHYSICAL_STORE_GROUP_POLICY_NAME[] =
2373  {'.','G','r','o','u','p','P','o','l','i','c','y',0};
2374 static const WCHAR CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME[] =
2375  {'.','L','o','c','a','l','M','a','c','h','i','n','e',0};
2376 static const WCHAR CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME[] =
2377  {'.','U','s','e','r','C','e','r','t','i','f','i','c','a','t','e',0};
2378 static const WCHAR CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME[] =
2379  {'.','L','o','c','a','l','M','a','c','h','i','n','e','G','r','o','u','p',
2380  'P','o','l','i','c','y',0};
2381 static const WCHAR CERT_PHYSICAL_STORE_ENTERPRISE_NAME[] =
2382  {'.','E','n','t','e','r','p','r','i','s','e',0};
2383 static const WCHAR CERT_PHYSICAL_STORE_AUTH_ROOT_NAME[] =
2384  {'.','A','u','t','h','R','o','o','t',0};
2385 #endif
2386
2387 /* cert system store flags */
2388 #define CERT_SYSTEM_STORE_MASK 0xffff0000
2389 #define CERT_SYSTEM_STORE_RELOCATE_FLAG 0x80000000
2390
2391 /* CertFindChainInStore dwFindType types */
2392 #define CERT_CHAIN_FIND_BY_ISSUER 1
2393
2394 /* CertSaveStore dwSaveAs values */
2395 #define CERT_STORE_SAVE_AS_STORE 1
2396 #define CERT_STORE_SAVE_AS_PKCS7 2
2397 /* CertSaveStore dwSaveTo values */
2398 #define CERT_STORE_SAVE_TO_FILE       1
2399 #define CERT_STORE_SAVE_TO_MEMORY     2
2400 #define CERT_STORE_SAVE_TO_FILENAME_A 3
2401 #define CERT_STORE_SAVE_TO_FILENAME_W 4
2402 #define CERT_STORE_SAVE_TO_FILENAME   CERT_STORE_SAVE_TO_FILENAME_W
2403
2404 /* CERT_INFO versions/flags */
2405 #define CERT_V1 0
2406 #define CERT_V2 1
2407 #define CERT_V3 2
2408 #define CERT_INFO_VERSION_FLAG                 1
2409 #define CERT_INFO_SERIAL_NUMBER_FLAG           2
2410 #define CERT_INFO_SIGNATURE_ALGORITHM_FLAG     3
2411 #define CERT_INFO_ISSUER_FLAG                  4
2412 #define CERT_INFO_NOT_BEFORE_FLAG              5
2413 #define CERT_INFO_NOT_AFTER_FLAG               6
2414 #define CERT_INFO_SUBJECT_FLAG                 7
2415 #define CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG 8
2416 #define CERT_INFO_ISSUER_UNIQUE_ID_FLAG        9
2417 #define CERT_INFO_SUBJECT_UNIQUE_ID_FLAG       10
2418 #define CERT_INFO_EXTENSION_FLAG               11
2419
2420 /* CERT_REQUEST_INFO versions */
2421 #define CERT_REQUEST_V1 0
2422
2423 /* CERT_KEYGEN_REQUEST_INFO versions */
2424 #define CERT_KEYGEN_REQUEST_V1 0
2425
2426 /* CRL versions */
2427 #define CRL_V1 0
2428 #define CRL_V2 1
2429
2430 /* CTL versions */
2431 #define CTL_V1 0
2432
2433 /* Certificate, CRL, CTL property IDs */
2434 #define CERT_KEY_PROV_HANDLE_PROP_ID               1
2435 #define CERT_KEY_PROV_INFO_PROP_ID                 2
2436 #define CERT_SHA1_HASH_PROP_ID                     3
2437 #define CERT_HASH_PROP_ID                          CERT_SHA1_HASH_PROP_ID
2438 #define CERT_MD5_HASH_PROP_ID                      4
2439 #define CERT_KEY_CONTEXT_PROP_ID                   5
2440 #define CERT_KEY_SPEC_PROP_ID                      6
2441 #define CERT_IE30_RESERVED_PROP_ID                 7
2442 #define CERT_PUBKEY_HASH_RESERVED_PROP_ID          8
2443 #define CERT_ENHKEY_USAGE_PROP_ID                  9
2444 #define CERT_CTL_USAGE_PROP_ID                     CERT_ENHKEY_USAGE_PROP_ID
2445 #define CERT_NEXT_UPDATE_LOCATION_PROP_ID          10
2446 #define CERT_FRIENDLY_NAME_PROP_ID                 11
2447 #define CERT_PVK_FILE_PROP_ID                      12
2448 #define CERT_DESCRIPTION_PROP_ID                   13
2449 #define CERT_ACCESS_STATE_PROP_ID                  14
2450 #define CERT_SIGNATURE_HASH_PROP_ID                15
2451 #define CERT_SMART_CARD_DATA_PROP_ID               16
2452 #define CERT_EFS_PROP_ID                           17
2453 #define CERT_FORTEZZA_DATA_PROP                    18
2454 #define CERT_ARCHIVED_PROP_ID                      19
2455 #define CERT_KEY_IDENTIFIER_PROP_ID                20
2456 #define CERT_AUTO_ENROLL_PROP_ID                   21
2457 #define CERT_PUBKEY_ALG_PARA_PROP_ID               22
2458 #define CERT_CROSS_CERT_DIST_POINTS_PROP_ID        23
2459 #define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID    24
2460 #define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID   25
2461 #define CERT_ENROLLMENT_PROP_ID                    26
2462 #define CERT_DATE_STAMP_PROP_ID                    27
2463 #define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID 28
2464 #define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID         29
2465 #define CERT_EXTENDED_ERROR_INFO_PROP_ID           30
2466 /* 31    -- unused?
2467    32    -- cert prop id
2468    33    -- CRL prop id
2469    34    -- CTL prop id
2470    35    -- KeyId prop id
2471    36-63 -- reserved
2472  */
2473 #define CERT_RENEWAL_PROP_ID                       64
2474 #define CERT_ARCHIVED_KEY_HASH_PROP_ID             65
2475 #define CERT_AUTO_ENROLL_RETRY_PROP_ID             66
2476 #define CERT_AIA_URL_RETRIEVED_PROP_ID             67
2477 #define CERT_AUTHORITY_INFO_ACCESS_PROP_ID         68
2478 #define CERT_BACKED_UP_PROP_ID                     69
2479 #define CERT_OCSP_RESPONSE_PROP_ID                 70
2480 #define CERT_REQUEST_ORIGINATOR_PROP_ID            71
2481 #define CERT_SOURCE_LOCATION_PROP_ID               72
2482 #define CERT_SOURCE_URL_PROP_ID                    73
2483 #define CERT_NEW_KEY_PROP_ID                       74
2484 #define CERT_OCSP_CACHE_PREFIX_PROP_ID             75
2485 #define CERT_SMART_CARD_ROOT_INFO_PROP_ID          76
2486 #define CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID          77
2487 #define CERT_NCRYPT_KEY_HANDLE_PROP_ID             78
2488 #define CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID 79
2489 #define CERT_SUBJECT_INFO_ACCESS_PROP_ID           80
2490 #define CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID 81
2491 #define CERT_CA_DISABLE_CRL_PROP_ID                82
2492 #define CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID    83
2493 #define CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID 84
2494
2495 #define CERT_FIRST_RESERVED_PROP_ID                85
2496 #define CERT_LAST_RESERVED_PROP_ID                 0x00007fff
2497 #define CERT_FIRST_USER_PROP_ID                    0x00008000
2498 #define CERT_LAST_USER_PROP_ID                     0x0000ffff
2499
2500 #define IS_CERT_HASH_PROP_ID(x) \
2501  ((x) == CERT_SHA1_HASH_PROP_ID || (x) == CERT_MD5_HASH_PROP_ID || \
2502   (x) == CERT_SIGNATURE_HASH_PROP_ID)
2503
2504 #define IS_PUBKEY_HASH_PROP_ID(x) \
2505  ((x) == CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID || \
2506   (x) == CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID)
2507
2508 #define IS_CHAIN_HASH_PROP_ID(x) \
2509  ((x) == CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID || \
2510   (x) == CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID || \
2511   (x) == CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID || \
2512   (x) == CERT_SUBJECT_NAME_MD5_HASH_PROP_ID)
2513
2514 /* access state flags */
2515 #define CERT_ACCESS_STATE_WRITE_PERSIST_FLAG   0x1
2516 #define CERT_ACCESS_STATE_SYSTEM_STORE_FLAG    0x2
2517 #define CERT_ACCESS_STATE_LM_SYSTEM_STORE_FLAG 0x4
2518
2519 /* CertSetCertificateContextProperty flags */
2520 #define CERT_SET_PROPERTY_INHIBIT_PERSIST_FLAG      0x40000000
2521 #define CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG 0x80000000
2522
2523 /* CERT_RDN attribute dwValueType types */
2524 #define CERT_RDN_TYPE_MASK 0x000000ff
2525 #define CERT_RDN_ANY_TYPE         0
2526 #define CERT_RDN_ENCODED_BLOB     1
2527 #define CERT_RDN_OCTET_STRING     2
2528 #define CERT_RDN_NUMERIC_STRING   3
2529 #define CERT_RDN_PRINTABLE_STRING 4
2530 #define CERT_RDN_TELETEX_STRING   5
2531 #define CERT_RDN_T61_STRING       5
2532 #define CERT_RDN_VIDEOTEX_STRING  6
2533 #define CERT_RDN_IA5_STRING       7
2534 #define CERT_RDN_GRAPHIC_STRING   8
2535 #define CERT_RDN_VISIBLE_STRING   9
2536 #define CERT_RDN_ISO646_STRING    9
2537 #define CERT_RDN_GENERAL_STRING   10
2538 #define CERT_RDN_UNIVERSAL_STRING 11
2539 #define CERT_RDN_INT4_STRING      11
2540 #define CERT_RDN_BMP_STRING       12
2541 #define CERT_RDN_UNICODE_STRING   12
2542 #define CERT_RDN_UTF8_STRING      13
2543
2544 /* CERT_RDN attribute dwValueType flags */
2545 #define CERT_RDN_FLAGS_MASK 0xff000000
2546 #define CERT_RDN_ENABLE_T61_UNICODE_FLAG  0x80000000
2547 #define CERT_RDN_DISABLE_CHECK_TYPE_FLAG  0x4000000
2548 #define CERT_RDN_ENABLE_UTF8_UNICODE_FLAG 0x2000000
2549 #define CERT_RDN_DISABLE_IE4_UTF8_FLAG    0x0100000
2550
2551 #define IS_CERT_RDN_CHAR_STRING(x) \
2552  (((x) & CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING)
2553
2554 /* CertIsRDNAttrsInCertificateName flags */
2555 #define CERT_UNICODE_IS_RDN_ATTRS_FLAG          0x1
2556 #define CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG 0x2
2557
2558 /* CRL reason codes */
2559 #define CRL_REASON_UNSPECIFIED            0
2560 #define CRL_REASON_KEY_COMPROMISE         1
2561 #define CRL_REASON_CA_COMPROMISE          2
2562 #define CRL_REASON_AFFILIATION_CHANGED    3
2563 #define CRL_REASON_SUPERSEDED             4
2564 #define CRL_REASON_CESSATION_OF_OPERATION 5
2565 #define CRL_REASON_CERTIFICATE_HOLD       6
2566 #define CRL_REASON_REMOVE_FROM_CRL        8
2567
2568 /* CertControlStore control types */
2569 #define CERT_STORE_CTRL_RESYNC        1
2570 #define CERT_STORE_CTRL_NOTIFY_CHANGE 2
2571 #define CERT_STORE_CTRL_COMMIT        3
2572 #define CERT_STORE_CTRL_AUTO_RESYNC   4
2573 #define CERT_STORE_CTRL_CANCEL_NOTIFY 5
2574
2575 #define CERT_STORE_CTRL_COMMIT_FORCE_FLAG 0x1
2576 #define CERT_STORE_CTRL_COMMIT_CLEAR_FLAG 0x2
2577
2578 /* cert store properties */
2579 #define CERT_STORE_LOCALIZED_NAME_PROP_ID 0x1000
2580
2581 /* CertCreateContext flags */
2582 #define CERT_CREATE_CONTEXT_NOCOPY_FLAG       0x1
2583 #define CERT_CREATE_CONTEXT_SORTED_FLAG       0x2
2584 #define CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG 0x4
2585 #define CERT_CREATE_CONTEXT_NO_ENTRY_FLAG     0x8
2586
2587 #define CERT_COMPARE_MASK                   0xffff
2588 #define CERT_COMPARE_SHIFT                  16
2589 #define CERT_COMPARE_ANY                    0
2590 #define CERT_COMPARE_SHA1_HASH              1
2591 #define CERT_COMPARE_HASH                   CERT_COMPARE_SHA1_HASH
2592 #define CERT_COMPARE_NAME                   2
2593 #define CERT_COMPARE_ATTR                   3
2594 #define CERT_COMPARE_MD5_HASH               4
2595 #define CERT_COMPARE_PROPERTY               5
2596 #define CERT_COMPARE_PUBLIC_KEY             6
2597 #define CERT_COMPARE_NAME_STR_A             7
2598 #define CERT_COMPARE_NAME_STR_W             8
2599 #define CERT_COMPARE_KEY_SPEC               9
2600 #define CERT_COMPARE_ENHKEY_USAGE           10
2601 #define CERT_COMPARE_CTL_USAGE              CERT_COMPARE_ENHKEY_USAGE
2602 #define CERT_COMPARE_SUBJECT_CERT           11
2603 #define CERT_COMPARE_ISSUER_OF              12
2604 #define CERT_COMPARE_EXISTING               13
2605 #define CERT_COMPARE_SIGNATURE_HASH         14
2606 #define CERT_COMPARE_KEY_IDENTIFIER         15
2607 #define CERT_COMPARE_CERT_ID                16
2608 #define CERT_COMPARE_CROSS_CERT_DIST_POINTS 17
2609 #define CERT_COMPARE_PUBKEY_MD5_HASH        18
2610
2611 /* values of dwFindType for CertFind*InStore */
2612 #define CERT_FIND_ANY \
2613  (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
2614 #define CERT_FIND_SHA1_HASH \
2615  (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
2616 #define CERT_FIND_MD5_HASH \
2617  (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
2618 #define CERT_FIND_SIGNATURE_HASH \
2619  (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
2620 #define CERT_FIND_KEY_IDENTIFIER \
2621  (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
2622 #define CERT_FIND_HASH CERT_FIND_SHA1_HASH
2623 #define CERT_FIND_PROPERTY \
2624  (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
2625 #define CERT_FIND_PUBLIC_KEY \
2626  (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
2627 #define CERT_FIND_SUBJECT_NAME \
2628  (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
2629 #define CERT_FIND_SUBJECT_ATTR \
2630  (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
2631 #define CERT_FIND_ISSUER_NAME \
2632  (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2633 #define CERT_FIND_ISSUER_ATTR \
2634  (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2635 #define CERT_FIND_SUBJECT_STR_A \
2636  (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
2637 #define CERT_FIND_SUBJECT_STR_W \
2638  (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
2639 #define CERT_FIND_SUBJECT_STR CERT_FIND_SUBJECT_STR_W
2640 #define CERT_FIND_ISSUER_STR_A \
2641  (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2642 #define CERT_FIND_ISSUER_STR_W \
2643  (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2644 #define CERT_FIND_ISSUER_STR CERT_FIND_ISSUER_STR_W
2645 #define CERT_FIND_KEY_SPEC \
2646  (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
2647 #define CERT_FIND_ENHKEY_USAGE \
2648  (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
2649 #define CERT_FIND_CTL_USAGE CERT_FIND_ENHKEY_USAGE
2650 #define CERT_FIND_SUBJECT_CERT \
2651  (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
2652 #define CERT_FIND_ISSUER_OF \
2653  (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
2654 #define CERT_FIND_EXISTING \
2655  (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
2656 #define CERT_FIND_CERT_ID \
2657  (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
2658 #define CERT_FIND_CROSS_CERT_DIST_POINTS \
2659  (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
2660 #define CERT_FIND_PUBKEY_MD5_HASH \
2661  (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
2662
2663 #define CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG  0x1
2664 #define CERT_FIND_OPTIONAL_CTL_USAGE_FLAG     0x1
2665 #define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG  0x2
2666 #define CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG     0x2
2667 #define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG 0x4
2668 #define CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG    0x4
2669 #define CERT_FIND_NO_ENHKEY_USAGE_FLAG        0x8
2670 #define CERT_FIND_NO_CTL_USAGE_FLAG           0x8
2671 #define CERT_FIND_OR_ENHKEY_USAGE_FLAG        0x10
2672 #define CERT_FIND_OR_CTL_USAGE_FLAG           0x10
2673 #define CERT_FIND_VALID_ENHKEY_USAGE_FLAG     0x20
2674 #define CERT_FIND_VALID_CTL_USAGE_FLAG        0x20
2675
2676 #define CRL_FIND_ANY        0
2677 #define CRL_FIND_ISSUED_BY  1
2678 #define CRL_FIND_EXISTING   2
2679 #define CRL_FIND_ISSUED_FOR 3
2680
2681 #define CRL_FIND_ISSUED_BY_AKI_FLAG       0x1
2682 #define CRL_FIND_ISSUED_BY_SIGNATURE_FLAG 0x2
2683 #define CRL_FIND_ISSUED_BY_DELTA_FLAG     0x4
2684 #define CRL_FIND_ISSUED_BY_BASE_FLAG      0x8
2685
2686 typedef struct _CRL_FIND_ISSUED_FOR_PARA
2687 {
2688     PCCERT_CONTEXT pSubjectCert;
2689     PCCERT_CONTEXT pIssuerCert;
2690 } CRL_FIND_ISSUED_FOR_PARA, *PCRL_FIND_ISSUED_FOR_PARA;
2691
2692 #define CTL_FIND_ANY       0
2693 #define CTL_FIND_SHA1_HASH 1
2694 #define CTL_FIND_MD5_HASH  2
2695 #define CTL_FIND_USAGE     3
2696 #define CTL_FIND_SUBJECT   4
2697 #define CTL_FIND_EXISTING  5
2698
2699 typedef struct _CTL_FIND_USAGE_PARA
2700 {
2701     DWORD           cbSize;
2702     CTL_USAGE       SubjectUsage;
2703     CRYPT_DATA_BLOB ListIdentifier;
2704     PCERT_INFO      pSigner;
2705 } CTL_FIND_USAGE_PARA, *PCTL_FIND_USAGE_PARA;
2706
2707 #define CTL_FIND_NO_LIST_ID_CBDATA 0xffffffff
2708 #define CTL_FIND_NO_SIGNER_PTR     ((PCERT_INFO)-1)
2709 #define CTL_FIND_SAME_USAGE_FLAG   0x00000001
2710
2711 typedef struct _CTL_FIND_SUBJECT_PARA
2712 {
2713     DWORD                cbSize;
2714     PCTL_FIND_USAGE_PARA pUsagePara;
2715     DWORD                dwSubjectType;
2716     void                *pvSubject;
2717 } CTL_FIND_SUBJECT_PARA, *PCTL_FIND_SUBJECT_PARA;
2718
2719 /* PFN_CERT_STORE_PROV_WRITE_CERT dwFlags values */
2720 #define CERT_STORE_PROV_WRITE_ADD_FLAG 0x1
2721
2722 /* CertAddSerializedElementToStore context types */
2723 #define CERT_STORE_CERTIFICATE_CONTEXT 1
2724 #define CERT_STORE_CRL_CONTEXT         2
2725 #define CERT_STORE_CTL_CONTEXT         3
2726 #define CERT_STORE_ALL_CONTEXT_FLAG    ~0U
2727 #define CERT_STORE_CERTIFICATE_CONTEXT_FLAG \
2728                                     (1 << CERT_STORE_CERTIFICATE_CONTEXT)
2729 #define CERT_STORE_CRL_CONTEXT_FLAG (1 << CERT_STORE_CRL_CONTEXT)
2730 #define CERT_STORE_CTL_CONTEXT_FLAG (1 << CERT_STORE_CTL_CONTEXT)
2731
2732 /* CryptBinaryToString/CryptStringToBinary flags */
2733 #define CRYPT_STRING_BASE64HEADER        0x00000000
2734 #define CRYPT_STRING_BASE64              0x00000001
2735 #define CRYPT_STRING_BINARY              0x00000002
2736 #define CRYPT_STRING_BASE64REQUESTHEADER 0x00000003
2737 #define CRYPT_STRING_HEX                 0x00000004
2738 #define CRYPT_STRING_HEXASCII            0x00000005
2739 #define CRYPT_STRING_BASE64_ANY          0x00000006
2740 #define CRYPT_STRING_ANY                 0x00000007
2741 #define CRYPT_STRING_HEX_ANY             0x00000008
2742 #define CRYPT_STRING_BASE64X509CRLHEADER 0x00000009
2743 #define CRYPT_STRING_HEXADDR             0x0000000a
2744 #define CRYPT_STRING_HEXASCIIADDR        0x0000000b
2745 #define CRYPT_STRING_NOCR                0x80000000
2746
2747 /* OIDs */
2748 #define szOID_RSA                           "1.2.840.113549"
2749 #define szOID_PKCS                          "1.2.840.113549.1"
2750 #define szOID_RSA_HASH                      "1.2.840.113549.2"
2751 #define szOID_RSA_ENCRYPT                   "1.2.840.113549.3"
2752 #define szOID_PKCS_1                        "1.2.840.113549.1.1"
2753 #define szOID_PKCS_2                        "1.2.840.113549.1.2"
2754 #define szOID_PKCS_3                        "1.2.840.113549.1.3"
2755 #define szOID_PKCS_4                        "1.2.840.113549.1.4"
2756 #define szOID_PKCS_5                        "1.2.840.113549.1.5"
2757 #define szOID_PKCS_6                        "1.2.840.113549.1.6"
2758 #define szOID_PKCS_7                        "1.2.840.113549.1.7"
2759 #define szOID_PKCS_8                        "1.2.840.113549.1.8"
2760 #define szOID_PKCS_9                        "1.2.840.113549.1.9"
2761 #define szOID_PKCS_10                       "1.2.840.113549.1.10"
2762 #define szOID_PKCS_11                       "1.2.840.113549.1.12"
2763 #define szOID_RSA_RSA                       "1.2.840.113549.1.1.1"
2764 #define CERT_RSA_PUBLIC_KEY_OBJID           szOID_RSA_RSA
2765 #define CERT_DEFAULT_OID_PUBLIC_KEY_SIGN    szOID_RSA_RSA
2766 #define CERT_DEFAULT_OID_PUBLIC_KEY_XCHG    szOID_RSA_RSA
2767 #define szOID_RSA_MD2RSA                    "1.2.840.113549.1.1.2"
2768 #define szOID_RSA_MD4RSA                    "1.2.840.113549.1.1.3"
2769 #define szOID_RSA_MD5RSA                    "1.2.840.113549.1.1.4"
2770 #define szOID_RSA_SHA1RSA                   "1.2.840.113549.1.1.5"
2771 #define szOID_RSA_SET0AEP_RSA               "1.2.840.113549.1.1.6"
2772 #define szOID_RSA_DH                        "1.2.840.113549.1.3.1"
2773 #define szOID_RSA_data                      "1.2.840.113549.1.7.1"
2774 #define szOID_RSA_signedData                "1.2.840.113549.1.7.2"
2775 #define szOID_RSA_envelopedData             "1.2.840.113549.1.7.3"
2776 #define szOID_RSA_signEnvData               "1.2.840.113549.1.7.4"
2777 #define szOID_RSA_digestedData              "1.2.840.113549.1.7.5"
2778 #define szOID_RSA_hashedData                "1.2.840.113549.1.7.5"
2779 #define szOID_RSA_encryptedData             "1.2.840.113549.1.7.6"
2780 #define szOID_RSA_emailAddr                 "1.2.840.113549.1.9.1"
2781 #define szOID_RSA_unstructName              "1.2.840.113549.1.9.2"
2782 #define szOID_RSA_contentType               "1.2.840.113549.1.9.3"
2783 #define szOID_RSA_messageDigest             "1.2.840.113549.1.9.4"
2784 #define szOID_RSA_signingTime               "1.2.840.113549.1.9.5"
2785 #define szOID_RSA_counterSign               "1.2.840.113549.1.9.6"
2786 #define szOID_RSA_challengePwd              "1.2.840.113549.1.9.7"
2787 #define szOID_RSA_unstructAddr              "1.2.840.113549.1.9.9"
2788 #define szOID_RSA_extCertAttrs              "1.2.840.113549.1.9.9"
2789 #define szOID_RSA_certExtensions            "1.2.840.113549.1.9.14"
2790 #define szOID_RSA_SMIMECapabilities         "1.2.840.113549.1.9.15"
2791 #define szOID_RSA_preferSignedData          "1.2.840.113549.1.9.15.1"
2792 #define szOID_RSA_SMIMEalg                  "1.2.840.113549.1.9.16.3"
2793 #define szOID_RSA_SMIMEalgESDH              "1.2.840.113549.1.9.16.3.5"
2794 #define szOID_RSA_SMIMEalgCMS3DESwrap       "1.2.840.113549.1.9.16.3.6"
2795 #define szOID_RSA_SMIMEalgCMSRC2wrap        "1.2.840.113549.1.9.16.3.7"
2796 #define szOID_RSA_MD2                       "1.2.840.113549.2.2"
2797 #define szOID_RSA_MD4                       "1.2.840.113549.2.4"
2798 #define szOID_RSA_MD5                       "1.2.840.113549.2.5"
2799 #define szOID_RSA_RC2CBC                    "1.2.840.113549.3.2"
2800 #define szOID_RSA_RC4                       "1.2.840.113549.3.4"
2801 #define szOID_RSA_DES_EDE3_CBC              "1.2.840.113549.3.7"
2802 #define szOID_RSA_RC5_CBCPad                "1.2.840.113549.3.9"
2803 #define szOID_ANSI_X942                     "1.2.840.10046"
2804 #define szOID_ANSI_X942_DH                  "1.2.840.10046.2.1"
2805 #define szOID_X957                          "1.2.840.10040"
2806 #define szOID_X957_DSA                      "1.2.840.10040.4.1"
2807 #define szOID_X957_SHA1DSA                  "1.2.840.10040.4.3"
2808 #define szOID_DS                            "2.5"
2809 #define szOID_DSALG                         "2.5.8"
2810 #define szOID_DSALG_CRPT                    "2.5.8.1"
2811 #define szOID_DSALG_HASH                    "2.5.8.2"
2812 #define szOID_DSALG_SIGN                    "2.5.8.3"
2813 #define szOID_DSALG_RSA                     "2.5.8.1.1"
2814 #define szOID_OIW                           "1.3.14"
2815 #define szOID_OIWSEC                        "1.3.14.3.2"
2816 #define szOID_OIWSEC_md4RSA                 "1.3.14.3.2.2"
2817 #define szOID_OIWSEC_md5RSA                 "1.3.14.3.2.3"
2818 #define szOID_OIWSEC_md4RSA2                "1.3.14.3.2.4"
2819 #define szOID_OIWSEC_desECB                 "1.3.14.3.2.6"
2820 #define szOID_OIWSEC_desCBC                 "1.3.14.3.2.7"
2821 #define szOID_OIWSEC_desOFB                 "1.3.14.3.2.8"
2822 #define szOID_OIWSEC_desCFB                 "1.3.14.3.2.9"
2823 #define szOID_OIWSEC_desMAC                 "1.3.14.3.2.10"
2824 #define szOID_OIWSEC_rsaSign                "1.3.14.3.2.11"
2825 #define szOID_OIWSEC_dsa                    "1.3.14.3.2.12"
2826 #define szOID_OIWSEC_shaDSA                 "1.3.14.3.2.13"
2827 #define szOID_OIWSEC_mdc2RSA                "1.3.14.3.2.14"
2828 #define szOID_OIWSEC_shaRSA                 "1.3.14.3.2.15"
2829 #define szOID_OIWSEC_dhCommMod              "1.3.14.3.2.16"
2830 #define szOID_OIWSEC_desEDE                 "1.3.14.3.2.17"
2831 #define szOID_OIWSEC_sha                    "1.3.14.3.2.18"
2832 #define szOID_OIWSEC_mdc2                   "1.3.14.3.2.19"
2833 #define szOID_OIWSEC_dsaComm                "1.3.14.3.2.20"
2834 #define szOID_OIWSEC_dsaCommSHA             "1.3.14.3.2.21"
2835 #define szOID_OIWSEC_rsaXchg                "1.3.14.3.2.22"
2836 #define szOID_OIWSEC_keyHashSeal            "1.3.14.3.2.23"
2837 #define szOID_OIWSEC_md2RSASign             "1.3.14.3.2.24"
2838 #define szOID_OIWSEC_md5RSASign             "1.3.14.3.2.25"
2839 #define szOID_OIWSEC_sha1                   "1.3.14.3.2.26"
2840 #define szOID_OIWSEC_dsaSHA1                "1.3.14.3.2.27"
2841 #define szOID_OIWSEC_dsaCommSHA1            "1.3.14.3.2.28"
2842 #define szOID_OIWSEC_sha1RSASign            "1.3.14.3.2.29"
2843 #define szOID_OIWDIR                        "1.3.14.7.2"
2844 #define szOID_OIWDIR_CRPT                   "1.3.14.7.2.1"
2845 #define szOID_OIWDIR_HASH                   "1.3.14.7.2.2"
2846 #define szOID_OIWDIR_SIGN                   "1.3.14.7.2.3"
2847 #define szOID_OIWDIR_md2                    "1.3.14.7.2.2.1"
2848 #define szOID_OIWDIR_md2RSA                 "1.3.14.7.2.3.1"
2849 #define szOID_INFOSEC                       "2.16.840.1.101.2.1"
2850 #define szOID_INFOSEC_sdnsSignature         "2.16.840.1.101.2.1.1.1"
2851 #define szOID_INFOSEC_mosaicSignature       "2.16.840.1.101.2.1.1.2"
2852 #define szOID_INFOSEC_sdnsConfidentiality   "2.16.840.1.101.2.1.1.3"
2853 #define szOID_INFOSEC_mosaicConfidentiality "2.16.840.1.101.2.1.1.4"
2854 #define szOID_INFOSEC_sdnsIntegrity         "2.16.840.1.101.2.1.1.5"
2855 #define szOID_INFOSEC_mosaicIntegrity       "2.16.840.1.101.2.1.1.6"
2856 #define szOID_INFOSEC_sdnsTokenProtection   "2.16.840.1.101.2.1.1.7"
2857 #define szOID_INFOSEC_mosaicTokenProtection "2.16.840.1.101.2.1.1.8"
2858 #define szOID_INFOSEC_sdnsKeyManagement     "2.16.840.1.101.2.1.1.9"
2859 #define szOID_INFOSEC_mosaicKeyManagement   "2.16.840.1.101.2.1.1.10"
2860 #define szOID_INFOSEC_sdnsKMandSig          "2.16.840.1.101.2.1.1.11"
2861 #define szOID_INFOSEC_mosaicKMandSig        "2.16.840.1.101.2.1.1.12"
2862 #define szOID_INFOSEC_SuiteASignature       "2.16.840.1.101.2.1.1.13"
2863 #define szOID_INFOSEC_SuiteAConfidentiality "2.16.840.1.101.2.1.1.14"
2864 #define szOID_INFOSEC_SuiteAIntegrity       "2.16.840.1.101.2.1.1.15"
2865 #define szOID_INFOSEC_SuiteATokenProtection "2.16.840.1.101.2.1.1.16"
2866 #define szOID_INFOSEC_SuiteAKeyManagement   "2.16.840.1.101.2.1.1.17"
2867 #define szOID_INFOSEC_SuiteAKMandSig        "2.16.840.1.101.2.1.1.18"
2868 #define szOID_INFOSEC_mosaicUpdatedSig      "2.16.840.1.101.2.1.1.19"
2869 #define szOID_INFOSEC_mosaicKMandUpdSig     "2.16.840.1.101.2.1.1.20"
2870 #define szOID_INFOSEC_mosaicUpdateInteg     "2.16.840.1.101.2.1.1.21"
2871 #define szOID_COMMON_NAME                   "2.5.4.3"
2872 #define szOID_SUR_NAME                      "2.5.4.4"
2873 #define szOID_DEVICE_SERIAL_NUMBER          "2.5.4.5"
2874 #define szOID_COUNTRY_NAME                  "2.5.4.6"
2875 #define szOID_LOCALITY_NAME                 "2.5.4.7"
2876 #define szOID_STATE_OR_PROVINCE_NAME        "2.5.4.8"
2877 #define szOID_STREET_ADDRESS                "2.5.4.9"
2878 #define szOID_ORGANIZATION_NAME             "2.5.4.10"
2879 #define szOID_ORGANIZATIONAL_UNIT_NAME      "2.5.4.11"
2880 #define szOID_TITLE                         "2.5.4.12"
2881 #define szOID_DESCRIPTION                   "2.5.4.13"
2882 #define szOID_SEARCH_GUIDE                  "2.5.4.14"
2883 #define szOID_BUSINESS_CATEGORY             "2.5.4.15"
2884 #define szOID_POSTAL_ADDRESS                "2.5.4.16"
2885 #define szOID_POSTAL_CODE                   "2.5.4.17"
2886 #define szOID_POST_OFFICE_BOX               "2.5.4.18"
2887 #define szOID_PHYSICAL_DELIVERY_OFFICE_NAME "2.5.4.19"
2888 #define szOID_TELEPHONE_NUMBER              "2.5.4.20"
2889 #define szOID_TELEX_NUMBER                  "2.5.4.21"
2890 #define szOID_TELETEXT_TERMINAL_IDENTIFIER  "2.5.4.22"
2891 #define szOID_FACSIMILE_TELEPHONE_NUMBER    "2.5.4.23"
2892 #define szOID_X21_ADDRESS                   "2.5.4.24"
2893 #define szOID_INTERNATIONAL_ISDN_NUMBER     "2.5.4.25"
2894 #define szOID_REGISTERED_ADDRESS            "2.5.4.26"
2895 #define szOID_DESTINATION_INDICATOR         "2.5.4.27"
2896 #define szOID_PREFERRED_DELIVERY_METHOD     "2.5.4.28"
2897 #define szOID_PRESENTATION_ADDRESS          "2.5.4.29"
2898 #define szOID_SUPPORTED_APPLICATION_CONTEXT "2.5.4.30"
2899 #define szOID_MEMBER                        "2.5.4.31"
2900 #define szOID_OWNER                         "2.5.4.32"
2901 #define szOID_ROLE_OCCUPANT                 "2.5.4.33"
2902 #define szOID_SEE_ALSO                      "2.5.4.34"
2903 #define szOID_USER_PASSWORD                 "2.5.4.35"
2904 #define szOID_USER_CERTIFICATE              "2.5.4.36"
2905 #define szOID_CA_CERTIFICATE                "2.5.4.37"
2906 #define szOID_AUTHORITY_REVOCATION_LIST     "2.5.4.38"
2907 #define szOID_CERTIFICATE_REVOCATION_LIST   "2.5.4.39"
2908 #define szOID_CROSS_CERTIFICATE_PAIR        "2.5.4.40"
2909 #define szOID_GIVEN_NAME                    "2.5.4.42"
2910 #define szOID_INITIALS                      "2.5.4.43"
2911 #define szOID_DN_QUALIFIER                  "2.5.4.46"
2912 #define szOID_AUTHORITY_KEY_IDENTIFIER      "2.5.29.1"
2913 #define szOID_KEY_ATTRIBUTES                "2.5.29.2"
2914 #define szOID_CERT_POLICIES_95              "2.5.29.3"
2915 #define szOID_KEY_USAGE_RESTRICTION         "2.5.29.4"
2916 #define szOID_LEGACY_POLICY_MAPPINGS        "2.5.29.5"
2917 #define szOID_SUBJECT_ALT_NAME              "2.5.29.7"
2918 #define szOID_ISSUER_ALT_NAME               "2.5.29.8"
2919 #define szOID_SUBJECT_DIR_ATTRS             "2.5.29.9"
2920 #define szOID_BASIC_CONSTRAINTS             "2.5.29.10"
2921 #define szOID_SUBJECT_KEY_IDENTIFIER        "2.5.29.14"
2922 #define szOID_KEY_USAGE                     "2.5.29.15"
2923 #define szOID_PRIVATEKEY_USAGE_PERIOD       "2.5.29.16"
2924 #define szOID_SUBJECT_ALT_NAME2             "2.5.29.17"
2925 #define szOID_ISSUER_ALT_NAME2              "2.5.29.18"
2926 #define szOID_BASIC_CONSTRAINTS2            "2.5.29.19"
2927 #define szOID_CRL_NUMBER                    "2.5.29.20"
2928 #define szOID_CRL_REASON_CODE               "2.5.29.21"
2929 #define szOID_REASON_CODE_HOLD              "2.5.29.23"
2930 #define szOID_DELTA_CRL_INDICATOR           "2.5.29.27"
2931 #define szOID_ISSUING_DIST_POINT            "2.5.29.28"
2932 #define szOID_NAME_CONSTRAINTS              "2.5.29.30"
2933 #define szOID_CRL_DIST_POINTS               "2.5.29.31"
2934 #define szOID_CERT_POLICIES                 "2.5.29.32"
2935 #define szOID_ANY_CERT_POLICY               "2.5.29.32.0"
2936 #define szOID_POLICY_MAPPINGS               "2.5.29.33"
2937 #define szOID_AUTHORITY_KEY_IDENTIFIER2     "2.5.29.35"
2938 #define szOID_POLICY_CONSTRAINTS            "2.5.29.36"
2939 #define szOID_ENHANCED_KEY_USAGE            "2.5.29.37"
2940 #define szOID_FRESHEST_CRL                  "2.5.29.46"
2941 #define szOID_DOMAIN_COMPONENT              "0.9.2342.19200300.100.1.25"
2942 #define szOID_PKCS_12_FRIENDLY_NAME_ATTR     "1.2.840.113549.1.9.20"
2943 #define szOID_PKCS_12_LOCAL_KEY_ID           "1.2.840.113549.1.9.21"
2944 #define szOID_CERT_EXTENSIONS                "1.3.6.1.4.1.311.2.1.14"
2945 #define szOID_NEXT_UPDATE_LOCATION           "1.3.6.1.4.1.311.10.2"
2946 #define szOID_KP_CTL_USAGE_SIGNING           "1.3.6.1.4.1.311.10.3.1"
2947 #define szOID_KP_TIME_STAMP_SIGNING          "1.3.6.1.4.1.311.10.3.2"
2948 #ifndef szOID_SERVER_GATED_CRYPTO
2949 #define szOID_SERVER_GATED_CRYPTO            "1.3.6.1.4.1.311.10.3.3"
2950 #endif
2951 #ifndef szOID_SGC_NETSCAPE
2952 #define szOID_SGC_NETSCAPE                   "2.16.840.1.113730.4.1"
2953 #endif
2954 #define szOID_KP_EFS                         "1.3.6.1.4.1.311.10.3.4"
2955 #define szOID_EFS_RECOVERY                   "1.3.6.1.4.1.311.10.3.4.1"
2956 #define szOID_WHQL_CRYPTO                    "1.3.6.1.4.1.311.10.3.5"
2957 #define szOID_NT5_CRYPTO                     "1.3.6.1.4.1.311.10.3.6"
2958 #define szOID_OEM_WHQL_CRYPTO                "1.3.6.1.4.1.311.10.3.7"
2959 #define szOID_EMBEDDED_NT_CRYPTO             "1.3.6.1.4.1.311.10.3.8"
2960 #define szOID_ROOT_LIST_SIGNER               "1.3.6.1.4.1.311.10.3.9"
2961 #define szOID_KP_QUALIFIED_SUBORDINATION     "1.3.6.1.4.1.311.10.3.10"
2962 #define szOID_KP_KEY_RECOVERY                "1.3.6.1.4.1.311.10.3.11"
2963 #define szOID_KP_DOCUMENT_SIGNING            "1.3.6.1.4.1.311.10.3.12"
2964 #define szOID_KP_LIFETIME_SIGNING            "1.3.6.1.4.1.311.10.3.13"
2965 #define szOID_KP_MOBILE_DEVICE_SOFTWARE      "1.3.6.1.4.1.311.10.3.14"
2966 #define szOID_YESNO_TRUST_ATTR               "1.3.6.1.4.1.311.10.4.1"
2967 #ifndef szOID_DRM
2968 #define szOID_DRM                            "1.3.6.1.4.1.311.10.5.1"
2969 #endif
2970 #ifndef szOID_DRM_INDIVIDUALIZATION
2971 #define szOID_DRM_INDIVIDUALIZATION          "1.3.6.1.4.1.311.10.5.2"
2972 #endif
2973 #ifndef szOID_LICENSES
2974 #define szOID_LICENSES                       "1.3.6.1.4.1.311.10.6.1"
2975 #endif
2976 #ifndef szOID_LICENSE_SERVER
2977 #define szOID_LICENSE_SERVER                 "1.3.6.1.4.1.311.10.6.2"
2978 #endif
2979 #define szOID_REMOVE_CERTIFICATE             "1.3.6.1.4.1.311.10.8.1"
2980 #define szOID_CROSS_CERT_DIST_POINTS         "1.3.6.1.4.1.311.10.9.1"
2981 #define szOID_CTL                            "1.3.6.1.4.1.311.10.1"
2982 #define szOID_SORTED_CTL                     "1.3.6.1.4.1.311.10.1.1"
2983 #define szOID_ANY_APPLICATION_POLICY         "1.3.6.1.4.1.311.10.12.1"
2984 #define szOID_RENEWAL_CERTIFICATE            "1.3.6.1.4.1.311.13.1"
2985 #define szOID_ENROLLMENT_NAME_VALUE_PAIR     "1.3.6.1.4.1.311.13.2.1"
2986 #define szOID_ENROLLMENT_CSP_PROVIDER        "1.3.6.1.4.1.311.13.2.2"
2987 #define szOID_OS_VERSION                     "1.3.6.1.4.1.311.13.2.3"
2988 #define szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR "1.3.6.1.4.1.311.17.1"
2989 #define szOID_LOCAL_MACHINE_KEYSET           "1.3.6.1.4.1.311.17.2"
2990 #define szOID_AUTO_ENROLL_CTL_USAGE          "1.3.6.1.4.1.311.20.1"
2991 #define szOID_ENROLL_CERTTYPE_EXTENSION      "1.3.6.1.4.1.311.20.2"
2992 #define szOID_ENROLLMENT_AGENT               "1.3.6.1.4.1.311.20.2.1"
2993 #define szOID_KP_SMARTCARD_LOGON             "1.3.6.1.4.1.311.20.2.2"
2994 #define szOID_CERT_MANIFOLD                  "1.3.6.1.4.1.311.20.3"
2995 #ifndef szOID_CERTSRV_CA_VERSION
2996 #define szOID_CERTSRV_CA_VERSION             "1.3.6.1.4.1.311.21.1"
2997 #endif
2998 #define szOID_CERTSRV_PREVIOUS_CERT_HASH     "1.3.6.1.4.1.311.21.2"
2999 #define szOID_CRL_VIRTUAL_BASE               "1.3.6.1.4.1.311.21.3"
3000 #define szOID_CRL_NEXT_PUBLISH               "1.3.6.1.4.1.311.21.4"
3001 #define szOID_KP_CA_EXCHANGE                 "1.3.6.1.4.1.311.21.5"
3002 #define szOID_KP_KEY_RECOVERY_AGENT          "1.3.6.1.4.1.311.21.6"
3003 #define szOID_CERTIFICATE_TEMPLATE           "1.3.6.1.4.1.311.21.7"
3004 #define szOID_ENTERPRISE_OID_ROOT            "1.3.6.1.4.1.311.21.8"
3005 #define szOID_RDN_DUMMY_SIGNER               "1.3.6.1.4.1.311.21.9"
3006 #define szOID_APPLICATION_CERT_POLICIES      "1.3.6.1.4.1.311.21.10"
3007 #define szOID_APPLICATION_POLICY_MAPPINGS    "1.3.6.1.4.1.311.21.11"
3008 #define szOID_APPLICATION_POLICY_CONSTRAINTS "1.3.6.1.4.1.311.21.12"
3009 #define szOID_ARCHIVED_KEY_ATTR              "1.3.6.1.4.1.311.21.13"
3010 #define szOID_CRL_SELF_CDP                   "1.3.6.1.4.1.311.21.14"
3011 #define szOID_REQUIRE_CERT_CHAIN_POLICY      "1.3.6.1.4.1.311.21.15"
3012 #define szOID_ARCHIVED_KEY_CERT_HASH         "1.3.6.1.4.1.311.21.16"
3013 #define szOID_ISSUED_CERT_HASH               "1.3.6.1.4.1.311.21.17"
3014 #define szOID_DS_EMAIL_REPLICATION           "1.3.6.1.4.1.311.21.19"
3015 #define szOID_REQUEST_CLIENT_INFO            "1.3.6.1.4.1.311.21.20"
3016 #define szOID_ENCRYPTED_KEY_HASH             "1.3.6.1.4.1.311.21.21"
3017 #define szOID_CERTSRV_CROSSCA_VERSION        "1.3.6.1.4.1.311.21.22"
3018 #define szOID_KEYID_RDN                      "1.3.6.1.4.1.311.10.7.1"
3019 #define szOID_PKIX                           "1.3.6.1.5.5.7"
3020 #define szOID_PKIX_PE                        "1.3.6.1.5.5.7.1"
3021 #define szOID_AUTHORITY_INFO_ACCESS          "1.3.6.1.5.5.7.1.1"
3022 #define szOID_PKIX_POLICY_QUALIFIER_CPS      "1.3.6.1.5.5.7.2.1"
3023 #define szOID_PKIX_POLICY_QUALIFIER_USERNOTICE "1.3.6.1.5.5.7.2.2"
3024 #define szOID_PKIX_KP                        "1.3.6.1.5.5.7.3"
3025 #define szOID_PKIX_KP_SERVER_AUTH            "1.3.6.1.5.5.7.3.1"
3026 #define szOID_PKIX_KP_CLIENT_AUTH            "1.3.6.1.5.5.7.3.2"
3027 #define szOID_PKIX_KP_CODE_SIGNING           "1.3.6.1.5.5.7.3.3"
3028 #define szOID_PKIX_KP_EMAIL_PROTECTION       "1.3.6.1.5.5.7.3.4"
3029 #define szOID_PKIX_KP_IPSEC_END_SYSTEM       "1.3.6.1.5.5.7.3.5"
3030 #define szOID_PKIX_KP_IPSEC_TUNNEL           "1.3.6.1.5.5.7.3.6"
3031 #define szOID_PKIX_KP_IPSEC_USER             "1.3.6.1.5.5.7.3.7"
3032 #define szOID_PKIX_KP_TIMESTAMP_SIGNING      "1.3.6.1.5.5.7.3.8"
3033 #define szOID_PKIX_NO_SIGNATURE              "1.3.6.1.5.5.7.6.2"
3034 #define szOID_CMC                            "1.3.6.1.5.5.7.7"
3035 #define szOID_CMC_STATUS_INFO                "1.3.6.1.5.5.7.7.1"
3036 #define szOID_CMC_IDENTIFICATION             "1.3.6.1.5.5.7.7.2"
3037 #define szOID_CMC_IDENTITY_PROOF             "1.3.6.1.5.5.7.7.3"
3038 #define szOID_CMC_DATA_RETURN                "1.3.6.1.5.5.7.7.4"
3039 #define szOID_CMC_TRANSACTION_ID             "1.3.6.1.5.5.7.7.5"
3040 #define szOID_CMC_SENDER_NONCE               "1.3.6.1.5.5.7.7.6"
3041 #define szOID_CMC_RECIPIENT_NONCE            "1.3.6.1.5.5.7.7.7"
3042 #define szOID_CMC_ADD_EXTENSIONS             "1.3.6.1.5.5.7.7.8"
3043 #define szOID_CMC_ENCRYPTED_POP              "1.3.6.1.5.5.7.7.9"
3044 #define szOID_CMC_DECRYPTED_POP              "1.3.6.1.5.5.7.7.10"
3045 #define szOID_CMC_LRA_POP_WITNESS            "1.3.6.1.5.5.7.7.11"
3046 #define szOID_CMC_GET_CERT                   "1.3.6.1.5.5.7.7.15"
3047 #define szOID_CMC_GET_CRL                    "1.3.6.1.5.5.7.7.16"
3048 #define szOID_CMC_REVOKE_REQUEST             "1.3.6.1.5.5.7.7.17"
3049 #define szOID_CMC_REG_INFO                   "1.3.6.1.5.5.7.7.18"
3050 #define szOID_CMC_RESPONSE_INFO              "1.3.6.1.5.5.7.7.19"
3051 #define szOID_CMC_QUERY_PENDING              "1.3.6.1.5.5.7.7.21"
3052 #define szOID_CMC_ID_POP_LINK_RANDOM         "1.3.6.1.5.5.7.7.22"
3053 #define szOID_CMC_ID_POP_LINK_WITNESS        "1.3.6.1.5.5.7.7.23"
3054 #define szOID_CT_PKI_DATA                    "1.3.6.1.5.5.7.12.2"
3055 #define szOID_CT_PKI_RESPONSE                "1.3.6.1.5.5.7.12.3"
3056 #define szOID_PKIX_ACC_DESCR                 "1.3.6.1.5.5.7.48"
3057 #define szOID_PKIX_OCSP                      "1.3.6.1.5.5.7.48.1"
3058 #define szOID_PKIX_CA_ISSUERS                "1.3.6.1.5.5.7.48.2"
3059 #define szOID_IPSEC_KP_IKE_INTERMEDIATE      "1.3.6.1.5.5.8.2.2"
3060
3061 #ifndef szOID_SERIALIZED
3062 #define szOID_SERIALIZED                     "1.3.6.1.4.1.311.10.3.3.1"
3063 #endif
3064
3065 #define szOID_AUTO_ENROLL_CTL_USAGE          "1.3.6.1.4.1.311.20.1"
3066 #define szOID_ENROLL_CERTTYPE_EXTENSION      "1.3.6.1.4.1.311.20.2"
3067 #define szOID_ENROLLMENT_AGENT               "1.3.6.1.4.1.311.20.2.1"
3068 #ifndef szOID_KP_SMARTCARD_LOGON
3069 #define szOID_KP_SMARTCARD_LOGON             "1.3.6.1.4.1.311.20.2.2"
3070 #endif
3071 #ifndef szOID_NT_PRINCIPAL_NAME
3072 #define szOID_NT_PRINCIPAL_NAME              "1.3.6.1.4.1.311.20.2.3"
3073 #endif
3074 #define szOID_CERT_MANIFOLD                  "1.3.6.1.4.1.311.20.3"
3075
3076 #ifndef szOID_CERTSRV_CA_VERSION
3077 #define szOID_CERTSRV_CA_VERSION             "1.3.6.1.4.1.311.21.1"
3078 #endif
3079
3080 #ifndef szOID_PRODUCT_UPDATE
3081 #define szOID_PRODUCT_UPDATE                 "1.3.6.1.4.1.311.31.1"
3082 #endif
3083
3084 #define szOID_NETSCAPE                       "2.16.840.1.113730"
3085 #define szOID_NETSCAPE_CERT_EXTENSION        "2.16.840.1.113730.1"
3086 #define szOID_NETSCAPE_CERT_TYPE             "2.16.840.1.113730.1.1"
3087 #define szOID_NETSCAPE_BASE_URL              "2.16.840.1.113730.1.2"
3088 #define szOID_NETSCAPE_REVOCATION_URL        "2.16.840.1.113730.1.3"
3089 #define szOID_NETSCAPE_CA_REVOCATION_URL     "2.16.840.1.113730.1.4"
3090 #define szOID_NETSCAPE_CERT_RENEWAL_URL      "2.16.840.1.113730.1.7"
3091 #define szOID_NETSCAPE_CA_POLICY_URL         "2.16.840.1.113730.1.8"
3092 #define szOID_NETSCAPE_SSL_SERVER_NAME       "2.16.840.1.113730.1.12"
3093 #define szOID_NETSCAPE_COMMENT               "2.16.840.1.113730.1.13"
3094 #define szOID_NETSCAPE_DATA_TYPE             "2.16.840.1.113730.2"
3095 #define szOID_NETSCAPE_CERT_SEQUENCE         "2.16.840.1.113730.2.5"
3096
3097 /* Bits for szOID_NETSCAPE_CERT_TYPE */
3098 #define NETSCAPE_SSL_CLIENT_AUTH_CERT_TYPE 0x80
3099 #define NETSCAPE_SSL_SERVER_AUTH_CERT_TYPE 0x40
3100 #define NETSCAPE_SMIME_CERT_TYPE           0x20
3101 #define NETSCAPE_SIGN_CERT_TYPE            0x10
3102 #define NETSCAPE_SSL_CA_CERT_TYPE          0x04
3103 #define NETSCAPE_SMIME_CA_CERT_TYPE        0x02
3104 #define NETSCAPE_SIGN_CA_CERT_TYPE         0x01
3105
3106 #define CRYPT_ENCODE_DECODE_NONE             0
3107 #define X509_CERT                            ((LPCSTR)1)
3108 #define X509_CERT_TO_BE_SIGNED               ((LPCSTR)2)
3109 #define X509_CERT_CRL_TO_BE_SIGNED           ((LPCSTR)3)
3110 #define X509_CERT_REQUEST_TO_BE_SIGNED       ((LPCSTR)4)
3111 #define X509_EXTENSIONS                      ((LPCSTR)5)
3112 #define X509_NAME_VALUE                      ((LPCSTR)6)
3113 #define X509_ANY_STRING                      X509_NAME_VALUE
3114 #define X509_NAME                            ((LPCSTR)7)
3115 #define X509_PUBLIC_KEY_INFO                 ((LPCSTR)8)
3116 #define X509_AUTHORITY_KEY_ID                ((LPCSTR)9)
3117 #define X509_KEY_ATTRIBUTES                  ((LPCSTR)10)
3118 #define X509_KEY_USAGE_RESTRICTION           ((LPCSTR)11)
3119 #define X509_ALTERNATE_NAME                  ((LPCSTR)12)
3120 #define X509_BASIC_CONSTRAINTS               ((LPCSTR)13)
3121 #define X509_KEY_USAGE                       ((LPCSTR)14)
3122 #define X509_BASIC_CONSTRAINTS2              ((LPCSTR)15)
3123 #define X509_CERT_POLICIES                   ((LPCSTR)16)
3124 #define PKCS_UTC_TIME                        ((LPCSTR)17)
3125 #define PKCS_TIME_REQUEST                    ((LPCSTR)18)
3126 #define RSA_CSP_PUBLICKEYBLOB                ((LPCSTR)19)
3127 #define X509_UNICODE_NAME                    ((LPCSTR)20)
3128 #define X509_KEYGEN_REQUEST_TO_BE_SIGNED     ((LPCSTR)21)
3129 #define PKCS_ATTRIBUTE                       ((LPCSTR)22)
3130 #define PKCS_CONTENT_INFO_SEQUENCE_OF_ANY    ((LPCSTR)23)
3131 #define X509_UNICODE_NAME_VALUE              ((LPCSTR)24)
3132 #define X509_UNICODE_ANY_STRING              X509_UNICODE_NAME_VALUE
3133 #define X509_OCTET_STRING                    ((LPCSTR)25)
3134 #define X509_BITS                            ((LPCSTR)26)
3135 #define X509_INTEGER                         ((LPCSTR)27)
3136 #define X509_MULTI_BYTE_INTEGER              ((LPCSTR)28)
3137 #define X509_ENUMERATED                      ((LPCSTR)29)
3138 #define X509_CRL_REASON_CODE                 X509_ENUMERATED
3139 #define X509_CHOICE_OF_TIME                  ((LPCSTR)30)
3140 #define X509_AUTHORITY_KEY_ID2               ((LPCSTR)31)
3141 #define X509_AUTHORITY_INFO_ACCESS           ((LPCSTR)32)
3142 #define PKCS_CONTENT_INFO                    ((LPCSTR)33)
3143 #define X509_SEQUENCE_OF_ANY                 ((LPCSTR)34)
3144 #define X509_CRL_DIST_POINTS                 ((LPCSTR)35)
3145 #define X509_ENHANCED_KEY_USAGE              ((LPCSTR)36)
3146 #define PKCS_CTL                             ((LPCSTR)37)
3147 #define X509_MULTI_BYTE_UINT                 ((LPCSTR)38)
3148 #define X509_DSS_PUBLICKEY                   X509_MULTI_BYTE_UINT
3149 #define X509_DSS_PARAMETERS                  ((LPCSTR)39)
3150 #define X509_DSS_SIGNATURE                   ((LPCSTR)40)
3151 #define PKCS_RC2_CBC_PARAMETERS              ((LPCSTR)41)
3152 #define PKCS_SMIME_CAPABILITIES              ((LPCSTR)42)
3153 #define PKCS_RSA_PRIVATE_KEY                 ((LPCSTR)43)
3154 #define PKCS_PRIVATE_KEY_INFO                ((LPCSTR)44)
3155 #define PKCS_ENCRYPTED_PRIVATE_KEY_INFO      ((LPCSTR)45)
3156 #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46)
3157 #define X509_DH_PUBLICKEY                    X509_MULTI_BYTE_UINT
3158 #define X509_DH_PARAMETERS                   ((LPCSTR)47)
3159 #define PKCS_ATTRIBUTES                      ((LPCSTR)48)
3160 #define PKCS_SORTED_CTL                      ((LPCSTR)49)
3161 #define X942_DH_PARAMETERS                   ((LPCSTR)50)
3162 #define X509_BITS_WITHOUT_TRAILING_ZEROES    ((LPCSTR)51)
3163 #define X942_OTHER_INFO                      ((LPCSTR)52)
3164 #define X509_CERT_PAIR                       ((LPCSTR)53)
3165 #define X509_ISSUING_DIST_POINT              ((LPCSTR)54)
3166 #define X509_NAME_CONSTRAINTS                ((LPCSTR)55)
3167 #define X509_POLICY_MAPPINGS                 ((LPCSTR)56)
3168 #define X509_POLICY_CONSTRAINTS              ((LPCSTR)57)
3169 #define X509_CROSS_CERT_DIST_POINTS          ((LPCSTR)58)
3170 #define CMC_DATA                             ((LPCSTR)59)
3171 #define CMC_RESPONSE                         ((LPCSTR)60)
3172 #define CMC_STATUS                           ((LPCSTR)61)
3173 #define CMC_ADD_EXTENSIONS                   ((LPCSTR)62)
3174 #define CMC_ADD_ATTRIBUTES                   ((LPCSTR)63)
3175 #define X509_CERTIFICATE_TEMPLATE            ((LPCSTR)64)
3176 #define PKCS7_SIGNER_INFO                    ((LPCSTR)500)
3177 #define CMS_SIGNER_INFO                      ((LPCSTR)501)
3178
3179 /* encode/decode flags */
3180 #define CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG           0x00008
3181 #define CRYPT_ENCODE_ALLOC_FLAG                                0x08000
3182 #define CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG 0x10000
3183 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG \
3184  CERT_RDN_ENABLE_T61_UNICODE_FLAG
3185 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG \
3186  CERT_RDN_ENABLE_UTF8_UNICODE_FLAG
3187 #define CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG \
3188  CERT_RDN_DISABLE_CHECK_TYPE_FLAG
3189
3190 #define CRYPT_DECODE_NOCOPY_FLAG                               0x00001
3191 #define CRYPT_DECODE_TO_BE_SIGNED_FLAG                         0x00002
3192 #define CRYPT_DECODE_SHARE_OID_STRING_FLAG                     0x00004
3193 #define CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG           0x00008
3194 #define CRYPT_DECODE_ALLOC_FLAG                                0x08000
3195 #define CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG \
3196  CERT_RDN_DISABLE_IE4_UTF8_FLAG
3197
3198 #define CERT_STORE_SIGNATURE_FLAG     0x00000001
3199 #define CERT_STORE_TIME_VALIDITY_FLAG 0x00000002
3200 #define CERT_STORE_REVOCATION_FLAG    0x00000004
3201 #define CERT_STORE_NO_CRL_FLAG        0x00010000
3202 #define CERT_STORE_NO_ISSUER_FLAG     0x00020000
3203
3204 #define CERT_STORE_BASE_CRL_FLAG  0x00000100
3205 #define CERT_STORE_DELTA_CRL_FLAG 0x00000200
3206
3207 /* subject types for CryptVerifyCertificateSignatureEx */
3208 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB 1
3209 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT 2
3210 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL  3
3211
3212 /* issuer types for CryptVerifyCertificateSignatureEx */
3213 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY 1
3214 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT   2
3215 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN  3
3216 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL   4
3217
3218 #define CRYPT_GET_URL_FROM_PROPERTY         0x00000001
3219 #define CRYPT_GET_URL_FROM_EXTENSION        0x00000002
3220 #define CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE 0x00000004
3221 #define CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE   0x00000008
3222
3223 /* Certificate name string types and flags */
3224 #define CERT_SIMPLE_NAME_STR 1
3225 #define CERT_OID_NAME_STR    2
3226 #define CERT_X500_NAME_STR   3
3227 #define CERT_NAME_STR_SEMICOLON_FLAG           0x40000000
3228 #define CERT_NAME_STR_NO_PLUS_FLAG             0x20000000
3229 #define CERT_NAME_STR_NO_QUOTING_FLAG          0x10000000
3230 #define CERT_NAME_STR_CRLF_FLAG                0x08000000
3231 #define CERT_NAME_STR_COMMA_FLAG               0x04000000
3232 #define CERT_NAME_STR_REVERSE_FLAG             0x02000000
3233 #define CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG 0x00040000
3234 #define CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG  0x00020000
3235 #define CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG    0x00010000
3236
3237 #define CERT_NAME_EMAIL_TYPE            1
3238 #define CERT_NAME_RDN_TYPE              2
3239 #define CERT_NAME_ATTR_TYPE             3
3240 #define CERT_NAME_SIMPLE_DISPLAY_TYPE   4
3241 #define CERT_NAME_FRIENDLY_DISPLAY_TYPE 5
3242 #define CERT_NAME_DNS_TYPE              6
3243 #define CERT_NAME_URL_TYPE              7
3244 #define CERT_NAME_UPN_TYPE              8
3245
3246 #define CERT_NAME_ISSUER_FLAG           0x00000001
3247 #define CERT_NAME_DISABLE_IE4_UTF8_FLAG 0x00010000
3248
3249 /* CryptFormatObject flags */
3250 #define CRYPT_FORMAT_STR_MULTI_LINE 0x0001
3251 #define CRYPT_FORMAT_STR_NO_HEX     0x0010
3252
3253 #define CRYPT_FORMAT_SIMPLE        0x0001
3254 #define CRYPT_FORMAT_X509          0x0002
3255 #define CRYPT_FORMAT_OID           0x0004
3256 #define CRYPT_FORMAT_RDN_SEMICOLON 0x0100
3257 #define CRYPT_FORMAT_RDN_CRLF      0x0200
3258 #define CRYPT_FORMAT_RDN_UNQUOTE   0x0400
3259 #define CRYPT_FORMAT_RDN_REVERSE   0x0800
3260
3261 #define CRYPT_FORMAT_COMMA     0x1000
3262 #define CRYPT_FORMAT_SEMICOLON CRYPT_FORMAT_RDN_SEMICOLON
3263 #define CRYPT_FORMAT_CRLF      CRYPT_FORMAT_RDN_CRLF
3264
3265 /* CryptQueryObject types and flags */
3266 #define CERT_QUERY_OBJECT_FILE 1
3267 #define CERT_QUERY_OBJECT_BLOB 2
3268
3269 #define CERT_QUERY_CONTENT_CERT               1
3270 #define CERT_QUERY_CONTENT_CTL                2
3271 #define CERT_QUERY_CONTENT_CRL                3
3272 #define CERT_QUERY_CONTENT_SERIALIZED_STORE   4
3273 #define CERT_QUERY_CONTENT_SERIALIZED_CERT    5
3274 #define CERT_QUERY_CONTENT_SERIALIZED_CTL     6
3275 #define CERT_QUERY_CONTENT_SERIALIZED_CRL     7
3276 #define CERT_QUERY_CONTENT_PKCS7_SIGNED       8
3277 #define CERT_QUERY_CONTENT_PKCS7_UNSIGNED     9
3278 #define CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED 10
3279 #define CERT_QUERY_CONTENT_PKCS10             11
3280 #define CERT_QUERY_CONTENT_PFX                12
3281 #define CERT_QUERY_CONTENT_CERT_PAIR          13
3282
3283 #define CERT_QUERY_CONTENT_FLAG_CERT      (1 << CERT_QUERY_CONTENT_CERT)
3284 #define CERT_QUERY_CONTENT_FLAG_CTL       (1 << CERT_QUERY_CONTENT_CTL)
3285 #define CERT_QUERY_CONTENT_FLAG_CRL       (1 << CERT_QUERY_CONTENT_CRL)
3286 #define CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE \
3287  (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
3288 #define CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT \
3289  (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
3290 #define CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL \
3291  (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
3292 #define CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL \
3293  (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
3294 #define CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED \
3295  (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
3296 #define CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED \
3297  (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
3298 #define CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED \
3299  (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
3300 #define CERT_QUERY_CONTENT_FLAG_PKCS10    (1 << CERT_QUERY_CONTENT_PKCS10)
3301 #define CERT_QUERY_CONTENT_FLAG_PFX       (1 << CERT_QUERY_CONTENT_PFX)
3302 #define CERT_QUERY_CONTENT_FLAG_CERT_PAIR (1 << CERT_QUERY_CONTENT_CERT_PAIR)
3303
3304 #define CERT_QUERY_CONTENT_FLAG_ALL \
3305  CERT_QUERY_CONTENT_FLAG_CERT | \
3306  CERT_QUERY_CONTENT_FLAG_CTL | \
3307  CERT_QUERY_CONTENT_FLAG_CRL | \
3308  CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | \
3309  CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | \
3310  CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL | \
3311  CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL | \
3312  CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | \
3313  CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED | \
3314  CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED | \
3315  CERT_QUERY_CONTENT_FLAG_PKCS10 | \
3316  CERT_QUERY_CONTENT_FLAG_PFX | \
3317  CERT_QUERY_CONTENT_FLAG_CERT_PAIR
3318
3319 #define CERT_QUERY_FORMAT_BINARY                1
3320 #define CERT_QUERY_FORMAT_BASE64_ENCODED        2
3321 #define CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED 3
3322
3323 #define CERT_QUERY_FORMAT_FLAG_BINARY (1 << CERT_QUERY_FORMAT_BINARY)
3324 #define CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED \
3325  (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
3326 #define CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED \
3327  (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
3328
3329 #define CERT_QUERY_FORMAT_FLAG_ALL \
3330  CERT_QUERY_FORMAT_FLAG_BINARY | \
3331  CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | \
3332  CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED \
3333
3334 #define CERT_SET_KEY_PROV_HANDLE_PROP_ID 0x00000001
3335 #define CERT_SET_KEY_CONTEXT_PROP_ID     0x00000001
3336
3337 #define CERT_CREATE_SELFSIGN_NO_SIGN     1
3338 #define CERT_CREATE_SELFSIGN_NO_KEY_INFO 2
3339
3340 /* flags for CryptAcquireCertificatePrivateKey */
3341 #define CRYPT_ACQUIRE_CACHE_FLAG         0x00000001
3342 #define CRYPT_ACQUIRE_USE_PROV_INFO_FLAG 0x00000002
3343 #define CRYPT_ACQUIRE_COMPARE_KEY_FLAG   0x00000004
3344 #define CRYPT_ACQUIRE_SILENT_FLAG        0x00000040
3345
3346 /* flags for CryptFindCertificateKeyProvInfo */
3347 #define CRYPT_FIND_USER_KEYSET_FLAG    0x00000001
3348 #define CRYPT_FIND_MACHINE_KEYSET_FLAG 0x00000002
3349 #define CRYPT_FIND_SILENT_KEYSET_FLAG  0x00000040
3350
3351 /* Chain engines and chains */
3352 typedef HANDLE HCERTCHAINENGINE;
3353 #define HCCE_CURRENT_USER  ((HCERTCHAINENGINE)NULL)
3354 #define HCCE_LOCAL_MACHINE ((HCERTCHAINENGINE)1)
3355
3356 #define CERT_CHAIN_CACHE_END_CERT           0x00000001
3357 #define CERT_CHAIN_THREAD_STORE_SYNC        0x00000002
3358 #define CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL 0x00000004
3359 #define CERT_CHAIN_USE_LOCAL_MACHINE_STORE  0x00000008
3360 #define CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE 0x00000010
3361 #define CERT_CHAIN_ENABLE_SHARE_STORE       0x00000020
3362
3363 typedef struct _CERT_CHAIN_ENGINE_CONFIG
3364 {
3365     DWORD       cbSize;
3366     HCERTSTORE  hRestrictedRoot;
3367     HCERTSTORE  hRestrictedTrust;
3368     HCERTSTORE  hRestrictedOther;
3369     DWORD       cAdditionalStore;
3370     HCERTSTORE *rghAdditionalStore;
3371     DWORD       dwFlags;
3372     DWORD       dwUrlRetrievalTimeout;
3373     DWORD       MaximumCachedCertificates;
3374     DWORD       CycleDetectionModulus;
3375 } CERT_CHAIN_ENGINE_CONFIG, *PCERT_CHAIN_ENGINE_CONFIG;
3376
3377 /* message-related definitions */
3378
3379 typedef BOOL (WINAPI *PFN_CMSG_STREAM_OUTPUT)(const void *pvArg, BYTE *pbData,
3380  DWORD cbData, BOOL fFinal);
3381
3382 #define CMSG_INDEFINITE_LENGTH 0xffffffff
3383
3384 typedef struct _CMSG_STREAM_INFO
3385 {
3386     DWORD cbContent;
3387     PFN_CMSG_STREAM_OUTPUT pfnStreamOutput;
3388     void *pvArg;
3389 } CMSG_STREAM_INFO, *PCMSG_STREAM_INFO;
3390
3391 typedef struct _CERT_ISSUER_SERIAL_NUMBER
3392 {
3393     CERT_NAME_BLOB     Issuer;
3394     CRYPT_INTEGER_BLOB SerialNumber;
3395 } CERT_ISSUER_SERIAL_NUMBER, *PCERT_ISSUER_SERIAL_NUMBER;
3396
3397 typedef struct _CERT_ID
3398 {
3399     DWORD dwIdChoice;
3400     union {
3401         CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber;
3402         CRYPT_HASH_BLOB           KeyId;
3403         CRYPT_HASH_BLOB           HashId;
3404     } DUMMYUNIONNAME;
3405 } CERT_ID, *PCERT_ID;
3406
3407 #define CERT_ID_ISSUER_SERIAL_NUMBER 1
3408 #define CERT_ID_KEY_IDENTIFIER       2
3409 #define CERT_ID_SHA1_HASH            3
3410
3411 #undef CMSG_DATA /* may be defined by sys/socket.h */
3412 #define CMSG_DATA                 1
3413 #define CMSG_SIGNED               2
3414 #define CMSG_ENVELOPED            3
3415 #define CMSG_SIGNED_AND_ENVELOPED 4
3416 #define CMSG_HASHED               5
3417 #define CMSG_ENCRYPTED            6
3418
3419 #define CMSG_ALL_FLAGS                 ~0U
3420 #define CMSG_DATA_FLAG                 (1 << CMSG_DATA)
3421 #define CMSG_SIGNED_FLAG               (1 << CMSG_SIGNED)
3422 #define CMSG_ENVELOPED_FLAG            (1 << CMSG_ENVELOPED)
3423 #define CMSG_SIGNED_AND_ENVELOPED_FLAG (1 << CMSG_SIGNED_AND_ENVELOPED)
3424 #define CMSG_ENCRYPTED_FLAG            (1 << CMSG_ENCRYPTED)
3425
3426 typedef struct _CMSG_SIGNER_ENCODE_INFO
3427 {
3428     DWORD                      cbSize;
3429     PCERT_INFO                 pCertInfo;
3430     HCRYPTPROV                 hCryptProv;
3431     DWORD                      dwKeySpec;
3432     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
3433     void                      *pvHashAuxInfo;
3434     DWORD                      cAuthAttr;
3435     PCRYPT_ATTRIBUTE           rgAuthAttr;
3436     DWORD                      cUnauthAttr;
3437     PCRYPT_ATTRIBUTE           rgUnauthAttr;
3438 #ifdef CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS
3439     CERT_ID                    SignerId;
3440     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
3441     void                      *pvHashEncryptionAuxInfo;
3442 #endif
3443 } CMSG_SIGNER_ENCODE_INFO, *PCMSG_SIGNER_ENCODE_INFO;
3444
3445 typedef struct _CMSG_SIGNED_ENCODE_INFO
3446 {
3447     DWORD                    cbSize;
3448     DWORD                    cSigners;
3449     PCMSG_SIGNER_ENCODE_INFO rgSigners;
3450     DWORD                    cCertEncoded;
3451     PCERT_BLOB               rgCertEncoded;
3452     DWORD                    cCrlEncoded;
3453     PCRL_BLOB                rgCrlEncoded;
3454 #ifdef CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS
3455     DWORD                    cAttrCertEncoded;
3456     PCERT_BLOB               rgAttrCertEncoded;
3457 #endif
3458 } CMSG_SIGNED_ENCODE_INFO, *PCMSG_SIGNED_ENCODE_INFO;
3459
3460 typedef struct _CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO
3461 {
3462     DWORD                      cbSize;
3463     CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
3464     void                      *pvKeyEncryptionAuxInfo;
3465     HCRYPTPROV_LEGACY          hCryptProv;
3466     CRYPT_BIT_BLOB             RecipientPublicKey;
3467     CERT_ID                    RecipientId;
3468 } CMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO, *PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO;
3469
3470 typedef struct _CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO
3471 {
3472     DWORD                       cbSize;
3473     CRYPT_BIT_BLOB              RecipientPublicKey;
3474     CERT_ID                     RecipientId;
3475     FILETIME                    Date;
3476     PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr;
3477 } CMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO,
3478  *PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO;
3479
3480 typedef struct _CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO
3481 {
3482     DWORD                      cbSize;
3483     CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
3484     void                      *pvKeyEncryptionAuxInfo;
3485     CRYPT_ALGORITHM_IDENTIFIER KeyWrapAlgorithm;
3486     void                      *pvKeyWrapAuxInfo;
3487     HCRYPTPROV_LEGACY          hCryptProv;
3488     DWORD                      dwKeySpec;
3489     DWORD                      dwKeyChoice;
3490     union {
3491         PCRYPT_ALGORITHM_IDENTIFIER pEphemeralAlgorithm;
3492         PCERT_ID                    pSenderId;
3493     } DUMMYUNIONNAME;
3494     CRYPT_DATA_BLOB            UserKeyingMaterial;
3495     DWORD                      cRecipientEncryptedKeys;
3496     PCMSG_RECIPIENT_ENCRYPTED_KEY_ENCODE_INFO *rgpRecipientEncryptedKeys;
3497 } CMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO, *PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO;
3498
3499 #define CMSG_KEY_AGREE_EPHEMERAL_KEY_CHOICE 1
3500 #define CMSG_KEY_AGREE_STATIC_KEY_CHOICE    2
3501
3502 typedef struct _CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO
3503 {
3504     DWORD                       cbSize;
3505     CRYPT_ALGORITHM_IDENTIFIER  KeyEncryptionAlgorithm;
3506     void                       *pvKeyEncryptionAuxInfo;
3507     HCRYPTPROV                  hCryptProv;
3508     DWORD                       dwKeyChoice;
3509     union {
3510         HCRYPTKEY hKeyEncryptionKey;
3511         void     *pvKeyEncryptionKey;
3512     } DUMMYUNIONNAME;
3513     CRYPT_DATA_BLOB             KeyId;
3514     FILETIME                    Date;
3515     PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr;
3516 } CMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO, *PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO;
3517
3518 #define CMSG_MAIL_LIST_HANDLE_KEY_CHOICE 1
3519
3520 typedef struct _CMSG_RECIPIENT_ENCODE_INFO
3521 {
3522     DWORD dwRecipientChoice;
3523     union {
3524         PCMSG_KEY_TRANS_RECIPIENT_ENCODE_INFO pKeyTrans;
3525         PCMSG_KEY_AGREE_RECIPIENT_ENCODE_INFO pKeyAgree;
3526         PCMSG_MAIL_LIST_RECIPIENT_ENCODE_INFO pMailList;
3527     } DUMMYUNIONNAME;
3528 } CMSG_RECIPIENT_ENCODE_INFO, *PCMSG_RECIPIENT_ENCODE_INFO;
3529
3530 #define CMSG_KEY_TRANS_RECIPIENT 1
3531 #define CMSG_KEY_AGREE_RECIPIENT 2
3532 #define CMSG_MAIL_LIST_RECIPIENT 3
3533
3534 typedef struct _CMSG_ENVELOPED_ENCODE_INFO
3535 {
3536     DWORD                       cbSize;
3537     HCRYPTPROV_LEGACY           hCryptProv;
3538     CRYPT_ALGORITHM_IDENTIFIER  ContentEncryptionAlgorithm;
3539     void                       *pvEncryptionAuxInfo;
3540     DWORD                       cRecipients;
3541     PCERT_INFO                 *rgpRecipientCert;
3542 #ifdef CMSG_ENVELOPED_ENCODE_INFO_HAS_CMS_FIELDS
3543     PCMSG_RECIPIENT_ENCODE_INFO rgCmsRecipients;
3544     DWORD                       cCertEncoded;
3545     PCERT_BLOB                  rgCertEncoded;
3546     DWORD                       cCrlEncoded;
3547     PCRL_BLOB                   rgCrlEncoded;
3548     DWORD                       cAttrCertEncoded;
3549     PCERT_BLOB                  rgAttrCertEncoded;
3550     DWORD                       cUnprotectedAttr;
3551     PCRYPT_ATTRIBUTE            rgUnprotectedAttr;
3552 #endif
3553 } CMSG_ENVELOPED_ENCODE_INFO, *PCMSG_ENVELOPED_ENCODE_INFO;
3554
3555 typedef struct _CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO
3556 {
3557     DWORD                      cbSize;
3558     CMSG_SIGNED_ENCODE_INFO    SignedInfo;
3559     CMSG_ENVELOPED_ENCODE_INFO EnvelopedInfo;
3560 } CMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO,
3561  *PCMSG_SIGNED_AND_ENVELOPED_ENCODE_INFO;
3562
3563 typedef struct _CMSG_HASHED_ENCODE_INFO
3564 {
3565     DWORD                      cbSize;
3566     HCRYPTPROV_LEGACY          hCryptProv;
3567     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
3568     void                      *pvHashAuxInfo;
3569 } CMSG_HASHED_ENCODE_INFO, *PCMSG_HASHED_ENCODE_INFO;
3570
3571 typedef struct _CMSG_ENCRYPTED_ENCODE_INFO
3572 {
3573     DWORD                      cbSize;
3574     CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
3575     void                      *pvEncryptionAuxInfo;
3576 } CMSG_ENCRYPTED_ENCODE_INFO, *PCMSG_ENCRYPTED_ENCODE_INFO;
3577
3578 #define CMSG_BARE_CONTENT_FLAG             0x00000001
3579 #define CMSG_LENGTH_ONLY_FLAG              0x00000002
3580 #define CMSG_DETACHED_FLAG                 0x00000004
3581 #define CMSG_AUTHENTICATED_ATTRIBUTES_FLAG 0x00000008
3582 #define CMSG_CONTENTS_OCTETS_FLAG          0x00000010
3583 #define CMSG_MAX_LENGTH_FLAG               0x00000020
3584 #define CMSG_CMS_ENCAPSULATED_CONTENT_FLAG 0x00000040
3585 #define CMSG_CRYPT_RELEASE_CONTEXT_FLAG    0x00008000
3586
3587 #define CMSG_CTRL_VERIFY_SIGNATURE       1
3588 #define CMSG_CTRL_DECRYPT                2
3589 #define CMSG_CTRL_VERIFY_HASH            5
3590 #define CMSG_CTRL_ADD_SIGNER             6
3591 #define CMSG_CTRL_DEL_SIGNER             7
3592 #define CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR 8
3593 #define CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR 9
3594 #define CMSG_CTRL_ADD_CERT               10
3595 #define CMSG_CTRL_DEL_CERT               11
3596 #define CMSG_CTRL_ADD_CRL                12
3597 #define CMSG_CTRL_DEL_CRL                13
3598 #define CMSG_CTRL_ADD_ATTR_CERT          14
3599 #define CMSG_CTRL_DEL_ATTR_CERT          15
3600 #define CMSG_CTRL_KEY_TRANS_DECRYPT      16
3601 #define CMSG_CTRL_KEY_AGREE_DECRYPT      17
3602 #define CMSG_CTRL_MAIL_LIST_DECRYPT      18
3603 #define CMSG_CTRL_VERIFY_SIGNATURE_EX    19
3604 #define CMSG_CTRL_ADD_CMS_SIGNER_INFO    20
3605
3606 typedef struct _CMSG_CTRL_DECRYPT_PARA
3607 {
3608     DWORD      cbSize;
3609     HCRYPTPROV hCryptProv;
3610     DWORD      dwKeySpec;
3611     DWORD      dwRecipientIndex;
3612 } CMSG_CTRL_DECRYPT_PARA, *PCMSG_CTRL_DECRYPT_PARA;
3613
3614 typedef struct _CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA
3615 {
3616     DWORD           cbSize;
3617     DWORD           dwSignerIndex;
3618     CRYPT_DATA_BLOB blob;
3619 } CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA,
3620  *PCMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR_PARA;
3621
3622 typedef struct _CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA
3623 {
3624     DWORD           cbSize;
3625     DWORD           dwSignerIndex;
3626     DWORD           dwUnauthAttrIndex;
3627 } CMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA,
3628  *PCMSG_CTRL_DEL_SIGNER_UNAUTH_ATTR_PARA;
3629
3630 typedef struct _CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA {
3631     DWORD      cbSize;
3632     HCRYPTPROV hCryptProv;
3633     DWORD      dwSignerIndex;
3634     DWORD      dwSignerType;
3635     void      *pvSigner;
3636 } CMSG_CTRL_VERIFY_SIGNATURE_EX_PARA, *PCMSG_CTRL_VERIFY_SIGNATURE_EX_PARA;
3637
3638 #define CMSG_VERIFY_SIGNER_PUBKEY 1
3639 #define CMSG_VERIFY_SIGNER_CERT   2
3640 #define CMSG_VERIFY_SIGNER_CHAIN  3
3641 #define CMSG_VERIFY_SIGNER_NULL   4
3642
3643 #define CMSG_TYPE_PARAM                  1
3644 #define CMSG_CONTENT_PARAM               2
3645 #define CMSG_BARE_CONTENT_PARAM          3
3646 #define CMSG_INNER_CONTENT_TYPE_PARAM    4
3647 #define CMSG_SIGNER_COUNT_PARAM          5
3648 #define CMSG_SIGNER_INFO_PARAM           6
3649 #define CMSG_SIGNER_CERT_INFO_PARAM      7
3650 #define CMSG_SIGNER_HASH_ALGORITHM_PARAM 8
3651 #define CMSG_SIGNER_AUTH_ATTR_PARAM      9
3652 #define CMSG_SIGNER_UNAUTH_ATTR_PARAM    10
3653 #define CMSG_CERT_COUNT_PARAM            11
3654 #define CMSG_CERT_PARAM                  12
3655 #define CMSG_CRL_COUNT_PARAM             13
3656 #define CMSG_CRL_PARAM                   14
3657 #define CMSG_ENVELOPE_ALGORITHM_PARAM    15
3658 #define CMSG_RECIPIENT_COUNT_PARAM       17
3659 #define CMSG_RECIPIENT_INDEX_PARAM       18
3660 #define CMSG_RECIPIENT_INFO_PARAM        19
3661 #define CMSG_HASH_ALGORITHM_PARAM        20
3662 #define CMSG_HASH_DATA_PARAM             21
3663 #define CMSG_COMPUTED_HASH_PARAM         22
3664 #define CMSG_ENCRYPT_PARAM               26
3665 #define CMSG_ENCRYPTED_DIGEST            27
3666 #define CMSG_ENCODED_SIGNER              28
3667 #define CMSG_ENCODED_MESSAGE             29
3668 #define CMSG_VERSION_PARAM               30
3669 #define CMSG_ATTR_CERT_COUNT_PARAM       31
3670 #define CMSG_ATTR_CERT_PARAM             32
3671 #define CMSG_CMS_RECIPIENT_COUNT_PARAM   33
3672 #define CMSG_CMS_RECIPIENT_INDEX_PARAM   34
3673 #define CMSG_CMS_RECIPIENT_ENCRYPTED_KEY_INDEX_PARAM 35
3674 #define CMSG_CMS_RECIPIENT_INFO_PARAM    36
3675 #define CMSG_UNPROTECTED_ATTR_PARAM      37
3676 #define CMSG_SIGNER_CERT_ID_PARAM        38
3677 #define CMSG_CMS_SIGNER_INFO_PARAM       39
3678
3679 typedef struct _CMSG_CMS_SIGNER_INFO {
3680     DWORD                      dwVersion;
3681     CERT_ID                    SignerId;
3682     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
3683     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
3684     CRYPT_DATA_BLOB            EncryptedHash;
3685     CRYPT_ATTRIBUTES           AuthAttrs;
3686     CRYPT_ATTRIBUTES           UnauthAttrs;
3687 } CMSG_CMS_SIGNER_INFO, *PCMSG_CMS_SIGNER_INFO;
3688
3689 typedef CRYPT_ATTRIBUTES CMSG_ATTR, *PCMSG_ATTR;
3690
3691 #define CMSG_SIGNED_DATA_V1               1
3692 #define CMSG_SIGNED_DATA_V3               3
3693 #define CMSG_SIGNED_DATA_PKCS_1_5_VERSION CMSG_SIGNED_DATA_V1
3694 #define CMSG_SIGNED_DATA_CMS_VERSION      CMSG_SIGNED_DATA_V3
3695
3696 #define CMSG_SIGNER_INFO_V1               1
3697 #define CMSG_SIGNER_INFO_V3               3
3698 #define CMSG_SIGNER_INFO_PKCS_1_5_VERSION CMSG_SIGNER_INFO_V1
3699 #define CMSG_SIGNER_INFO_CMS_VERSION      CMSG_SIGNER_INFO_V3
3700
3701 #define CMSG_HASHED_DATA_V0               0
3702 #define CMSG_HASHED_DATA_V2               2
3703 #define CMSG_HASHED_DATA_PKCS_1_5_VERSION CMSG_HASHED_DATA_V0
3704 #define CMSG_HASHED_DATA_CMS_VERSION      CMSG_HASHED_DATA_V2
3705
3706 #define CMSG_ENVELOPED_DATA_V0               0
3707 #define CMSG_ENVELOPED_DATA_V2               2
3708 #define CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION CMSG_ENVELOPED_DATA_V0
3709 #define CMSG_ENVELOPED_DATA_CMS_VERSION      CMSG_ENVELOPED_DATA_V2
3710
3711 typedef struct _CMSG_KEY_TRANS_RECIPIENT_INFO {
3712     DWORD                      dwVersion;
3713     CERT_ID                    RecipientId;
3714     CRYPT_ALGORITHM_IDENTIFIER KeyEncryptionAlgorithm;
3715     CRYPT_DATA_BLOB            EncryptedKey;
3716 } CMSG_KEY_TRANS_RECIPIENT_INFO, *PCMSG_KEY_TRANS_RECIPIENT_INFO;
3717
3718 typedef struct _CMSG_RECIPIENT_ENCRYPTED_KEY_INFO {
3719     CERT_ID                     RecipientId;
3720     CRYPT_DATA_BLOB             EncryptedKey;
3721     PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr;
3722 } CMSG_RECIPIENT_ENCRYPTED_KEY_INFO, *PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO;
3723
3724 typedef struct _CMSG_KEY_AGREE_RECIPIENT_INFO {
3725     DWORD                               dwVersion;
3726     DWORD                               dwOriginatorChoice;
3727     union {
3728         CERT_ID              OriginatorCertId;
3729         CERT_PUBLIC_KEY_INFO OriginatorPublicKeyInfo;
3730     } DUMMYUNIONNAME;
3731     CRYPT_ALGORITHM_IDENTIFIER          UserKeyingMaterial;
3732     DWORD                               cRecipientEncryptedKeys;
3733     PCMSG_RECIPIENT_ENCRYPTED_KEY_INFO *rgpRecipientEncryptedKeys;
3734 } CMSG_KEY_AGREE_RECIPIENT_INFO, *PCMSG_KEY_AGREE_RECIPIENT_INFO;
3735
3736 #define CMSG_KEY_AGREE_ORIGINATOR_CERT       1
3737 #define CMSG_KEY_AGREE_ORIGINATOR_PUBLIC_KEY 2
3738
3739 typedef struct _CMSG_MAIL_LIST_RECIPIENT_INFO {
3740     DWORD                       dwVersion;
3741     CRYPT_DATA_BLOB             KeyId;
3742     CRYPT_ALGORITHM_IDENTIFIER  KeyEncryptionAlgorithm;
3743     CRYPT_DATA_BLOB             EncryptedKey;
3744     FILETIME                    Date;
3745     PCRYPT_ATTRIBUTE_TYPE_VALUE pOtherAttr;
3746 } CMSG_MAIL_LIST_RECIPIENT_INFO, *PCMSG_MAIL_LIST_RECIPIENT_INFO;
3747
3748 typedef struct _CMSG_CMS_RECIPIENT_INFO {
3749     DWORD dwRecipientChoice;
3750     union {
3751         PCMSG_KEY_TRANS_RECIPIENT_INFO pKeyTrans;
3752         PCMSG_KEY_AGREE_RECIPIENT_INFO pKeyAgree;
3753         PCMSG_MAIL_LIST_RECIPIENT_INFO pMailList;
3754     } DUMMYUNIONNAME;
3755 } CMSG_CMS_RECIPIENT_INFO, *PCMSG_CMS_RECIPIENT_INFO;
3756
3757 #define CMSG_ENVELOPED_RECIPIENT_V0     0
3758 #define CMSG_ENVELOPED_RECIPIENT_V2     2
3759 #define CMSG_ENVELOPED_RECIPIENT_V3     3
3760 #define CMSG_ENVELOPED_RECIPIENT_V4     4
3761 #define CMSG_KEY_TRANS_PKCS_1_5_VERSION CMSG_ENVELOPED_RECIPIENT_V0
3762 #define CMSG_KEY_TRANS_CMS_VERSION      CMSG_ENVELOPED_RECIPIENT_V2
3763 #define CMSG_KEY_AGREE_VERSION          CMSG_ENVELOPED_RECIPIENT_V3
3764 #define CMSG_MAIL_LIST_VERSION          CMSG_ENVELOPED_RECIPIENT_V4
3765
3766 /* CryptMsgGetAndVerifySigner flags */
3767 #define CMSG_TRUSTED_SIGNER_FLAG   0x1
3768 #define CMSG_SIGNER_ONLY_FLAG      0x2
3769 #define CMSG_USE_SIGNER_INDEX_FLAG 0x4
3770
3771 /* CryptMsgSignCTL flags */
3772 #define CMSG_CMS_ENCAPSULATED_CTL_FLAG 0x00008000
3773
3774 /* CryptMsgEncodeAndSignCTL flags */
3775 #define CMSG_ENCODED_SORTED_CTL_FLAG               0x1
3776 #define CMSG_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG 0x2
3777
3778 /* PFXImportCertStore flags */
3779 #define CRYPT_USER_KEYSET           0x00001000
3780 #define PKCS12_IMPORT_RESERVED_MASK 0xffff0000
3781 /* PFXExportCertStore flags */
3782 #define REPORT_NO_PRIVATE_KEY                 0x00000001
3783 #define REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY 0x00000002
3784 #define EXPORT_PRIVATE_KEYS                   0x00000004
3785 #define PKCS12_EXPORT_RESERVED_MASK           0xffff0000
3786
3787 /* function declarations */
3788 /* advapi32.dll */
3789 WINADVAPI BOOL WINAPI CryptAcquireContextA(HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD);
3790 WINADVAPI BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *, LPCWSTR, LPCWSTR, DWORD, DWORD);
3791 #define               CryptAcquireContext WINELIB_NAME_AW(CryptAcquireContext)
3792 WINADVAPI BOOL WINAPI CryptGenRandom (HCRYPTPROV, DWORD, BYTE *);
3793 WINADVAPI BOOL WINAPI CryptContextAddRef (HCRYPTPROV, DWORD *, DWORD);
3794 WINADVAPI BOOL WINAPI CryptCreateHash (HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH *);
3795 WINADVAPI BOOL WINAPI CryptDecrypt (HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *);
3796 WINADVAPI BOOL WINAPI CryptDeriveKey (HCRYPTPROV, ALG_ID, HCRYPTHASH, DWORD, HCRYPTKEY *);
3797 WINADVAPI BOOL WINAPI CryptDestroyHash (HCRYPTHASH);
3798 WINADVAPI BOOL WINAPI CryptDestroyKey (HCRYPTKEY);
3799 WINADVAPI BOOL WINAPI CryptDuplicateKey (HCRYPTKEY, DWORD *, DWORD, HCRYPTKEY *);
3800 WINADVAPI BOOL WINAPI CryptDuplicateHash (HCRYPTHASH, DWORD *, DWORD, HCRYPTHASH *);
3801 WINADVAPI BOOL WINAPI CryptEncrypt (HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD);
3802 WINADVAPI BOOL WINAPI CryptEnumProvidersA (DWORD, DWORD *, DWORD, DWORD *, LPSTR, DWORD *);
3803 WINADVAPI BOOL WINAPI CryptEnumProvidersW (DWORD, DWORD *, DWORD, DWORD *, LPWSTR, DWORD *);
3804 #define               CryptEnumProviders WINELIB_NAME_AW(CryptEnumProviders)
3805 WINADVAPI BOOL WINAPI CryptEnumProviderTypesA (DWORD, DWORD *, DWORD, DWORD *, LPSTR, DWORD *);
3806 WINADVAPI BOOL WINAPI CryptEnumProviderTypesW (DWORD, DWORD *, DWORD, DWORD *, LPWSTR, DWORD *);
3807 #define               CryptEnumProviderTypes WINELIB_NAME_AW(CryptEnumProviderTypes)
3808 WINADVAPI BOOL WINAPI CryptExportKey (HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, BYTE *, DWORD *);
3809 WINADVAPI BOOL WINAPI CryptGenKey (HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY *);
3810 WINADVAPI BOOL WINAPI CryptGetKeyParam (HCRYPTKEY, DWORD, BYTE *, DWORD *, DWORD);
3811 WINADVAPI BOOL WINAPI CryptGetHashParam (HCRYPTHASH, DWORD, BYTE *, DWORD *, DWORD);
3812 WINADVAPI BOOL WINAPI CryptGetProvParam (HCRYPTPROV, DWORD, BYTE *, DWORD *, DWORD);
3813 WINADVAPI BOOL WINAPI CryptGetDefaultProviderA (DWORD, DWORD *, DWORD, LPSTR, DWORD *);
3814 WINADVAPI BOOL WINAPI CryptGetDefaultProviderW (DWORD, DWORD *, DWORD, LPWSTR, DWORD *);
3815 #define               CryptGetDefaultProvider WINELIB_NAME_AW(CryptGetDefaultProvider)
3816 WINADVAPI BOOL WINAPI CryptGetUserKey (HCRYPTPROV, DWORD, HCRYPTKEY *);
3817 WINADVAPI BOOL WINAPI CryptHashData (HCRYPTHASH, CONST BYTE *, DWORD, DWORD);
3818 WINADVAPI BOOL WINAPI CryptHashSessionKey (HCRYPTHASH, HCRYPTKEY, DWORD);
3819 WINADVAPI BOOL WINAPI CryptImportKey (HCRYPTPROV, CONST BYTE *, DWORD, HCRYPTKEY, DWORD, HCRYPTKEY *);
3820 WINADVAPI BOOL WINAPI CryptReleaseContext (HCRYPTPROV, ULONG_PTR);
3821 WINADVAPI BOOL WINAPI CryptSetHashParam (HCRYPTHASH, DWORD, CONST BYTE *, DWORD);
3822 WINADVAPI BOOL WINAPI CryptSetKeyParam (HCRYPTKEY, DWORD, CONST BYTE *, DWORD);
3823 WINADVAPI BOOL WINAPI CryptSetProviderA (LPCSTR, DWORD);
3824 WINADVAPI BOOL WINAPI CryptSetProviderW (LPCWSTR, DWORD);
3825 #define               CryptSetProvider WINELIB_NAME_AW(CryptSetProvider)
3826 WINADVAPI BOOL WINAPI CryptSetProviderExA (LPCSTR, DWORD, DWORD *, DWORD);
3827 WINADVAPI BOOL WINAPI CryptSetProviderExW (LPCWSTR, DWORD, DWORD *, DWORD);
3828 #define               CryptSetProviderEx WINELIB_NAME_AW(CryptSetProviderEx)
3829 WINADVAPI BOOL WINAPI CryptSetProvParam (HCRYPTPROV, DWORD, CONST BYTE *, DWORD);
3830 WINADVAPI BOOL WINAPI CryptSignHashA (HCRYPTHASH, DWORD, LPCSTR, DWORD, BYTE *, DWORD *);
3831 WINADVAPI BOOL WINAPI CryptSignHashW (HCRYPTHASH, DWORD, LPCWSTR, DWORD, BYTE *, DWORD *);
3832 #define               CryptSignHash WINELIB_NAME_AW(CryptSignHash)
3833 WINADVAPI BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCSTR, DWORD);
3834 WINADVAPI BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCWSTR, DWORD);
3835 #define               CryptVerifySignature WINELIB_NAME_AW(CryptVerifySignature)
3836
3837 /* crypt32.dll functions */
3838 LPVOID WINAPI CryptMemAlloc(ULONG cbSize) __WINE_ALLOC_SIZE(1);
3839 LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize) __WINE_ALLOC_SIZE(2);
3840 VOID   WINAPI CryptMemFree(LPVOID pv);
3841
3842 BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary,
3843  DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString);
3844 BOOL WINAPI CryptBinaryToStringW(const BYTE *pbBinary,
3845  DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString);
3846 #define CryptBinaryToString WINELIB_NAME_AW(CryptBinaryToString)
3847
3848 BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString,
3849  DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
3850  DWORD *pdwSkip, DWORD *pdwFlags);
3851 BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString,
3852  DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
3853  DWORD *pdwSkip, DWORD *pdwFlags);
3854 #define CryptStringToBinary WINELIB_NAME_AW(CryptStringToBinary)
3855
3856 BOOL WINAPI CryptCreateAsyncHandle(DWORD dwFlags, PHCRYPTASYNC phAsync);
3857 BOOL WINAPI CryptSetAsyncParam(HCRYPTASYNC hAsync, LPSTR pszParamOid,
3858  LPVOID pvParam, PFN_CRYPT_ASYNC_PARAM_FREE_FUNC pfnFree);
3859 BOOL WINAPI CryptGetAsyncParam(HCRYPTASYNC hAsync, LPSTR pszParamOid,
3860  LPVOID *ppvParam, PFN_CRYPT_ASYNC_PARAM_FREE_FUNC *ppfnFree);
3861 BOOL WINAPI CryptCloseAsyncHandle(HCRYPTASYNC hAsync);
3862
3863 BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD,LPCSTR,DWORD,LPCWSTR);
3864 BOOL WINAPI CryptRegisterOIDFunction(DWORD,LPCSTR,LPCSTR,LPCWSTR,LPCSTR);
3865 BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
3866                                      LPCSTR pszOID, LPCWSTR szValueName, DWORD *pdwValueType,
3867                                      BYTE *pbValueData, DWORD *pcbValueData);
3868 BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
3869                                      LPCSTR pszOID, LPCWSTR pwszValueName, DWORD dwValueType,
3870                                      const BYTE *pbValueData, DWORD cbValueData);
3871 BOOL WINAPI CryptUnregisterDefaultOIDFunction(DWORD,LPCSTR,LPCWSTR);
3872 BOOL WINAPI CryptUnregisterOIDFunction(DWORD,LPCSTR,LPCSTR);
3873 BOOL WINAPI CryptEnumOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
3874  LPCSTR pszOID, DWORD dwFlags, void *pvArg,
3875  PFN_CRYPT_ENUM_OID_FUNC pfnEnumOIDFunc);
3876 HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR,DWORD);
3877 BOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet,
3878  DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList);
3879 BOOL WINAPI CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,
3880  DWORD dwEncodingType, LPCWSTR pwszDll, DWORD dwFlags, void **ppvFuncAddr,
3881  HCRYPTOIDFUNCADDR *phFuncAddr);
3882 BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,
3883  DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr,
3884  HCRYPTOIDFUNCADDR *phFuncAddr);
3885 BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,
3886  DWORD dwFlags);
3887 BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule,
3888  DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry,
3889  const CRYPT_OID_FUNC_ENTRY rgFuncEntry[], DWORD dwFlags);
3890 BOOL WINAPI CryptInstallDefaultContext(HCRYPTPROV hCryptProv,
3891  DWORD dwDefaultType, const void *pvDefaultPara, DWORD dwFlags,
3892  void *pvReserved, HCRYPTDEFAULTCONTEXT *phDefaultContext);
3893 BOOL WINAPI CryptUninstallDefaultContext(HCRYPTDEFAULTCONTEXT hDefaultContext,
3894  DWORD dwFlags, void *pvReserved);
3895
3896 BOOL WINAPI CryptEnumOIDInfo(DWORD dwGroupId, DWORD dwFlags, void *pvArg,
3897  PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo);
3898 PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
3899  DWORD dwGroupId);
3900 BOOL WINAPI CryptRegisterOIDInfo(PCCRYPT_OID_INFO pInfo, DWORD dwFlags);
3901 BOOL WINAPI CryptUnregisterOIDInfo(PCCRYPT_OID_INFO pInfo);
3902
3903 LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName);
3904
3905 LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId);
3906 DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId);
3907
3908 /* cert store functions */
3909 HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwEncodingType,
3910  HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara);
3911
3912 HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv,
3913  LPCSTR szSubSystemProtocol);
3914 HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv,
3915  LPCWSTR szSubSystemProtocol);
3916 #define CertOpenSystemStore WINELIB_NAME_AW(CertOpenSystemStore)
3917
3918 PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore,
3919  PCCERT_CONTEXT pPrev);
3920
3921 PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore,
3922  PCCRL_CONTEXT pPrev);
3923
3924 PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(HCERTSTORE hCertStore,
3925  PCCTL_CONTEXT pPrev);
3926
3927 BOOL WINAPI CertEnumSystemStoreLocation(DWORD dwFlags, void *pvArg,
3928  PFN_CERT_ENUM_SYSTEM_STORE_LOCATION pfnEnum);
3929
3930 BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
3931  void *pvArg, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum);
3932
3933 BOOL WINAPI CertEnumPhysicalStore(const void *pvSystemStore, DWORD dwFlags,
3934  void *pvArg, PFN_CERT_ENUM_PHYSICAL_STORE pfnEnum);
3935
3936 BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType,
3937              DWORD dwSaveAs, DWORD dwSaveTo, void* pvSaveToPara, DWORD dwFlags);
3938
3939 BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore,
3940  HCERTSTORE hSiblingStore, DWORD dwUpdateFlags, DWORD dwPriority);
3941
3942 void WINAPI CertRemoveStoreFromCollection(HCERTSTORE hCollectionStore,
3943  HCERTSTORE hSiblingStore);
3944
3945 BOOL WINAPI CertCreateCertificateChainEngine(PCERT_CHAIN_ENGINE_CONFIG pConfig,
3946  HCERTCHAINENGINE *phChainEngine);
3947
3948 BOOL WINAPI CertResyncCertificateChainEngine(HCERTCHAINENGINE hChainEngine);
3949
3950 VOID WINAPI CertFreeCertificateChainEngine(HCERTCHAINENGINE hChainEngine);
3951
3952 BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine,
3953  PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore,
3954  PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved,
3955  PCCERT_CHAIN_CONTEXT *ppChainContext);
3956
3957 PCCERT_CHAIN_CONTEXT WINAPI CertDuplicateCertificateChain(
3958  PCCERT_CHAIN_CONTEXT pChainContext);
3959
3960 VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext);
3961
3962 PCCERT_CHAIN_CONTEXT WINAPI CertFindChainInStore(HCERTSTORE hCertStore,
3963  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
3964  const void *pvFindPara, PCCERT_CHAIN_CONTEXT pPrevChainContext);
3965
3966 BOOL WINAPI CertVerifyCertificateChainPolicy(LPCSTR szPolicyOID,
3967  PCCERT_CHAIN_CONTEXT pChainContext, PCERT_CHAIN_POLICY_PARA pPolicyPara,
3968  PCERT_CHAIN_POLICY_STATUS pPolicyStatus);
3969
3970 DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,
3971  DWORD dwPropId);
3972
3973 BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
3974  DWORD dwPropId, void *pvData, DWORD *pcbData);
3975
3976 BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
3977  DWORD dwPropId, DWORD dwFlags, const void *pvData);
3978
3979 DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
3980  DWORD dwPropId);
3981
3982 BOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
3983  DWORD dwPropId, void *pvData, DWORD *pcbData);
3984
3985 BOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
3986  DWORD dwPropId, DWORD dwFlags, const void *pvData);
3987
3988 DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
3989  DWORD dwPropId);
3990
3991 BOOL WINAPI CertEnumSubjectInSortedCTL(PCCTL_CONTEXT pCTLContext,
3992  void **ppvNextSubject, PCRYPT_DER_BLOB pSubjectIdentifier,
3993  PCRYPT_DER_BLOB pEncodedAttributes);
3994
3995 BOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
3996  DWORD dwPropId, void *pvData, DWORD *pcbData);
3997
3998 BOOL WINAPI CertSetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
3999  DWORD dwPropId, DWORD dwFlags, const void *pvData);
4000
4001 BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId,
4002  void *pvData, DWORD *pcbData);
4003
4004 BOOL WINAPI CertSetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId,
4005  DWORD dwFlags, const void *pvData);
4006
4007 BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags,
4008  DWORD dwCtrlType, void const *pvCtrlPara);
4009
4010 HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore);
4011
4012 BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags );
4013
4014 BOOL WINAPI CertFreeCertificateContext( PCCERT_CONTEXT pCertContext );
4015
4016 BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext );
4017
4018 BOOL WINAPI CertFreeCTLContext( PCCTL_CONTEXT pCtlContext );
4019
4020 BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,
4021  PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition,
4022  PCCERT_CONTEXT *ppStoreContext);
4023
4024 BOOL WINAPI CertAddCRLContextToStore( HCERTSTORE hCertStore,
4025  PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition,
4026  PCCRL_CONTEXT *ppStoreContext );
4027
4028 BOOL WINAPI CertAddCTLContextToStore( HCERTSTORE hCertStore,
4029  PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
4030  PCCTL_CONTEXT *ppStoreContext );
4031
4032 BOOL WINAPI CertAddCertificateLinkToStore(HCERTSTORE hCertStore,
4033  PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition,
4034  PCCERT_CONTEXT *ppStoreContext);
4035
4036 BOOL WINAPI CertAddCRLLinkToStore(HCERTSTORE hCertStore,
4037  PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition,
4038  PCCRL_CONTEXT *ppStoreContext);
4039
4040 BOOL WINAPI CertAddCTLLinkToStore(HCERTSTORE hCertStore,
4041  PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
4042  PCCTL_CONTEXT *ppStoreContext);
4043
4044 BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore,
4045  DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded,
4046  DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext);
4047
4048 BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore,
4049  DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded,
4050  DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext);
4051
4052 BOOL WINAPI CertAddEncodedCTLToStore(HCERTSTORE hCertStore,
4053  DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded,
4054  DWORD dwAddDisposition, PCCTL_CONTEXT *ppCtlContext);
4055
4056 BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,
4057  const BYTE *pbElement, DWORD cbElement, DWORD dwAddDisposition, DWORD dwFlags,
4058  DWORD dwContextTypeFlags, DWORD *pdwContentType, const void **ppvContext);
4059
4060 BOOL WINAPI CertCompareCertificate(DWORD dwCertEncodingType,
4061  PCERT_INFO pCertId1, PCERT_INFO pCertId2);
4062 BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType,
4063  PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2);
4064 BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1,
4065  PCRYPT_INTEGER_BLOB pInt2);
4066 BOOL WINAPI CertComparePublicKeyInfo(DWORD dwCertEncodingType,
4067  PCERT_PUBLIC_KEY_INFO pPublicKey1, PCERT_PUBLIC_KEY_INFO pPublicKey2);
4068 DWORD WINAPI CertGetPublicKeyLength(DWORD dwCertEncodingType,
4069  PCERT_PUBLIC_KEY_INFO pPublicKey);
4070
4071 const void * WINAPI CertCreateContext(DWORD dwContextType, DWORD dwEncodingType,
4072  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
4073  PCERT_CREATE_CONTEXT_PARA pCreatePara);
4074
4075 PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
4076  const BYTE *pbCertEncoded, DWORD cbCertEncoded);
4077
4078 PCCRL_CONTEXT WINAPI CertCreateCRLContext( DWORD dwCertEncodingType,
4079   const BYTE* pbCrlEncoded, DWORD cbCrlEncoded);
4080
4081 PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType,
4082  const BYTE *pbCtlEncoded, DWORD cbCtlEncoded);
4083
4084 PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hProv,
4085  PCERT_NAME_BLOB pSubjectIssuerBlob, DWORD dwFlags,
4086  PCRYPT_KEY_PROV_INFO pKeyProvInfo,
4087  PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, PSYSTEMTIME pStartTime,
4088  PSYSTEMTIME pEndTime, PCERT_EXTENSIONS pExtensions);
4089
4090 BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext);
4091
4092 BOOL WINAPI CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext);
4093
4094 BOOL WINAPI CertDeleteCTLFromStore(PCCTL_CONTEXT pCtlContext);
4095
4096 PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
4097  PCCERT_CONTEXT pCertContext);
4098
4099 PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext);
4100
4101 PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext);
4102
4103 PCCERT_CONTEXT WINAPI CertFindCertificateInStore( HCERTSTORE hCertStore,
4104  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
4105  const void *pvFindPara, PCCERT_CONTEXT pPrevCertContext );
4106
4107 PCCRL_CONTEXT WINAPI CertFindCRLInStore(HCERTSTORE hCertStore,
4108  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
4109  const void *pvFindPara, PCCRL_CONTEXT pPrevCrlContext);
4110
4111 PCCTL_CONTEXT WINAPI CertFindCTLInStore(HCERTSTORE hCertStore,
4112  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
4113  const void *pvFindPara, PCCTL_CONTEXT pPrevCtlContext);
4114
4115 PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore,
4116  PCCERT_CONTEXT pSubjectContext, PCCERT_CONTEXT pPrevIssuerContext,
4117  DWORD *pdwFlags);
4118
4119 PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(HCERTSTORE hCertStore,
4120  DWORD dwCertEncodingType, PCERT_INFO pCertId);
4121
4122 PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore,
4123  PCCERT_CONTEXT pIssuerContext, PCCRL_CONTEXT pPrevCrlContext, DWORD *pdwFlags);
4124
4125 BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
4126  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
4127
4128 BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
4129  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
4130
4131 BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
4132  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
4133
4134 BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags,
4135  PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage);
4136 BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext,
4137  PCERT_ENHKEY_USAGE pUsage);
4138 BOOL WINAPI CertAddEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext,
4139  LPCSTR pszUsageIdentifer);
4140 BOOL WINAPI CertRemoveEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext,
4141  LPCSTR pszUsageIdentifer);
4142 BOOL WINAPI CertGetValidUsages(DWORD cCerts, PCCERT_CONTEXT *rghCerts,
4143  int *cNumOIDs, LPSTR *rghOIDs, DWORD *pcbOIDs);
4144
4145 BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType,
4146  const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded);
4147 BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
4148  const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara,
4149  void *pvEncoded, DWORD *pcbEncoded);
4150
4151 BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType,
4152  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo,
4153  DWORD *pcbStructInfo);
4154 BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
4155  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
4156  PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo);
4157
4158 BOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType, DWORD dwFormatType,
4159  DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
4160  const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat);
4161
4162 BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid,
4163  DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash,
4164  DWORD *pcbComputedHash);
4165
4166 BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid,
4167  DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo,
4168  BYTE *pbComputedHash, DWORD *pcbComputedHash);
4169
4170 BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType,
4171  const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash,
4172  DWORD *pcbComputedHash);
4173
4174 BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void* pvObject,
4175  DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags,
4176  DWORD dwFlags, DWORD* pdwMsgAndCertEncodingType, DWORD* pdwContentType,
4177  DWORD* pdwFormatType, HCERTSTORE* phCertStore, HCRYPTMSG* phMsg,
4178  const void** ppvContext);
4179
4180 BOOL WINAPI CryptSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec,
4181  DWORD dwCertEncodingType, const BYTE *pbEncodedToBeSigned,
4182  DWORD cbEncodedToBeSigned, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
4183  const void *pvHashAuxInfo, BYTE *pbSignature, DWORD *pcbSignature);
4184
4185 BOOL WINAPI CryptSignAndEncodeCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv,
4186  DWORD dwKeySpec, DWORD dwCertEncodingType, LPCSTR lpszStructType,
4187  const void *pvStructInfo, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
4188  const void *pvHashAuxInfo, BYTE *pbEncoded, DWORD *pcbEncoded);
4189
4190 BOOL WINAPI CryptVerifyCertificateSignature(HCRYPTPROV_LEGACY hCryptProv,
4191  DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
4192  PCERT_PUBLIC_KEY_INFO pPublicKey);
4193
4194 BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv,
4195  DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject,
4196  DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved);
4197
4198 PCRYPT_ATTRIBUTE WINAPI CertFindAttribute(LPCSTR pszObjId, DWORD cAttr,
4199  CRYPT_ATTRIBUTE rgAttr[]);
4200 PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions,
4201  CERT_EXTENSION rgExtensions[]);
4202 PCERT_RDN_ATTR WINAPI CertFindRDNAttr(LPCSTR pszObjId, PCERT_NAME_INFO pName);
4203
4204 BOOL WINAPI CertFindSubjectInSortedCTL(PCRYPT_DATA_BLOB pSubjectIdentifier,
4205  PCCTL_CONTEXT pCtlContext, DWORD dwFlags, void *pvReserved,
4206  PCRYPT_DER_BLOB pEncodedAttributes);
4207
4208 BOOL WINAPI CertIsRDNAttrsInCertificateName(DWORD dwCertEncodingType,
4209  DWORD dwFlags, PCERT_NAME_BLOB pCertName, PCERT_RDN pRDN);
4210
4211 BOOL WINAPI CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert,
4212  PCCRL_CONTEXT pCrl, DWORD dwFlags, void *pvReserved);
4213 BOOL WINAPI CertFindCertificateInCRL(PCCERT_CONTEXT pCert,
4214  PCCRL_CONTEXT pCrlContext, DWORD dwFlags, void *pvReserved,
4215  PCRL_ENTRY *ppCrlEntry);
4216 BOOL WINAPI CertVerifyCRLRevocation(DWORD dwCertEncodingType,
4217  PCERT_INFO pCertId, DWORD cCrlInfo, PCRL_INFO rgpCrlInfo[]);
4218
4219 BOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject,
4220  PCCERT_CONTEXT pIssuer, DWORD *pdwFlags);
4221
4222 LONG WINAPI CertVerifyCRLTimeValidity(LPFILETIME pTimeToVerify,
4223  PCRL_INFO pCrlInfo);
4224 LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify,
4225  PCERT_INFO pCertInfo);
4226 BOOL WINAPI CertVerifyValidityNesting(PCERT_INFO pSubjectInfo,
4227  PCERT_INFO pIssuerInfo);
4228
4229 BOOL WINAPI CertVerifyCTLUsage(DWORD dwEncodingType, DWORD dwSubjectType,
4230  void *pvSubject, PCTL_USAGE pSubjectUsage, DWORD dwFlags,
4231  PCTL_VERIFY_USAGE_PARA pVerifyUsagePara,
4232  PCTL_VERIFY_USAGE_STATUS pVerifyUsageStatus);
4233
4234 BOOL WINAPI CertVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType,
4235  DWORD cContext, PVOID rgpvContext[], DWORD dwFlags,
4236  PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus);
4237
4238 BOOL WINAPI CryptExportPublicKeyInfo(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec,
4239  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo);
4240 BOOL WINAPI CryptExportPublicKeyInfoEx(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec,
4241  DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags,
4242  void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo);
4243 BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv,
4244  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey);
4245 BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv,
4246  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg,
4247  DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey);
4248
4249 BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
4250  DWORD dwFlags, void *pvReserved, HCRYPTPROV_OR_NCRYPT_KEY_HANDLE *phCryptProv, DWORD *pdwKeySpec,
4251  BOOL *pfCallerFreeProv);
4252
4253 BOOL WINAPI CryptFindCertificateKeyProvInfo(PCCERT_CONTEXT pCert,
4254  DWORD dwFlags, void *pvReserved);
4255
4256 BOOL WINAPI CryptProtectData( DATA_BLOB* pDataIn, LPCWSTR szDataDescr,
4257  DATA_BLOB* pOptionalEntropy, PVOID pvReserved,
4258  CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut );
4259
4260 BOOL WINAPI CryptUnprotectData( DATA_BLOB* pDataIn, LPWSTR* ppszDataDescr,
4261  DATA_BLOB* pOptionalEntropy, PVOID pvReserved,
4262  CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut );
4263
4264 DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType,
4265  DWORD dwFlags, void *pvTypePara, LPSTR pszNameString, DWORD cchNameString);
4266 DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
4267  DWORD dwFlags, void *pvTypePara, LPWSTR pszNameString, DWORD cchNameString);
4268 #define CertGetNameString WINELIB_NAME_AW(CertGetNameString)
4269
4270 DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
4271  LPSTR psz, DWORD csz);
4272 DWORD WINAPI CertRDNValueToStrW(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
4273  LPWSTR psz, DWORD csz);
4274 #define CertRDNValueToStr WINELIB_NAME_AW(CertRDNValueToStr)
4275
4276 DWORD WINAPI CertNameToStrA(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
4277  DWORD dwStrType, LPSTR psz, DWORD csz);
4278 DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
4279  DWORD dwStrType, LPWSTR psz, DWORD csz);
4280 #define CertNameToStr WINELIB_NAME_AW(CertNameToStr)
4281
4282 BOOL WINAPI CertStrToNameA(DWORD dwCertEncodingType, LPCSTR pszX500,
4283  DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
4284  LPCSTR *ppszError);
4285 BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
4286  DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
4287  LPCWSTR *ppszError);
4288 #define CertStrToName WINELIB_NAME_AW(CertStrToName)
4289
4290 DWORD WINAPI CryptMsgCalculateEncodedLength(DWORD dwMsgEncodingType,
4291  DWORD dwFlags, DWORD dwMsgType, const void *pvMsgEncodeInfo,
4292  LPSTR pszInnerContentObjID, DWORD cbData);
4293
4294 BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg);
4295
4296 BOOL WINAPI CryptMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags,
4297  DWORD dwCtrlType, const void *pvCtrlPara);
4298
4299 BOOL WINAPI CryptMsgCountersign(HCRYPTMSG hCryptMsg, DWORD dwIndex,
4300  DWORD dwCountersigners, PCMSG_SIGNER_ENCODE_INFO rgCountersigners);
4301
4302 BOOL WINAPI CryptMsgCountersignEncoded(DWORD dwEncodingType, PBYTE pbSignerInfo,
4303  DWORD cbSignerInfo, DWORD cCountersigners,
4304  PCMSG_SIGNER_ENCODE_INFO rgCountersigners, PBYTE pbCountersignature,
4305  PDWORD pcbCountersignature);
4306
4307 HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg);
4308
4309 BOOL WINAPI CryptMsgEncodeAndSignCTL(DWORD dwMsgEncodingType,
4310  PCTL_INFO pCtlInfo, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags,
4311  BYTE *pbEncoded, DWORD *pcbEncoded);
4312
4313 BOOL WINAPI CryptMsgGetAndVerifySigner(HCRYPTMSG hCryptMsg, DWORD cSignerStore,
4314  HCERTSTORE *rghSignerStore, DWORD dwFlags, PCCERT_CONTEXT *ppSigner,
4315  DWORD *pdwSignerIndex);
4316
4317 BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
4318  DWORD dwIndex, void *pvData, DWORD *pcbData);
4319
4320 HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
4321  DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo,
4322  PCMSG_STREAM_INFO pStreamInfo);
4323
4324 HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
4325  DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID,
4326  PCMSG_STREAM_INFO pStreamInfo);
4327
4328 BOOL WINAPI CryptMsgSignCTL(DWORD dwMsgEncodingType, BYTE *pbCtlContent,
4329  DWORD cbCtlContent, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags,
4330  BYTE *pbEncoded, DWORD *pcbEncoded);
4331
4332 BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData,
4333  DWORD cbData, BOOL fFinal);
4334
4335 BOOL WINAPI CryptMsgVerifyCountersignatureEncoded(HCRYPTPROV_LEGACY hCryptProv,
4336  DWORD dwEncodingType, PBYTE pbSignerInfo, DWORD cbSignerInfo,
4337  PBYTE pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature,
4338  PCERT_INFO pciCountersigner);
4339
4340 BOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx(HCRYPTPROV_LEGACY hCryptProv,
4341  DWORD dwEncodingType, PBYTE pbSignerInfo, DWORD cbSignerInfo,
4342  PBYTE pbSignerInfoCountersignature, DWORD cbSignerInfoCountersignature,
4343  DWORD dwSignerType, void *pvSigner, DWORD dwFlags, void *pvReserved);
4344
4345 BOOL WINAPI CryptSignMessage(PCRYPT_SIGN_MESSAGE_PARA pSignPara,
4346  BOOL fDetachedSignature, DWORD cToBeSigned, const BYTE *rgpbToBeSigned[],
4347  DWORD rgcbToBeSigned[], BYTE *pbSignedBlob, DWORD *pcbSignedBlob);
4348 BOOL WINAPI CryptSignMessageWithKey(PCRYPT_KEY_SIGN_MESSAGE_PARA pSignPara,
4349  const BYTE *pbToBeSigned, DWORD cbToBeSigned, BYTE *pbSignedBlob,
4350  DWORD *pcbSignedBlob);
4351
4352 BOOL WINAPI CryptVerifyMessageSignature(PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
4353  DWORD dwSignerIndex, const BYTE* pbSignedBlob, DWORD cbSignedBlob,
4354  BYTE* pbDecoded, DWORD* pcbDecoded, PCCERT_CONTEXT* ppSignerCert);
4355 BOOL WINAPI CryptVerifyMessageSignatureWithKey(
4356  PCRYPT_KEY_VERIFY_MESSAGE_PARA pVerifyPara,
4357  PCERT_PUBLIC_KEY_INFO pPublicKeyInfo, const BYTE *pbSignedBlob,
4358  DWORD cbSignedBlob, BYTE *pbDecoded, DWORD *pcbDecoded);
4359
4360 BOOL WINAPI CryptVerifyDetachedMessageSignature(
4361  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
4362  const BYTE *pbDetachedSignBlob, DWORD cbDetachedSignBlob, DWORD cToBeSigned,
4363  const BYTE *rgpbToBeSigned[], DWORD rgcbToBeSigned[],
4364  PCCERT_CONTEXT *ppSignerCert);
4365 LONG WINAPI CryptGetMessageSignerCount(DWORD dwMsgEncodingType,
4366  const BYTE *pbSignedBlob, DWORD cbSignedBlob);
4367
4368 BOOL WINAPI CryptEncryptMessage(PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
4369  DWORD cRecipientCert, PCCERT_CONTEXT rgpRecipientCert[],
4370  const BYTE *pbToBeEncrypted, DWORD cbToBeEncrypted, BYTE *pbEncryptedBlob,
4371  DWORD *pcbEncryptedBlob);
4372 BOOL WINAPI CryptDecryptMessage(PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
4373  const BYTE *pbEncryptedBlob, DWORD cbEncryptedBlob, BYTE *pbDecrypted,
4374  DWORD *pcbDecrypted, PCCERT_CONTEXT *ppXchgCert);
4375
4376 BOOL WINAPI CryptSignAndEncryptMessage(PCRYPT_SIGN_MESSAGE_PARA pSignPara,
4377  PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara, DWORD cRecipientCert,
4378  PCCERT_CONTEXT rgpRecipientCert[], const BYTE *pbToBeSignedAndEncrypted,
4379  DWORD cbToBeSignedAndEncrypted, BYTE *pbSignedAndEncryptedBlob,
4380  DWORD *pcbSignedAndEncryptedBlob);
4381 BOOL WINAPI CryptDecryptAndVerifyMessageSignature(
4382  PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
4383  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
4384  const BYTE *pbEncryptedBlob, DWORD cbEncryptedBlob, BYTE *pbDecrypted,
4385  DWORD *pcbDecrypted, PCCERT_CONTEXT *ppXchgCert, PCCERT_CONTEXT *ppSignerCert);
4386
4387 HCERTSTORE WINAPI CryptGetMessageCertificates(DWORD dwMsgAndCertEncodingType,
4388  HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const BYTE *pbSignedBlob,
4389  DWORD cbSignedBlob);
4390
4391 BOOL WINAPI CryptDecodeMessage(DWORD dwMsgTypeFlags,
4392  PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
4393  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
4394  const BYTE *pbEncodedBlob, DWORD cbEncodedBlob, DWORD dwPrevInnerContentType,
4395  DWORD *pdwMsgType, DWORD *pdwInnerContentType, BYTE *pbDecoded,
4396  DWORD *pcbDecoded, PCCERT_CONTEXT *ppXchgCert, PCCERT_CONTEXT *ppSignerCert);
4397
4398 BOOL WINAPI CryptHashMessage(PCRYPT_HASH_MESSAGE_PARA pHashPara,
4399  BOOL fDetachedHash, DWORD cToBeHashed, const BYTE *rgpbToBeHashed[],
4400  DWORD rgcbToBeHashed[], BYTE *pbHashedBlob, DWORD *pcbHashedBlob,
4401  BYTE *pbComputedHash, DWORD *pcbComputedHash);
4402 BOOL WINAPI CryptVerifyMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara,
4403  BYTE *pbHashedBlob, DWORD cbHashedBlob, BYTE *pbToBeHashed,
4404  DWORD *pcbToBeHashed, BYTE *pbComputedHash, DWORD *pcbComputedHash);
4405 BOOL WINAPI CryptVerifyDetachedMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara,
4406  BYTE *pbDetachedHashBlob, DWORD cbDetachedHashBlob, DWORD cToBeHashed,
4407  const BYTE *rgpbToBeHashed[], DWORD rgcbToBeHashed[], BYTE *pbComputedHash,
4408  DWORD *pcbComputedHash);
4409
4410 /* PFX functions */
4411 HCERTSTORE WINAPI PFXImportCertStore(CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword,
4412  DWORD dwFlags);
4413 BOOL WINAPI PFXIsPFXBlob(CRYPT_DATA_BLOB *pPFX);
4414 BOOL WINAPI PFXVerifyPassword(CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword,
4415  DWORD dwFlags);
4416 BOOL WINAPI PFXExportCertStoreEx(HCERTSTORE hStore, CRYPT_DATA_BLOB *pPFX,
4417  LPCWSTR szPassword, void *pvReserved, DWORD dwFlags);
4418 BOOL WINAPI PFXExportCertStore(HCERTSTORE hStore, CRYPT_DATA_BLOB *pPFX,
4419  LPCWSTR szPassword, DWORD dwFlags);
4420
4421 /* cryptnet.dll functions */
4422 BOOL WINAPI CryptCancelAsyncRetrieval(HCRYPTASYNC hAsyncRetrieval);
4423
4424 BOOL WINAPI CryptGetObjectUrl(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags,
4425  PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo,
4426  DWORD *pcbUrlInfo, LPVOID pvReserved);
4427
4428 BOOL WINAPI CryptGetTimeValidObject(LPCSTR pszTimeValidOid, void *pvPara,
4429  PCCERT_CONTEXT pIssuer, LPFILETIME pftValidFor, DWORD dwFlags, DWORD dwTimeout,
4430  void **ppvObject, PCRYPT_CREDENTIALS pCredentials, void *pvReserved);
4431
4432 BOOL WINAPI CryptFlushTimeValidObject(LPCSTR pszFlushTimeValidOid, void *pvPara,
4433  PCCERT_CONTEXT pIssuer, DWORD dwFlags, void *pvReserved);
4434
4435 BOOL WINAPI CryptInstallCancelRetrieval(PFN_CRYPT_CANCEL_RETRIEVAL pfnCancel,
4436  const void *pvArg, DWORD dwFlags, void *pvReserved);
4437
4438 BOOL WINAPI CryptUninstallCancelRetrieval(DWORD dwFlags, void *pvReserved);
4439
4440 BOOL WINAPI CryptRetrieveObjectByUrlA(LPCSTR pszURL, LPCSTR pszObjectOid,
4441  DWORD dwRetrievalFlags, DWORD dwTimeout, LPVOID *ppvObject,
4442  HCRYPTASYNC hAsyncRetrieve, PCRYPT_CREDENTIALS pCredentials, LPVOID pvVerify,
4443  PCRYPT_RETRIEVE_AUX_INFO pAuxInfo);
4444 BOOL WINAPI CryptRetrieveObjectByUrlW(LPCWSTR pszURL, LPCSTR pszObjectOid,
4445  DWORD dwRetrievalFlags, DWORD dwTimeout, LPVOID *ppvObject,
4446  HCRYPTASYNC hAsyncRetrieve, PCRYPT_CREDENTIALS pCredentials, LPVOID pvVerify,
4447  PCRYPT_RETRIEVE_AUX_INFO pAuxInfo);
4448 #define CryptRetrieveObjectByUrl WINELIB_NAME_AW(CryptRetrieveObjectByUrl)
4449
4450 #ifdef __cplusplus
4451 }
4452 #endif
4453
4454 #endif