Sync to trunk revision 61757.
[reactos.git] / dll / win32 / crypt32 / crypt32_private.h
1 /*
2 * Copyright 2005 Juan Lang
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef __CRYPT32_PRIVATE_H__
20 #define __CRYPT32_PRIVATE_H__
21
22 #include <wine/config.h>
23 #include <wine/port.h>
24
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28
29 #define _INC_WINDOWS
30 #define COM_NO_WINDOWS_H
31
32 #define NONAMELESSUNION
33
34 #include <windef.h>
35 #include <winbase.h>
36 #include <winuser.h>
37 #include <winreg.h>
38 #include <snmp.h>
39
40 #define CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
41 #define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS
42 #include <wincrypt.h>
43
44 #include <mssip.h>
45
46 #include <wine/unicode.h>
47 #include <wine/list.h>
48 #include <wine/exception.h>
49 #include <wine/debug.h>
50
51 #include "cryptres.h"
52
53 /* a few asn.1 tags we need */
54 #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
55 #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
56 #define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
57 #define ASN_UTF8STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0c)
58 #define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
59 #define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
60 #define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
61 #define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
62 #define ASN_VIDEOTEXSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x15)
63 #define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
64 #define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
65 #define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
66 #define ASN_GRAPHICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x19)
67 #define ASN_VISIBLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1a)
68 #define ASN_GENERALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1b)
69 #define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c)
70 #define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
71
72 BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
73
74 typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *,
75 DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *);
76
77 struct AsnEncodeSequenceItem
78 {
79 const void *pvStructInfo;
80 CryptEncodeObjectExFunc encodeFunc;
81 DWORD size; /* used during encoding, not for your use */
82 };
83
84 BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType,
85 struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags,
86 PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
87
88 struct AsnConstructedItem
89 {
90 BYTE tag;
91 const void *pvStructInfo;
92 CryptEncodeObjectExFunc encodeFunc;
93 };
94
95 BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType,
96 LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
97 PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
98 BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
99 LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
100 PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
101 BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType,
102 LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
103 PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
104
105 typedef struct _CRYPT_DIGESTED_DATA
106 {
107 DWORD version;
108 CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
109 CRYPT_CONTENT_INFO ContentInfo;
110 CRYPT_HASH_BLOB hash;
111 } CRYPT_DIGESTED_DATA;
112
113 BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
114 void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
115
116 typedef struct _CRYPT_ENCRYPTED_CONTENT_INFO
117 {
118 LPSTR contentType;
119 CRYPT_ALGORITHM_IDENTIFIER contentEncryptionAlgorithm;
120 CRYPT_DATA_BLOB encryptedContent;
121 } CRYPT_ENCRYPTED_CONTENT_INFO;
122
123 typedef struct _CRYPT_ENVELOPED_DATA
124 {
125 DWORD version;
126 DWORD cRecipientInfo;
127 PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo;
128 CRYPT_ENCRYPTED_CONTENT_INFO encryptedContentInfo;
129 } CRYPT_ENVELOPED_DATA;
130
131 BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
132 void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
133
134 BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
135 DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
136 CRYPT_ENVELOPED_DATA *envelopedData, DWORD *pcbEnvelopedData) DECLSPEC_HIDDEN;
137
138 typedef struct _CRYPT_SIGNED_INFO
139 {
140 DWORD version;
141 DWORD cCertEncoded;
142 PCERT_BLOB rgCertEncoded;
143 DWORD cCrlEncoded;
144 PCRL_BLOB rgCrlEncoded;
145 CRYPT_CONTENT_INFO content;
146 DWORD cSignerInfo;
147 PCMSG_CMS_SIGNER_INFO rgSignerInfo;
148 } CRYPT_SIGNED_INFO;
149
150 BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *, void *pvData,
151 DWORD *pcbData) DECLSPEC_HIDDEN;
152
153 BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
154 DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
155 CRYPT_SIGNED_INFO *signedInfo, DWORD *pcbSignedInfo) DECLSPEC_HIDDEN;
156
157 /* Helper function to check *pcbEncoded, set it to the required size, and
158 * optionally to allocate memory. Assumes pbEncoded is not NULL.
159 * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a
160 * pointer to the newly allocated memory.
161 */
162 BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara,
163 BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded) DECLSPEC_HIDDEN;
164
165 BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
166 DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
167 CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData) DECLSPEC_HIDDEN;
168
169 BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
170 LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
171 PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
172
173 /* The following aren't defined in wincrypt.h, as they're "reserved" */
174 #define CERT_CERT_PROP_ID 32
175 #define CERT_CRL_PROP_ID 33
176 #define CERT_CTL_PROP_ID 34
177
178 /* Returns a handle to the default crypto provider; loads it if necessary.
179 * Returns NULL on failure.
180 */
181 HCRYPTPROV CRYPT_GetDefaultProvider(void) DECLSPEC_HIDDEN;
182
183 HINSTANCE hInstance DECLSPEC_HIDDEN;
184
185 void crypt_oid_init(void) DECLSPEC_HIDDEN;
186 void crypt_oid_free(void) DECLSPEC_HIDDEN;
187 void crypt_sip_free(void) DECLSPEC_HIDDEN;
188 void root_store_free(void) DECLSPEC_HIDDEN;
189 void default_chain_engine_free(void) DECLSPEC_HIDDEN;
190
191 /* Some typedefs that make it easier to abstract which type of context we're
192 * working with.
193 */
194 typedef const void *(WINAPI *CreateContextFunc)(DWORD dwCertEncodingType,
195 const BYTE *pbCertEncoded, DWORD cbCertEncoded);
196 typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore,
197 const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
198 typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
199 DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
200 DWORD dwAddDisposition, const void **ppContext);
201 typedef const void *(WINAPI *DuplicateContextFunc)(const void *context);
202 typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
203 const void *pPrevContext);
204 typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId);
205 typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
206 DWORD dwPropID, void *pvData, DWORD *pcbData);
207 typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
208 DWORD dwPropID, DWORD dwFlags, const void *pvData);
209 typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags,
210 BYTE *pbElement, DWORD *pcbElement);
211 typedef BOOL (WINAPI *FreeContextFunc)(const void *context);
212 typedef BOOL (WINAPI *DeleteContextFunc)(const void *contex);
213
214 /* An abstract context (certificate, CRL, or CTL) interface */
215 typedef struct _WINE_CONTEXT_INTERFACE
216 {
217 CreateContextFunc create;
218 AddContextToStoreFunc addContextToStore;
219 AddEncodedContextToStoreFunc addEncodedToStore;
220 DuplicateContextFunc duplicate;
221 EnumContextsInStoreFunc enumContextsInStore;
222 EnumPropertiesFunc enumProps;
223 GetContextPropertyFunc getProp;
224 SetContextPropertyFunc setProp;
225 SerializeElementFunc serialize;
226 FreeContextFunc free;
227 DeleteContextFunc deleteFromStore;
228 } WINE_CONTEXT_INTERFACE, *PWINE_CONTEXT_INTERFACE;
229 typedef const WINE_CONTEXT_INTERFACE *PCWINE_CONTEXT_INTERFACE;
230
231 extern PCWINE_CONTEXT_INTERFACE pCertInterface DECLSPEC_HIDDEN;
232 extern PCWINE_CONTEXT_INTERFACE pCRLInterface DECLSPEC_HIDDEN;
233 extern PCWINE_CONTEXT_INTERFACE pCTLInterface DECLSPEC_HIDDEN;
234
235 /* (Internal) certificate store types and functions */
236 struct WINE_CRYPTCERTSTORE;
237
238 typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
239 DWORD dwFlags, const void *pvPara);
240
241 /* Called to enumerate the next context in a store. */
242 typedef void * (*EnumFunc)(struct WINE_CRYPTCERTSTORE *store, void *pPrev);
243
244 /* Called to add a context to a store. If toReplace is not NULL,
245 * context replaces toReplace in the store, and access checks should not be
246 * performed. Otherwise context is a new context, and it should only be
247 * added if the store allows it. If ppStoreContext is not NULL, the added
248 * context should be returned in *ppStoreContext.
249 */
250 typedef BOOL (*AddFunc)(struct WINE_CRYPTCERTSTORE *store, void *context,
251 void *toReplace, const void **ppStoreContext);
252
253 typedef BOOL (*DeleteFunc)(struct WINE_CRYPTCERTSTORE *store, void *context);
254
255 typedef struct _CONTEXT_FUNCS
256 {
257 AddFunc addContext;
258 EnumFunc enumContext;
259 DeleteFunc deleteContext;
260 } CONTEXT_FUNCS, *PCONTEXT_FUNCS;
261
262 typedef enum _CertStoreType {
263 StoreTypeMem,
264 StoreTypeCollection,
265 StoreTypeProvider,
266 } CertStoreType;
267
268 struct _CONTEXT_PROPERTY_LIST;
269 typedef struct _CONTEXT_PROPERTY_LIST *PCONTEXT_PROPERTY_LIST;
270
271 #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
272
273 /* A cert store is polymorphic through the use of function pointers. A type
274 * is still needed to distinguish collection stores from other types.
275 * On the function pointers:
276 * - closeStore is called when the store's ref count becomes 0
277 * - control is optional, but should be implemented by any store that supports
278 * persistence
279 */
280 typedef struct WINE_CRYPTCERTSTORE
281 {
282 DWORD dwMagic;
283 LONG ref;
284 DWORD dwOpenFlags;
285 CertStoreType type;
286 PFN_CERT_STORE_PROV_CLOSE closeStore;
287 CONTEXT_FUNCS certs;
288 CONTEXT_FUNCS crls;
289 CONTEXT_FUNCS ctls;
290 PFN_CERT_STORE_PROV_CONTROL control; /* optional */
291 PCONTEXT_PROPERTY_LIST properties;
292 } WINECRYPT_CERTSTORE, *PWINECRYPT_CERTSTORE;
293
294 void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
295 CertStoreType type) DECLSPEC_HIDDEN;
296 void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store) DECLSPEC_HIDDEN;
297 BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
298 DWORD unk1) DECLSPEC_HIDDEN;
299
300 PWINECRYPT_CERTSTORE CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
301 DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
302 PWINECRYPT_CERTSTORE CRYPT_ProvCreateStore(DWORD dwFlags,
303 PWINECRYPT_CERTSTORE memStore, const CERT_STORE_PROV_INFO *pProvInfo) DECLSPEC_HIDDEN;
304 PWINECRYPT_CERTSTORE CRYPT_ProvOpenStore(LPCSTR lpszStoreProvider,
305 DWORD dwEncodingType, HCRYPTPROV hCryptProv, DWORD dwFlags,
306 const void *pvPara) DECLSPEC_HIDDEN;
307 PWINECRYPT_CERTSTORE CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
308 const void *pvPara) DECLSPEC_HIDDEN;
309 PWINECRYPT_CERTSTORE CRYPT_FileOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
310 const void *pvPara) DECLSPEC_HIDDEN;
311 PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv,
312 DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
313 PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
314 DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
315 PWINECRYPT_CERTSTORE CRYPT_RootOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags) DECLSPEC_HIDDEN;
316
317 /* Allocates and initializes a certificate chain engine, but without creating
318 * the root store. Instead, it uses root, and assumes the caller has done any
319 * checking necessary.
320 */
321 HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root,
322 PCERT_CHAIN_ENGINE_CONFIG pConfig) DECLSPEC_HIDDEN;
323
324 /* Helper function for store reading functions and
325 * CertAddSerializedElementToStore. Returns a context of the appropriate type
326 * if it can, or NULL otherwise. Doesn't validate any of the properties in
327 * the serialized context (for example, bad hashes are retained.)
328 * *pdwContentType is set to the type of the returned context.
329 */
330 const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
331 DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType) DECLSPEC_HIDDEN;
332
333 /* Reads contexts serialized in the file into the memory store. Returns FALSE
334 * if the file is not of the expected format.
335 */
336 BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store) DECLSPEC_HIDDEN;
337
338 /* Reads contexts serialized in the blob into the memory store. Returns FALSE
339 * if the file is not of the expected format.
340 */
341 BOOL CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB *blob,
342 HCERTSTORE store) DECLSPEC_HIDDEN;
343
344 /* Fixes up the pointers in info, where info is assumed to be a
345 * CRYPT_KEY_PROV_INFO, followed by its container name, provider name, and any
346 * provider parameters, in a contiguous buffer, but where info's pointers are
347 * assumed to be invalid. Upon return, info's pointers point to the
348 * appropriate memory locations.
349 */
350 void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info) DECLSPEC_HIDDEN;
351
352 /**
353 * String functions
354 */
355
356 DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
357 const CERT_NAME_BLOB *pName, DWORD dwStrType, LPWSTR psz, DWORD csz) DECLSPEC_HIDDEN;
358
359 /**
360 * Context functions
361 */
362
363 /* Allocates a new data context, a context which owns properties directly.
364 * contextSize is the size of the public data type associated with context,
365 * which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
366 * Free with Context_Release.
367 */
368 void *Context_CreateDataContext(size_t contextSize) DECLSPEC_HIDDEN;
369
370 /* Creates a new link context with extra bytes. The context refers to linked
371 * rather than owning its own properties. If addRef is TRUE (which ordinarily
372 * it should be) linked is addref'd.
373 * Free with Context_Release.
374 */
375 void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra,
376 BOOL addRef) DECLSPEC_HIDDEN;
377
378 /* Returns a pointer to the extra bytes allocated with context, which must be
379 * a link context.
380 */
381 void *Context_GetExtra(const void *context, size_t contextSize) DECLSPEC_HIDDEN;
382
383 /* Gets the context linked to by context, which must be a link context. */
384 void *Context_GetLinkedContext(void *context, size_t contextSize) DECLSPEC_HIDDEN;
385
386 /* Copies properties from fromContext to toContext. */
387 void Context_CopyProperties(const void *to, const void *from,
388 size_t contextSize) DECLSPEC_HIDDEN;
389
390 /* Returns context's properties, or the linked context's properties if context
391 * is a link context.
392 */
393 PCONTEXT_PROPERTY_LIST Context_GetProperties(const void *context, size_t contextSize) DECLSPEC_HIDDEN;
394
395 void Context_AddRef(void *context, size_t contextSize) DECLSPEC_HIDDEN;
396
397 typedef void (*ContextFreeFunc)(void *context);
398
399 /* Decrements context's ref count. If context is a link context, releases its
400 * linked context as well.
401 * If a data context has its ref count reach 0, calls dataContextFree on it.
402 * Returns FALSE if the reference count is <= 0 when called.
403 */
404 BOOL Context_Release(void *context, size_t contextSize,
405 ContextFreeFunc dataContextFree) DECLSPEC_HIDDEN;
406
407 /**
408 * Context property list functions
409 */
410
411 PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void) DECLSPEC_HIDDEN;
412
413 /* Searches for the property with ID id in the context. Returns TRUE if found,
414 * and copies the property's length and a pointer to its data to blob.
415 * Otherwise returns FALSE.
416 */
417 BOOL ContextPropertyList_FindProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
418 PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN;
419
420 BOOL ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
421 const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN;
422
423 void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list, DWORD id) DECLSPEC_HIDDEN;
424
425 DWORD ContextPropertyList_EnumPropIDs(PCONTEXT_PROPERTY_LIST list, DWORD id) DECLSPEC_HIDDEN;
426
427 void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to,
428 PCONTEXT_PROPERTY_LIST from) DECLSPEC_HIDDEN;
429
430 void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list) DECLSPEC_HIDDEN;
431
432 /**
433 * Context list functions. A context list is a simple list of link contexts.
434 */
435 struct ContextList;
436
437 struct ContextList *ContextList_Create(
438 PCWINE_CONTEXT_INTERFACE contextInterface, size_t contextSize) DECLSPEC_HIDDEN;
439
440 void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) DECLSPEC_HIDDEN;
441
442 void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN;
443
444 /* Removes a context from the list. Returns TRUE if the context was removed,
445 * or FALSE if not. (The context may have been duplicated, so subsequent
446 * removes have no effect.)
447 */
448 BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN;
449
450 void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
451
452 /**
453 * Utilities.
454 */
455
456 /* Align up to a DWORD_PTR boundary
457 */
458 #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
459 #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p)))
460
461 /* Check if the OID is a small int
462 */
463 #define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
464
465 #endif /* __CRYPT32_PRIVATE_H__ */