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