[21311] | 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 "winerror.h"
|
---|
| 23 |
|
---|
| 24 | /* a few asn.1 tags we need */
|
---|
| 25 | #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
|
---|
| 26 | #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
|
---|
| 27 | #define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
|
---|
| 28 | #define ASN_UTF8STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0c)
|
---|
| 29 | #define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
|
---|
| 30 | #define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
|
---|
| 31 | #define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
|
---|
| 32 | #define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
|
---|
| 33 | #define ASN_VIDEOTEXSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x15)
|
---|
| 34 | #define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
|
---|
| 35 | #define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
|
---|
| 36 | #define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
|
---|
| 37 | #define ASN_GRAPHICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x19)
|
---|
| 38 | #define ASN_VISIBLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1a)
|
---|
| 39 | #define ASN_GENERALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1b)
|
---|
| 40 | #define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c)
|
---|
| 41 | #define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
|
---|
| 42 |
|
---|
| 43 | BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded);
|
---|
| 44 |
|
---|
| 45 | typedef BOOL (*WINAPI CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *,
|
---|
| 46 | DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *);
|
---|
| 47 |
|
---|
| 48 | struct AsnEncodeSequenceItem
|
---|
| 49 | {
|
---|
| 50 | const void *pvStructInfo;
|
---|
| 51 | CryptEncodeObjectExFunc encodeFunc;
|
---|
| 52 | DWORD size; /* used during encoding, not for your use */
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType,
|
---|
| 56 | struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags,
|
---|
| 57 | PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded);
|
---|
| 58 |
|
---|
| 59 | struct AsnConstructedItem
|
---|
| 60 | {
|
---|
| 61 | BYTE tag;
|
---|
| 62 | const void *pvStructInfo;
|
---|
| 63 | CryptEncodeObjectExFunc encodeFunc;
|
---|
| 64 | };
|
---|
| 65 |
|
---|
| 66 | BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType,
|
---|
| 67 | LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
---|
| 68 | PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded);
|
---|
| 69 | BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
|
---|
| 70 | LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
---|
| 71 | PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded);
|
---|
| 72 | BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType,
|
---|
| 73 | LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
---|
| 74 | PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded);
|
---|
| 75 |
|
---|
| 76 | typedef struct _CRYPT_DIGESTED_DATA
|
---|
| 77 | {
|
---|
| 78 | DWORD version;
|
---|
| 79 | CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
|
---|
| 80 | CRYPT_CONTENT_INFO ContentInfo;
|
---|
| 81 | CRYPT_HASH_BLOB hash;
|
---|
| 82 | } CRYPT_DIGESTED_DATA;
|
---|
| 83 |
|
---|
| 84 | BOOL CRYPT_AsnEncodePKCSDigestedData(CRYPT_DIGESTED_DATA *digestedData,
|
---|
| 85 | void *pvData, DWORD *pcbData);
|
---|
| 86 |
|
---|
| 87 | typedef struct _CRYPT_SIGNED_INFO
|
---|
| 88 | {
|
---|
| 89 | DWORD version;
|
---|
| 90 | DWORD cCertEncoded;
|
---|
| 91 | PCERT_BLOB rgCertEncoded;
|
---|
| 92 | DWORD cCrlEncoded;
|
---|
| 93 | PCRL_BLOB rgCrlEncoded;
|
---|
| 94 | CRYPT_CONTENT_INFO content;
|
---|
| 95 | DWORD cSignerInfo;
|
---|
| 96 | PCMSG_CMS_SIGNER_INFO rgSignerInfo;
|
---|
| 97 | } CRYPT_SIGNED_INFO;
|
---|
| 98 |
|
---|
| 99 | BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *, void *pvData,
|
---|
| 100 | DWORD *pcbData);
|
---|
| 101 |
|
---|
| 102 | BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
|
---|
| 103 | DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
---|
| 104 | CRYPT_SIGNED_INFO *signedInfo, DWORD *pcbSignedInfo);
|
---|
| 105 |
|
---|
| 106 | /* Helper function to check *pcbEncoded, set it to the required size, and
|
---|
| 107 | * optionally to allocate memory. Assumes pbEncoded is not NULL.
|
---|
| 108 | * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a
|
---|
| 109 | * pointer to the newly allocated memory.
|
---|
| 110 | */
|
---|
| 111 | BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara,
|
---|
| 112 | BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded);
|
---|
| 113 |
|
---|
| 114 | BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
|
---|
| 115 | DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
---|
| 116 | CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData);
|
---|
| 117 |
|
---|
| 118 | /* The following aren't defined in wincrypt.h, as they're "reserved" */
|
---|
| 119 | #define CERT_CERT_PROP_ID 32
|
---|
| 120 | #define CERT_CRL_PROP_ID 33
|
---|
| 121 | #define CERT_CTL_PROP_ID 34
|
---|
| 122 |
|
---|
| 123 | /* Returns a handle to the default crypto provider; loads it if necessary.
|
---|
| 124 | * Returns NULL on failure.
|
---|
| 125 | */
|
---|
| 126 | HCRYPTPROV CRYPT_GetDefaultProvider(void);
|
---|
| 127 |
|
---|
| 128 | HINSTANCE hInstance;
|
---|
| 129 |
|
---|
| 130 | void crypt_oid_init(void);
|
---|
| 131 | void crypt_oid_free(void);
|
---|
| 132 | void crypt_sip_free(void);
|
---|
| 133 | void root_store_free(void);
|
---|
| 134 | void default_chain_engine_free(void);
|
---|
| 135 |
|
---|
| 136 | /* Some typedefs that make it easier to abstract which type of context we're
|
---|
| 137 | * working with.
|
---|
| 138 | */
|
---|
| 139 | typedef const void *(*WINAPI CreateContextFunc)(DWORD dwCertEncodingType,
|
---|
| 140 | const BYTE *pbCertEncoded, DWORD cbCertEncoded);
|
---|
| 141 | typedef BOOL (*WINAPI AddContextToStoreFunc)(HCERTSTORE hCertStore,
|
---|
| 142 | const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
|
---|
| 143 | typedef BOOL (*WINAPI AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
|
---|
| 144 | DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
|
---|
| 145 | DWORD dwAddDisposition, const void **ppContext);
|
---|
| 146 | typedef const void *(*WINAPI DuplicateContextFunc)(const void *context);
|
---|
| 147 | typedef const void *(*WINAPI EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
|
---|
| 148 | const void *pPrevContext);
|
---|
| 149 | typedef DWORD (*WINAPI EnumPropertiesFunc)(const void *context, DWORD dwPropId);
|
---|
| 150 | typedef BOOL (*WINAPI GetContextPropertyFunc)(const void *context,
|
---|
| 151 | DWORD dwPropID, void *pvData, DWORD *pcbData);
|
---|
| 152 | typedef BOOL (*WINAPI SetContextPropertyFunc)(const void *context,
|
---|
| 153 | DWORD dwPropID, DWORD dwFlags, const void *pvData);
|
---|
| 154 | typedef BOOL (*WINAPI SerializeElementFunc)(const void *context, DWORD dwFlags,
|
---|
| 155 | BYTE *pbElement, DWORD *pcbElement);
|
---|
| 156 | typedef BOOL (*WINAPI FreeContextFunc)(const void *context);
|
---|
| 157 | typedef BOOL (*WINAPI DeleteContextFunc)(const void *context);
|
---|
| 158 |
|
---|
| 159 | /* An abstract context (certificate, CRL, or CTL) interface */
|
---|
| 160 | typedef struct _WINE_CONTEXT_INTERFACE
|
---|
| 161 | {
|
---|
| 162 | CreateContextFunc create;
|
---|
| 163 | AddContextToStoreFunc addContextToStore;
|
---|
| 164 | AddEncodedContextToStoreFunc addEncodedToStore;
|
---|
| 165 | DuplicateContextFunc duplicate;
|
---|
| 166 | EnumContextsInStoreFunc enumContextsInStore;
|
---|
| 167 | EnumPropertiesFunc enumProps;
|
---|
| 168 | GetContextPropertyFunc getProp;
|
---|
| 169 | SetContextPropertyFunc setProp;
|
---|
| 170 | SerializeElementFunc serialize;
|
---|
| 171 | FreeContextFunc confree;
|
---|
| 172 | DeleteContextFunc deleteFromStore;
|
---|
| 173 | } WINE_CONTEXT_INTERFACE, *PWINE_CONTEXT_INTERFACE;
|
---|
| 174 | typedef const WINE_CONTEXT_INTERFACE *PCWINE_CONTEXT_INTERFACE;
|
---|
| 175 |
|
---|
| 176 | extern PCWINE_CONTEXT_INTERFACE pCertInterface;
|
---|
| 177 | extern PCWINE_CONTEXT_INTERFACE pCRLInterface;
|
---|
| 178 | extern PCWINE_CONTEXT_INTERFACE pCTLInterface;
|
---|
| 179 |
|
---|
| 180 | /* (Internal) certificate store types and functions */
|
---|
| 181 | struct WINE_CRYPTCERTSTORE;
|
---|
| 182 |
|
---|
| 183 | typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
|
---|
| 184 | DWORD dwFlags, const void *pvPara);
|
---|
| 185 |
|
---|
| 186 | /* Called to enumerate the next context in a store. */
|
---|
| 187 | typedef void * (*EnumFunc)(struct WINE_CRYPTCERTSTORE *store, void *pPrev);
|
---|
| 188 |
|
---|
| 189 | /* Called to add a context to a store. If toReplace is not NULL,
|
---|
| 190 | * context replaces toReplace in the store, and access checks should not be
|
---|
| 191 | * performed. Otherwise context is a new context, and it should only be
|
---|
| 192 | * added if the store allows it. If ppStoreContext is not NULL, the added
|
---|
| 193 | * context should be returned in *ppStoreContext.
|
---|
| 194 | */
|
---|
| 195 | typedef BOOL (*AddFunc)(struct WINE_CRYPTCERTSTORE *store, void *context,
|
---|
| 196 | void *toReplace, const void **ppStoreContext);
|
---|
| 197 |
|
---|
| 198 | typedef BOOL (*DeleteFunc)(struct WINE_CRYPTCERTSTORE *store, void *context);
|
---|
| 199 |
|
---|
| 200 | typedef struct _CONTEXT_FUNCS
|
---|
| 201 | {
|
---|
| 202 | AddFunc addContext;
|
---|
| 203 | EnumFunc enumContext;
|
---|
| 204 | DeleteFunc deleteContext;
|
---|
| 205 | } CONTEXT_FUNCS, *PCONTEXT_FUNCS;
|
---|
| 206 |
|
---|
| 207 | typedef enum _CertStoreType {
|
---|
| 208 | StoreTypeMem,
|
---|
| 209 | StoreTypeCollection,
|
---|
| 210 | StoreTypeProvider,
|
---|
| 211 | } CertStoreType;
|
---|
| 212 |
|
---|
| 213 | struct _CONTEXT_PROPERTY_LIST;
|
---|
| 214 | typedef struct _CONTEXT_PROPERTY_LIST *PCONTEXT_PROPERTY_LIST;
|
---|
| 215 |
|
---|
| 216 | #define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
|
---|
| 217 |
|
---|
| 218 | /* A cert store is polymorphic through the use of function pointers. A type
|
---|
| 219 | * is still needed to distinguish collection stores from other types.
|
---|
| 220 | * On the function pointers:
|
---|
| 221 | * - closeStore is called when the store's ref count becomes 0
|
---|
| 222 | * - control is optional, but should be implemented by any store that supports
|
---|
| 223 | * persistence
|
---|
| 224 | */
|
---|
| 225 | typedef struct WINE_CRYPTCERTSTORE
|
---|
| 226 | {
|
---|
| 227 | DWORD dwMagic;
|
---|
| 228 | LONG ref;
|
---|
| 229 | DWORD dwOpenFlags;
|
---|
| 230 | CertStoreType type;
|
---|
| 231 | PFN_CERT_STORE_PROV_CLOSE closeStore;
|
---|
| 232 | CONTEXT_FUNCS certs;
|
---|
| 233 | CONTEXT_FUNCS crls;
|
---|
| 234 | CONTEXT_FUNCS ctls;
|
---|
| 235 | PFN_CERT_STORE_PROV_CONTROL control; /* optional */
|
---|
| 236 | PCONTEXT_PROPERTY_LIST properties;
|
---|
| 237 | } WINECRYPT_CERTSTORE, *PWINECRYPT_CERTSTORE;
|
---|
| 238 |
|
---|
| 239 | void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
---|
| 240 | CertStoreType type);
|
---|
| 241 | void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store);
|
---|
| 242 | BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
|
---|
| 243 | DWORD unk1);
|
---|
| 244 |
|
---|
| 245 | PWINECRYPT_CERTSTORE CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
---|
| 246 | DWORD dwFlags, const void *pvPara);
|
---|
| 247 | PWINECRYPT_CERTSTORE CRYPT_ProvCreateStore(DWORD dwFlags,
|
---|
| 248 | PWINECRYPT_CERTSTORE memStore, const CERT_STORE_PROV_INFO *pProvInfo);
|
---|
| 249 | PWINECRYPT_CERTSTORE CRYPT_ProvOpenStore(LPCSTR lpszStoreProvider,
|
---|
| 250 | DWORD dwEncodingType, HCRYPTPROV hCryptProv, DWORD dwFlags,
|
---|
| 251 | const void *pvPara);
|
---|
| 252 | PWINECRYPT_CERTSTORE CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
|
---|
| 253 | const void *pvPara);
|
---|
| 254 | PWINECRYPT_CERTSTORE CRYPT_FileOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
|
---|
| 255 | const void *pvPara);
|
---|
| 256 | PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv,
|
---|
| 257 | DWORD dwFlags, const void *pvPara);
|
---|
| 258 | PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
|
---|
| 259 | DWORD dwFlags, const void *pvPara);
|
---|
| 260 | PWINECRYPT_CERTSTORE CRYPT_RootOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags);
|
---|
| 261 |
|
---|
| 262 | /* Allocates and initializes a certificate chain engine, but without creating
|
---|
| 263 | * the root store. Instead, it uses root, and assumes the caller has done any
|
---|
| 264 | * checking necessary.
|
---|
| 265 | */
|
---|
| 266 | HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root,
|
---|
| 267 | PCERT_CHAIN_ENGINE_CONFIG pConfig);
|
---|
| 268 |
|
---|
| 269 | /* Helper function for store reading functions and
|
---|
| 270 | * CertAddSerializedElementToStore. Returns a context of the appropriate type
|
---|
| 271 | * if it can, or NULL otherwise. Doesn't validate any of the properties in
|
---|
| 272 | * the serialized context (for example, bad hashes are retained.)
|
---|
| 273 | * *pdwContentType is set to the type of the returned context.
|
---|
| 274 | */
|
---|
| 275 | const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
|
---|
| 276 | DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType);
|
---|
| 277 |
|
---|
| 278 | /* Reads contexts serialized in the file into the memory store. Returns FALSE
|
---|
| 279 | * if the file is not of the expected format.
|
---|
| 280 | */
|
---|
| 281 | BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store);
|
---|
| 282 |
|
---|
| 283 | /* Fixes up the pointers in info, where info is assumed to be a
|
---|
| 284 | * CRYPT_KEY_PROV_INFO, followed by its container name, provider name, and any
|
---|
| 285 | * provider parameters, in a contiguous buffer, but where info's pointers are
|
---|
| 286 | * assumed to be invalid. Upon return, info's pointers point to the
|
---|
| 287 | * appropriate memory locations.
|
---|
| 288 | */
|
---|
| 289 | void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info);
|
---|
| 290 |
|
---|
| 291 | /**
|
---|
| 292 | * String functions
|
---|
| 293 | */
|
---|
| 294 |
|
---|
| 295 | DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
|
---|
| 296 | PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz);
|
---|
| 297 |
|
---|
| 298 | /**
|
---|
| 299 | * Context functions
|
---|
| 300 | */
|
---|
| 301 |
|
---|
| 302 | /* Allocates a new data context, a context which owns properties directly.
|
---|
| 303 | * contextSize is the size of the public data type associated with context,
|
---|
| 304 | * which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
|
---|
| 305 | * Free with Context_Release.
|
---|
| 306 | */
|
---|
| 307 | void *Context_CreateDataContext(size_t contextSize);
|
---|
| 308 |
|
---|
| 309 | /* Creates a new link context with extra bytes. The context refers to linked
|
---|
| 310 | * rather than owning its own properties. If addRef is TRUE (which ordinarily
|
---|
| 311 | * it should be) linked is addref'd.
|
---|
| 312 | * Free with Context_Release.
|
---|
| 313 | */
|
---|
| 314 | void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra,
|
---|
| 315 | BOOL addRef);
|
---|
| 316 |
|
---|
| 317 | /* Returns a pointer to the extra bytes allocated with context, which must be
|
---|
| 318 | * a link context.
|
---|
| 319 | */
|
---|
| 320 | void *Context_GetExtra(const void *context, size_t contextSize);
|
---|
| 321 |
|
---|
| 322 | /* Gets the context linked to by context, which must be a link context. */
|
---|
| 323 | void *Context_GetLinkedContext(void *context, size_t contextSize);
|
---|
| 324 |
|
---|
| 325 | /* Copies properties from fromContext to toContext. */
|
---|
| 326 | void Context_CopyProperties(const void *to, const void *from,
|
---|
| 327 | size_t contextSize);
|
---|
| 328 |
|
---|
| 329 | /* Returns context's properties, or the linked context's properties if context
|
---|
| 330 | * is a link context.
|
---|
| 331 | */
|
---|
| 332 | PCONTEXT_PROPERTY_LIST Context_GetProperties(const void *context, size_t contextSize);
|
---|
| 333 |
|
---|
| 334 | void Context_AddRef(void *context, size_t contextSize);
|
---|
| 335 |
|
---|
| 336 | typedef void (*ContextFreeFunc)(void *context);
|
---|
| 337 |
|
---|
| 338 | /* Decrements context's ref count. If context is a link context, releases its
|
---|
| 339 | * linked context as well.
|
---|
| 340 | * If a data context has its ref count reach 0, calls dataContextFree on it.
|
---|
| 341 | */
|
---|
| 342 | void Context_Release(void *context, size_t contextSize,
|
---|
| 343 | ContextFreeFunc dataContextFree);
|
---|
| 344 |
|
---|
| 345 | /**
|
---|
| 346 | * Context property list functions
|
---|
| 347 | */
|
---|
| 348 |
|
---|
| 349 | PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void);
|
---|
| 350 |
|
---|
| 351 | /* Searches for the property with ID id in the context. Returns TRUE if found,
|
---|
| 352 | * and copies the property's length and a pointer to its data to blob.
|
---|
| 353 | * Otherwise returns FALSE.
|
---|
| 354 | */
|
---|
| 355 | BOOL ContextPropertyList_FindProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
|
---|
| 356 | PCRYPT_DATA_BLOB blob);
|
---|
| 357 |
|
---|
| 358 | BOOL ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
|
---|
| 359 | const BYTE *pbData, size_t cbData);
|
---|
| 360 |
|
---|
| 361 | void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list, DWORD id);
|
---|
| 362 |
|
---|
| 363 | DWORD ContextPropertyList_EnumPropIDs(PCONTEXT_PROPERTY_LIST list, DWORD id);
|
---|
| 364 |
|
---|
| 365 | void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to,
|
---|
| 366 | PCONTEXT_PROPERTY_LIST from);
|
---|
| 367 |
|
---|
| 368 | void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list);
|
---|
| 369 |
|
---|
| 370 | /**
|
---|
| 371 | * Context list functions. A context list is a simple list of link contexts.
|
---|
| 372 | */
|
---|
| 373 | struct ContextList;
|
---|
| 374 |
|
---|
| 375 | struct ContextList *ContextList_Create(
|
---|
| 376 | PCWINE_CONTEXT_INTERFACE contextInterface, size_t contextSize);
|
---|
| 377 |
|
---|
| 378 | void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace);
|
---|
| 379 |
|
---|
| 380 | void *ContextList_Enum(struct ContextList *list, void *pPrev);
|
---|
| 381 |
|
---|
| 382 | void ContextList_Delete(struct ContextList *list, void *context);
|
---|
| 383 |
|
---|
| 384 | void ContextList_Empty(struct ContextList *list);
|
---|
| 385 |
|
---|
| 386 | void ContextList_Free(struct ContextList *list);
|
---|
| 387 |
|
---|
| 388 | /**
|
---|
| 389 | * Utilities.
|
---|
| 390 | */
|
---|
| 391 |
|
---|
| 392 | /* Align up to a DWORD_PTR boundary
|
---|
| 393 | */
|
---|
| 394 | #define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
|
---|
| 395 | #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((/*DWORD_PTR*/unsigned int)(p)))
|
---|
| 396 |
|
---|
[21325] | 397 | #define strcasecmp lstrcmpiA
|
---|
[21311] | 398 |
|
---|
[21354] | 399 | /**
|
---|
| 400 | * In crypt32\main.c but not prototyped elsewhere
|
---|
| 401 | */
|
---|
| 402 |
|
---|
[21916] | 403 | int crypt32_vsnprintf (char *buf, int n, const char *fmt, va_list args);
|
---|
| 404 | int crypt32_snprintf (char *buf, int n, const char *fmt, ...);
|
---|
[21354] | 405 |
|
---|
[21311] | 406 | #endif
|
---|