msi: Support MSIDBOPEN_CREATEDIRECT and MSIDBOPEN_DIRECT in MSI_OpenDatabaseW.
[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 /* some typedefs for function parameters */
28 typedef unsigned int ALG_ID;
29 typedef unsigned long HCRYPTPROV;
30 typedef unsigned long HCRYPTKEY;
31 typedef unsigned long HCRYPTHASH;
32 typedef void *HCERTSTORE;
33 typedef void *HCRYPTMSG;
34 typedef void *HCERTSTOREPROV;
35 typedef void *HCRYPTOIDFUNCSET;
36 typedef void *HCRYPTOIDFUNCADDR;
37
38 /* CSP Structs */
39
40 typedef struct _PROV_ENUMALGS {
41   ALG_ID aiAlgid;
42   DWORD  dwBitLen;
43   DWORD  dwNameLen;
44   CHAR   szName[20];
45 } PROV_ENUMALGS;
46
47 typedef struct _PROV_ENUMALGS_EX {
48   ALG_ID aiAlgid;
49   DWORD  dwDefaultLen;
50   DWORD  dwMinLen;
51   DWORD  dwMaxLen;
52   DWORD  dwProtocols;
53   DWORD  dwNameLen;
54   CHAR   szName[20];
55   DWORD  dwLongNameLen;
56   CHAR   szLongName[40];
57 } PROV_ENUMALGS_EX;
58
59 #define SCHANNEL_MAC_KEY 0
60 #define SCHANNEL_ENC_KEY 1
61
62 typedef struct _SCHANNEL_ALG {
63   DWORD  dwUse;
64   ALG_ID Algid;
65   DWORD  cBits;
66   DWORD  dwFlags;
67   DWORD  dwReserved;
68 } SCHANNEL_ALG, *PSCHANNEL_ALG;
69
70 typedef struct _HMAC_INFO {
71   ALG_ID HashAlgid;
72   BYTE*  pbInnerString;
73   DWORD  cbInnerString;
74   BYTE*  pbOuterString;
75   DWORD  cbOuterString;
76 } HMAC_INFO, *PHMAC_INFO;
77                 
78 typedef struct _CRYPTOAPI_BLOB {
79   DWORD    cbData;
80   BYTE*    pbData;
81 } CRYPT_INTEGER_BLOB,  *PCRYPT_INTEGER_BLOB,
82   CRYPT_UINT_BLOB,     *PCRYPT_UINT_BLOB,
83   CRYPT_OBJID_BLOB,    *PCRYPT_OBJID_BLOB,
84   CERT_NAME_BLOB,      *PCERT_NAME_BLOB,
85   CERT_RDN_VALUE_BLOB, *PCERT_RDN_VALUE_BLOB,
86   CERT_BLOB,           *PCERT_BLOB,
87   CRL_BLOB,            *PCRL_BLOB,
88   DATA_BLOB,           *PDATA_BLOB,
89   CRYPT_DATA_BLOB,     *PCRYPT_DATA_BLOB,
90   CRYPT_HASH_BLOB,     *PCRYPT_HASH_BLOB,
91   CRYPT_DIGEST_BLOB,   *PCRYPT_DIGEST_BLOB,
92   CRYPT_DER_BLOB,      *PCRYPT_DER_BLOB,
93   CRYPT_ATTR_BLOB,     *PCRYPT_ATTR_BLOB;
94
95 typedef struct _CRYPTPROTECT_PROMPTSTRUCT{
96   DWORD   cbSize;
97   DWORD   dwPromptFlags;
98   HWND    hwndApp;
99   LPCWSTR szPrompt;
100 } CRYPTPROTECT_PROMPTSTRUCT, *PCRYPTPROTECT_PROMPTSTRUCT;
101
102 typedef struct _CRYPT_ALGORITHM_IDENTIFIER {
103   LPSTR            pszObjId;
104   CRYPT_OBJID_BLOB Parameters;
105 } CRYPT_ALGORITHM_IDENTIFIER, *PCRYPT_ALGORITHM_IDENTIFIER;
106
107 typedef struct _CRYPT_ATTRIBUTE_TYPE_VALUE {
108   LPSTR               pszObjId;
109   CRYPT_OBJID_BLOB    Value;
110 } CRYPT_ATTRIBUTE_TYPE_VALUE, *PCRYPT_ATTRIBUTE_TYPE_VALUE;
111
112 typedef struct _PUBLICKEYSTRUC {
113     BYTE   bType;
114     BYTE   bVersion;
115     WORD   reserved;
116     ALG_ID aiKeyAlg;
117 } BLOBHEADER, PUBLICKEYSTRUC;
118
119 typedef struct _RSAPUBKEY {
120     DWORD   magic;
121     DWORD   bitlen;
122     DWORD   pubexp;
123 } RSAPUBKEY;
124
125 typedef struct _CRYPT_BIT_BLOB {
126     DWORD cbData;
127     BYTE  *pbData;
128     DWORD cUnusedBits;
129 } CRYPT_BIT_BLOB, *PCRYPT_BIT_BLOB;
130
131 typedef struct _CRYPT_KEY_PROV_PARAM {
132     DWORD dwParam;
133     BYTE *pbData;
134     DWORD cbData;
135     DWORD dwFlags;
136 } CRYPT_KEY_PROV_PARAM, *PCRYPT_KEY_PROV_PARAM;
137
138 typedef struct _CRYPT_KEY_PROV_INFO {
139     LPWSTR                pwszContainerName;
140     LPWSTR                pwszProvName;
141     DWORD                 dwProvType;
142     DWORD                 dwFlags;
143     DWORD                 cProvParam;
144     PCRYPT_KEY_PROV_PARAM rgProvParam;
145     DWORD                 dwKeySpec;
146 } CRYPT_KEY_PROV_INFO, *PCRYPT_KEY_PROV_INFO;
147
148 typedef struct _CERT_KEY_CONTEXT {
149     DWORD      cbSize;
150     HCRYPTPROV hCryptProv;
151     DWORD      dwKeySpec;
152 } CERT_KEY_CONTEXT, *PCERT_KEY_CONTEXT;
153
154 typedef struct _CERT_PUBLIC_KEY_INFO {
155     CRYPT_ALGORITHM_IDENTIFIER Algorithm;
156     CRYPT_BIT_BLOB             PublicKey;
157 } CERT_PUBLIC_KEY_INFO, *PCERT_PUBLIC_KEY_INFO;
158
159 typedef struct _CERT_EXTENSION {
160     LPSTR               pszObjId;
161     BOOL                fCritical;
162     CRYPT_OBJID_BLOB    Value;
163 } CERT_EXTENSION, *PCERT_EXTENSION;
164
165 typedef struct _CERT_EXTENSIONS {
166     DWORD           cExtension;
167     PCERT_EXTENSION rgExtension;
168 } CERT_EXTENSIONS, *PCERT_EXTENSIONS;
169
170 typedef struct _CERT_INFO {
171     DWORD                      dwVersion;
172     CRYPT_INTEGER_BLOB         SerialNumber;
173     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
174     CERT_NAME_BLOB             Issuer;
175     FILETIME                   NotBefore;
176     FILETIME                   NotAfter;
177     CERT_NAME_BLOB             Subject;
178     CERT_PUBLIC_KEY_INFO       SubjectPublicKeyInfo;
179     CRYPT_BIT_BLOB             IssuerUniqueId;
180     CRYPT_BIT_BLOB             SubjectUniqueId;
181     DWORD                      cExtension;
182     PCERT_EXTENSION            rgExtension;
183 } CERT_INFO, *PCERT_INFO;
184
185 typedef struct _CERT_RDN_ATTR {
186     LPSTR               pszObjId;
187     DWORD               dwValueType;
188     CERT_RDN_VALUE_BLOB Value;
189 } CERT_RDN_ATTR, *PCERT_RDN_ATTR;
190
191 typedef struct _CERT_RDN {
192     DWORD          cRDNAttr;
193     PCERT_RDN_ATTR rgRDNAttr;
194 } CERT_RDN, *PCERT_RDN;
195
196 typedef struct _CERT_NAME_INFO {
197     DWORD     cRDN;
198     PCERT_RDN rgRDN;
199 } CERT_NAME_INFO, *PCERT_NAME_INFO;
200
201 typedef struct _CERT_NAME_VALUE {
202     DWORD               dwValueType;
203     CERT_RDN_VALUE_BLOB Value;
204 } CERT_NAME_VALUE, *PCERT_NAME_VALUE;
205
206 typedef struct _CERT_ENCRYPTED_PRIVATE_KEY_INFO {
207     CRYPT_ALGORITHM_IDENTIFIER EncryptionAlgorithm;
208     CRYPT_DATA_BLOB            EncryptedPrivateKey;
209 } CERT_ENCRYPTED_PRIVATE_KEY_INFO, *PCERT_ENCRYPTED_PRIVATE_KEY_INFO;
210
211 typedef struct _CERT_AUTHORITY_KEY_ID_INFO {
212     CRYPT_DATA_BLOB    KeyId;
213     CERT_NAME_BLOB     CertIssuer;
214     CRYPT_INTEGER_BLOB CertSerialNumber;
215 } CERT_AUTHORITY_KEY_ID_INFO, *PCERT_AUTHORITY_KEY_ID_INFO;
216
217 typedef struct _CERT_PRIVATE_KEY_VALIDITY {
218     FILETIME NotBefore;
219     FILETIME NotAfter;
220 } CERT_PRIVATE_KEY_VALIDITY, *PCERT_PRIVATE_KEY_VALIDITY;
221
222 typedef struct _CERT_KEY_ATTRIBUTES_INFO {
223     CRYPT_DATA_BLOB            KeyId;
224     CRYPT_BIT_BLOB             IntendedKeyUsage;
225     PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod;
226 } CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO;
227
228 /* byte 0 */
229 #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80
230 #define CERT_NON_REPUDIATION_KEY_USAGE   0x40
231 #define CERT_KEY_ENCIPHERMENT_KEY_USAGE  0x20
232 #define CERT_DATA_ENCIPHERMENT_KEY_USAGE 0x10
233 #define CERT_KEY_AGREEMENT_KEY_USAGE     0x80
234 #define CERT_KEY_CERT_SIGN_KEY_USAGE     0x40
235 #define CERT_OFFLINE_CRL_SIGN_KEY_USAGE  0x20
236 #define CERT_CRL_SIGN_KEY_USAGE          0x10
237 #define CERT_ENCIPHER_ONLY_KEY_USAGE     0x01
238 /* byte 1 */
239 #define CERT_DECIPHER_ONLY_KEY_USAGE     0x80
240
241 typedef struct _CERT_POLICY_ID {
242     DWORD  cCertPolicyElementId;
243     LPSTR *rgbszCertPolicyElementId;
244 } CERT_POLICY_ID, *PCERT_POLICY_ID;
245
246 typedef struct _CERT_KEY_USAGE_RESTRICTION_INFO {
247     DWORD           cCertPolicyId;
248     PCERT_POLICY_ID rgCertPolicyId;
249     CRYPT_BIT_BLOB  RestrictedKeyUsage;
250 } CERT_KEY_USAGE_RESTRICTION_INFO, *PCERT_KEY_USAGE_RESTRICTION_INFO;
251
252 typedef struct _CERT_OTHER_NAME {
253     LPSTR            pszObjId;
254     CRYPT_OBJID_BLOB Value;
255 } CERT_OTHER_NAME, *PCERT_OTHER_NAME;
256
257 typedef struct _CERT_ALT_NAME_ENTRY {
258     DWORD dwAltNameChoice;
259     union {
260         PCERT_OTHER_NAME pOtherName;
261         LPWSTR           pwszRfc822Name;
262         LPWSTR           pwszDNSName;
263         CERT_NAME_BLOB   DirectoryName;
264         LPWSTR           pwszURL;
265         CRYPT_DATA_BLOB  IPAddress;
266         LPSTR            pszRegisteredID;
267     } DUMMYUNIONNAME;
268 } CERT_ALT_NAME_ENTRY, *PCERT_ALT_NAME_ENTRY;
269
270 #define CERT_ALT_NAME_OTHER_NAME     1
271 #define CERT_ALT_NAME_RFC822_NAME    2
272 #define CERT_ALT_NAME_DNS_NAME       3
273 #define CERT_ALT_NAME_X400_ADDRESS   4
274 #define CERT_ALT_NAME_DIRECTORY_NAME 5
275 #define CERT_ALT_NAME_EDI_PARTY_NAME 6
276 #define CERT_ALT_NAME_URL            7
277 #define CERT_ALT_NAME_IP_ADDRESS     8
278 #define CERT_ALT_NAME_REGISTERED_ID  9
279
280 typedef struct _CERT_ALT_NAME_INFO {
281     DWORD                cAltEntry;
282     PCERT_ALT_NAME_ENTRY rgAltEntry;
283 } CERT_ALT_NAME_INFO, *PCERT_ALT_NAME_INFO;
284
285 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK  0xff
286 #define CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT 16
287 #define CERT_ALT_NAME_VALUE_ERR_INDEX_MASK  0x0000ffff
288 #define CERT_ALT_NAME_VALUE_ERR_INDEX_SHIFT 0
289 #define GET_CERT_ALT_NAME_ENTRY_ERR_INDEX(x) \
290  (((x) >> CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT) & \
291   CERT_ALT_NAME_ENTRY_ERR_INDEX_MASK)
292 #define GET_CERT_ALT_NAME_VALUE_ERR_INDEX(x) \
293  ((x) & CERT_ALT_NAME_VALUE_ERR_INDEX_MASK)
294
295 typedef struct _CERT_BASIC_CONSTRAINTS_INFO {
296     CRYPT_BIT_BLOB  SubjectType;
297     BOOL            fPathLenConstraint;
298     DWORD           dwPathLenConstraint;
299     DWORD           cSubtreesConstraint;
300     CERT_NAME_BLOB *rgSubtreesConstraint;
301 } CERT_BASIC_CONSTRAINTS_INFO, *PCERT_BASIC_CONSTRAINTS_INFO;
302
303 #define CERT_CA_SUBJECT_FLAG         0x80
304 #define CERT_END_ENTITY_SUBJECT_FLAG 0x40
305
306 typedef struct _CERT_BASIC_CONSTRAINTS2_INFO {
307     BOOL  fCA;
308     BOOL  fPathLenConstraint;
309     DWORD dwPathLenConstraint;
310 } CERT_BASIC_CONSTRAINTS2_INFO, *PCERT_BASIC_CONSTRAINTS2_INFO;
311
312 typedef struct _CERT_POLICY_QUALIFIER_INFO {
313     LPSTR            pszPolicyQualifierId;
314     CRYPT_OBJID_BLOB Qualifier;
315 } CERT_POLICY_QUALIFIER_INFO, *PCERT_POLICY_QUALIFIER_INFO;
316
317 typedef struct _CERT_POLICY_INFO {
318     LPSTR                       pszPolicyIdentifier;
319     DWORD                       cPolicyQualifier;
320     CERT_POLICY_QUALIFIER_INFO *rgPolicyQualifier;
321 } CERT_POLICY_INFO, *PCERT_POLICY_INFO;
322
323 typedef struct _CERT_POLICIES_INFO {
324     DWORD             cPolicyInfo;
325     CERT_POLICY_INFO *rgPolicyInfo;
326 } CERT_POLICIES_INFO, *PCERT_POLICIES_INFO;
327
328 typedef struct _CERT_POLICY_QUALIFIER_NOTICE_REFERENCE {
329     LPSTR pszOrganization;
330     DWORD cNoticeNumbers;
331     int  *rgNoticeNumbers;
332 } CERT_POLICY_QUALIFIER_NOTICE_REFERENCE,
333  *PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE;
334
335 typedef struct _CERT_POLICY_QUALIFIER_USER_NOTICE {
336     CERT_POLICY_QUALIFIER_NOTICE_REFERENCE *pNoticeReference;
337     LPWSTR                                  pszDisplayText;
338 } CERT_POLICY_QUALIFIER_USER_NOTICE, *PCERT_POLICY_QUALIFIER_USER_NOTICE;
339
340 typedef struct _CPS_URLS {
341     LPWSTR                      pszURL;
342     CRYPT_ALGORITHM_IDENTIFIER *pAlgorithm;
343     CRYPT_DATA_BLOB            *pDigest;
344 } CPS_URLS, *PCPS_URLS;
345
346 typedef struct _CERT_POLICY95_QUALIFIER1 {
347     LPWSTR    pszPracticesReference;
348     LPSTR     pszNoticeIdentifier;
349     LPSTR     pszNSINoticeIdentifier;
350     DWORD     cCPSURLs;
351     CPS_URLS *rgCPSURLs;
352 } CERT_POLICY95_QUALIFIER1, *PCERT_POLICY95_QUALIFIER1;
353
354 typedef struct _CERT_POLICY_MAPPING {
355     LPSTR pszIssuerDomainPolicy;
356     LPSTR pszSubjectDomainPolicy;
357 } CERT_POLICY_MAPPING, *PCERT_POLICY_MAPPING;
358
359 typedef struct _CERT_POLICY_MAPPINGS_INFO {
360     DWORD                cPolicyMapping;
361     PCERT_POLICY_MAPPING rgPolicyMapping;
362 } CERT_POLICY_MAPPINGS_INFO, *PCERT_POLICY_MAPPINGS_INFO;
363
364 typedef struct _CERT_POLICY_CONSTRAINTS_INFO {
365     BOOL  fRequireExplicitPolicy;
366     DWORD dwRequireExplicitPolicySkipCerts;
367     BOOL  fInhibitPolicyMapping;
368     DWORD dwInhibitPolicyMappingSkipCerts;
369 } CERT_POLICY_CONSTRAINTS_INFO, *PCERT_POLICY_CONSTRAINTS_INFO;
370
371 typedef struct _CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY {
372     LPSTR           pszObjId;
373     DWORD           cValue;
374     PCRYPT_DER_BLOB rgValue;
375 } CRYPT_CONTENT_INFO_SEQUENCE_OF_ANY, *PCRYPT_CONTENT_INFO_SEQUENCE_OF_ANY;
376
377 typedef struct _CRYPT_CONTENT_INFO {
378     LPSTR          pszObjId;
379     CRYPT_DER_BLOB Content;
380 } CRYPT_CONTENT_INFO, *PCRYPT_CONTENT_INFO;
381
382 typedef struct _CRYPT_SEQUENCE_OF_ANY {
383     DWORD           cValue;
384     PCRYPT_DER_BLOB rgValue;
385 } CRYPT_SEQUENCE_OF_ANY, *PCRYPT_SEQUENCE_OF_ANY;
386
387 typedef struct _CERT_AUTHORITY_KEY_ID2_INFO {
388     CRYPT_DATA_BLOB    KeyId;
389     CERT_ALT_NAME_INFO AuthorityCertIssuer;
390     CRYPT_INTEGER_BLOB AuthorityCertSerialNumber;
391 } CERT_AUTHORITY_KEY_ID2_INFO, *PCERT_AUTHORITY_KEY_ID2_INFO;
392
393 typedef struct _CERT_ACCESS_DESCRIPTION {
394     LPSTR               pszAccessMethod;
395     CERT_ALT_NAME_ENTRY AccessLocation;
396 } CERT_ACCESS_DESCRIPTION, *PCERT_ACCESS_DESCRIPTION;
397
398 typedef struct _CERT_AUTHORITY_INFO_ACCESS {
399     DWORD                    cAccDescr;
400     PCERT_ACCESS_DESCRIPTION rgAccDescr;
401 } CERT_AUTHORITY_INFO_ACCESS, *PCERT_AUTHORITY_INFO_ACCESS;
402
403 typedef struct _CERT_CONTEXT {
404     DWORD      dwCertEncodingType;
405     BYTE       *pbCertEncoded;
406     DWORD      cbCertEncoded;
407     PCERT_INFO pCertInfo;
408     HCERTSTORE hCertStore;
409 } CERT_CONTEXT, *PCERT_CONTEXT;
410 typedef const CERT_CONTEXT *PCCERT_CONTEXT;
411
412 typedef struct _CRL_ENTRY {
413     CRYPT_INTEGER_BLOB SerialNumber;
414     FILETIME           RevocationDate;
415     DWORD              cExtension;
416     PCERT_EXTENSION    rgExtension;
417 } CRL_ENTRY, *PCRL_ENTRY;
418
419 typedef struct _CRL_INFO {
420     DWORD           dwVersion;
421     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
422     CERT_NAME_BLOB  Issuer;
423     FILETIME        ThisUpdate;
424     FILETIME        NextUpdate;
425     DWORD           cCRLEntry;
426     PCRL_ENTRY      rgCRLEntry;
427     DWORD           cExtension;
428     PCERT_EXTENSION rgExtension;
429 } CRL_INFO, *PCRL_INFO;
430
431 typedef struct _CRL_DIST_POINT_NAME {
432     DWORD dwDistPointNameChoice;
433     union {
434         CERT_ALT_NAME_INFO FullName;
435     } DUMMYUNIONNAME;
436 } CRL_DIST_POINT_NAME, *PCRL_DIST_POINT_NAME;
437
438 #define CRL_DIST_POINT_NO_NAME         0
439 #define CRL_DIST_POINT_FULL_NAME       1
440 #define CRL_DIST_POINT_ISSUER_RDN_NAME 2
441
442 typedef struct _CRL_DIST_POINT {
443     CRL_DIST_POINT_NAME DistPointName;
444     CRYPT_BIT_BLOB      ReasonFlags;
445     CERT_ALT_NAME_INFO  CRLIssuer;
446 } CRL_DIST_POINT, *PCRL_DIST_POINT;
447
448 #define CRL_REASON_UNUSED_FLAG                 0x80
449 #define CRL_REASON_KEY_COMPROMISE_FLAG         0x40
450 #define CRL_REASON_CA_COMPROMISE_FLAG          0x20
451 #define CRL_REASON_AFFILIATION_CHANGED_FLAG    0x10
452 #define CRL_REASON_SUPERSEDED_FLAG             0x08
453 #define CRL_REASON_CESSATION_OF_OPERATION_FLAG 0x04
454 #define CRL_REASON_CERTIFICATE_HOLD_FLAG       0x02
455
456 typedef struct _CRL_DIST_POINTS_INFO {
457     DWORD           cDistPoint;
458     PCRL_DIST_POINT rgDistPoint;
459 } CRL_DIST_POINTS_INFO, *PCRL_DIST_POINTS_INFO;
460
461 #define CRL_DIST_POINT_ERR_INDEX_MASK  0x7f
462 #define CRL_DIST_POINT_ERR_INDEX_SHIFT 24
463 #define GET_CRL_DIST_POINT_ERR_INDEX(x) \
464  (((x) >> CRL_DIST_POINT_ERR_INDEX_SHIFT) & CRL_DIST_POINT_ERR_INDEX_MASK)
465
466 #define CRL_DIST_POINT_ERR_CRL_ISSUER_BIT 0x80000000L
467 #define IS_CRL_DIST_POINT_ERR_CRL_ISSUER(x) \
468  ((x) & CRL_DIST_POINT_ERR_CRL_ISSUER_BIT)
469
470 typedef struct _CROSS_CERT_DIST_POINTS_INFO {
471     DWORD               dwSyncDeltaTime;
472     DWORD               cDistPoint;
473     PCERT_ALT_NAME_INFO rgDistPoint;
474 } CROSS_CERT_DIST_POINTS_INFO, *PCROSS_CERT_DIST_POINTS_INFO;
475
476 #define CROSS_CERT_DIST_POINT_ERR_INDEX_MASK  0xff
477 #define CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT 24
478 #define GET_CROSS_CERT_DIST_POINT_ERR_INDEX(x) \
479  (((x) >> CROSS_CERT_DIST_POINT_ERR_INDEX_SHIFT) & \
480  CROSS_CERT_DIST_POINT_ERR_INDEX_MASK)
481
482 typedef struct _CERT_PAIR {
483     CERT_BLOB Forward;
484     CERT_BLOB Reverse;
485 } CERT_PAIR, *PCERT_PAIR;
486
487 typedef struct _CRL_ISSUING_DIST_POINT {
488     CRL_DIST_POINT_NAME DistPointName;
489     BOOL                fOnlyContainsUserCerts;
490     BOOL                fOnlyContainsCACerts;
491     CRYPT_BIT_BLOB      OnlySomeReasonFlags;
492     BOOL                fIndirectCRL;
493 } CRL_ISSUING_DIST_POINT, *PCRL_ISSUING_DIST_POINT;
494
495 typedef struct _CERT_GENERAL_SUBTREE {
496     CERT_ALT_NAME_ENTRY Base;
497     DWORD               dwMinimum;
498     BOOL                fMaximum;
499     DWORD               dwMaximum;
500 } CERT_GENERAL_SUBTREE, *PCERT_GENERAL_SUBTREE;
501
502 typedef struct _CERT_NAME_CONSTRAINTS_INFO {
503     DWORD                 cPermittedSubtree;
504     PCERT_GENERAL_SUBTREE rgPermittedSubtree;
505     DWORD                 cExcludedSubtree;
506     PCERT_GENERAL_SUBTREE rgExcludedSubtree;
507 } CERT_NAME_CONSTRAINTS_INFO, *PCERT_NAME_CONSTRAINTS_INFO;
508
509 #define CERT_EXCLUDED_SUBTREE_BIT 0x80000000L
510 #define IS_CERT_EXCLUDED_SUBTREE(x) ((x) & CERT_EXCLUDED_SUBTREE_BIT)
511
512 typedef struct _CRYPT_ATTRIBUTE {
513     LPSTR            pszObjId;
514     DWORD            cValue;
515     PCRYPT_DATA_BLOB rgValue;
516 } CRYPT_ATTRIBUTE, *PCRYPT_ATTRIBUTE;
517
518 typedef struct _CRYPT_ATTRIBUTES {
519     DWORD            cAttr;
520     PCRYPT_ATTRIBUTE rgAttr;
521 } CRYPT_ATTRIBUTES, *PCRYPT_ATTRIBUTES;
522
523 typedef struct _CERT_REQUEST_INFO {
524     DWORD                dwVersion;
525     CERT_NAME_BLOB       Subject;
526     CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
527     DWORD                cAttribute;
528     PCRYPT_ATTRIBUTE     rgAttribute;
529 } CERT_REQUEST_INFO, *PCERT_REQUEST_INFO;
530
531 typedef struct _CERT_KEYGEN_REQUEST_INFO {
532     DWORD                dwVersion;
533     CERT_PUBLIC_KEY_INFO SubjectPubliceKeyInfo;
534     LPWSTR               pwszChallengeString;
535 } CERT_KEYGEN_REQUEST_INFO, *PCERT_KEYGEN_REQUEST_INFO;
536
537 typedef struct _CERT_SIGNED_CONTENT_INFO {
538     CRYPT_DER_BLOB             ToBeSigned;
539     CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
540     CRYPT_BIT_BLOB             Signature;
541 } CERT_SIGNED_CONTENT_INFO, *PCERT_SIGNED_CONTENT_INFO;
542
543 typedef struct _CRL_CONTEXT {
544     DWORD      dwCertEncodingType;
545     BYTE      *pbCrlEncoded;
546     DWORD      cbCrlEncoded;
547     PCRL_INFO  pCrlInfo;
548     HCERTSTORE hCertStore;
549 } CRL_CONTEXT, *PCRL_CONTEXT;
550 typedef const CRL_CONTEXT *PCCRL_CONTEXT;
551
552 typedef struct _VTableProvStruc {
553     DWORD    Version;
554     FARPROC  pFuncVerifyImage;
555     FARPROC  pFuncReturnhWnd;
556     DWORD    dwProvType;
557     BYTE    *pbContextInfo;
558     DWORD    cbContextInfo;
559     LPSTR    pszProvName;
560 } VTableProvStruc, *PVTableProvStruc;
561
562 typedef struct _CERT_PRIVATE_KEY_INFO {
563     DWORD                      Version;
564     CRYPT_ALGORITHM_IDENTIFIER Algorithm;
565     CRYPT_DER_BLOB             PrivateKey;
566     PCRYPT_ATTRIBUTES          pAttributes;
567 } CERT_PRIVATE_KEY_INFO, *PCERT_PRIVATE_KEY_INFO;
568
569 typedef struct _CTL_USAGE {
570     DWORD  cUsageIdentifier;
571     LPSTR *rgpszUsageIdentifier;
572 } CTL_USAGE, *PCTL_USAGE, CERT_ENHKEY_USAGE, *PCERT_ENHKEY_USAGE;
573
574 typedef struct _CTL_ENTRY {
575     CRYPT_DATA_BLOB  SubjectIdentifier;
576     DWORD            cAttribute;
577     PCRYPT_ATTRIBUTE rgAttribute;
578 } CTL_ENTRY, *PCTL_ENTRY;
579
580 typedef struct _CTL_INFO {
581     DWORD                      dwVersion;
582     CTL_USAGE                  SubjectUsage;
583     CRYPT_DATA_BLOB            ListIdentifier;
584     CRYPT_INTEGER_BLOB         SequenceNumber;
585     FILETIME                   ThisUpdate;
586     FILETIME                   NextUpdate;
587     CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm;
588     DWORD                      cCTLEntry;
589     PCTL_ENTRY                 rgCTLEntry;
590     DWORD                      cExtension;
591     PCERT_EXTENSION            rgExtension;
592 } CTL_INFO, *PCTL_INFO;
593
594 typedef struct _CTL_CONTEXT {
595     DWORD      dwMsgAndCertEncodingType;
596     BYTE      *pbCtlEncoded;
597     DWORD      cbCtlEncoded;
598     PCTL_INFO  pCtlInfo;
599     HCERTSTORE hCertStore;
600     HCRYPTMSG  hCryptMsg;
601     BYTE      *pbCtlContext;
602     DWORD      cbCtlContext;
603 } CTL_CONTEXT, *PCTL_CONTEXT;
604 typedef const CTL_CONTEXT *PCCTL_CONTEXT;
605
606 typedef struct _CRYPT_TIME_STAMP_REQUEST_INFO {
607     LPSTR            pszTimeStampAlgorithm;
608     LPSTR            pszContentType;
609     CRYPT_OBJID_BLOB Content;
610     DWORD            cAttribute;
611     PCRYPT_ATTRIBUTE rgAttribute;
612 } CRYPT_TIME_STAMP_REQUEST_INFO, *PCRYPT_TIME_STAMP_REQUEST_INFO;
613
614 typedef struct _CRYPT_ENROLLMENT_NAME_VALUE_PAIR {
615     LPWSTR pwszName;
616     LPWSTR pwszValue;
617 } CRYPT_ENROLLMENT_NAME_VALUE_PAIR, *PCRYPT_ENROLLMENT_NAME_VALUE_PAIR;
618
619 typedef struct _CMSG_SIGNER_INFO {
620     DWORD                      dwVersion;
621     CERT_NAME_BLOB             Issuer;
622     CRYPT_INTEGER_BLOB         SerialNumber;
623     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
624     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
625     CRYPT_DATA_BLOB            EncryptedHash;
626     CRYPT_ATTRIBUTES           AuthAttrs;
627     CRYPT_ATTRIBUTES           UnauthAttrs;
628 } CMSG_SIGNER_INFO, *PCMSG_SIGNER_INFO;
629
630 typedef struct _CERT_REVOCATION_CRL_INFO {
631     DWORD         cbSize;
632     PCCRL_CONTEXT pBaseCrlContext;
633     PCCRL_CONTEXT pDeltaCrlContext;
634     PCRL_ENTRY    pCrlEntry;
635     BOOL          fDeltaCrlEntry;
636 } CERT_REVOCATION_CRL_INFO, *PCERT_REVOCATION_CRL_INFO;
637
638 typedef struct _CERT_REVOCATION_INFO {
639     DWORD                     cbSize;
640     DWORD                     dwRevocationResult;
641     LPCSTR                    pszRevocationOid;
642     LPVOID                    pvOidSpecificInfo;
643     BOOL                      fHasFreshnessTime;
644     DWORD                     dwFreshnessTime;
645     PCERT_REVOCATION_CRL_INFO pCrlInfo;
646 } CERT_REVOCATION_INFO, *PCERT_REVOCATION_INFO;
647
648 typedef struct _CERT_TRUST_LIST_INFO {
649     DWORD         cbSize;
650     PCTL_ENTRY    pCtlEntry;
651     PCCTL_CONTEXT pCtlContext;
652 } CERT_TRUST_LIST_INFO, *PCERT_TRUST_LIST_INFO;
653
654 typedef struct _CERT_TRUST_STATUS {
655     DWORD dwErrorStatus;
656     DWORD dwInfoStatus;
657 } CERT_TRUST_STATUS, *PCERT_TRUST_STATUS;
658
659 typedef struct _CERT_CHAIN_ELEMENT {
660     DWORD                 cbSize;
661     PCCERT_CONTEXT        pCertContext;
662     CERT_TRUST_STATUS     TrustStatus;
663     PCERT_REVOCATION_INFO pRevocationInfo;
664     PCERT_ENHKEY_USAGE    pIssuanceUsage;
665     PCERT_ENHKEY_USAGE    pApplicationUsage;
666     LPCWSTR               pwszExtendedErrorInfo;
667 } CERT_CHAIN_ELEMENT, *PCERT_CHAIN_ELEMENT;
668
669 typedef struct _CERT_SIMPLE_CHAIN {
670     DWORD                 cbSize;
671     CERT_TRUST_STATUS     TrustStatus;
672     DWORD                 cElement;
673     PCERT_CHAIN_ELEMENT  *rgpElement;
674     PCERT_TRUST_LIST_INFO pTrustListInfo;
675     BOOL                  fHasRevocationFreshnessTime;
676     DWORD                 dwRevocationFreshnessTime;
677 } CERT_SIMPLE_CHAIN, *PCERT_SIMPLE_CHAIN;
678
679 typedef struct _CERT_CHAIN_CONTEXT CERT_CHAIN_CONTEXT, *PCERT_CHAIN_CONTEXT;
680 typedef const CERT_CHAIN_CONTEXT *PCCERT_CHAIN_CONTEXT;
681
682 struct _CERT_CHAIN_CONTEXT {
683     DWORD                 cbSize;
684     CERT_TRUST_STATUS     TrustStatus;
685     DWORD                 cChain;
686     PCERT_SIMPLE_CHAIN   *rgpChain;
687     DWORD                 cLowerQualityChainContext;
688     PCCERT_CHAIN_CONTEXT *rgbLowerQualityChainContext;
689     BOOL                  fHasRevocationFreshnessTime;
690     DWORD                 dwRevocationFreshnessTime;
691 };
692
693 typedef struct _CERT_CHAIN_POLICY_PARA {
694     DWORD cbSize;
695     DWORD dwFlags;
696     void *pvExtraPolicyPara;
697 } CERT_CHAIN_POLICY_PARA, *PCERT_CHAIN_POLICY_PARA;
698
699 typedef struct _CERT_CHAIN_POLICY_STATUS {
700     DWORD cbSize;
701     DWORD dwError;
702     LONG  lChainIndex;
703     LONG  lElementIndex;
704     void *pvExtraPolicyStatus;
705 } CERT_CHAIN_POLICY_STATUS, *PCERT_CHAIN_POLICY_STATUS;
706
707 typedef struct _CERT_USAGE_MATCH {
708     DWORD             dwType;
709     CERT_ENHKEY_USAGE Usage;
710 } CERT_USAGE_MATCH, *PCERT_USAGE_MATCH;
711
712 typedef struct _CTL_USAGE_MATCH {
713     DWORD     dwType;
714     CTL_USAGE Usage;
715 } CTL_USAGE_MATCH, *PCTL_USAGE_MATCH;
716
717 typedef struct _CERT_CHAIN_PARA {
718     DWORD            cbSize;
719     CERT_USAGE_MATCH RequestedUsage;
720 #ifdef CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
721     CERT_USAGE_MATCH RequestedIssuancePolicy;
722     DWORD            dwUrlRetrievalTimeout;
723     BOOL             fCheckRevocationFreshnessTime;
724     DWORD            dwRevocationFreshnessTime;
725 #endif
726 } CERT_CHAIN_PARA, *PCERT_CHAIN_PARA;
727
728 typedef struct _CERT_SYSTEM_STORE_INFO {
729     DWORD cbSize;
730 } CERT_SYSTEM_STORE_INFO, *PCERT_SYSTEM_STORE_INFO;
731
732 typedef struct _CERT_PHYSICAL_STORE_INFO {
733     DWORD           cbSize;
734     LPSTR           pszOpenStoreProvider;
735     DWORD           dwOpenEncodingType;
736     DWORD           dwOpenFlags;
737     CRYPT_DATA_BLOB OpenParameters;
738     DWORD           dwFlags;
739     DWORD           dwPriority;
740 } CERT_PHYSICAL_STORE_INFO, *PCERT_PHYSICAL_STORE_INFO;
741
742 typedef struct _CERT_SYSTEM_STORE_RELOCATE_PARA {
743     union {
744         HKEY  hKeyBase;
745         VOID *pvBase;
746     } DUMMYUNIONNAME;
747     union {
748         void   *pvSystemStore;
749         LPCSTR  pszSystemStore;
750         LPCWSTR pwszSystemStore;
751     } DUMMYUNIONNAME2;
752 } CERT_SYSTEM_STORE_RELOCATE_PARA, *PCERT_SYSTEM_STORE_RELOCATE_PARA;
753
754 typedef BOOL (WINAPI *PFN_CERT_ENUM_SYSTEM_STORE_LOCATION)(
755  LPCWSTR pwszStoreLocation, DWORD dwFlags, void *pvReserved, void *pvArg);
756
757 typedef BOOL (WINAPI *PFN_CERT_ENUM_SYSTEM_STORE)(const void *pvSystemStore,
758  DWORD dwFlags, PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved,
759  void *pvArg);
760
761 typedef BOOL (WINAPI *PFN_CERT_ENUM_PHYSICAL_STORE)(const void *pvSystemStore,
762  DWORD dwFlags, LPCWSTR pwszStoreName, PCERT_PHYSICAL_STORE_INFO pStoreInfo,
763  void *pvReserved, void *pvArg);
764
765 /* Encode/decode object */
766 typedef LPVOID (WINAPI *PFN_CRYPT_ALLOC)(size_t cbsize);
767 typedef VOID   (WINAPI *PFN_CRYPT_FREE)(LPVOID pv);
768
769 typedef struct _CRYPT_ENCODE_PARA {
770     DWORD           cbSize;
771     PFN_CRYPT_ALLOC pfnAlloc;
772     PFN_CRYPT_FREE  pfnFree;
773 } CRYPT_ENCODE_PARA, *PCRYPT_ENCODE_PARA;
774
775 typedef struct _CRYPT_DECODE_PARA {
776     DWORD           cbSize;
777     PFN_CRYPT_ALLOC pfnAlloc;
778     PFN_CRYPT_FREE  pfnFree;
779 } CRYPT_DECODE_PARA, *PCRYPT_DECODE_PARA;
780
781 typedef struct _CERT_STORE_PROV_INFO {
782     DWORD             cbSize;
783     DWORD             cStoreProvFunc;
784     void            **rgpvStoreProvFunc;
785     HCERTSTOREPROV    hStoreProv;
786     DWORD             dwStoreProvFlags;
787     HCRYPTOIDFUNCADDR hStoreProvFuncAddr2;
788 } CERT_STORE_PROV_INFO, *PCERT_STORE_PROV_INFO;
789
790 typedef BOOL (WINAPI *PFN_CERT_DLL_OPEN_STORE_PROV_FUNC)(
791  LPCSTR lpszStoreProvider, DWORD dwEncodingType, HCRYPTPROV hCryptProv,
792  DWORD dwFlags, const void *pvPara, HCERTSTORE hCertStore,
793  PCERT_STORE_PROV_INFO pStoreProvInfo);
794
795 typedef void (WINAPI *PFN_CERT_STORE_PROV_CLOSE)(HCERTSTOREPROV hStoreProv,
796  DWORD dwFlags);
797
798 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CERT)(HCERTSTOREPROV hStoreProv,
799  PCCERT_CONTEXT pStoreCertContext, DWORD dwFlags,
800  PCCERT_CONTEXT *ppProvCertContext);
801
802 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CERT)(HCERTSTOREPROV hStoreProv,
803  PCCERT_CONTEXT pCertContext, DWORD dwFlags);
804
805 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CERT)(
806  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwFlags);
807
808 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CERT_PROPERTY)(
809  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwPropId,
810  DWORD dwFlags, const void *pvData);
811
812 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CRL)(HCERTSTOREPROV hStoreProv,
813  PCCRL_CONTEXT pStoreCrlContext, DWORD dwFlags,
814  PCCRL_CONTEXT *ppProvCrlContext);
815
816 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CRL)(HCERTSTOREPROV hStoreProv,
817  PCCRL_CONTEXT pCrlContext, DWORD dwFlags);
818
819 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CRL)(HCERTSTOREPROV hStoreProv,
820  PCCRL_CONTEXT pCrlContext, DWORD dwFlags);
821
822 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CRL_PROPERTY)(
823  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext, DWORD dwPropId,
824  DWORD dwFlags, const void *pvData);
825
826 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_READ_CTL)(HCERTSTOREPROV hStoreProv,
827  PCCTL_CONTEXT pStoreCtlContext, DWORD dwFlags,
828  PCCTL_CONTEXT *ppProvCtlContext);
829
830 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_WRITE_CTL)(HCERTSTOREPROV hStoreProv,
831  PCCTL_CONTEXT pCtlContext, DWORD dwFlags);
832
833 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_DELETE_CTL)(
834  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwFlags);
835
836 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_SET_CTL_PROPERTY)(
837  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwPropId,
838  DWORD dwFlags, const void *pvData);
839
840 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_CONTROL)(HCERTSTOREPROV hStoreProv,
841  DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara);
842
843 typedef struct _CERT_STORE_PROV_FIND_INFO {
844     DWORD       cbSize;
845     DWORD       dwMsgAndCertEncodingType;
846     DWORD       dwFindFlags;
847     DWORD       dwFindType;
848     const void *pvFindPara;
849 } CERT_STORE_PROV_FIND_INFO, *PCERT_STORE_PROV_FIND_INFO;
850 typedef const CERT_STORE_PROV_FIND_INFO CCERT_STORE_PROV_FIND_INFO,
851  *PCCERT_STORE_PROV_FIND_INFO;
852
853 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CERT)(HCERTSTOREPROV hStoreProv,
854  PCCERT_STORE_PROV_FIND_INFO pFindInfo, PCCERT_CONTEXT pPrevCertContext,
855  DWORD dwFlags, void **ppvStoreProvFindInfo, PCCERT_CONTEXT *ppProvCertContext);
856
857 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CERT)(
858  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext,
859  void *pvStoreProvFindInfo, DWORD dwFlags);
860
861 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CERT_PROPERTY)(
862  HCERTSTOREPROV hStoreProv, PCCERT_CONTEXT pCertContext, DWORD dwPropId,
863  DWORD dwFlags, void *pvData, DWORD *pcbData);
864
865 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CRL)(HCERTSTOREPROV hStoreProv,
866  PCCERT_STORE_PROV_FIND_INFO pFindInfo, PCCRL_CONTEXT pPrevCrlContext,
867  DWORD dwFlags, void **ppvStoreProvFindInfo, PCCRL_CONTEXT *ppProvCrlContext);
868
869 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FREE_FIND_CRL)(
870  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext,
871  void *pvStoreProvFindInfo, DWORD dwFlags);
872
873 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CRL_PROPERTY)(
874  HCERTSTOREPROV hStoreProv, PCCRL_CONTEXT pCrlContext, DWORD dwPropId,
875  DWORD dwFlags, void *pvData, DWORD *pcbData);
876
877 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_FIND_CTL)(HCERTSTOREPROV hStoreProv,
878  PCCTL_CONTEXT pCtlContext, void *pvStoreProvFindInfo, DWORD dwFlags);
879
880 typedef BOOL (WINAPI *PFN_CERT_STORE_PROV_GET_CTL_PROPERTY)(
881  HCERTSTOREPROV hStoreProv, PCCTL_CONTEXT pCtlContext, DWORD dwPropId,
882  DWORD dwFlags, void *pvData);
883
884 typedef struct _CERT_CREATE_CONTEXT_PARA {
885     DWORD          cbSize;
886     PFN_CRYPT_FREE pfnFree;
887     void          *pvFree;
888 } CERT_CREATE_CONTEXT_PARA, *PCERT_CREATE_CONTEXT_PARA;
889
890 typedef struct _CRYPT_OID_FUNC_ENTRY {
891     LPCSTR pszOID;
892     void  *pvFuncAddr;
893 } CRYPT_OID_FUNC_ENTRY, *PCRYPT_OID_FUNC_ENTRY;
894
895 typedef BOOL (WINAPI *PFN_CRYPT_ENUM_OID_FUNC)(DWORD dwEncodingType,
896  LPCSTR pszFuncName, LPCSTR pszOID, DWORD cValue, const DWORD rgdwValueType[],
897  LPCWSTR const rgpwszValueName[], const BYTE * const rgpbValueData[],
898  const DWORD rgcbValueData[], void *pvArg);
899
900 #define CRYPT_MATCH_ANY_ENCODING_TYPE 0xffffffff
901
902 typedef struct _CRYPT_OID_INFO {
903     DWORD   cbSize;
904     LPCSTR  pszOID;
905     LPCWSTR pwszName;
906     DWORD   dwGroupId;
907     union {
908         DWORD  dwValue;
909         ALG_ID Algid;
910         DWORD  dwLength;
911     } DUMMYUNIONNAME;
912     CRYPT_DATA_BLOB ExtraInfo;
913 } CRYPT_OID_INFO, *PCRYPT_OID_INFO;
914 typedef const CRYPT_OID_INFO CCRYPT_OID_INFO, *PCCRYPT_OID_INFO;
915
916 typedef BOOL (WINAPI *PFN_CRYPT_ENUM_OID_INFO)(PCCRYPT_OID_INFO pInfo,
917  void *pvArg);
918
919 typedef struct _CRYPT_SIGN_MESSAGE_PARA {
920     DWORD                      cbSize;
921     DWORD                      dwMsgEncodingType;
922     PCCERT_CONTEXT             pSigningCert;
923     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
924     void *                     pvHashAuxInfo;
925     DWORD                      cMsgCert;
926     PCCERT_CONTEXT            *rgpMsgCert;
927     DWORD                      cMsgCrl;
928     PCCRL_CONTEXT             *rgpMsgCrl;
929     DWORD                      cAuthAttr;
930     PCRYPT_ATTRIBUTE           rgAuthAttr;
931     DWORD                      cUnauthAttr;
932     PCRYPT_ATTRIBUTE           rgUnauthAttr;
933     DWORD                      dwFlags;
934     DWORD                      dwInnerContentType;
935 #ifdef CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS
936     CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm;
937     void *                     pvHashEncryptionAuxInfo;
938 #endif
939 } CRYPT_SIGN_MESSAGE_PARA, *PCRYPT_SIGN_MESSAGE_PARA;
940
941 #define CRYPT_MESSAGE_BARE_CONTENT_OUT_FLAG         0x00000001
942 #define CRYPT_MESSAGE_ENCAPSULATED_CONTENT_OUT_FLAG 0x00000002
943 #define CRYPT_MESSAGE_KEYID_SIGNER_FLAG             0x00000004
944 #define CRYPT_MESSAGE_SILENT_KEYSET_FLAG            0x00000008
945
946 typedef PCCERT_CONTEXT (WINAPI *PFN_CRYPT_GET_SIGNER_CERTIFICATE)(void *pvArg,
947  DWORD dwCertEncodingType, PCERT_INFO pSignerId, HCERTSTORE hMsgCertStore);
948
949 typedef struct _CRYPT_VERIFY_MESSAGE_PARA {
950     DWORD                            cbSize;
951     DWORD                            dwMsgAndCertEncodingType;
952     HCRYPTPROV                       hCryptProv;
953     PFN_CRYPT_GET_SIGNER_CERTIFICATE pfnGetSignerCertificate;
954     void *                           pvGetArg;
955 } CRYPT_VERIFY_MESSAGE_PARA, *PCRYPT_VERIFY_MESSAGE_PARA;
956
957 typedef struct _CRYPT_ENCRYPT_MESSAGE_PARA {
958     DWORD                      cbSize;
959     DWORD                      dwMsgEncodingType;
960     HCRYPTPROV                 hCryptProv;
961     CRYPT_ALGORITHM_IDENTIFIER ContentEncryptionAlgorithm;
962     void *                     pvEncryptionAuxInfo;
963     DWORD                      dwFlags;
964     DWORD                      dwInnerContentType;
965 } CRYPT_ENCRYPT_MESSAGE_PARA, *PCRYPT_ENCRYPT_MESSAGE_PARA;
966
967 #define CRYPT_MESSAGE_KEYID_RECIPIENT_FLAG 0x00000004
968
969 typedef struct _CRYPT_DECRYPT_MESSAGE_PARA {
970     DWORD       cbSize;
971     DWORD       dwMsgAndCertEncodingType;
972     DWORD       cCertStore;
973     HCERTSTORE *rghCertStore;
974 #ifdef CRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS
975     DWORD       dwFlags;
976 #endif
977 } CRYPT_DECRYPT_MESSAGE_PARA, *PCRYPT_DECRYPT_MESSAGE_PARA;
978
979 typedef struct _CRYPT_HASH_MESSAGE_PARA {
980     DWORD                      cbSize;
981     DWORD                      dwMsgEncodingType;
982     HCRYPTPROV                 hCryptProv;
983     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
984     void *                     pvHashAuxInfo;
985 } CRYPT_HASH_MESSAGE_PARA, *PCRYPT_HASH_MESSAGE_PARA;
986
987 typedef struct _CRYPT_KEY_SIGN_MESSAGE_PARA {
988     DWORD                      cbSize;
989     DWORD                      dwMsgAndCertEncodingType;
990     HCRYPTPROV                 hCryptProv;
991     DWORD                      dwKeySpec;
992     CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm;
993     void *                     pvHashAuxInfo;
994 } CRYPT_KEY_SIGN_MESSAGE_PARA, *PCRYPT_KEY_SIGN_MESSAGE_PARA;
995
996 typedef struct _CRYPT_KEY_VERIFY_MESSAGE_PARA {
997     DWORD      cbSize;
998     DWORD      dwMsgEncodingType;
999     HCRYPTPROV hCryptProv;
1000 } CRYPT_KEY_VERIFY_MESSAGE_PARA, *PCRYPT_KEY_VERIFY_MESSAGE_PARA;
1001
1002 typedef struct _CRYPT_URL_ARRAY {
1003     DWORD   cUrl;
1004     LPWSTR *rgwszUrl;
1005 } CRYPT_URL_ARRAY, *PCRYPT_URL_ARRAY;
1006
1007 typedef struct _CRYPT_URL_INFO {
1008     DWORD  cbSize;
1009     DWORD  dwSyncDeltaTime;
1010     DWORD  cGroup;
1011     DWORD *rgcGroupEntry;
1012 } CRYPT_URL_INFO, *PCRYPT_URL_INFO;
1013
1014 /* OID group IDs */
1015 #define CRYPT_HASH_ALG_OID_GROUP_ID     1
1016 #define CRYPT_ENCRYPT_ALG_OID_GROUP_ID  2
1017 #define CRYPT_PUBKEY_ALG_OID_GROUP_ID   3
1018 #define CRYPT_SIGN_ALG_OID_GROUP_ID     4
1019 #define CRYPT_RDN_ATTR_OID_GROUP_ID     5
1020 #define CRYPT_EXT_OR_ATTR_OID_GROUP_ID  6
1021 #define CRYPT_ENHKEY_USAGE_OID_GROUP_ID 7
1022 #define CRYPT_POLICY_OID_GROUP_ID       8
1023 #define CRYPT_TEMPLATE_OID_GROUP_ID     9
1024 #define CRYPT_LAST_OID_GROUP_ID         9
1025
1026 #define CRYPT_FIRST_ALG_OID_GROUP_ID CRYPT_HASH_ALG_OID_GROUP_ID
1027 #define CRYPT_LAST_ALG_OID_GROUP_ID  CRYPT_SIGN_ALG_OID_GROUP_ID
1028
1029 #define CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG  0x1
1030 #define CRYPT_OID_USE_PUBKEY_PARA_FOR_PKCS7_FLAG 0x2
1031 #define CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG    0x4
1032
1033 #define CRYPT_OID_INFO_OID_KEY   1
1034 #define CRYPT_OID_INFO_NAME_KEY  2
1035 #define CRYPT_OID_INFO_ALGID_KEY 3
1036 #define CRYPT_OID_INFO_SIGN_KEY  4
1037
1038 /* Algorithm IDs */
1039
1040 #define GET_ALG_CLASS(x)                (x & (7 << 13))
1041 #define GET_ALG_TYPE(x)                 (x & (15 << 9))
1042 #define GET_ALG_SID(x)                  (x & (511))
1043
1044 /* Algorithm Classes */
1045 #define ALG_CLASS_ANY                   (0)
1046 #define ALG_CLASS_SIGNATURE             (1 << 13)
1047 #define ALG_CLASS_MSG_ENCRYPT           (2 << 13)
1048 #define ALG_CLASS_DATA_ENCRYPT          (3 << 13)
1049 #define ALG_CLASS_HASH                  (4 << 13)
1050 #define ALG_CLASS_KEY_EXCHANGE          (5 << 13)
1051 /* Algorithm types */
1052 #define ALG_TYPE_ANY                    (0)
1053 #define ALG_TYPE_DSS                    (1 << 9)
1054 #define ALG_TYPE_RSA                    (2 << 9)
1055 #define ALG_TYPE_BLOCK                  (3 << 9)
1056 #define ALG_TYPE_STREAM                 (4 << 9)
1057 #define ALG_TYPE_DH                     (5 << 9)
1058 #define ALG_TYPE_SECURECHANNEL          (6 << 9)
1059
1060 /* SIDs */
1061 #define ALG_SID_ANY                     (0)
1062 /* RSA SIDs */
1063 #define ALG_SID_RSA_ANY                 0
1064 #define ALG_SID_RSA_PKCS                1
1065 #define ALG_SID_RSA_MSATWORK            2
1066 #define ALG_SID_RSA_ENTRUST             3
1067 #define ALG_SID_RSA_PGP                 4
1068 /* DSS SIDs */
1069 #define ALG_SID_DSS_ANY                 0
1070 #define ALG_SID_DSS_PKCS                1
1071 #define ALG_SID_DSS_DMS                 2
1072
1073 /* DES SIDs */
1074 #define ALG_SID_DES                     1
1075 #define ALG_SID_3DES                    3
1076 #define ALG_SID_DESX                    4
1077 #define ALG_SID_IDEA                    5
1078 #define ALG_SID_CAST                    6
1079 #define ALG_SID_SAFERSK64               7
1080 #define ALG_SID_SAFERSK128              8
1081 #define ALG_SID_3DES_112                9
1082 /* Diffie-Hellmans SIDs */
1083 #define ALG_SID_DH_SANDF                1
1084 #define ALG_SID_DH_EPHEM                2
1085 #define ALG_SID_AGREED_KEY_ANY          3
1086 #define ALG_SID_KEA                     4
1087 /* RC2 SIDs */
1088 #define ALG_SID_RC4                     1
1089 #define ALG_SID_RC2                     2
1090 #define ALG_SID_SEAL                    2
1091 /* Hash SIDs */
1092 #define ALG_SID_MD2                     1
1093 #define ALG_SID_MD4                     2
1094 #define ALG_SID_MD5                     3
1095 #define ALG_SID_SHA                     4
1096 #define ALG_SID_SHA1                    CALG_SHA
1097 #define ALG_SID_MAC                     5
1098 #define ALG_SID_RIPEMD                  6
1099 #define ALG_SID_RIPEMD160               7
1100 #define ALG_SID_SSL3SHAMD5              8
1101 #define ALG_SID_HMAC                    9
1102 #define ALG_SID_TLS1PRF                10
1103 /* SCHANNEL SIDs */
1104 #define ALG_SID_SSL3_MASTER             1
1105 #define ALG_SID_SCHANNEL_MASTER_HASH    2
1106 #define ALG_SID_SCHANNEL_MAC_KEY        3
1107 #define ALG_SID_PCT1_MASTER             4
1108 #define ALG_SID_SSL2_MASTER             5
1109 #define ALG_SID_TLS1_MASTER             6
1110 #define ALG_SID_SCHANNEL_ENC_KEY        7
1111 #define ALG_SID_EXAMPLE                80
1112
1113 /* Algorithm Definitions */
1114 #define CALG_MD2                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD2)
1115 #define CALG_MD4                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD4)
1116 #define CALG_MD5                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MD5)
1117 #define CALG_SHA                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SHA)
1118 #define CALG_SHA1 CALG_SHA
1119 #define CALG_MAC                  (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_MAC)
1120 #define CALG_SSL3_SHAMD5          (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_SSL3SHAMD5)
1121 #define CALG_HMAC                 (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_HMAC)
1122 #define CALG_TLS1PRF              (ALG_CLASS_HASH         | ALG_TYPE_ANY           | ALG_SID_TLS1PRF)
1123 #define CALG_RSA_SIGN             (ALG_CLASS_SIGNATURE    | ALG_TYPE_RSA           | ALG_SID_RSA_ANY)
1124 #define CALG_DSS_SIGN             (ALG_CLASS_SIGNATURE    | ALG_TYPE_DSS           | ALG_SID_DSS_ANY)
1125 #define CALG_NO_SIGN              (ALG_CLASS_SIGNATURE    | ALG_TYPE_ANY           | ALG_SID_ANY)
1126 #define CALG_DH_SF                (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH            | ALG_SID_DH_SANDF)
1127 #define CALG_DH_EPHEM             (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH            | ALG_SID_DH_EPHEM)
1128 #define CALG_RSA_KEYX             (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA           | ALG_SID_RSA_ANY)
1129 #define CALG_DES                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_DES)
1130 #define CALG_RC2                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_RC2)
1131 #define CALG_3DES                 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_3DES)
1132 #define CALG_3DES_112             (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK         | ALG_SID_3DES_112)
1133 #define CALG_RC4                  (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM        | ALG_SID_RC4)
1134 #define CALG_SEAL                 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM        | ALG_SID_SEAL)
1135 #define CALG_SSL3_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL3_MASTER)
1136 #define CALG_SCHANNEL_MASTER_HASH (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MASTER_HASH)
1137 #define CALG_SCHANNEL_MAC_KEY     (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MAC_KEY)
1138 #define CALG_SCHANNEL_ENC_KEY     (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_ENC_KEY)
1139 #define CALG_PCT1_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_PCT1_MASTER)
1140 #define CALG_SSL2_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL2_MASTER)
1141 #define CALG_TLS1_MASTER          (ALG_CLASS_MSG_ENCRYPT  | ALG_TYPE_SECURECHANNEL | ALG_SID_TLS1_MASTER)
1142
1143 /* Protocol Flags */
1144 #define CRYPT_FLAG_PCT1    0x0001
1145 #define CRYPT_FLAG_SSL2    0x0002
1146 #define CRYPT_FLAG_SSL3    0x0004
1147 #define CRYPT_FLAG_TLS1    0x0008
1148 #define CRYPT_FLAG_IPSEC   0x0010
1149 #define CRYPT_FLAG_SIGNING 0x0020
1150
1151 /* Provider names */
1152 #define MS_DEF_PROV_A                            "Microsoft Base Cryptographic Provider v1.0"
1153 #if defined(__GNUC__)
1154 # define MS_DEF_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1155         'B','a','s','e',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1156         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 }
1157 #elif defined(_MSC_VER)
1158 # define MS_DEF_PROV_W      L"Microsoft Base Cryptographic Provider v1.0"
1159 #else
1160 static const WCHAR MS_DEF_PROV_W[] =             { 'M','i','c','r','o','s','o','f','t',' ',
1161         'B','a','s','e',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1162         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 };
1163 #endif
1164 #define MS_DEF_PROV                              WINELIB_NAME_AW(MS_DEF_PROV_)
1165
1166 #define MS_ENHANCED_PROV_A                       "Microsoft Enhanced Cryptographic Provider v1.0"
1167 #if defined(__GNUC__)
1168 # define MS_ENHANCED_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1169         'E','n','h','a','n','c','e','d',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1170         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 }
1171 #elif defined(_MSC_VER)
1172 # define MS_ENHANCED_PROV_W     L"Microsoft Enhanced Cryptographic Provider v1.0"
1173 #else
1174 static const WCHAR MS_ENHANCED_PROV_W[] =        { 'M','i','c','r','o','s','o','f','t',' ',
1175         'E','n','h','a','n','c','e','d',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1176         'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 };
1177 #endif
1178 #define MS_ENHANCED_PROV                         WINELIB_NAME_AW(MS_ENHANCED_PROV_)
1179
1180 #define MS_STRONG_PROV_A                         "Microsoft Strong Cryptographic Provider"
1181 #if defined(__GNUC__)
1182 # define MS_STRONG_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1183         'S','t','r','o','n','g',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ', \
1184         'P','r','o','v','i','d','e','r',0 }
1185 #elif defined(_MSC_VER)
1186 # define MS_STRONG_PROV_W     L"Microsoft Strong Cryptographic Provider"
1187 #else
1188 static const WCHAR MS_STRONG_PROV_W[] =          { 'M','i','c','r','o','s','o','f','t',' ',
1189         'S','t','r','o','n','g',' ','C','r','y','p','t','o','g','r','a','p','h','i','c',' ',
1190         'P','r','o','v','i','d','e','r',0 };
1191 #endif
1192 #define MS_STRONG_PROV                           WINELIB_NAME_AW(MS_STRONG_PROV_)
1193
1194 #define MS_DEF_RSA_SIG_PROV_A                    "Microsoft RSA Signature Cryptographic Provider"
1195 #if defined(__GNUC__)
1196 # define MS_DEF_RSA_SIG_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1197         'R','S','A',' ','S','i','g','n','a','t','u','r','e',' ', \
1198         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1199 #elif defined(_MSC_VER)
1200 # define MS_DEF_RSA_SIG_PROV_W      L"Microsoft RSA Signature Cryptographic Provider"
1201 #else
1202 static const WCHAR MS_DEF_RSA_SIG_PROV_W[] =     { 'M','i','c','r','o','s','o','f','t',' ',
1203         'R','S','A',' ','S','i','g','n','a','t','u','r','e',' ',
1204         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1205 #endif
1206 #define MS_DEF_RSA_SIG_PROV                      WINELIB_NAME_AW(MS_DEF_RSA_SIG_PROV_)
1207
1208 #define MS_DEF_RSA_SCHANNEL_PROV_A               "Microsoft RSA SChannel Cryptographic Provider"
1209 #if defined(__GNUC__)
1210 # define MS_DEF_RSA_SCHANNEL_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1211         'R','S','A',' ','S','C','h','a','n','n','e','l',' ', \
1212         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1213 #elif defined(_MSC_VER)
1214 # define MS_DEF_RSA_SCHANNEL_PROV_W     L"Microsoft RSA SChannel Cryptographic Provider"
1215 #else
1216 static const WCHAR MS_DEF_RSA_SCHANNEL_PROV_W[] = { 'M','i','c','r','o','s','o','f','t',' ',
1217         'R','S','A',' ','S','C','h','a','n','n','e','l',' ',
1218         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1219 #endif
1220 #define MS_DEF_RSA_SCHANNEL_PROV                 WINELIB_NAME_AW(MS_DEF_RSA_SCHANNEL_PROV_)
1221
1222 #define MS_DEF_DSS_PROV_A                        "Microsoft Base DSS Cryptographic Provider"
1223 #if defined(__GNUC__)
1224 # define MS_DEF_DSS_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1225         'B','a','s','e',' ','D','S','S',' ', \
1226         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1227 #elif defined(_MSC_VER)
1228 # define MS_DEF_DSS_PROV_W     L"Microsoft Base DSS Cryptographic Provider"
1229 #else
1230 static const WCHAR MS_DEF_DSS_PROV_W[] =         { 'M','i','c','r','o','s','o','f','t',' ',
1231         'B','a','s','e',' ','D','S','S',' ',
1232         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1233 #endif
1234 #define MS_DEF_DSS_PROV                          WINELIB_NAME_AW(MS_DEF_DSS_PROV_)
1235
1236 #define MS_DEF_DSS_DH_PROV_A                     "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
1237 #if defined(__GNUC__)
1238 # define MS_DEF_DSS_DH_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1239         'B','a','s','e',' ','D','S','S',' ','a','n','d',' ', \
1240         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ', \
1241         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1242 #elif defined(_MSC_VER)
1243 # define MS_DEF_DSS_DH_PROV_W     L"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
1244 #else
1245 static const WCHAR MS_DEF_DSS_DH_PROV_W[] =      { 'M','i','c','r','o','s','o','f','t',' ',
1246         'B','a','s','e',' ','D','S','S',' ','a','n','d',' ',
1247         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ',
1248         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1249 #endif
1250 #define MS_DEF_DSS_DH_PROV                       WINELIB_NAME_AW(MS_DEF_DSS_DH_PROV_)
1251
1252 #define MS_ENH_DSS_DH_PROV_A                     "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"
1253 #if defined(__GNUC__)
1254 # define MS_ENH_DSS_DH_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1255         'E','n','h','a','n','c','e','d',' ','D','S','S',' ','a','n','d',' ', \
1256         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ', \
1257         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1258 #elif defined(_MSC_VER)
1259 # define MS_ENH_DSS_DH_PROV_W     L"Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"
1260 #else
1261 static const WCHAR MS_ENH_DSS_DH_PROV_W[] =      { 'M','i','c','r','o','s','o','f','t',' ',
1262         'E','n','h','a','n','c','e','d',' ','D','S','S',' ','a','n','d',' ',
1263         'D','i','f','f','i','e','-','H','e','l','l','m','a','n',' ',
1264         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1265 #endif
1266 #define MS_ENH_DSS_DH_PROV                       WINELIB_NAME_AW(MS_ENH_DSS_DH_PROV_)
1267
1268 #define MS_DEF_DH_SCHANNEL_PROV_A                "Microsoft DH SChannel Cryptographic Provider"
1269 #if defined(__GNUC__)
1270 # define MS_DEF_DH_SCHANNEL_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1271         'D','H',' ','S','C','h','a','n','n','e','l',' ', \
1272         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1273 #elif defined(_MSC_VER)
1274 # define MS_DEF_DH_SCHANNEL_PROV_W     L"Microsoft DH SChannel Cryptographic Provider"
1275 #else
1276 static const WCHAR MS_DEF_DH_SCHANNEL_PROV_W[] = { 'M','i','c','r','o','s','o','f','t',' ',
1277         'D','H',' ','S','C','h','a','n','n','e','l',' ',
1278         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1279 #endif
1280 #define MS_DEF_DH_SCHANNEL_PROV                  WINELIB_NAME_AW(MS_DEF_DH_SCHANNEL_PROV_)
1281
1282 #define MS_SCARD_PROV_A                          "Microsoft Base Smart Card Cryptographic Provider"
1283 #if defined(__GNUC__)
1284 # define MS_SCARD_PROV_W (const WCHAR []){ 'M','i','c','r','o','s','o','f','t',' ', \
1285         'B','a','s','e',' ','S','m','a','r','t',' ','C','a','r','d',' ', \
1286         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }
1287 #elif defined(_MSC_VER)
1288 # define MS_SCARD_PROV_W     L"Microsoft Base Smart Card Cryptographic Provider"
1289 #else
1290 static const WCHAR MS_SCARD_PROV_W[] =           { 'M','i','c','r','o','s','o','f','t',' ',
1291         'B','a','s','e',' ','S','m','a','r','t',' ','C','a','r','d',' ',
1292         'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 };
1293 #endif
1294 #define MS_SCARD_PROV                            WINELIB_NAME_AW(MS_SCARD_PROV_)
1295
1296 /* Key Specs*/
1297 #define AT_KEYEXCHANGE          1
1298 #define AT_SIGNATURE            2
1299
1300 /* Provider Types */
1301 #define PROV_RSA_FULL             1
1302 #define PROV_RSA_SIG              2
1303 #define PROV_DSS                  3
1304 #define PROV_FORTEZZA             4
1305 #define PROV_MS_EXCHANGE          5
1306 #define PROV_SSL                  6
1307 #define PROV_RSA_SCHANNEL         12
1308 #define PROV_DSS_DH               13
1309 #define PROV_EC_ECDSA_SIG         14
1310 #define PROV_EC_ECNRA_SIG         15
1311 #define PROV_EC_ECDSA_FULL        16
1312 #define PROV_EC_ECNRA_FULL        17
1313 #define PROV_DH_SCHANNEL          18
1314 #define PROV_SPYRUS_LYNKS         20
1315 #define PROV_RNG                  21
1316 #define PROV_INTEL_SEC            22
1317 #define PROV_REPLACE_OWF          23
1318 #define PROV_RSA_AES              24
1319
1320 /* FLAGS Section */
1321
1322 /* Provider Parameters */
1323 #define PP_ENUMALGS             1
1324 #define PP_ENUMCONTAINERS       2
1325 #define PP_IMPTYPE              3
1326 #define PP_NAME                 4
1327 #define PP_VERSION              5
1328 #define PP_CONTAINER            6
1329
1330 #define CRYPT_FIRST             1
1331 #define CRYPT_NEXT              2
1332
1333 #define CRYPT_IMPL_HARDWARE     1
1334 #define CRYPT_IMPL_SOFTWARE     2
1335 #define CRYPT_IMPL_MIXED        3
1336 #define CRYPT_IMPL_UNKNOWN      4
1337
1338 /* CryptAcquireContext */
1339 #define CRYPT_VERIFYCONTEXT       0xF0000000
1340 #define CRYPT_NEWKEYSET           0x00000008
1341 #define CRYPT_DELETEKEYSET        0x00000010
1342 #define CRYPT_MACHINE_KEYSET      0x00000020
1343 #define CRYPT_SILENT              0x00000040
1344
1345 /* Crypt{Get|Set}Provider */
1346 #define CRYPT_MACHINE_DEFAULT     0x00000001
1347 #define CRYPT_USER_DEFAULT        0x00000002
1348 #define CRYPT_DELETE_DEFAULT      0x00000004
1349
1350 /* Crypt{Get/Set}ProvParam */
1351 #define PP_CLIENT_HWND          1
1352 #define PP_ENUMALGS             1
1353 #define PP_ENUMCONTAINERS       2
1354 #define PP_IMPTYPE              3
1355 #define PP_NAME                 4
1356 #define PP_VERSION              5
1357 #define PP_CONTAINER            6
1358 #define PP_CHANGE_PASSWORD      7
1359 #define PP_KEYSET_SEC_DESCR     8
1360 #define PP_KEY_TYPE_SUBTYPE     10
1361 #define PP_CONTEXT_INFO         11
1362 #define PP_KEYEXCHANGE_KEYSIZE  12
1363 #define PP_SIGNATURE_KEYSIZE    13
1364 #define PP_KEYEXCHANGE_ALG      14
1365 #define PP_SIGNATURE_ALG        15
1366 #define PP_PROVTYPE             16
1367 #define PP_KEYSTORAGE           17
1368 #define PP_SYM_KEYSIZE          19
1369 #define PP_SESSION_KEYSIZE      20
1370 #define PP_UI_PROMPT            21
1371 #define PP_ENUMALGS_EX          22
1372 #define PP_DELETEKEY            24
1373 #define PP_ENUMMANDROOTS        25
1374 #define PP_ENUMELECTROOTS       26
1375 #define PP_KEYSET_TYPE          27
1376 #define PP_ADMIN_PIN            31
1377 #define PP_KEYEXCHANGE_PIN      32
1378 #define PP_SIGNATURE_PIN        33
1379 #define PP_SIG_KEYSIZE_INC      34
1380 #define PP_KEYX_KEYSIZE_INC     35
1381 #define PP_UNIQUE_CONTAINER     36
1382 #define PP_SGC_INFO             37
1383 #define PP_USE_HARDWARE_RNG     38
1384 #define PP_KEYSPEC              39
1385 #define PP_ENUMEX_SIGNING_PROT  40
1386
1387 /* Crypt{Get/Set}KeyParam */
1388 #define KP_IV                   1
1389 #define KP_SALT                 2
1390 #define KP_PADDING              3
1391 #define KP_MODE                 4
1392 #define KP_MODE_BITS            5
1393 #define KP_PERMISSIONS          6
1394 #define KP_ALGID                7
1395 #define KP_BLOCKLEN             8
1396 #define KP_KEYLEN               9
1397 #define KP_SALT_EX              10
1398 #define KP_P                    11
1399 #define KP_G                    12
1400 #define KP_Q                    13
1401 #define KP_X                    14
1402 #define KP_Y                    15
1403 #define KP_RA                   16
1404 #define KP_RB                   17
1405 #define KP_INFO                 18
1406 #define KP_EFFECTIVE_KEYLEN     19
1407 #define KP_SCHANNEL_ALG         20
1408 #define KP_CLIENT_RANDOM        21
1409 #define KP_SERVER_RANDOM        22
1410 #define KP_RP                   23
1411 #define KP_PRECOMP_MD5          24
1412 #define KP_PRECOMP_SHA          25
1413 #define KP_CERTIFICATE          26
1414 #define KP_CLEAR_KEY            27
1415 #define KP_PUB_EX_LEN           28
1416 #define KP_PUB_EX_VAL           29
1417 #define KP_KEYVAL               30
1418 #define KP_ADMIN_PIN            31
1419 #define KP_KEYEXCHANGE_PIN      32
1420 #define KP_SIGNATURE_PIN        33
1421 #define KP_PREHASH              34
1422
1423 /* CryptSignHash/CryptVerifySignature */
1424 #define CRYPT_NOHASHOID         0x00000001
1425 #define CRYPT_TYPE2_FORMAT      0x00000002
1426 #define CRYPT_X931_FORMAT       0x00000004
1427
1428 /* Crypt{Get,Set}HashParam */
1429 #define HP_ALGID                0x0001
1430 #define HP_HASHVAL              0x0002
1431 #define HP_HASHSIZE             0x0004
1432 #define HP_HMAC_INFO            0x0005
1433 #define HP_TLS1PRF_LABEL        0x0006
1434 #define HP_TLS1PRF_SEED         0x0007
1435
1436 /* Crypt{Get,Set}KeyParam */
1437 #define CRYPT_MODE_CBC          1
1438 #define CRYPT_MODE_ECB          2
1439 #define CRYPT_MODE_OFB          3
1440 #define CRYPT_MODE_CFB          4
1441
1442 #define CRYPT_ENCRYPT           0x0001 
1443 #define CRYPT_DECRYPT           0x0002
1444 #define CRYPT_EXPORT            0x0004
1445 #define CRYPT_READ              0x0008
1446 #define CRYPT_WRITE             0x0010
1447 #define CRYPT_MAC               0x0020
1448
1449 /* Crypt*Key */
1450 #define CRYPT_EXPORTABLE        0x00000001
1451 #define CRYPT_USER_PROTECTED    0x00000002
1452 #define CRYPT_CREATE_SALT       0x00000004
1453 #define CRYPT_UPDATE_KEY        0x00000008
1454 #define CRYPT_NO_SALT           0x00000010
1455 #define CRYPT_PREGEN            0x00000040
1456 #define CRYPT_SERVER            0x00000400
1457 #define CRYPT_ARCHIVABLE        0x00004000
1458
1459 /* CryptExportKey */
1460 #define CRYPT_SSL2_FALLBACK     0x00000002
1461 #define CRYPT_DESTROYKEY        0x00000004
1462 #define CRYPT_OAEP              0x00000040
1463
1464 /* CryptHashSessionKey */
1465 #define CRYPT_LITTLE_ENDIAN     0x00000001
1466
1467 /* Crypt{Protect,Unprotect}Data PROMPTSTRUCT flags */
1468 #define CRYPTPROTECT_PROMPT_ON_PROTECT    0x0001
1469 #define CRYPTPROTECT_PROMPT_ON_UNPROTECT  0x0002
1470 /* Crypt{Protect,Unprotect}Data flags */
1471 #define CRYPTPROTECT_UI_FORBIDDEN       0x0001
1472 #define CRYPTPROTECT_LOCAL_MACHINE      0x0004
1473 #define CRYPTPROTECT_AUDIT              0x0010
1474 #define CRYPTPROTECT_VERIFY_PROTECTION  0x0040
1475
1476 /* Blob Types */
1477 #define SIMPLEBLOB              0x1
1478 #define PUBLICKEYBLOB           0x6
1479 #define PRIVATEKEYBLOB          0x7
1480 #define PLAINTEXTKEYBLOB        0x8
1481 #define OPAQUEKEYBLOB           0x9
1482 #define PUBLICKEYBLOBEX         0xA
1483 #define SYMMETRICWRAPKEYBLOB    0xB
1484
1485 #define CUR_BLOB_VERSION        2
1486
1487 /* cert store provider types */
1488 #define CERT_STORE_PROV_MSG                  ((LPCSTR)1)
1489 #define CERT_STORE_PROV_MEMORY               ((LPCSTR)2)
1490 #define CERT_STORE_PROV_FILE                 ((LPCSTR)3)
1491 #define CERT_STORE_PROV_REG                  ((LPCSTR)4)
1492 #define CERT_STORE_PROV_PKCS7                ((LPCSTR)5)
1493 #define CERT_STORE_PROV_SERIALIZED           ((LPCSTR)6)
1494 #define CERT_STORE_PROV_FILENAME_A           ((LPCSTR)7)
1495 #define CERT_STORE_PROV_FILENAME_W           ((LPCSTR)8)
1496 #define CERT_STORE_PROV_SYSTEM_A             ((LPCSTR)9)
1497 #define CERT_STORE_PROV_SYSTEM_W             ((LPCSTR)10)
1498 #define CERT_STORE_PROV_SYSTEM               CERT_STORE_PROV_SYSTEM_W
1499 #define CERT_STORE_PROV_COLLECTION           ((LPCSTR)11)
1500 #define CERT_STORE_PROV_SYSTEM_REGISTRY_A    ((LPCSTR)12)
1501 #define CERT_STORE_PROV_SYSTEM_REGISTRY_W    ((LPCSTR)13)
1502 #define CERT_STORE_PROV_SYSTEM_REGISTRY      CERT_STORE_PROV_SYSTEM_REGISTRY_W
1503 #define CERT_STORE_PROV_PHYSICAL_W           ((LPCSTR)14)
1504 #define CERT_STORE_PROV_PHYSICAL             CERT_STORE_PROV_PHYSICAL_W
1505 #define CERT_STORE_PROV_SMART_CARD_W         ((LPCSTR)15)
1506 #define CERT_STORE_PROV_SMART_CARD           CERT_STORE_PROV_SMART_CARD_W
1507 #define CERT_STORE_PROV_LDAP_W               ((LPCSTR)16)
1508 #define CERT_STORE_PROV_LDAP                 CERT_STORE_PROV_LDAP_W
1509
1510 #define sz_CERT_STORE_PROV_MEMORY            "Memory"
1511 #define sz_CERT_STORE_PROV_FILENAME_W        "File"
1512 #define sz_CERT_STORE_PROV_FILENAME          sz_CERT_STORE_PROV_FILENAME_W
1513 #define sz_CERT_STORE_PROV_SYSTEM_W          "System"
1514 #define sz_CERT_STORE_PROV_SYSTEM            sz_CERT_STORE_PROV_SYSTEM_W
1515 #define sz_CERT_STORE_PROV_PKCS7             "PKCS7"
1516 #define sz_CERT_STORE_PROV_SERIALIZED        "Serialized"
1517 #define sz_CERT_STORE_PROV_COLLECTION        "Collection"
1518 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W "SystemRegistry"
1519 #define sz_CERT_STORE_PROV_SYSTEM_REGISTRY   sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W
1520 #define sz_CERT_STORE_PROV_PHYSICAL_W        "Physical"
1521 #define sz_CERT_STORE_PROV_PHYSICAL          sz_CERT_STORE_PROV_PHYSICAL_W
1522 #define sz_CERT_STORE_PROV_SMART_CARD_W      "SmartCard"
1523 #define sz_CERT_STORE_PROV_SMART_CARD        sz_CERT_STORE_PROV_SMART_CARD_W
1524 #define sz_CERT_STORE_PROV_LDAP_W            "Ldap"
1525 #define sz_CERT_STORE_PROV_LDAP              sz_CERT_STORE_PROV_LDAP_W
1526
1527 /* types for CertOpenStore dwEncodingType */
1528 #define CERT_ENCODING_TYPE_MASK 0x0000ffff
1529 #define CMSG_ENCODING_TYPE_MASK 0xffff0000
1530 #define GET_CERT_ENCODING_TYPE(x) ((x) & CERT_ENCODING_TYPE_MASK)
1531 #define GET_CMSG_ENCODING_TYPE(x) ((x) & CMSG_ENCODING_TYPE_MASK)
1532
1533 #define CRYPT_ASN_ENCODING  0x00000001
1534 #define CRYPT_NDR_ENCODING  0x00000002
1535 #define X509_ASN_ENCODING   0x00000001
1536 #define X509_NDR_ENCODING   0x00000002
1537 #define PKCS_7_ASN_ENCODING 0x00010000
1538 #define PKCS_7_NDR_ENCODING 0x00020000
1539
1540 /* system store locations */
1541 #define CERT_SYSTEM_STORE_LOCATION_MASK  0x00ff0000
1542 #define CERT_SYSTEM_STORE_LOCATION_SHIFT 16
1543
1544 /* system store location ids */
1545 /* hkcu */
1546 #define CERT_SYSTEM_STORE_CURRENT_USER_ID               1
1547 /* hklm */
1548 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ID              2
1549 /* hklm\Software\Microsoft\Cryptography\Services */
1550 #define CERT_SYSTEM_STORE_CURRENT_SERVICE_ID            4
1551 #define CERT_SYSTEM_STORE_SERVICES_ID                   5
1552 /* HKEY_USERS */
1553 #define CERT_SYSTEM_STORE_USERS_ID                      6
1554 /* hkcu\Software\Policies\Microsoft\SystemCertificates */
1555 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID  7
1556 /* hklm\Software\Policies\Microsoft\SystemCertificates */
1557 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID 8
1558 /* hklm\Software\Microsoft\EnterpriseCertificates */
1559 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID   9
1560
1561 /* system store location values */
1562 #define CERT_SYSTEM_STORE_CURRENT_USER \
1563  (CERT_SYSTEM_STORE_CURRENT_USER_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1564 #define CERT_SYSTEM_STORE_LOCAL_MACHINE \
1565  (CERT_SYSTEM_STORE_LOCAL_MACHINE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1566 #define CERT_SYSTEM_STORE_CURRENT_SERVICE \
1567  (CERT_SYSTEM_STORE_CURRENT_SERVICE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1568 #define CERT_SYSTEM_STORE_SERVICES \
1569  (CERT_SYSTEM_STORE_SERVICES_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1570 #define CERT_SYSTEM_STORE_USERS \
1571  (CERT_SYSTEM_STORE_USERS_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1572 #define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY \
1573  (CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1574 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY \
1575  (CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1576 #define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE \
1577  (CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT)
1578
1579 #if defined(__GNUC__)
1580 #define CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH (const WCHAR[])\
1581  {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t',\
1582   '\\','S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',\
1583   0 }
1584 #define CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH (const WCHAR[])\
1585  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',\
1586   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',\
1587   't','i','f','i','c','a','t','e','s',0 }
1588 #elif defined(_MSC_VER)
1589 #define CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH \
1590  L"Software\\Microsoft\\SystemCertificates"
1591 #define CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH \
1592  L"Software\\Policies\\Microsoft\\SystemCertificates"
1593 #else
1594 static const WCHAR CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH[] = 
1595  {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1596   'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s',0 };
1597 static const WCHAR CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH[] = 
1598  {'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
1599   'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m','C','e','r',
1600   't','i','f','i','c','a','t','e','s',0 };
1601 #endif
1602
1603 /* flags for CertOpenStore dwFlags */
1604 #define CERT_STORE_NO_CRYPT_RELEASE_FLAG            0x00000001
1605 #define CERT_STORE_SET_LOCALIZED_NAME_FLAG          0x00000002
1606 #define CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG 0x00000004
1607 #define CERT_STORE_DELETE_FLAG                      0x00000010
1608 #define CERT_STORE_UNSAFE_PHYSICAL_FLAG             0x00000020
1609 #define CERT_STORE_SHARE_STORE_FLAG                 0x00000040
1610 #define CERT_STORE_SHARE_CONTEXT_FLAG               0x00000080
1611 #define CERT_STORE_MANIFOLD_FLAG                    0x00000100
1612 #define CERT_STORE_ENUM_ARCHIVED_FLAG               0x00000200
1613 #define CERT_STORE_UPDATE_KEYID_FLAG                0x00000400
1614 #define CERT_STORE_BACKUP_RESTORE_FLAG              0x00000800
1615 #define CERT_STORE_MAXIMUM_ALLOWED_FLAG             0x00001000
1616 #define CERT_STORE_CREATE_NEW_FLAG                  0x00002000
1617 #define CERT_STORE_OPEN_EXISTING_FLAG               0x00004000
1618 #define CERT_STORE_READONLY_FLAG                    0x00008000
1619
1620 #define CERT_REGISTRY_STORE_REMOTE_FLAG      0x00010000
1621 #define CERT_REGISTRY_STORE_SERIALIZED_FLAG  0x00020000
1622 #define CERT_REGISTRY_STORE_ROAMING_FLAG     0x00040000
1623 #define CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG 0x00080000
1624 #define CERT_REGISTRY_STORE_LM_GPT_FLAG      0x01000000
1625 #define CERT_REGISTRY_STORE_CLIENT_GPT_FLAG  0x80000000
1626
1627 #define CERT_FILE_STORE_COMMIT_ENABLE_FLAG 0x00010000
1628
1629 /* dwAddDisposition */
1630 #define CERT_STORE_ADD_NEW                                 1
1631 #define CERT_STORE_ADD_USE_EXISTING                        2
1632 #define CERT_STORE_ADD_REPLACE_EXISTING                    3
1633 #define CERT_STORE_ADD_ALWAYS                              4
1634 #define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES 5
1635 #define CERT_STORE_ADD_NEWER                               6
1636 #define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES            7
1637
1638 /* Installable OID function defs */
1639 #define CRYPT_OID_OPEN_STORE_PROV_FUNC     "CertDllOpenStoreProv"
1640 #define CRYPT_OID_ENCODE_OBJECT_FUNC       "CryptDllEncodeObject"
1641 #define CRYPT_OID_DECODE_OBJECT_FUNC       "CryptDllDecodeObject"
1642 #define CRYPT_OID_ENCODE_OBJECT_EX_FUNC    "CryptDllEncodeObjectEx"
1643 #define CRYPT_OID_DECODE_OBJECT_EX_FUNC    "CryptDllDecodeObjectEx"
1644 #define CRYPT_OID_CREATE_COM_OBJECT_FUNC   "CryptDllCreateComObject"
1645 #define CRYPT_OID_VERIFY_REVOCATION_FUNC   "CertDllVerifyRevocation"
1646 #define CRYPT_OID_VERIFY_CTL_USAGE_FUNC    "CertDllVerifyCTLUsage"
1647 #define CRYPT_OID_FORMAT_OBJECT_FUNC       "CryptDllFormatObject"
1648 #define CRYPT_OID_FIND_OID_INFO_FUNC       "CryptDllFindOIDInfo"
1649 #define CRYPT_OID_FIND_LOCALIZED_NAME_FUNC "CryptDllFindLocalizedName"
1650 #define CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC  "CryptDllExportPublicKeyInfoEx"
1651 #define CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC  "CryptDllImportPublicKeyInfoEx"
1652 #define CRYPT_OID_EXPORT_PRIVATE_KEY_INFO_FUNC "CryptDllExportPrivateKeyInfoEx"
1653 #define CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC "CryptDllImportPrivateKeyInfoEx"
1654 #define CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC \
1655  "CertDllVerifyCertificateChainPolicy"
1656 #define URL_OID_GET_OBJECT_URL_FUNC    "UrlDllGetObjectUrl"
1657 #define TIME_VALID_OID_GET_OBJECT_FUNC "TimeValidDllGetObject"
1658
1659 #define CRYPT_OID_REGPATH "Software\\Microsoft\\Cryptography\\OID"
1660 #define CRYPT_OID_REG_ENCODING_TYPE_PREFIX "EncodingType "
1661 #if defined(__GNUC__)
1662 # define CRYPT_OID_REG_DLL_VALUE_NAME (const WCHAR []){ 'D','l','l',0 }
1663 # define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME \
1664  (const WCHAR []){ 'F','u','n','c','N','a','m','e',0 }
1665 # define CRYPT_OID_REG_FLAGS_VALUE_NAME \
1666  (const WCHAR []){ 'C','r','y','p','t','F','l','a','g','s',0 }
1667 #elif defined(_MSC_VER)
1668 # define CRYPT_OID_REG_DLL_VALUE_NAME       L"Dll"
1669 # define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME L"FuncName"
1670 # define CRYPT_OID_REG_FLAGS_VALUE_NAME     L"CryptFlags"
1671 #else
1672 static const WCHAR CRYPT_OID_REG_DLL_VALUE_NAME[] = { 'D','l','l',0 };
1673 static const WCHAR CRYPT_OID_REG_FUNC_NAME_VALUE_NAME[] =
1674  { 'F','u','n','c','N','a','m','e',0 };
1675 static const WCHAR CRYPT_OID_REG_FLAGS_VALUE_NAME[] =
1676  { 'C','r','y','p','t','F','l','a','g','s',0 };
1677 #endif
1678 #define CRYPT_OID_REG_FUNC_NAME_VALUE_NAME_A "FuncName"
1679 #define CRYPT_DEFAULT_OID                    "DEFAULT"
1680
1681 #define CRYPT_INSTALL_OID_FUNC_BEFORE_FLAG 1
1682
1683 #define CRYPT_GET_INSTALLED_OID_FUNC_FLAG  0x1
1684
1685 #define CRYPT_REGISTER_FIRST_INDEX 0
1686 #define CRYPT_REGISTER_LAST_INDEX  0xffffffff
1687
1688 /* values for CERT_STORE_PROV_INFO's dwStoreProvFlags */
1689 #define CERT_STORE_PROV_EXTERNAL_FLAG        0x1
1690 #define CERT_STORE_PROV_DELETED_FLAG         0x2
1691 #define CERT_STORE_PROV_NO_PERSIST_FLAG      0x4
1692 #define CERT_STORE_PROV_SYSTEM_STORE_FLAG    0x8
1693 #define CERT_STORE_PROV_LM_SYSTEM_STORE_FLAG 0x10
1694
1695 /* function indices */
1696 #define CERT_STORE_PROV_CLOSE_FUNC             0
1697 #define CERT_STORE_PROV_READ_CERT_FUNC         1
1698 #define CERT_STORE_PROV_WRITE_CERT_FUNC        2
1699 #define CERT_STORE_PROV_DELETE_CERT_FUNC       3
1700 #define CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC 4
1701 #define CERT_STORE_PROV_READ_CRL_FUNC          5
1702 #define CERT_STORE_PROV_WRITE_CRL_FUNC         6
1703 #define CERT_STORE_PROV_DELETE_CRL_FUNC        7
1704 #define CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC  8
1705 #define CERT_STORE_PROV_READ_CTL_FUNC          9
1706 #define CERT_STORE_PROV_WRITE_CTL_FUNC         10
1707 #define CERT_STORE_PROV_DELETE_CTL_FUNC        11
1708 #define CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC  12
1709 #define CERT_STORE_PROV_CONTROL_FUNC           13
1710 #define CERT_STORE_PROV_FIND_CERT_FUNC         14
1711 #define CERT_STORE_PROV_FREE_FIND_CERT_FUNC    15
1712 #define CERT_STORE_PROV_GET_CERT_PROPERTY_FUNC 16
1713 #define CERT_STORE_PROV_FIND_CRL_FUNC          17
1714 #define CERT_STORE_PROV_FREE_FIND_CRL_FUNC     18
1715 #define CERT_STORE_PROV_GET_CRL_PROPERTY_FUNC  19
1716 #define CERT_STORE_PROV_FIND_CTL_FUNC          20
1717 #define CERT_STORE_PROV_FREE_FIND_CTL_FUNC     21
1718 #define CERT_STORE_PROV_GET_CTL_PROPERTY_FUNC  22
1719
1720 /* physical store dwFlags, also used by CertAddStoreToCollection as
1721  * dwUpdateFlags
1722  */
1723 #define CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG                  0x1
1724 #define CERT_PHYSICAL_STORE_OPEN_DISABLE_FLAG                0x2
1725 #define CERT_PHYSICAL_STORE_REMOVE_OPEN_DISABLE_FLAG         0x4
1726 #define CERT_PHYSICAL_STORE_INSERT_COMPUTER_NAME_ENABLE_FLAG 0x8
1727
1728 /* dwFlag values for CertEnumPhysicalStore callback */
1729 #define CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG 0x1
1730
1731 /* predefined store names */
1732 #if defined(__GNUC__)
1733 # define CERT_PHYSICAL_STORE_DEFAULT_NAME (const WCHAR[])\
1734  {'.','D','e','f','a','u','l','t','0'}
1735 # define CERT_PHYSICAL_STORE_GROUP_POLICY_NAME (const WCHAR[])\
1736  {'.','G','r','o','u','p','P','o','l','i','c','y',0}
1737 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME (const WCHAR[])\
1738  {'.','L','o','c','a','l','M','a','c','h','i','n','e',0}
1739 # define CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME (const WCHAR[])\
1740  {'.','U','s','e','r','C','e','r','t','i','f','i','c','a','t','e',0}
1741 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME (const WCHAR[])\
1742  {'.','L','o','c','a','l','M','a','c','h','i','n','e','G','r','o','u','p',\
1743  'P','o','l','i','c','y',0}
1744 # define CERT_PHYSICAL_STORE_ENTERPRISE_NAME (const WCHAR[])\
1745  {'.','E','n','t','e','r','p','r','i','s','e',0}
1746 # define CERT_PHYSICAL_STORE_AUTH_ROOT_NAME (const WCHAR[])\
1747  {'.','A','u','t','h','R','o','o','t',0}
1748 #elif defined(_MSC_VER)
1749 # define CERT_PHYSICAL_STORE_DEFAULT_NAME \
1750  L".Default"
1751 # define CERT_PHYSICAL_STORE_GROUP_POLICY_NAME \
1752  L".GroupPolicy"
1753 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME \
1754  L".LocalMachine"
1755 # define CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME \
1756  L".UserCertificate"
1757 # define CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME \
1758  L".LocalMachineGroupPolicy"
1759 # define CERT_PHYSICAL_STORE_ENTERPRISE_NAME \
1760  L".Enterprise"
1761 # define CERT_PHYSICAL_STORE_AUTH_ROOT_NAME \
1762  L".AuthRoot"
1763 #else
1764 static const WCHAR CERT_PHYSICAL_STORE_DEFAULT_NAME[] = 
1765  {'.','D','e','f','a','u','l','t','0'};
1766 static const WCHAR CERT_PHYSICAL_STORE_GROUP_POLICY_NAME[] =
1767  {'.','G','r','o','u','p','P','o','l','i','c','y',0};
1768 static const WCHAR CERT_PHYSICAL_STORE_LOCAL_MACHINE_NAME[] =
1769  {'.','L','o','c','a','l','M','a','c','h','i','n','e',0};
1770 static const WCHAR CERT_PHYSICAL_STORE_DS_USER_CERTIFICATE_NAME[] =
1771  {'.','U','s','e','r','C','e','r','t','i','f','i','c','a','t','e',0};
1772 static const WCHAR CERT_PHYSICAL_STORE_LOCAL_MACHINE_GROUP_POLICY_NAME[] =
1773  {'.','L','o','c','a','l','M','a','c','h','i','n','e','G','r','o','u','p',
1774  'P','o','l','i','c','y',0};
1775 static const WCHAR CERT_PHYSICAL_STORE_ENTERPRISE_NAME[] =
1776  {'.','E','n','t','e','r','p','r','i','s','e',0};
1777 static const WCHAR CERT_PHYSICAL_STORE_AUTH_ROOT_NAME[] =
1778  {'.','A','u','t','h','R','o','o','t',0};
1779 #endif
1780
1781 /* cert system store flags */
1782 #define CERT_SYSTEM_STORE_MASK 0xffff0000
1783 #define CERT_SYSTEM_STORE_RELOCATE_FLAG 0x80000000
1784
1785 /* CertFindChainInStore dwFindType types */
1786 #define CERT_CHAIN_FIND_BY_ISSUER 1
1787
1788 /* CERT_INFO versions/flags */
1789 #define CERT_V1 0
1790 #define CERT_V2 1
1791 #define CERT_V3 2
1792 #define CERT_INFO_VERSION_FLAG                 1
1793 #define CERT_INFO_SERIAL_NUMBER_FLAG           2
1794 #define CERT_INFO_SIGNATURE_ALGORITHM_FLAG     3
1795 #define CERT_INFO_ISSUER_FLAG                  4
1796 #define CERT_INFO_NOT_BEFORE_FLAG              5
1797 #define CERT_INFO_NOT_AFTER_FLAG               6
1798 #define CERT_INFO_SUBJECT_FLAG                 7
1799 #define CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG 8
1800 #define CERT_INFO_ISSUER_UNIQUE_ID_FLAG        9
1801 #define CERT_INFO_SUBJECT_UNIQUE_ID_FLAG       10
1802 #define CERT_INFO_EXTENSION_FLAG               11
1803
1804 /* CERT_REQUEST_INFO versions */
1805 #define CERT_REQUEST_V1 0
1806
1807 /* CERT_KEYGEN_REQUEST_INFO versions */
1808 #define CERT_KEYGEN_REQUEST_V1 0
1809
1810 /* CRL versions */
1811 #define CRL_V1 0
1812 #define CRL_V2 1
1813
1814 /* CTL versions */
1815 #define CTL_V1 0
1816
1817 /* Certificate, CRL, CTL property IDs */
1818 #define CERT_KEY_PROV_HANDLE_PROP_ID               1
1819 #define CERT_KEY_PROV_INFO_PROP_ID                 2
1820 #define CERT_SHA1_HASH_PROP_ID                     3
1821 #define CERT_HASH_PROP_ID                          CERT_SHA1_HASH_PROP_ID
1822 #define CERT_MD5_HASH_PROP_ID                      4
1823 #define CERT_KEY_CONTEXT_PROP_ID                   5
1824 #define CERT_KEY_SPEC_PROP_ID                      6
1825 #define CERT_IE30_RESERVED_PROP_ID                 7
1826 #define CERT_PUBKEY_HASH_RESERVED_PROP_ID          8
1827 #define CERT_ENHKEY_USAGE_PROP_ID                  9
1828 #define CERT_CTL_USAGE_PROP_ID                     CERT_ENHKEY_USAGE_PROP_ID
1829 #define CERT_NEXT_UPDATE_LOCATION_PROP_ID          10
1830 #define CERT_FRIENDLY_NAME_PROP_ID                 11
1831 #define CERT_PVK_FILE_PROP_ID                      12
1832 #define CERT_DESCRIPTION_PROP_ID                   13
1833 #define CERT_ACCESS_STATE_PROP_ID                  14
1834 #define CERT_SIGNATURE_HASH_PROP_ID                15
1835 #define CERT_SMART_CARD_DATA_PROP_ID               16
1836 #define CERT_EFS_PROP_ID                           17
1837 #define CERT_FORTEZZA_DATA_PROP                    18
1838 #define CERT_ARCHIVED_PROP_ID                      19
1839 #define CERT_KEY_IDENTIFIER_PROP_ID                20
1840 #define CERT_AUTO_ENROLL_PROP_ID                   21
1841 #define CERT_PUBKEY_ALG_PARA_PROP_ID               22
1842 #define CERT_CROSS_CERT_DIST_POINTS_PROP_ID        23
1843 #define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID    24
1844 #define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID   25
1845 #define CERT_ENROLLMENT_PROP_ID                    26
1846 #define CERT_DATE_STAMP_PROP_ID                    27
1847 #define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID 28
1848 #define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID         29
1849 #define CERT_EXTENDED_ERROR_INFO_PROP_ID           30
1850 /* 31    -- unused?
1851    32    -- cert prop id
1852    33    -- CRL prop id
1853    34    -- CTL prop id
1854    35    -- KeyId prop id
1855    36-63 -- reserved
1856  */
1857 #define CERT_RENEWAL_PROP_ID                       64
1858 #define CERT_ARCHIVED_KEY_HASH_PROP_ID             65
1859 #define CERT_AUTO_ENROLL_RETRY_PROP_ID             66
1860 #define CERT_AIA_URL_RETRIEVED_PROP_ID             67
1861 #define CERT_FIRST_RESERVED_PROP_ID                68
1862 #define CERT_LAST_RESERVED_PROP_ID                 0x00007fff
1863 #define CERT_FIRST_USER_PROP_ID                    0x00008000
1864 #define CERT_LAST_USER_PROP_ID                     0x0000ffff
1865
1866 #define IS_CERT_HASH_PROP_ID(x) \
1867  ((x) == CERT_SHA1_HASH_PROP_ID || (x) == CERT_MD5_HASH_PROP_ID || \
1868   (x) == CERT_SIGNATURE_HASH_PROP_ID)
1869
1870 #define IS_PUBKEY_HASH_PROP_ID(x) \
1871  ((x) == CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID || \
1872   (x) == CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID)
1873
1874 #define IS_CHAIN_HASH_PROP_ID(x) \
1875  ((x) == CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID || \
1876   (x) == CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID || \
1877   (x) == CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID || \
1878   (x) == CERT_SUBJECT_NAME_MD5_HASH_PROP_ID)
1879
1880 /* access state flags */
1881 #define CERT_ACCESS_STATE_WRITE_PERSIST_FLAG   0x1
1882 #define CERT_ACCESS_STATE_SYSTEM_STORE_FLAG    0x2
1883 #define CERT_ACCESS_STATE_LM_SYSTEM_STORE_FLAG 0x4
1884
1885 /* CERT_RDN attribute dwValueType types */
1886 #define CERT_RDN_TYPE_MASK 0x000000ff
1887 #define CERT_RDN_ANY_TYPE         0
1888 #define CERT_RDN_ENCODED_BLOB     1
1889 #define CERT_RDN_OCTET_STRING     2
1890 #define CERT_RDN_NUMERIC_STRING   3
1891 #define CERT_RDN_PRINTABLE_STRING 4
1892 #define CERT_RDN_TELETEX_STRING   5
1893 #define CERT_RDN_T61_STRING       5
1894 #define CERT_RDN_VIDEOTEX_STRING  6
1895 #define CERT_RDN_IA5_STRING       7
1896 #define CERT_RDN_GRAPHIC_STRING   8
1897 #define CERT_RDN_VISIBLE_STRING   9
1898 #define CERT_RDN_ISO646_STRING    9
1899 #define CERT_RDN_GENERAL_STRING   10
1900 #define CERT_RDN_UNIVERSAL_STRING 11
1901 #define CERT_RDN_INT4_STRING      11
1902 #define CERT_RDN_BMP_STRING       12
1903 #define CERT_RDN_UNICODE_STRING   12
1904 #define CERT_RDN_UTF8_STRING      13
1905
1906 /* CERT_RDN attribute dwValueType flags */
1907 #define CERT_RDN_FLAGS_MASK 0xff000000
1908 #define CERT_RDN_ENABLE_T61_UNICODE_FLAG  0x80000000
1909 #define CERT_RDN_DISABLE_CHECK_TYPE_FLAG  0x4000000
1910 #define CERT_RDN_ENABLE_UTF8_UNICODE_FLAG 0x2000000
1911 #define CERT_RDN_DISABLE_IE4_UTF8_FLAG    0x0100000
1912
1913 #define IS_CERT_RDN_CHAR_STRING(x) \
1914  (((x) & CERT_RDN_TYPE_MASK) >= CERT_RDN_NUMERIC_STRING)
1915
1916 /* CRL reason codes */
1917 #define CRL_REASON_UNSPECIFIED            0
1918 #define CRL_REASON_KEY_COMPROMISE         1
1919 #define CRL_REASON_CA_COMPROMISE          2
1920 #define CRL_REASON_AFFILIATION_CHANGED    3
1921 #define CRL_REASON_SUPERSEDED             4
1922 #define CRL_REASON_CESSATION_OF_OPERATION 5
1923 #define CRL_REASON_CERTIFICATE_HOLD       6
1924 #define CRL_REASON_REMOVE_FROM_CRL        8
1925
1926 /* CertControlStore control types */
1927 #define CERT_STORE_CTRL_RESYNC        1
1928 #define CERT_STORE_CTRL_NOTIFY_CHANGE 2
1929 #define CERT_STORE_CTRL_COMMIT        3
1930 #define CERT_STORE_CTRL_AUTO_RESYNC   4
1931 #define CERT_STORE_CTRL_CANCEL_NOTIFY 5
1932
1933 #define CERT_STORE_CTRL_COMMIT_FORCE_FLAG 0x1
1934 #define CERT_STORE_CTRL_COMMIT_CLEAR_FLAG 0x2
1935
1936 /* cert store properties */
1937 #define CERT_STORE_LOCALIZED_NAME_PROP_ID 0x1000
1938
1939 /* CertCreateContext flags */
1940 #define CERT_CREATE_CONTEXT_NOCOPY_FLAG       0x1
1941 #define CERT_CREATE_CONTEXT_SORTED_FLAG       0x2
1942 #define CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG 0x4
1943 #define CERT_CREATE_CONTEXT_NO_ENTRY_FLAG     0x8
1944
1945 #define CERT_COMPARE_MASK                   0xffff
1946 #define CERT_COMPARE_SHIFT                  16
1947 #define CERT_COMPARE_ANY                    0
1948 #define CERT_COMPARE_SHA1_HASH              1
1949 #define CERT_COMPARE_HASH                   CERT_COMPARE_SHA1_HASH
1950 #define CERT_COMPARE_NAME                   2
1951 #define CERT_COMPARE_ATTR                   3
1952 #define CERT_COMPARE_MD5_HASH               4
1953 #define CERT_COMPARE_PROPERTY               5
1954 #define CERT_COMPARE_PUBLIC_KEY             6
1955 #define CERT_COMPARE_NAME_STR_A             7
1956 #define CERT_COMPARE_NAME_STR_W             8
1957 #define CERT_COMPARE_KEY_SPEC               9
1958 #define CERT_COMPARE_ENHKEY_USAGE           10
1959 #define CERT_COMPARE_CTL_USAGE              CERT_COMPARE_ENHKEY_USAGE
1960 #define CERT_COMPARE_SUBJECT_CERT           11
1961 #define CERT_COMPARE_ISSUER_OF              12
1962 #define CERT_COMPARE_EXISTING               13
1963 #define CERT_COMPARE_SIGNATURE_HASH         14
1964 #define CERT_COMPARE_KEY_IDENTIFIER         15
1965 #define CERT_COMPARE_CERT_ID                16
1966 #define CERT_COMPARE_CROSS_CERT_DIST_POINTS 17
1967 #define CERT_COMPARE_PUBKEY_MD5_HASH        18
1968
1969 /* values of dwFindType for CertFind*InStore */
1970 #define CERT_FIND_ANY \
1971  (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
1972 #define CERT_FIND_SHA1_HASH \
1973  (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
1974 #define CERT_FIND_MD5_HASH \
1975  (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
1976 #define CERT_FIND_SIGNATURE_HASH \
1977  (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
1978 #define CERT_FIND_KEY_IDENTIFIER \
1979  (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
1980 #define CERT_FIND_HASH CERT_FIND_SHA1_HASH
1981 #define CERT_FIND_PROPERTY \
1982  (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
1983 #define CERT_FIND_PUBLIC_KEY \
1984  (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
1985 #define CERT_FIND_SUBJECT_NAME \
1986  (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
1987 #define CERT_FIND_SUBJECT_ATTR \
1988  (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
1989 #define CERT_FIND_ISSUER_NAME \
1990  (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
1991 #define CERT_FIND_ISSUER_ATTR \
1992  (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
1993 #define CERT_FIND_SUBJECT_STR_A \
1994  (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
1995 #define CERT_FIND_SUBJECT_STR_W \
1996  (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
1997 #define CERT_FIND_SUBJECT_STR CERT_FIND_SUBJECT_STR_W
1998 #define CERT_FIND_ISSUER_STR_A \
1999  (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2000 #define CERT_FIND_ISSUER_STR_W \
2001  (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
2002 #define CERT_FIND_ISSUER_STR CERT_FIND_ISSUER_STR_W
2003 #define CERT_FIND_KEY_SPEC \
2004  (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
2005 #define CERT_FIND_ENHKEY_USAGE \
2006  (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
2007 #define CERT_FIND_CTL_USAGE CERT_FIND_ENHKEY_USAGE
2008 #define CERT_FIND_SUBJECT_CERT \
2009  (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
2010 #define CERT_FIND_ISSUER_OF \
2011  (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
2012 #define CERT_FIND_EXISTING \
2013  (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
2014 #define CERT_FIND_CERT_ID \
2015  (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
2016 #define CERT_FIND_CROSS_CERT_DIST_POINTS \
2017  (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
2018 #define CERT_FIND_PUBKEY_MD5_HASH \
2019  (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
2020
2021 #define CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG  0x1
2022 #define CERT_FIND_OPTIONAL_CTL_USAGE_FLAG     0x1
2023 #define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG  0x2
2024 #define CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG     0x2
2025 #define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG 0x4
2026 #define CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG    0x4
2027 #define CERT_FIND_NO_ENHKEY_USAGE_FLAG        0x8
2028 #define CERT_FIND_NO_CTL_USAGE_FLAG           0x8
2029 #define CERT_FIND_OR_ENHKEY_USAGE_FLAG        0x10
2030 #define CERT_FIND_OR_CTL_USAGE_FLAG           0x10
2031 #define CERT_FIND_VALID_ENHKEY_USAGE_FLAG     0x20
2032 #define CERT_FIND_VALID_CTL_USAGE_FLAG        0x20
2033
2034 #define CRL_FIND_ANY        0
2035 #define CRL_FIND_ISSUED_BY  1
2036 #define CRL_FIND_EXISTING   2
2037 #define CRL_FIND_ISSUED_FOR 3
2038
2039 #define CRL_FIND_ISSUED_BY_AKI_FLAG       0x1
2040 #define CRL_FIND_ISSUED_BY_SIGNATURE_FLAG 0x2
2041 #define CRL_FIND_ISSUED_BY_DELTA_FLAG     0x4
2042 #define CRL_FIND_ISSUED_BY_BASE_FLAG      0x8
2043
2044 typedef struct _CRL_FIND_ISSUED_FOR_PARA
2045 {
2046     PCCERT_CONTEXT pSubjectCert;
2047     PCCERT_CONTEXT pIssuerCert;
2048 } CRL_FIND_ISSUED_FOR_PARA, *PCRL_FIND_ISSUED_FOR_PARA;
2049
2050 /* PFN_CERT_STORE_PROV_WRITE_CERT dwFlags values */
2051 #define CERT_STORE_PROV_WRITE_ADD_FLAG 0x1
2052
2053 /* CertAddSerializedElementToStore context types */
2054 #define CERT_STORE_CERTIFICATE_CONTEXT 1
2055 #define CERT_STORE_CRL_CONTEXT         2
2056 #define CERT_STORE_CTL_CONTEXT         3
2057 #define CERT_STORE_ALL_CONTEXT_FLAG    ~0U
2058 #define CERT_STORE_CERTIFICATE_CONTEXT_FLAG \
2059                                     (1 << CERT_STORE_CERTIFICATE_CONTEXT)
2060 #define CERT_STORE_CRL_CONTEXT_FLAG (1 << CERT_STORE_CRL_CONTEXT)
2061 #define CERT_STORE_CTL_CONTEXT_FLAG (1 << CERT_STORE_CTL_CONTEXT)
2062
2063 /* CryptBinaryToString/CryptStringToBinary flags */
2064 #define CRYPT_STRING_BASE64HEADER        0x00000000
2065 #define CRYPT_STRING_BASE64              0x00000001
2066 #define CRYPT_STRING_BINARY              0x00000002
2067 #define CRYPT_STRING_BASE64REQUESTHEADER 0x00000003
2068 #define CRYPT_STRING_HEX                 0x00000004
2069 #define CRYPT_STRING_HEXASCII            0x00000005
2070 #define CRYPT_STRING_BASE64_ANY          0x00000006
2071 #define CRYPT_STRING_ANY                 0x00000007
2072 #define CRYPT_STRING_HEX_ANY             0x00000008
2073 #define CRYPT_STRING_BASE64X509CRLHEADER 0x00000009
2074 #define CRYPT_STRING_HEXADDR             0x0000000a
2075 #define CRYPT_STRING_HEXASCIIADDR        0x0000000b
2076 #define CRYPT_STRING_NOCR                0x80000000
2077
2078 /* OIDs */
2079 #define szOID_RSA                           "1.2.840.113549"
2080 #define szOID_PKCS                          "1.2.840.113549.1"
2081 #define szOID_RSA_HASH                      "1.2.840.113549.2"
2082 #define szOID_RSA_ENCRYPT                   "1.2.840.113549.3"
2083 #define szOID_PKCS_1                        "1.2.840.113549.1.1"
2084 #define szOID_PKCS_2                        "1.2.840.113549.1.2"
2085 #define szOID_PKCS_3                        "1.2.840.113549.1.3"
2086 #define szOID_PKCS_4                        "1.2.840.113549.1.4"
2087 #define szOID_PKCS_5                        "1.2.840.113549.1.5"
2088 #define szOID_PKCS_6                        "1.2.840.113549.1.6"
2089 #define szOID_PKCS_7                        "1.2.840.113549.1.7"
2090 #define szOID_PKCS_8                        "1.2.840.113549.1.8"
2091 #define szOID_PKCS_9                        "1.2.840.113549.1.9"
2092 #define szOID_PKCS_10                       "1.2.840.113549.1.10"
2093 #define szOID_PKCS_11                       "1.2.840.113549.1.12"
2094 #define szOID_RSA_RSA                       "1.2.840.113549.1.1.1"
2095 #define CERT_RSA_PUBLIC_KEY_OBJID           szOID_RSA_RSA
2096 #define CERT_DEFAULT_OID_PUBLIC_KEY_SIGN    szOID_RSA_RSA
2097 #define CERT_DEFAULT_OID_PUBLIC_KEY_XCHG    szOID_RSA_RSA
2098 #define szOID_RSA_MD2RSA                    "1.2.840.113549.1.1.2"
2099 #define szOID_RSA_MD4RSA                    "1.2.840.113549.1.1.3"
2100 #define szOID_RSA_MD5RSA                    "1.2.840.113549.1.1.4"
2101 #define szOID_RSA_SHA1RSA                   "1.2.840.113549.1.1.5"
2102 #define szOID_RSA_SET0AEP_RSA               "1.2.840.113549.1.1.6"
2103 #define szOID_RSA_DH                        "1.2.840.113549.1.3.1"
2104 #define szOID_RSA_data                      "1.2.840.113549.1.7.1"
2105 #define szOID_RSA_signedData                "1.2.840.113549.1.7.2"
2106 #define szOID_RSA_envelopedData             "1.2.840.113549.1.7.3"
2107 #define szOID_RSA_signEnvData               "1.2.840.113549.1.7.4"
2108 #define szOID_RSA_digestedData              "1.2.840.113549.1.7.5"
2109 #define szOID_RSA_hashedData                "1.2.840.113549.1.7.5"
2110 #define szOID_RSA_encryptedData             "1.2.840.113549.1.7.6"
2111 #define szOID_RSA_emailAddr                 "1.2.840.113549.1.9.1"
2112 #define szOID_RSA_unstructName              "1.2.840.113549.1.9.2"
2113 #define szOID_RSA_contentType               "1.2.840.113549.1.9.3"
2114 #define szOID_RSA_messageDigest             "1.2.840.113549.1.9.4"
2115 #define szOID_RSA_signingTime               "1.2.840.113549.1.9.5"
2116 #define szOID_RSA_counterSign               "1.2.840.113549.1.9.6"
2117 #define szOID_RSA_challengePwd              "1.2.840.113549.1.9.7"
2118 #define szOID_RSA_unstructAddr              "1.2.840.113549.1.9.9"
2119 #define szOID_RSA_extCertAttrs              "1.2.840.113549.1.9.9"
2120 #define szOID_RSA_certExtensions            "1.2.840.113549.1.9.14"
2121 #define szOID_RSA_SMIMECapabilities         "1.2.840.113549.1.9.15"
2122 #define szOID_RSA_preferSignedData          "1.2.840.113549.1.9.15.1"
2123 #define szOID_RSA_SMIMEalg                  "1.2.840.113549.1.9.16.3"
2124 #define szOID_RSA_SMIMEalgESDH              "1.2.840.113549.1.9.16.3.5"
2125 #define szOID_RSA_SMIMEalgCMS3DESwrap       "1.2.840.113549.1.9.16.3.6"
2126 #define szOID_RSA_SMIMEalgCMSRC2wrap        "1.2.840.113549.1.9.16.3.7"
2127 #define szOID_RSA_MD2                       "1.2.840.113549.2.2"
2128 #define szOID_RSA_MD4                       "1.2.840.113549.2.4"
2129 #define szOID_RSA_MD5                       "1.2.840.113549.2.5"
2130 #define szOID_RSA_RC2CBC                    "1.2.840.113549.3.2"
2131 #define szOID_RSA_RC4                       "1.2.840.113549.3.4"
2132 #define szOID_RSA_DES_EDE3_CBC              "1.2.840.113549.3.7"
2133 #define szOID_RSA_RC5_CBCPad                "1.2.840.113549.3.9"
2134 #define szOID_ANSI_X942                     "1.2.840.10046"
2135 #define szOID_ANSI_X942_DH                  "1.2.840.10046.2.1"
2136 #define szOID_X957                          "1.2.840.10040"
2137 #define szOID_X957_DSA                      "1.2.840.10040.4.1"
2138 #define szOID_X957_SHA1DSA                  "1.2.840.10040.4.3"
2139 #define szOID_DS                            "2.5"
2140 #define szOID_DSALG                         "2.5.8"
2141 #define szOID_DSALG_CRPT                    "2.5.8.1"
2142 #define szOID_DSALG_HASH                    "2.5.8.2"
2143 #define szOID_DSALG_SIGN                    "2.5.8.3"
2144 #define szOID_DSALG_RSA                     "2.5.8.1.1"
2145 #define szOID_OIW                           "1.3.14"
2146 #define szOID_OIWSEC                        "1.3.14.3.2"
2147 #define szOID_OIWSEC_md4RSA                 "1.3.14.3.2.2"
2148 #define szOID_OIWSEC_md5RSA                 "1.3.14.3.2.3"
2149 #define szOID_OIWSEC_md4RSA2                "1.3.14.3.2.4"
2150 #define szOID_OIWSEC_desECB                 "1.3.14.3.2.6"
2151 #define szOID_OIWSEC_desCBC                 "1.3.14.3.2.7"
2152 #define szOID_OIWSEC_desOFB                 "1.3.14.3.2.8"
2153 #define szOID_OIWSEC_desCFB                 "1.3.14.3.2.9"
2154 #define szOID_OIWSEC_desMAC                 "1.3.14.3.2.10"
2155 #define szOID_OIWSEC_rsaSign                "1.3.14.3.2.11"
2156 #define szOID_OIWSEC_dsa                    "1.3.14.3.2.12"
2157 #define szOID_OIWSEC_shaDSA                 "1.3.14.3.2.13"
2158 #define szOID_OIWSEC_mdc2RSA                "1.3.14.3.2.14"
2159 #define szOID_OIWSEC_shaRSA                 "1.3.14.3.2.15"
2160 #define szOID_OIWSEC_dhCommMod              "1.3.14.3.2.16"
2161 #define szOID_OIWSEC_desEDE                 "1.3.14.3.2.17"
2162 #define szOID_OIWSEC_sha                    "1.3.14.3.2.18"
2163 #define szOID_OIWSEC_mdc2                   "1.3.14.3.2.19"
2164 #define szOID_OIWSEC_dsaComm                "1.3.14.3.2.20"
2165 #define szOID_OIWSEC_dsaCommSHA             "1.3.14.3.2.21"
2166 #define szOID_OIWSEC_rsaXchg                "1.3.14.3.2.22"
2167 #define szOID_OIWSEC_keyHashSeal            "1.3.14.3.2.23"
2168 #define szOID_OIWSEC_md2RSASign             "1.3.14.3.2.24"
2169 #define szOID_OIWSEC_md5RSASign             "1.3.14.3.2.25"
2170 #define szOID_OIWSEC_sha1                   "1.3.14.3.2.26"
2171 #define szOID_OIWSEC_dsaSHA1                "1.3.14.3.2.27"
2172 #define szOID_OIWSEC_dsaCommSHA1            "1.3.14.3.2.28"
2173 #define szOID_OIWSEC_sha1RSASign            "1.3.14.3.2.29"
2174 #define szOID_OIWDIR                        "1.3.14.7.2"
2175 #define szOID_OIWDIR_CRPT                   "1.3.14.7.2.1"
2176 #define szOID_OIWDIR_HASH                   "1.3.14.7.2.2"
2177 #define szOID_OIWDIR_SIGN                   "1.3.14.7.2.3"
2178 #define szOID_OIWDIR_md2                    "1.3.14.7.2.2.1"
2179 #define szOID_OIWDIR_md2RSA                 "1.3.14.7.2.3.1"
2180 #define szOID_INFOSEC                       "2.16.840.1.101.2.1"
2181 #define szOID_INFOSEC_sdnsSignature         "2.16.840.1.101.2.1.1.1"
2182 #define szOID_INFOSEC_mosaicSignature       "2.16.840.1.101.2.1.1.2"
2183 #define szOID_INFOSEC_sdnsConfidentiality   "2.16.840.1.101.2.1.1.3"
2184 #define szOID_INFOSEC_mosaicConfidentiality "2.16.840.1.101.2.1.1.4"
2185 #define szOID_INFOSEC_sdnsIntegrity         "2.16.840.1.101.2.1.1.5"
2186 #define szOID_INFOSEC_mosaicIntegrity       "2.16.840.1.101.2.1.1.6"
2187 #define szOID_INFOSEC_sdnsTokenProtection   "2.16.840.1.101.2.1.1.7"
2188 #define szOID_INFOSEC_mosaicTokenProtection "2.16.840.1.101.2.1.1.8"
2189 #define szOID_INFOSEC_sdnsKeyManagement     "2.16.840.1.101.2.1.1.9"
2190 #define szOID_INFOSEC_mosaicKeyManagement   "2.16.840.1.101.2.1.1.10"
2191 #define szOID_INFOSEC_sdnsKMandSig          "2.16.840.1.101.2.1.1.11"
2192 #define szOID_INFOSEC_mosaicKMandSig        "2.16.840.1.101.2.1.1.12"
2193 #define szOID_INFOSEC_SuiteASignature       "2.16.840.1.101.2.1.1.13"
2194 #define szOID_INFOSEC_SuiteAConfidentiality "2.16.840.1.101.2.1.1.14"
2195 #define szOID_INFOSEC_SuiteAIntegrity       "2.16.840.1.101.2.1.1.15"
2196 #define szOID_INFOSEC_SuiteATokenProtection "2.16.840.1.101.2.1.1.16"
2197 #define szOID_INFOSEC_SuiteAKeyManagement   "2.16.840.1.101.2.1.1.17"
2198 #define szOID_INFOSEC_SuiteAKMandSig        "2.16.840.1.101.2.1.1.18"
2199 #define szOID_INFOSEC_mosaicUpdatedSig      "2.16.840.1.101.2.1.1.19"
2200 #define szOID_INFOSEC_mosaicKMandUpdSig     "2.16.840.1.101.2.1.1.20"
2201 #define szOID_INFOSEC_mosaicUpdateInteg     "2.16.840.1.101.2.1.1.21"
2202 #define szOID_COMMON_NAME                   "2.5.4.3"
2203 #define szOID_SUR_NAME                      "2.5.4.4"
2204 #define szOID_DEVICE_SERIAL_NUMBER          "2.5.4.5"
2205 #define szOID_COUNTRY_NAME                  "2.5.4.6"
2206 #define szOID_LOCALITY_NAME                 "2.5.4.7"
2207 #define szOID_STATE_OR_PROVINCE_NAME        "2.5.4.8"
2208 #define szOID_STREET_ADDRESS                "2.5.4.9"
2209 #define szOID_ORGANIZATION_NAME             "2.5.4.10"
2210 #define szOID_ORGANIZATIONAL_UNIT_NAME      "2.5.4.11"
2211 #define szOID_TITLE                         "2.5.4.12"
2212 #define szOID_DESCRIPTION                   "2.5.4.13"
2213 #define szOID_SEARCH_GUIDE                  "2.5.4.14"
2214 #define szOID_BUSINESS_CATEGORY             "2.5.4.15"
2215 #define szOID_POSTAL_ADDRESS                "2.5.4.16"
2216 #define szOID_POSTAL_CODE                   "2.5.4.17"
2217 #define szOID_POST_OFFICE_BOX               "2.5.4.18"
2218 #define szOID_PHYSICAL_DELIVERY_OFFICE_NAME "2.5.4.19"
2219 #define szOID_TELEPHONE_NUMBER              "2.5.4.20"
2220 #define szOID_TELEX_NUMBER                  "2.5.4.21"
2221 #define szOID_TELETEXT_TERMINAL_IDENTIFIER  "2.5.4.22"
2222 #define szOID_FACSIMILE_TELEPHONE_NUMBER    "2.5.4.23"
2223 #define szOID_X21_ADDRESS                   "2.5.4.24"
2224 #define szOID_INTERNATIONAL_ISDN_NUMBER     "2.5.4.25"
2225 #define szOID_REGISTERED_ADDRESS            "2.5.4.26"
2226 #define szOID_DESTINATION_INDICATOR         "2.5.4.27"
2227 #define szOID_PREFERRED_DELIVERY_METHOD     "2.5.4.28"
2228 #define szOID_PRESENTATION_ADDRESS          "2.5.4.29"
2229 #define szOID_SUPPORTED_APPLICATION_CONTEXT "2.5.4.30"
2230 #define szOID_MEMBER                        "2.5.4.31"
2231 #define szOID_OWNER                         "2.5.4.32"
2232 #define szOID_ROLE_OCCUPANT                 "2.5.4.33"
2233 #define szOID_SEE_ALSO                      "2.5.4.34"
2234 #define szOID_USER_PASSWORD                 "2.5.4.35"
2235 #define szOID_USER_CERTIFICATE              "2.5.4.36"
2236 #define szOID_CA_CERTIFICATE                "2.5.4.37"
2237 #define szOID_AUTHORITY_REVOCATION_LIST     "2.5.4.38"
2238 #define szOID_CERTIFICATE_REVOCATION_LIST   "2.5.4.39"
2239 #define szOID_CROSS_CERTIFICATE_PAIR        "2.5.4.40"
2240 #define szOID_GIVEN_NAME                    "2.5.4.42"
2241 #define szOID_INITIALS                      "2.5.4.43"
2242 #define szOID_DN_QUALIFIER                  "2.5.4.46"
2243 #define szOID_AUTHORITY_KEY_IDENTIFIER      "2.5.29.1"
2244 #define szOID_KEY_ATTRIBUTES                "2.5.29.2"
2245 #define szOID_CERT_POLICIES_95              "2.5.29.3"
2246 #define szOID_KEY_USAGE_RESTRICTION         "2.5.29.4"
2247 #define szOID_LEGACY_POLICY_MAPPINGS        "2.5.29.5"
2248 #define szOID_SUBJECT_ALT_NAME              "2.5.29.7"
2249 #define szOID_ISSUER_ALT_NAME               "2.5.29.8"
2250 #define szOID_SUBJECT_DIR_ATTRS             "2.5.29.9"
2251 #define szOID_BASIC_CONSTRAINTS             "2.5.29.10"
2252 #define szOID_SUBJECT_KEY_IDENTIFIER        "2.5.29.14"
2253 #define szOID_KEY_USAGE                     "2.5.29.15"
2254 #define szOID_PRIVATEKEY_USAGE_PERIOD       "2.5.29.16"
2255 #define szOID_SUBJECT_ALT_NAME2             "2.5.29.17"
2256 #define szOID_ISSUER_ALT_NAME2              "2.5.29.18"
2257 #define szOID_BASIC_CONSTRAINTS2            "2.5.29.19"
2258 #define szOID_CRL_NUMBER                    "2.5.29.20"
2259 #define szOID_CRL_REASON_CODE               "2.5.29.21"
2260 #define szOID_REASON_CODE_HOLD              "2.5.29.23"
2261 #define szOID_DELTA_CRL_INDICATOR           "2.5.29.27"
2262 #define szOID_ISSUING_DIST_POINT            "2.5.29.28"
2263 #define szOID_NAME_CONSTRAINTS              "2.5.29.30"
2264 #define szOID_CRL_DIST_POINTS               "2.5.29.31"
2265 #define szOID_CERT_POLICIES                 "2.5.29.32"
2266 #define szOID_ANY_CERT_POLICY               "2.5.29.32.0"
2267 #define szOID_POLICY_MAPPINGS               "2.5.29.33"
2268 #define szOID_AUTHORITY_KEY_IDENTIFIER2     "2.5.29.35"
2269 #define szOID_POLICY_CONSTRAINTS            "2.5.29.36"
2270 #define szOID_ENHANCED_KEY_USAGE            "2.5.29.37"
2271 #define szOID_FRESHEST_CRL                  "2.5.29.46"
2272 #define szOID_DOMAIN_COMPONENT              "0.9.2342.19200300.100.1.25"
2273 #define szOID_PKCS_12_FRIENDLY_NAME_ATTR     "1.2.840.113549.1.9.20"
2274 #define szOID_PKCS_12_LOCAL_KEY_ID           "1.2.840.113549.1.9.21"
2275 #define szOID_CERT_EXTENSIONS                "1.3.6.1.4.1.311.2.1.14"
2276 #define szOID_NEXT_UPDATE_LOCATION           "1.3.6.1.4.1.311.10.2"
2277 #define szOID_KP_CTL_USAGE_SIGNING           "1.3.6.1.4.1.311.10.3.1"
2278 #define szOID_KP_TIME_STAMP_SIGNING          "1.3.6.1.4.1.311.10.3.2"
2279 #ifndef szOID_SERVER_GATED_CRYPTO
2280 #define szOID_SERVER_GATED_CRYPTO            "1.3.6.1.4.1.311.10.3.3"
2281 #endif
2282 #define szOID_KP_EFS                         "1.3.6.1.4.1.311.10.3.4"
2283 #define szOID_EFS_RECOVERY                   "1.3.6.1.4.1.311.10.3.4.1"
2284 #define szOID_WHQL_CRYPTO                    "1.3.6.1.4.1.311.10.3.5"
2285 #define szOID_NT5_CRYPTO                     "1.3.6.1.4.1.311.10.3.6"
2286 #define szOID_OEM_WHQL_CRYPTO                "1.3.6.1.4.1.311.10.3.7"
2287 #define szOID_EMBEDDED_NT_CRYPTO             "1.3.6.1.4.1.311.10.3.8"
2288 #define szOID_ROOT_LIST_SIGNER               "1.3.6.1.4.1.311.10.3.9"
2289 #define szOID_KP_QUALIFIED_SUBORDINATION     "1.3.6.1.4.1.311.10.3.10"
2290 #define szOID_KP_KEY_RECOVERY                "1.3.6.1.4.1.311.10.3.11"
2291 #define szOID_KP_DOCUMENT_SIGNING            "1.3.6.1.4.1.311.10.3.12"
2292 #define szOID_KP_LIFETIME_SIGNING            "1.3.6.1.4.1.311.10.3.13"
2293 #define szOID_KP_MOBILE_DEVICE_SOFTWARE      "1.3.6.1.4.1.311.10.3.14"
2294 #define szOID_YESNO_TRUST_ATTR               "1.3.6.1.4.1.311.10.4.1"
2295 #ifndef szOID_DRM
2296 #define szOID_DRM                            "1.3.6.1.4.1.311.10.5.1"
2297 #endif
2298 #ifndef szOID_DRM_INDIVIDUALIZATION
2299 #define szOID_DRM_INDIVIDUALIZATION          "1.3.6.1.4.1.311.10.5.2"
2300 #endif
2301 #ifndef szOID_LICENSES
2302 #define szOID_LICENSES                       "1.3.6.1.4.1.311.10.6.1"
2303 #endif
2304 #ifndef szOID_LICENSE_SERVER
2305 #define szOID_LICENSE_SERVER                 "1.3.6.1.4.1.311.10.6.2"
2306 #endif
2307 #define szOID_REMOVE_CERTIFICATE             "1.3.6.1.4.1.311.10.8.1"
2308 #define szOID_CROSS_CERT_DIST_POINTS         "1.3.6.1.4.1.311.10.9.1"
2309 #define szOID_CTL                            "1.3.6.1.4.1.311.10.10.1"
2310 #define szOID_SORTED_CTL                     "1.3.6.1.4.1.311.10.10.1.1"
2311 #define szOID_ANY_APPLICATION_POLICY         "1.3.6.1.4.1.311.10.12.1"
2312 #define szOID_RENEWAL_CERTIFICATE            "1.3.6.1.4.1.311.13.1"
2313 #define szOID_ENROLLMENT_NAME_VALUE_PAIR     "1.3.6.1.4.1.311.13.2.1"
2314 #define szOID_ENROLLMENT_CSP_PROVIDER        "1.3.6.1.4.1.311.13.2.2"
2315 #define szOID_OS_VERSION                     "1.3.6.1.4.1.311.13.2.3"
2316 #define szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR "1.3.6.1.4.1.311.17.1"
2317 #define szOID_LOCAL_MACHINE_KEYSET           "1.3.6.1.4.1.311.17.2"
2318 #define szOID_AUTO_ENROLL_CTL_USAGE          "1.3.6.1.4.1.311.20.1"
2319 #define szOID_ENROLL_CERTTYPE_EXTENSION      "1.3.6.1.4.1.311.20.2"
2320 #define szOID_ENROLLMENT_AGENT               "1.3.6.1.4.1.311.20.2.1"
2321 #define szOID_KP_SMARTCARD_LOGON             "1.3.6.1.4.1.311.20.2.2"
2322 #define szOID_CERT_MANIFOLD                  "1.3.6.1.4.1.311.20.3"
2323 #ifndef szOID_CERTSRV_CA_VERSION
2324 #define szOID_CERTSRV_CA_VERSION             "1.3.6.1.4.1.311.21.1"
2325 #endif
2326 #define szOID_CERTSRV_PREVIOUS_CERT_HASH     "1.3.6.1.4.1.311.21.2"
2327 #define szOID_CRL_VIRTUAL_BASE               "1.3.6.1.4.1.311.21.3"
2328 #define szOID_CRL_NEXT_PUBLISH               "1.3.6.1.4.1.311.21.4"
2329 #define szOID_KP_CA_EXCHANGE                 "1.3.6.1.4.1.311.21.5"
2330 #define szOID_KP_KEY_RECOVERY_AGENT          "1.3.6.1.4.1.311.21.6"
2331 #define szOID_CERTIFICATE_TEMPLATE           "1.3.6.1.4.1.311.21.7"
2332 #define szOID_ENTERPRISE_OID_ROOT            "1.3.6.1.4.1.311.21.8"
2333 #define szOID_RDN_DUMMY_SIGNER               "1.3.6.1.4.1.311.21.9"
2334 #define szOID_APPLICATION_CERT_POLICIES      "1.3.6.1.4.1.311.21.10"
2335 #define szOID_APPLICATION_POLICY_MAPPINGS    "1.3.6.1.4.1.311.21.11"
2336 #define szOID_APPLICATION_POLICY_CONSTRAINTS "1.3.6.1.4.1.311.21.12"
2337 #define szOID_ARCHIVED_KEY_ATTR              "1.3.6.1.4.1.311.21.13"
2338 #define szOID_CRL_SELF_CDP                   "1.3.6.1.4.1.311.21.14"
2339 #define szOID_REQUIRE_CERT_CHAIN_POLICY      "1.3.6.1.4.1.311.21.15"
2340 #define szOID_ARCHIVED_KEY_CERT_HASH         "1.3.6.1.4.1.311.21.16"
2341 #define szOID_ISSUED_CERT_HASH               "1.3.6.1.4.1.311.21.17"
2342 #define szOID_DS_EMAIL_REPLICATION           "1.3.6.1.4.1.311.21.19"
2343 #define szOID_REQUEST_CLIENT_INFO            "1.3.6.1.4.1.311.21.20"
2344 #define szOID_ENCRYPTED_KEY_HASH             "1.3.6.1.4.1.311.21.21"
2345 #define szOID_CERTSRV_CROSSCA_VERSION        "1.3.6.1.4.1.311.21.22"
2346 #define szOID_KEYID_RDN                      "1.3.6.1.4.1.311.10.7.1"
2347 #define szOID_PKIX                           "1.3.6.1.5.5.7"
2348 #define szOID_PKIX_PE                        "1.3.6.1.5.5.7.1"
2349 #define szOID_AUTHORITY_INFO_ACCESS          "1.3.6.1.5.5.7.1.1"
2350 #define szOID_PKIX_POLICY_QUALIFIER_CPS      "1.3.6.1.5.5.7.2.1"
2351 #define szOID_PKIX_POLICY_QUALIFIER_USERNOTICE "1.3.6.1.5.5.7.2.2"
2352 #define szOID_PKIX_KP                        "1.3.6.1.5.5.7.3"
2353 #define szOID_PKIX_KP_SERVER_AUTH            "1.3.6.1.5.5.7.3.1"
2354 #define szOID_PKIX_KP_CLIENT_AUTH            "1.3.6.1.5.5.7.3.2"
2355 #define szOID_PKIX_KP_CODE_SIGNING           "1.3.6.1.5.5.7.3.3"
2356 #define szOID_PKIX_KP_EMAIL_PROTECTION       "1.3.6.1.5.5.7.3.4"
2357 #define szOID_PKIX_KP_IPSEC_END_SYSTEM       "1.3.6.1.5.5.7.3.5"
2358 #define szOID_PKIX_KP_IPSEC_TUNNEL           "1.3.6.1.5.5.7.3.6"
2359 #define szOID_PKIX_KP_IPSEC_USER             "1.3.6.1.5.5.7.3.7"
2360 #define szOID_PKIX_KP_TIMESTAMP_SIGNING      "1.3.6.1.5.5.7.3.8"
2361 #define szOID_PKIX_NO_SIGNATURE              "1.3.6.1.5.5.7.6.2"
2362 #define szOID_CMC                            "1.3.6.1.5.5.7.7"
2363 #define szOID_CMC_STATUS_INFO                "1.3.6.1.5.5.7.7.1"
2364 #define szOID_CMC_IDENTIFICATION             "1.3.6.1.5.5.7.7.2"
2365 #define szOID_CMC_IDENTITY_PROOF             "1.3.6.1.5.5.7.7.3"
2366 #define szOID_CMC_DATA_RETURN                "1.3.6.1.5.5.7.7.4"
2367 #define szOID_CMC_TRANSACTION_ID             "1.3.6.1.5.5.7.7.5"
2368 #define szOID_CMC_SENDER_NONCE               "1.3.6.1.5.5.7.7.6"
2369 #define szOID_CMC_RECIPIENT_NONCE            "1.3.6.1.5.5.7.7.7"
2370 #define szOID_CMC_ADD_EXTENSIONS             "1.3.6.1.5.5.7.7.8"
2371 #define szOID_CMC_ENCRYPTED_POP              "1.3.6.1.5.5.7.7.9"
2372 #define szOID_CMC_DECRYPTED_POP              "1.3.6.1.5.5.7.7.10"
2373 #define szOID_CMC_LRA_POP_WITNESS            "1.3.6.1.5.5.7.7.11"
2374 #define szOID_CMC_GET_CERT                   "1.3.6.1.5.5.7.7.15"
2375 #define szOID_CMC_GET_CRL                    "1.3.6.1.5.5.7.7.16"
2376 #define szOID_CMC_REVOKE_REQUEST             "1.3.6.1.5.5.7.7.17"
2377 #define szOID_CMC_REG_INFO                   "1.3.6.1.5.5.7.7.18"
2378 #define szOID_CMC_RESPONSE_INFO              "1.3.6.1.5.5.7.7.19"
2379 #define szOID_CMC_QUERY_PENDING              "1.3.6.1.5.5.7.7.21"
2380 #define szOID_CMC_ID_POP_LINK_RANDOM         "1.3.6.1.5.5.7.7.22"
2381 #define szOID_CMC_ID_POP_LINK_WITNESS        "1.3.6.1.5.5.7.7.23"
2382 #define szOID_CT_PKI_DATA                    "1.3.6.1.5.5.7.12.2"
2383 #define szOID_CT_PKI_RESPONSE                "1.3.6.1.5.5.7.12.3"
2384 #define szOID_PKIX_ACC_DESCR                 "1.3.6.1.5.5.7.48"
2385 #define szOID_PKIX_OCSP                      "1.3.6.1.5.5.7.48.1"
2386 #define szOID_PKIX_CA_ISSUERS                "1.3.6.1.5.5.7.48.2"
2387 #define szOID_IPSEC_KP_IKE_INTERMEDIATE      "1.3.6.1.5.5.8.2.2"
2388
2389 #ifndef szOID_SERIALIZED
2390 #define szOID_SERIALIZED                     "1.3.6.1.4.1.311.10.3.3.1"
2391 #endif
2392
2393 #define szOID_AUTO_ENROLL_CTL_USAGE          "1.3.6.1.4.1.311.20.1"
2394 #define szOID_ENROLL_CERTTYPE_EXTENSION      "1.3.6.1.4.1.311.20.2"
2395 #define szOID_ENROLLMENT_AGENT               "1.3.6.1.4.1.311.20.2.1"
2396 #ifndef szOID_KP_SMARTCARD_LOGON
2397 #define szOID_KP_SMARTCARD_LOGON             "1.3.6.1.4.1.311.20.2.2"
2398 #endif
2399 #ifndef szOID_NT_PRINCIPAL_NAME
2400 #define szOID_NT_PRINCIPAL_NAME              "1.3.6.1.4.1.311.20.2.3"
2401 #endif
2402 #define szOID_CERT_MANIFOLD                  "1.3.6.1.4.1.311.20.3"
2403
2404 #ifndef szOID_CERTSRV_CA_VERSION
2405 #define szOID_CERTSRV_CA_VERSION             "1.3.6.1.4.1.311.21.1"
2406 #endif
2407
2408 #ifndef szOID_PRODUCT_UPDATE
2409 #define szOID_PRODUCT_UPDATE                 "1.3.6.1.4.1.311.31.1"
2410 #endif
2411
2412 #define szOID_NETSCAPE                       "2.16.840.1.113730"
2413 #define szOID_NETSCAPE_CERT_EXTENSION        "2.16.840.1.113730.1"
2414 #define szOID_NETSCAPE_CERT_TYPE             "2.16.840.1.113730.1.1"
2415 #define szOID_NETSCAPE_BASE_URL              "2.16.840.1.113730.1.2"
2416 #define szOID_NETSCAPE_REVOCATION_URL        "2.16.840.1.113730.1.3"
2417 #define szOID_NETSCAPE_CA_REVOCATION_URL     "2.16.840.1.113730.1.4"
2418 #define szOID_NETSCAPE_CERT_RENEWAL_URL      "2.16.840.1.113730.1.7"
2419 #define szOID_NETSCAPE_CA_POLICY_URL         "2.16.840.1.113730.1.8"
2420 #define szOID_NETSCAPE_SSL_SERVER_NAME       "2.16.840.1.113730.1.12"
2421 #define szOID_NETSCAPE_COMMENT               "2.16.840.1.113730.1.13"
2422
2423 #define CRYPT_ENCODE_DECODE_NONE             0
2424 #define X509_CERT                            ((LPCSTR)1)
2425 #define X509_CERT_TO_BE_SIGNED               ((LPCSTR)2)
2426 #define X509_CERT_CRL_TO_BE_SIGNED           ((LPCSTR)3)
2427 #define X509_CERT_REQUEST_TO_BE_SIGNED       ((LPCSTR)4)
2428 #define X509_EXTENSIONS                      ((LPCSTR)5)
2429 #define X509_NAME_VALUE                      ((LPCSTR)6)
2430 #define X509_ANY_STRING                      X509_NAME_VALUE
2431 #define X509_NAME                            ((LPCSTR)7)
2432 #define X509_PUBLIC_KEY_INFO                 ((LPCSTR)8)
2433 #define X509_AUTHORITY_KEY_ID                ((LPCSTR)9)
2434 #define X509_KEY_ATTRIBUTES                  ((LPCSTR)10)
2435 #define X509_KEY_USAGE_RESTRICTION           ((LPCSTR)11)
2436 #define X509_ALTERNATE_NAME                  ((LPCSTR)12)
2437 #define X509_BASIC_CONSTRAINTS               ((LPCSTR)13)
2438 #define X509_KEY_USAGE                       ((LPCSTR)14)
2439 #define X509_BASIC_CONSTRAINTS2              ((LPCSTR)15)
2440 #define X509_CERT_POLICIES                   ((LPCSTR)16)
2441 #define PKCS_UTC_TIME                        ((LPCSTR)17)
2442 #define PKCS_TIME_REQUEST                    ((LPCSTR)18)
2443 #define RSA_CSP_PUBLICKEYBLOB                ((LPCSTR)19)
2444 #define X509_UNICODE_NAME                    ((LPCSTR)20)
2445 #define X509_KEYGEN_REQUEST_TO_BE_SIGNED     ((LPCSTR)21)
2446 #define PKCS_ATTRIBUTE                       ((LPCSTR)22)
2447 #define PKCS_CONTENT_INFO_SEQUENCE_OF_ANY    ((LPCSTR)23)
2448 #define X509_UNICODE_NAME_VALUE              ((LPCSTR)24)
2449 #define X509_UNICODE_ANY_STRING              X509_UNICODE_NAME_VALUE
2450 #define X509_OCTET_STRING                    ((LPCSTR)25)
2451 #define X509_BITS                            ((LPCSTR)26)
2452 #define X509_INTEGER                         ((LPCSTR)27)
2453 #define X509_MULTI_BYTE_INTEGER              ((LPCSTR)28)
2454 #define X509_ENUMERATED                      ((LPCSTR)29)
2455 #define X509_CRL_REASON_CODE                 X509_ENUMERATED
2456 #define X509_CHOICE_OF_TIME                  ((LPCSTR)30)
2457 #define X509_AUTHORITY_KEY_ID2               ((LPCSTR)31)
2458 #define X509_AUTHORITY_INFO_ACCESS           ((LPCSTR)32)
2459 #define PKCS_CONTENT_INFO                    ((LPCSTR)33)
2460 #define X509_SEQUENCE_OF_ANY                 ((LPCSTR)34)
2461 #define X509_CRL_DIST_POINTS                 ((LPCSTR)35)
2462 #define X509_ENHANCED_KEY_USAGE              ((LPCSTR)36)
2463 #define PKCS_CTL                             ((LPCSTR)37)
2464 #define X509_MULTI_BYTE_UINT                 ((LPCSTR)38)
2465 #define X509_DSS_PUBLICKEY                   X509_MULTI_BYTE_UINT
2466 #define X509_DSS_PARAMETERS                  ((LPCSTR)39)
2467 #define X509_DSS_SIGNATURE                   ((LPCSTR)40)
2468 #define PKCS_RC2_CBC_PARAMETERS              ((LPCSTR)41)
2469 #define PKCS_SMIME_CAPABILITIES              ((LPCSTR)42)
2470 #define PKCS_RSA_PRIVATE_KEY                 ((LPCSTR)43)
2471 #define PKCS_PRIVATE_KEY_INFO                ((LPCSTR)44)
2472 #define PKCS_ENCRYPTED_PRIVATE_KEY_INFO      ((LPCSTR)45)
2473 #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46)
2474 #define X509_DH_PUBLICKEY                    X509_MULTI_BYTE_UINT
2475 #define X509_DH_PARAMETERS                   ((LPCSTR)47)
2476 #define PKCS_ATTRIBUTES                      ((LPCSTR)48)
2477 #define PKCS_SORTED_CTL                      ((LPCSTR)49)
2478 #define X942_DH_PARAMETERS                   ((LPCSTR)50)
2479 #define X509_BITS_WITHOUT_TRAILING_ZEROES    ((LPCSTR)51)
2480 #define X942_OTHER_INFO                      ((LPCSTR)52)
2481 #define X509_CERT_PAIR                       ((LPCSTR)53)
2482 #define X509_ISSUING_DIST_POINT              ((LPCSTR)54)
2483 #define X509_NAME_CONSTRAINTS                ((LPCSTR)55)
2484 #define X509_POLICY_MAPPINGS                 ((LPCSTR)56)
2485 #define X509_POLICY_CONSTRAINTS              ((LPCSTR)57)
2486 #define X509_CROSS_CERT_DIST_POINTS          ((LPCSTR)58)
2487 #define CMC_DATA                             ((LPCSTR)59)
2488 #define CMC_RESPONSE                         ((LPCSTR)60)
2489 #define CMC_STATUS                           ((LPCSTR)61)
2490 #define CMC_ADD_EXTENSIONS                   ((LPCSTR)62)
2491 #define CMC_ADD_ATTRIBUTES                   ((LPCSTR)63)
2492 #define X509_CERTIFICATE_TEMPLATE            ((LPCSTR)64)
2493 #define PKCS7_SIGNER_INFO                    ((LPCSTR)500)
2494 #define CMS_SIGNER_INFO                      ((LPCSTR)501)
2495
2496 /* encode/decode flags */
2497 #define CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG           0x00008
2498 #define CRYPT_ENCODE_ALLOC_FLAG                                0x08000
2499 #define CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG 0x10000
2500 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG \
2501  CERT_RDN_ENABLE_T61_UNICODE_FLAG
2502 #define CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG \
2503  CERT_RDN_ENABLE_UTF8_UNICODE_FLAG
2504 #define CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG \
2505  CERT_RDN_DISABLE_CHECK_TYPE_FLAG
2506
2507 #define CRYPT_DECODE_NOCOPY_FLAG                               0x00001
2508 #define CRYPT_DECODE_TO_BE_SIGNED_FLAG                         0x00002
2509 #define CRYPT_DECODE_SHARE_OID_STRING_FLAG                     0x00004
2510 #define CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG           0x00008
2511 #define CRYPT_DECODE_ALLOC_FLAG                                0x08000
2512 #define CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG \
2513  CERT_RDN_DISABLE_IE4_UTF8_FLAG
2514
2515 #define CERT_STORE_SIGNATURE_FLAG     0x00000001
2516 #define CERT_STORE_TIME_VALIDITY_FLAG 0x00000002
2517 #define CERT_STORE_REVOCATION_FLAG    0x00000004
2518 #define CERT_STORE_NO_CRL_FLAG        0x00010000
2519 #define CERT_STORE_NO_ISSUER_FLAG     0x00020000
2520
2521 #define CERT_STORE_BASE_CRL_FLAG  0x00000100
2522 #define CERT_STORE_DELTA_CRL_FLAG 0x00000200
2523
2524 /* subject types for CryptVerifyCertificateSignatureEx */
2525 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB 1
2526 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT 2
2527 #define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL  3
2528
2529 /* issuer types for CryptVerifyCertificateSignatureEx */
2530 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY 1
2531 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT   2
2532 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN  3
2533 #define CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL   4
2534
2535 #define CRYPT_GET_URL_FROM_PROPERTY         0x00000001
2536 #define CRYPT_GET_URL_FROM_EXTENSION        0x00000002
2537 #define CRYPT_GET_URL_FROM_UNAUTH_ATTRIBUTE 0x00000004
2538 #define CRYPT_GET_URL_FROM_AUTH_ATTRIBUTE   0x00000008
2539
2540 /* Certificate name string types and flags */
2541 #define CERT_SIMPLE_NAME_STR 1
2542 #define CERT_OID_NAME_STR    2
2543 #define CERT_X500_NAME_STR   3
2544 #define CERT_NAME_STR_SEMICOLON_FLAG           0x40000000
2545 #define CERT_NAME_STR_NO_PLUS_FLAG             0x20000000
2546 #define CERT_NAME_STR_NO_QUOTING_FLAG          0x10000000
2547 #define CERT_NAME_STR_CRLF_FLAG                0x08000000
2548 #define CERT_NAME_STR_COMMA_FLAG               0x04000000
2549 #define CERT_NAME_STR_REVERSE_FLAG             0x02000000
2550 #define CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG 0x00040000
2551 #define CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG  0x00020000
2552 #define CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG    0x00010000
2553
2554 #define CERT_NAME_EMAIL_TYPE            1
2555 #define CERT_NAME_RDN_TYPE              2
2556 #define CERT_NAME_ATTR_TYPE             3
2557 #define CERT_NAME_SIMPLE_DISPLAY_TYPE   4
2558 #define CERT_NAME_FRIENDLY_DISPLAY_TYPE 5
2559 #define CERT_NAME_DNS_TYPE              6
2560 #define CERT_NAME_URL_TYPE              7
2561 #define CERT_NAME_UPN_TYPE              8
2562
2563 #define CERT_NAME_ISSUER_FLAG           0x00000001
2564 #define CERT_NAME_DISABLE_IE4_UTF8_FLAG 0x00010000
2565
2566 #define CERT_SET_KEY_PROV_HANDLE_PROP_ID 0x00000001
2567 #define CERT_SET_KEY_CONTEXT_PROP_ID     0x00000001
2568
2569 #define CERT_CREATE_SELFSIGN_NO_SIGN     1
2570 #define CERT_CREATE_SELFSIGN_NO_KEY_INFO 2
2571
2572 /* flags for CryptAcquireCertificatePrivateKey */
2573 #define CRYPT_ACQUIRE_CACHE_FLAG         0x00000001
2574 #define CRYPT_ACQUIRE_USE_PROV_INFO_FLAG 0x00000002
2575 #define CRYPT_ACQUIRE_COMPARE_KEY_FLAG   0x00000004
2576 #define CRYPT_ACQUIRE_SILENT_FLAG        0x00000040
2577
2578 /* function declarations */
2579 /* advapi32.dll */
2580 BOOL WINAPI CryptAcquireContextA(HCRYPTPROV *phProv, LPCSTR pszContainer,
2581                                    LPCSTR pszProvider, DWORD dwProvType,
2582                                    DWORD dwFlags);
2583 BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
2584                 LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
2585 #define CryptAcquireContext WINELIB_NAME_AW(CryptAcquireContext)
2586 BOOL WINAPI CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer);
2587 BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFlags);
2588 BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
2589                 DWORD dwFlags, HCRYPTHASH *phHash);
2590 BOOL WINAPI CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
2591                 DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen);
2592 BOOL WINAPI CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData,
2593                 DWORD dwFlags, HCRYPTKEY *phKey);
2594 BOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash);
2595 BOOL WINAPI CryptDestroyKey (HCRYPTKEY hKey);
2596 BOOL WINAPI CryptDuplicateKey (HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags, HCRYPTKEY *phKey);
2597 BOOL WINAPI CryptDuplicateHash (HCRYPTHASH hHash, DWORD *pdwReserved,
2598                 DWORD dwFlags, HCRYPTHASH *phHash);
2599 BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
2600                 DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen);
2601 BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
2602                 DWORD dwFlags, DWORD *pdwProvType, LPSTR pszProvName, DWORD *pcbProvName);
2603 BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
2604                 DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName);
2605 #define CryptEnumProviders WINELIB_NAME_AW(CryptEnumProviders)
2606 BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
2607                 DWORD dwFlags, DWORD *pdwProvType, LPSTR pszTypeName, DWORD *pcbTypeName);
2608 BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved,
2609                 DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszTypeName, DWORD *pcbTypeName);
2610 #define CryptEnumProviderTypes WINELIB_NAME_AW(CryptEnumProviderTypes)
2611 BOOL WINAPI CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType,
2612                 DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen);
2613 BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey);
2614 BOOL WINAPI CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData,
2615                 DWORD *pdwDataLen, DWORD dwFlags);
2616 BOOL WINAPI CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData,
2617                 DWORD *pdwDataLen, DWORD dwFlags);
2618 BOOL WINAPI CryptGetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData,
2619                 DWORD *pdwDataLen, DWORD dwFlags);
2620 BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved,
2621                 DWORD dwFlags, LPSTR pszProvName, DWORD *pcbProvName);
2622 BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved,
2623                 DWORD dwFlags, LPWSTR pszProvName, DWORD *pcbProvName);
2624 #define CryptGetDefaultProvider WINELIB_NAME_AW(CryptGetDefaultProvider)
2625 BOOL WINAPI CryptGetUserKey (HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey);
2626 BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags);
2627 BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags);
2628 BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, BYTE *pbData, DWORD dwDataLen,
2629                 HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey);
2630 BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, DWORD dwFlags);
2631 BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD dwFlags);
2632 BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD dwFlags);
2633 BOOL WINAPI CryptSetProviderA (LPCSTR pszProvName, DWORD dwProvType);
2634 BOOL WINAPI CryptSetProviderW (LPCWSTR pszProvName, DWORD dwProvType);
2635 #define CryptSetProvider WINELIB_NAME_AW(CryptSetProvider)
2636 BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags);
2637 BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags);
2638 #define CryptSetProviderEx WINELIB_NAME_AW(CryptSetProviderEx)
2639 BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD dwFlags);
2640 BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription,
2641                 DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen);
2642 BOOL WINAPI CryptSignHashW (HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription,
2643                 DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen);
2644 #define CryptSignHash WINELIB_NAME_AW(CryptSignHash)
2645 BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dwSigLen,
2646                 HCRYPTKEY hPubKey, LPCSTR sDescription, DWORD dwFlags);
2647 BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dwSigLen,
2648                 HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags);
2649 #define CryptVerifySignature WINELIB_NAME_AW(CryptVerifySignature)
2650
2651 /* crypt32.dll functions */
2652 LPVOID WINAPI CryptMemAlloc(ULONG cbSize);
2653 LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize);
2654 VOID   WINAPI CryptMemFree(LPVOID pv);
2655
2656 BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary,
2657  DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString);
2658 BOOL WINAPI CryptBinaryToStringW(const BYTE *pbBinary,
2659  DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString);
2660 #define CryptBinaryToString WINELIB_NAME_AW(CryptBinaryToString)
2661
2662 BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString,
2663  DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
2664  DWORD *pdwSkip, DWORD *pdwFlags);
2665 BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString,
2666  DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
2667  DWORD *pdwSkip, DWORD *pdwFlags);
2668 #define CryptStringToBinary WINELIB_NAME_AW(CryptStringToBinary)
2669
2670 BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD,LPCSTR,DWORD,LPCWSTR);
2671 BOOL WINAPI CryptRegisterOIDFunction(DWORD,LPCSTR,LPCSTR,LPCWSTR,LPCSTR);
2672 BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
2673                                      LPCSTR pszOID, LPCWSTR szValueName, DWORD *pdwValueType,
2674                                      BYTE *pbValueData, DWORD *pcbValueData);
2675 BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
2676                                      LPCSTR pszOID, LPCWSTR pwszValueName, DWORD dwValueType,
2677                                      const BYTE *pbValueData, DWORD cbValueData);
2678 BOOL WINAPI CryptUnregisterDefaultOIDFunction(DWORD,LPCSTR,LPCWSTR);
2679 BOOL WINAPI CryptUnregisterOIDFunction(DWORD,LPCSTR,LPCSTR);
2680 BOOL WINAPI CryptEnumOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
2681  LPCSTR pszOID, DWORD dwFlags, void *pvArg,
2682  PFN_CRYPT_ENUM_OID_FUNC pfnEnumOIDFunc);
2683 HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR,DWORD);
2684 BOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet,
2685  DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList);
2686 BOOL WINAPI CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,
2687  DWORD dwEncodingType, LPCWSTR pwszDll, DWORD dwFlags, void *ppvFuncAddr,
2688  HCRYPTOIDFUNCADDR *phFuncAddr);
2689 BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,
2690  DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr,
2691  HCRYPTOIDFUNCADDR *phFuncAddr);
2692 BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,
2693  DWORD dwFlags);
2694 BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule,
2695  DWORD dwEncodingType, LPCSTR pszFuncName, DWORD cFuncEntry,
2696  const CRYPT_OID_FUNC_ENTRY rgFuncEntry[], DWORD dwFlags);
2697
2698 BOOL WINAPI CryptEnumOIDInfo(DWORD dwGroupId, DWORD dwFlags, void *pvArg,
2699  PFN_CRYPT_ENUM_OID_INFO pfnEnumOIDInfo);
2700 PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey,
2701  DWORD dwGroupId);
2702 BOOL WINAPI CryptRegisterOIDInfo(PCCRYPT_OID_INFO pInfo, DWORD dwFlags);
2703 BOOL WINAPI CryptUnregisterOIDInfo(PCCRYPT_OID_INFO pInfo);
2704
2705 LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId);
2706 DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId);
2707
2708 /* cert store functions */
2709 HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwEncodingType,
2710  HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara);
2711
2712 HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV hProv,
2713  LPCSTR szSubSystemProtocol);
2714 HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV hProv,
2715  LPCWSTR szSubSystemProtocol);
2716 #define CertOpenSystemStore WINELIB_NAME_AW(CertOpenSystemStore)
2717
2718 PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore,
2719  PCCERT_CONTEXT pPrev);
2720
2721 PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore,
2722  PCCRL_CONTEXT pPrev);
2723
2724 PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(HCERTSTORE hCertStore,
2725  PCCTL_CONTEXT pPrev);
2726
2727 BOOL WINAPI CertEnumSystemStoreLocation(DWORD dwFlags, void *pvArg,
2728  PFN_CERT_ENUM_SYSTEM_STORE_LOCATION pfnEnum);
2729
2730 BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
2731  void *pvArg, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum);
2732
2733 BOOL WINAPI CertEnumPhysicalStore(const void *pvSystemStore, DWORD dwFlags,
2734  void *pvArg, PFN_CERT_ENUM_PHYSICAL_STORE pfnEnum);
2735
2736 BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType,
2737              DWORD dwSaveAs, DWORD dwSaveTo, void* pvSaveToPara, DWORD dwFlags);
2738
2739 BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore,
2740  HCERTSTORE hSiblingStore, DWORD dwUpdateFlags, DWORD dwPriority);
2741
2742 void WINAPI CertRemoveStoreFromCollection(HCERTSTORE hCollectionStore,
2743  HCERTSTORE hSiblingStore);
2744
2745 PCCERT_CHAIN_CONTEXT WINAPI CertFindChainInStore(HCERTSTORE hCertStore,
2746  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
2747  const void *pvFindPara, PCCERT_CHAIN_CONTEXT pPrevChainContext);
2748
2749 BOOL WINAPI CertVerifyCertificateChainPolicy(LPCSTR szPolicyOID,
2750  PCCERT_CHAIN_CONTEXT pChainContext, PCERT_CHAIN_POLICY_PARA pPolicyPara,
2751  PCERT_CHAIN_POLICY_STATUS pPolicyStatus);
2752
2753 DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,
2754  DWORD dwPropId);
2755
2756 BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
2757  DWORD dwPropId, void *pvData, DWORD *pcbData);
2758
2759 BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
2760  DWORD dwPropId, DWORD dwFlags, const void *pvData);
2761
2762 DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
2763  DWORD dwPropId);
2764
2765 BOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
2766  DWORD dwPropId, void *pvData, DWORD *pcbData);
2767
2768 BOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
2769  DWORD dwPropId, DWORD dwFlags, const void *pvData);
2770
2771 DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
2772  DWORD dwPropId);
2773
2774 BOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
2775  DWORD dwPropId, void *pvData, DWORD *pcbData);
2776
2777 BOOL WINAPI CertSetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
2778  DWORD dwPropId, DWORD dwFlags, const void *pvData);
2779
2780 BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId,
2781  void *pvData, DWORD *pcbData);
2782
2783 BOOL WINAPI CertSetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId,
2784  DWORD dwFlags, const void *pvData);
2785
2786 BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags,
2787  DWORD dwCtrlType, void const *pvCtrlPara);
2788
2789 HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore);
2790
2791 BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags );
2792
2793 BOOL WINAPI CertFreeCertificateContext( PCCERT_CONTEXT pCertContext );
2794
2795 BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext );
2796
2797 BOOL WINAPI CertFreeCTLContext( PCCTL_CONTEXT pCtlContext );
2798
2799 BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,
2800  PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition,
2801  PCCERT_CONTEXT *ppStoreContext);
2802
2803 BOOL WINAPI CertAddCRLContextToStore( HCERTSTORE hCertStore,
2804  PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition,
2805  PCCRL_CONTEXT *ppStoreContext );
2806
2807 BOOL WINAPI CertAddCTLContextToStore( HCERTSTORE hCertStore,
2808  PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
2809  PCCTL_CONTEXT *ppStoreContext );
2810
2811 BOOL WINAPI CertAddCertificateLinkToStore(HCERTSTORE hCertStore,
2812  PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition,
2813  PCCERT_CONTEXT *ppStoreContext);
2814
2815 BOOL WINAPI CertAddCRLLinkToStore(HCERTSTORE hCertStore,
2816  PCCRL_CONTEXT pCrlContext, DWORD dwAddDisposition,
2817  PCCRL_CONTEXT *ppStoreContext);
2818
2819 BOOL WINAPI CertAddCTLLinkToStore(HCERTSTORE hCertStore,
2820  PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
2821  PCCTL_CONTEXT *ppStoreContext);
2822
2823 BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore,
2824  DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded,
2825  DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext);
2826
2827 BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore,
2828  DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded,
2829  DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext);
2830
2831 BOOL WINAPI CertAddEncodedCTLToStore(HCERTSTORE hCertStore,
2832  DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded,
2833  DWORD dwAddDisposition, PCCTL_CONTEXT *ppCtlContext);
2834
2835 BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,
2836  const BYTE *pbElement, DWORD cbElement, DWORD dwAddDisposition, DWORD dwFlags,
2837  DWORD dwContextTypeFlags, DWORD *pdwContentType, const void **ppvContext);
2838
2839 BOOL WINAPI CertCompareCertificate(DWORD dwCertEncodingType,
2840  PCERT_INFO pCertId1, PCERT_INFO pCertId2);
2841 BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType,
2842  PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2);
2843 BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1,
2844  PCRYPT_INTEGER_BLOB pInt2);
2845 BOOL WINAPI CertComparePublicKeyInfo(DWORD dwCertEncodingType,
2846  PCERT_PUBLIC_KEY_INFO pPublicKey1, PCERT_PUBLIC_KEY_INFO pPublicKey2);
2847
2848 const void *CertCreateContext(DWORD dwContextType, DWORD dwEncodingType,
2849  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2850  PCERT_CREATE_CONTEXT_PARA pCreatePara);
2851
2852 PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
2853  const BYTE *pbCertEncoded, DWORD cbCertEncoded);
2854
2855 PCCRL_CONTEXT WINAPI CertCreateCRLContext( DWORD dwCertEncodingType,
2856   const BYTE* pbCrlEncoded, DWORD cbCrlEncoded);
2857
2858 PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType,
2859  const BYTE *pbCtlEncoded, DWORD cbCtlEncoded);
2860
2861 PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(HCRYPTPROV hProv,
2862  PCERT_NAME_BLOB pSubjectIssuerBlob, DWORD dwFlags,
2863  PCRYPT_KEY_PROV_INFO pKeyProvInfo,
2864  PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, PSYSTEMTIME pStartTime,
2865  PSYSTEMTIME pEndTime, PCERT_EXTENSIONS pExtensions);
2866
2867 BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext);
2868
2869 BOOL WINAPI CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext);
2870
2871 BOOL WINAPI CertDeleteCTLFromStore(PCCTL_CONTEXT pCtlContext);
2872
2873 PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
2874  PCCERT_CONTEXT pCertContext);
2875
2876 PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext);
2877
2878 PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext);
2879
2880 PCCERT_CONTEXT WINAPI CertFindCertificateInStore( HCERTSTORE hCertStore,
2881  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
2882  const void *pvFindPara, PCCERT_CONTEXT pPrevCertContext );
2883
2884 PCCRL_CONTEXT WINAPI CertFindCRLInStore(HCERTSTORE hCertStore,
2885  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
2886  const void *pvFindPara, PCCRL_CONTEXT pPrevCrlContext);
2887
2888 PCCTL_CONTEXT WINAPI CertFindCTLInStore(HCERTSTORE hCertStore,
2889  DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
2890  const void *pvFindPara, PCCTL_CONTEXT pPrevCtlContext);
2891
2892 PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore,
2893  PCCERT_CONTEXT pSubjectContext, PCCERT_CONTEXT pPrevIssuerContext,
2894  DWORD *pdwFlags);
2895
2896 PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(HCERTSTORE hCertStore,
2897  DWORD dwCertEncodingType, PCERT_INFO pCertId);
2898
2899 PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore,
2900  PCCERT_CONTEXT pIssuerContext, PCCRL_CONTEXT pPrevCrlContext, DWORD *pdwFlags);
2901
2902 BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
2903  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
2904
2905 BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
2906  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
2907
2908 BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
2909  DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement);
2910
2911 BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags,
2912  PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage);
2913 BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext,
2914  PCERT_ENHKEY_USAGE pUsage);
2915 BOOL WINAPI CertAddEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext,
2916  LPCSTR pszUsageIdentifer);
2917 BOOL WINAPI CertRemoveEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext,
2918  LPCSTR pszUsageIdentifer);
2919 BOOL WINAPI CertGetValidUsages(DWORD cCerts, PCCERT_CONTEXT *rghCerts,
2920  int *cNumOIDs, LPSTR *rghOIDs, DWORD *pcbOIDs);
2921
2922 BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType,
2923  const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded);
2924 BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
2925  const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara,
2926  void *pvEncoded, DWORD *pcbEncoded);
2927
2928 BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType,
2929  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo,
2930  DWORD *pcbStructInfo);
2931 BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
2932  const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2933  PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo);
2934
2935 BOOL WINAPI CryptHashCertificate(HCRYPTPROV hCryptProv, ALG_ID Algid,
2936  DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash,
2937  DWORD *pcbComputedHash);
2938
2939 BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV hCryptProv, ALG_ID Algid,
2940  DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo,
2941  BYTE *pbComputedHash, DWORD *pcbComputedHash);
2942
2943 BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType,
2944  const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash,
2945  DWORD *pcbComputedHash);
2946
2947 BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void* pvObject,
2948  DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags,
2949  DWORD dwFlags, DWORD* pdwMsgAndCertEncodingType, DWORD* pdwContentType,
2950  DWORD* pdwFormatType, HCERTSTORE* phCertStore, HCRYPTMSG* phMsg,
2951  const void** ppvContext);
2952
2953 BOOL WINAPI CryptSignCertificate(HCRYPTPROV hCryptProv, DWORD dwKeySpec,
2954  DWORD dwCertEncodingType, const BYTE *pbEncodedToBeSigned,
2955  DWORD cbEncodedToBeSigned, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
2956  const void *pvHashAuxInfo, BYTE *pbSignature, DWORD *pcbSignature);
2957
2958 BOOL WINAPI CryptSignAndEncodeCertificate(HCRYPTPROV hCryptProv,
2959  DWORD dwKeySpec, DWORD dwCertEncodingType, LPCSTR lpszStructType,
2960  const void *pvStructInfo, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
2961  const void *pvHashAuxInfo, PBYTE pbEncoded, DWORD *pcbEncoded);
2962
2963 BOOL WINAPI CryptVerifyCertificateSignature(HCRYPTPROV hCryptProv,
2964  DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
2965  PCERT_PUBLIC_KEY_INFO pPublicKey);
2966
2967 BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV hCryptProv,
2968  DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject,
2969  DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved);
2970
2971 PCRYPT_ATTRIBUTE WINAPI CertFindAttribute(LPCSTR pszObjId, DWORD cAttr,
2972  CRYPT_ATTRIBUTE rgAttr[]);
2973 PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions,
2974  CERT_EXTENSION rgExtensions[]);
2975 PCERT_RDN_ATTR WINAPI CertFindRDNAttr(LPCSTR pszObjId, PCERT_NAME_INFO pName);
2976
2977 BOOL WINAPI CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert,
2978  PCCRL_CONTEXT pCrl, DWORD dwFlags, void *pvReserved);
2979 BOOL WINAPI CertFindCertificateInCRL(PCCERT_CONTEXT pCert,
2980  PCCRL_CONTEXT pCrlContext, DWORD dwFlags, void *pvReserved,
2981  PCRL_ENTRY *ppCrlEntry);
2982 BOOL WINAPI CertVerifyCRLRevocation(DWORD dwCertEncodingType,
2983  PCERT_INFO pCertId, DWORD cCrlInfo, PCRL_INFO rgpCrlInfo[]);
2984
2985 BOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject,
2986  PCCERT_CONTEXT pIssuer, DWORD *pdwFlags);
2987
2988 LONG WINAPI CertVerifyCRLTimeValidity(LPFILETIME pTimeToVerify,
2989  PCRL_INFO pCrlInfo);
2990 LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify,
2991  PCERT_INFO pCertInfo);
2992
2993 BOOL WINAPI CryptExportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwKeySpec,
2994  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo);
2995 BOOL WINAPI CryptExportPublicKeyInfoEx(HCRYPTPROV hCryptProv, DWORD dwKeySpec,
2996  DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags,
2997  void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo);
2998 BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv,
2999  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey);
3000 BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv,
3001  DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg,
3002  DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey);
3003
3004 BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
3005  DWORD dwFlags, void *pvReserved, HCRYPTPROV *phCryptProv, DWORD *pdwKeySpec,
3006  BOOL *pfCallerFreeProv);
3007
3008 BOOL WINAPI CryptProtectData( DATA_BLOB* pDataIn, LPCWSTR szDataDescr,
3009  DATA_BLOB* pOptionalEntropy, PVOID pvReserved,
3010  CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut );
3011
3012 BOOL WINAPI CryptUnprotectData( DATA_BLOB* pDataIn, LPWSTR* ppszDataDescr,
3013  DATA_BLOB* pOptionalEntropy, PVOID pvReserved,
3014  CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, DATA_BLOB* pDataOut );
3015
3016 DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType,
3017  DWORD dwFlags, void *pvTypePara, LPSTR pszNameString, DWORD cchNameString);
3018 DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
3019  DWORD dwFlags, void *pvTypePara, LPWSTR pszNameString, DWORD cchNameString);
3020 #define CertGetNameString WINELIB_NAME_AW(CertGetNameString)
3021
3022 DWORD WINAPI CertRDNValueToStrA(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
3023  LPSTR psz, DWORD csz);
3024 DWORD WINAPI CertRDNValueToStrW(DWORD dwValueType, PCERT_RDN_VALUE_BLOB pValue,
3025  LPWSTR psz, DWORD csz);
3026 #define CertRDNValueToStr WINELIB_NAME_AW(CertRDNValueToStr)
3027
3028 DWORD WINAPI CertNameToStrA(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
3029  DWORD dwStrType, LPSTR psz, DWORD csz);
3030 DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
3031  DWORD dwStrType, LPWSTR psz, DWORD csz);
3032 #define CertNameToStr WINELIB_NAME_AW(CertNameToStr)
3033
3034 BOOL WINAPI CertStrToNameA(DWORD dwCertEncodingType, LPCSTR pszX500,
3035  DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
3036  LPCSTR *ppszError);
3037 BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
3038  DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded,
3039  LPCWSTR *ppszError);
3040 #define CertStrToName WINELIB_NAME_AW(CertStrToName)
3041
3042 BOOL WINAPI CryptSignMessage(PCRYPT_SIGN_MESSAGE_PARA pSignPara,
3043  BOOL fDetachedSignature, DWORD cToBeSigned, const BYTE *rgpbToBeSigned[],
3044  DWORD rgcbToBeSigned[], BYTE *pbSignedBlob, DWORD *pcbSignedBlob);
3045 BOOL WINAPI CryptSignMessageWithKey(PCRYPT_KEY_SIGN_MESSAGE_PARA pSignPara,
3046  const BYTE *pbToBeSigned, DWORD cbToBeSigned, BYTE *pbSignedBlob,
3047  DWORD *pcbSignedBlob);
3048
3049 BOOL WINAPI CryptVerifyMessageSignature(PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
3050  DWORD dwSignerIndex, const BYTE* pbSignedBlob, DWORD cbSignedBlob,
3051  BYTE* pbDecoded, DWORD* pcbDecoded, PCCERT_CONTEXT* ppSignerCert);
3052 BOOL WINAPI CryptVerifyMessageSignatureWithKey(
3053  PCRYPT_KEY_VERIFY_MESSAGE_PARA pVerifyPara,
3054  PCERT_PUBLIC_KEY_INFO pPublicKeyInfo, const BYTE *pbSignedBlob,
3055  DWORD cbSignedBlob, BYTE *pbDecoded, DWORD *pcbDecoded);
3056
3057 BOOL WINAPI CryptVerifyDetachedMessageSignature(
3058  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
3059  const BYTE *pbDetachedSignBlob, DWORD cbDetachedSignBlob, DWORD cToBeSigned,
3060  const BYTE *rgpbToBeSigned[], DWORD rgcbToBeSigned[],
3061  PCCERT_CONTEXT *ppSignerCert);
3062 LONG WINAPI CryptGetMessageSignerCount(DWORD dwMsgEncodingType,
3063  const BYTE *pbSignedBlob, DWORD cbSignedBlob);
3064
3065 BOOL WINAPI CryptEncryptMessage(PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
3066  DWORD cRecipientCert, PCCERT_CONTEXT rgpRecipientCert[],
3067  const BYTE *pbToBeEncrypted, DWORD cbToBeEncrypted, BYTE *pbEncryptedBlob,
3068  DWORD *pcbEncryptedBlob);
3069 BOOL WINAPI CryptDecryptMessage(PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
3070  const BYTE *pbEncryptedBlob, DWORD cbEncryptedBlob, BYTE *pbDecrypted,
3071  DWORD *pcbDecrypted, PCCERT_CONTEXT *ppXchgCert);
3072
3073 BOOL WINAPI CryptSignAndEncryptMessage(PCRYPT_SIGN_MESSAGE_PARA pSignPara,
3074  PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara, DWORD cRecipientCert,
3075  PCCERT_CONTEXT rgpRecipientCert[], const BYTE *pbToBeSignedAndEncrypted,
3076  DWORD cbToBeSignedAndEncrypted, BYTE *pbSignedAndEncryptedBlob,
3077  DWORD *pcbSignedAndEncryptedBlob);
3078 BOOL WINAPI CryptDecryptAndVerifyMessageSignature(
3079  PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
3080  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
3081  const BYTE *pbEncryptedBlob, DWORD cbEncryptedBlob, BYTE *pbDecrypted,
3082  DWORD *pcbDecrypted, PCCERT_CONTEXT *ppXchgCert, PCCERT_CONTEXT *ppSignerCert);
3083
3084 HCERTSTORE WINAPI CryptGetMessageCertificates(DWORD dwMsgAndCertEncodingType,
3085  HCRYPTPROV hCryptProv, DWORD dwFlags, const BYTE *pbSignedBlob,
3086  DWORD cbSignedBlob);
3087
3088 BOOL WINAPI CryptDecodeMessage(DWORD dwMsgTypeFlags,
3089  PCRYPT_DECRYPT_MESSAGE_PARA pDecryptPara,
3090  PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara, DWORD dwSignerIndex,
3091  const BYTE *pbEncodedBlob, DWORD cbEncodedBlob, DWORD dwPrevInnerContentType,
3092  DWORD *pdwMsgType, DWORD *pdwInnerContentType, BYTE *pbDecoded,
3093  DWORD *pcbDecoded, PCCERT_CONTEXT *ppXchgCert, PCCERT_CONTEXT *ppSignerCert);
3094
3095 BOOL WINAPI CryptHashMessage(PCRYPT_HASH_MESSAGE_PARA pHashPara,
3096  BOOL fDetachedHash, DWORD cToBeHashed, const BYTE *rgpbToBeHashed[],
3097  DWORD rgcbToBeHashed[], BYTE *pbHashedBlob, DWORD *pcbHashedBlob,
3098  BYTE *pbComputedHash, DWORD *pcbComputedHash);
3099 BOOL WINAPI CryptVerifyMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara,
3100  BYTE *pbHashedBlob, DWORD cbHashedBlob, BYTE *pbToBeHashed,
3101  DWORD *pcbToBeHashed, BYTE *pbComputedHash, DWORD *pcbComputedHash);
3102 BOOL WINAPI CryptVerifyDetachedMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara,
3103  BYTE *pbDetachedHashBlob, DWORD cbDetachedHashBlob, DWORD cToBeHashed,
3104  const BYTE *rgpbToBeHashed[], DWORD rgcbToBeHashed[], BYTE *pbComputedHash,
3105  DWORD *pcbComputedHash);
3106
3107 /* cryptnet.dll functions */
3108 BOOL WINAPI CryptGetObjectUrl(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags,
3109  PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo,
3110  DWORD *pcbUrlInfo, LPVOID pvReserved);
3111
3112 #ifdef __cplusplus
3113 }
3114 #endif
3115
3116 #endif