2005-08-25 11:51:59 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Juan Lang
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-25 11:51:59 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CRYPT32_PRIVATE_H__
|
|
|
|
#define __CRYPT32_PRIVATE_H__
|
|
|
|
|
2013-10-15 16:53:11 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
|
2006-05-16 02:01:28 +02:00
|
|
|
/* a few asn.1 tags we need */
|
|
|
|
#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
|
|
|
|
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
|
|
|
|
#define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
|
2006-07-19 16:44:48 +02:00
|
|
|
#define ASN_UTF8STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0c)
|
2006-05-16 02:01:28 +02:00
|
|
|
#define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
|
|
|
|
#define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
|
|
|
|
#define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
|
2006-06-02 22:20:13 +02:00
|
|
|
#define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
|
2006-07-19 16:44:48 +02:00
|
|
|
#define ASN_VIDEOTEXSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x15)
|
2006-05-16 02:01:28 +02:00
|
|
|
#define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
|
|
|
|
#define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
|
|
|
|
#define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
|
2006-07-19 16:44:48 +02:00
|
|
|
#define ASN_GRAPHICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x19)
|
|
|
|
#define ASN_VISIBLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1a)
|
|
|
|
#define ASN_GENERALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1b)
|
|
|
|
#define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c)
|
|
|
|
#define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
|
2006-05-16 02:01:28 +02:00
|
|
|
|
2011-04-21 10:52:29 +02:00
|
|
|
BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2007-07-12 23:09:00 +02:00
|
|
|
|
|
|
|
typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *,
|
|
|
|
DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *);
|
|
|
|
|
|
|
|
struct AsnEncodeSequenceItem
|
|
|
|
{
|
|
|
|
const void *pvStructInfo;
|
|
|
|
CryptEncodeObjectExFunc encodeFunc;
|
|
|
|
DWORD size; /* used during encoding, not for your use */
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType,
|
|
|
|
struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2007-07-12 23:09:00 +02:00
|
|
|
|
|
|
|
struct AsnConstructedItem
|
|
|
|
{
|
|
|
|
BYTE tag;
|
|
|
|
const void *pvStructInfo;
|
|
|
|
CryptEncodeObjectExFunc encodeFunc;
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType,
|
|
|
|
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2007-07-12 23:09:00 +02:00
|
|
|
BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
|
|
|
|
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2007-07-12 23:59:27 +02:00
|
|
|
BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType,
|
|
|
|
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2007-07-12 23:09:00 +02:00
|
|
|
|
2007-07-17 16:22:50 +02:00
|
|
|
typedef struct _CRYPT_DIGESTED_DATA
|
|
|
|
{
|
|
|
|
DWORD version;
|
|
|
|
CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm;
|
|
|
|
CRYPT_CONTENT_INFO ContentInfo;
|
|
|
|
CRYPT_HASH_BLOB hash;
|
|
|
|
} CRYPT_DIGESTED_DATA;
|
|
|
|
|
2009-06-12 19:27:56 +02:00
|
|
|
BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
|
2011-04-21 10:52:29 +02:00
|
|
|
void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
|
2007-07-17 16:22:50 +02:00
|
|
|
|
2010-12-01 12:40:27 +01:00
|
|
|
typedef struct _CRYPT_ENCRYPTED_CONTENT_INFO
|
|
|
|
{
|
|
|
|
LPSTR contentType;
|
|
|
|
CRYPT_ALGORITHM_IDENTIFIER contentEncryptionAlgorithm;
|
|
|
|
CRYPT_DATA_BLOB encryptedContent;
|
|
|
|
} CRYPT_ENCRYPTED_CONTENT_INFO;
|
|
|
|
|
|
|
|
typedef struct _CRYPT_ENVELOPED_DATA
|
|
|
|
{
|
|
|
|
DWORD version;
|
|
|
|
DWORD cRecipientInfo;
|
|
|
|
PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo;
|
|
|
|
CRYPT_ENCRYPTED_CONTENT_INFO encryptedContentInfo;
|
|
|
|
} CRYPT_ENVELOPED_DATA;
|
|
|
|
|
|
|
|
BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
|
2011-04-21 10:52:29 +02:00
|
|
|
void *pvData, DWORD *pcbData) DECLSPEC_HIDDEN;
|
2010-12-01 12:40:27 +01:00
|
|
|
|
2010-12-15 15:35:29 +01:00
|
|
|
BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
|
|
|
|
DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
2011-04-21 10:52:29 +02:00
|
|
|
CRYPT_ENVELOPED_DATA *envelopedData, DWORD *pcbEnvelopedData) DECLSPEC_HIDDEN;
|
2010-12-15 15:35:29 +01:00
|
|
|
|
2007-07-24 03:11:17 +02:00
|
|
|
typedef struct _CRYPT_SIGNED_INFO
|
|
|
|
{
|
2008-08-20 20:57:21 +02:00
|
|
|
DWORD version;
|
|
|
|
DWORD cCertEncoded;
|
|
|
|
PCERT_BLOB rgCertEncoded;
|
|
|
|
DWORD cCrlEncoded;
|
|
|
|
PCRL_BLOB rgCrlEncoded;
|
|
|
|
CRYPT_CONTENT_INFO content;
|
|
|
|
DWORD cSignerInfo;
|
|
|
|
PCMSG_CMS_SIGNER_INFO rgSignerInfo;
|
2018-11-14 13:33:38 +01:00
|
|
|
PDWORD signerKeySpec;
|
2007-07-24 03:11:17 +02:00
|
|
|
} CRYPT_SIGNED_INFO;
|
|
|
|
|
2008-08-20 20:57:21 +02:00
|
|
|
BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *, void *pvData,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD *pcbData) DECLSPEC_HIDDEN;
|
2007-07-24 03:11:17 +02:00
|
|
|
|
2008-08-20 20:57:21 +02:00
|
|
|
BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
|
2007-07-26 03:12:16 +02:00
|
|
|
DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
2011-04-21 10:52:29 +02:00
|
|
|
CRYPT_SIGNED_INFO *signedInfo, DWORD *pcbSignedInfo) DECLSPEC_HIDDEN;
|
2007-07-26 03:12:16 +02:00
|
|
|
|
2007-07-12 23:09:00 +02:00
|
|
|
/* Helper function to check *pcbEncoded, set it to the required size, and
|
|
|
|
* optionally to allocate memory. Assumes pbEncoded is not NULL.
|
|
|
|
* If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a
|
|
|
|
* pointer to the newly allocated memory.
|
|
|
|
*/
|
2010-08-15 21:15:26 +02:00
|
|
|
BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara,
|
2011-04-21 10:52:29 +02:00
|
|
|
BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded) DECLSPEC_HIDDEN;
|
2007-07-12 23:09:00 +02:00
|
|
|
|
2007-07-17 16:25:31 +02:00
|
|
|
BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
|
|
|
|
DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
2011-04-21 10:52:29 +02:00
|
|
|
CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData) DECLSPEC_HIDDEN;
|
2007-07-17 16:25:31 +02:00
|
|
|
|
2009-10-20 22:29:03 +02:00
|
|
|
BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
|
|
|
|
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) DECLSPEC_HIDDEN;
|
2009-10-20 22:29:03 +02:00
|
|
|
|
2006-03-03 19:48:52 +01:00
|
|
|
/* The following aren't defined in wincrypt.h, as they're "reserved" */
|
|
|
|
#define CERT_CERT_PROP_ID 32
|
|
|
|
#define CERT_CRL_PROP_ID 33
|
|
|
|
#define CERT_CTL_PROP_ID 34
|
|
|
|
|
2005-08-25 11:51:59 +02:00
|
|
|
/* Returns a handle to the default crypto provider; loads it if necessary.
|
|
|
|
* Returns NULL on failure.
|
|
|
|
*/
|
2018-11-06 11:40:59 +01:00
|
|
|
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID);
|
2005-08-25 11:51:59 +02:00
|
|
|
|
2020-01-24 00:05:19 +01:00
|
|
|
extern HINSTANCE hInstance DECLSPEC_HIDDEN;
|
2008-10-31 17:33:58 +01:00
|
|
|
|
2011-04-21 10:52:29 +02:00
|
|
|
void crypt_oid_init(void) DECLSPEC_HIDDEN;
|
|
|
|
void crypt_oid_free(void) DECLSPEC_HIDDEN;
|
|
|
|
void crypt_sip_free(void) DECLSPEC_HIDDEN;
|
|
|
|
void root_store_free(void) DECLSPEC_HIDDEN;
|
|
|
|
void default_chain_engine_free(void) DECLSPEC_HIDDEN;
|
2005-12-02 11:28:09 +01:00
|
|
|
|
2013-10-15 16:53:54 +02:00
|
|
|
/* (Internal) certificate store types and functions */
|
|
|
|
struct WINE_CRYPTCERTSTORE;
|
|
|
|
|
2013-10-14 14:47:07 +02:00
|
|
|
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
|
|
|
|
|
2013-10-14 14:47:30 +02:00
|
|
|
typedef struct _context_t context_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void (*free)(context_t*);
|
2013-10-17 11:06:44 +02:00
|
|
|
struct _context_t *(*clone)(context_t*,struct WINE_CRYPTCERTSTORE*,BOOL);
|
2013-10-14 14:47:30 +02:00
|
|
|
} context_vtbl_t;
|
|
|
|
|
2013-10-17 11:08:25 +02:00
|
|
|
struct _context_t {
|
2013-10-14 14:47:30 +02:00
|
|
|
const context_vtbl_t *vtbl;
|
2013-10-14 14:47:07 +02:00
|
|
|
LONG ref;
|
2013-10-18 10:50:43 +02:00
|
|
|
struct WINE_CRYPTCERTSTORE *store;
|
2013-10-14 14:47:07 +02:00
|
|
|
struct _context_t *linked;
|
|
|
|
CONTEXT_PROPERTY_LIST *properties;
|
2013-10-15 16:53:11 +02:00
|
|
|
union {
|
|
|
|
struct list entry;
|
2013-10-15 16:53:26 +02:00
|
|
|
void *ptr;
|
2013-10-15 16:53:11 +02:00
|
|
|
} u;
|
2013-10-17 11:08:25 +02:00
|
|
|
};
|
2013-10-14 14:47:07 +02:00
|
|
|
|
|
|
|
static inline context_t *context_from_ptr(const void *ptr)
|
|
|
|
{
|
|
|
|
return (context_t*)ptr-1;
|
|
|
|
}
|
|
|
|
|
2013-10-14 14:48:06 +02:00
|
|
|
static inline void *context_ptr(context_t *context)
|
|
|
|
{
|
|
|
|
return context+1;
|
|
|
|
}
|
|
|
|
|
2013-10-14 14:47:07 +02:00
|
|
|
typedef struct {
|
|
|
|
context_t base;
|
|
|
|
CERT_CONTEXT ctx;
|
|
|
|
} cert_t;
|
|
|
|
|
|
|
|
static inline cert_t *cert_from_ptr(const CERT_CONTEXT *ptr)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(ptr, cert_t, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
context_t base;
|
|
|
|
CRL_CONTEXT ctx;
|
|
|
|
} crl_t;
|
|
|
|
|
|
|
|
static inline crl_t *crl_from_ptr(const CRL_CONTEXT *ptr)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(ptr, crl_t, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
context_t base;
|
|
|
|
CTL_CONTEXT ctx;
|
|
|
|
} ctl_t;
|
|
|
|
|
|
|
|
static inline ctl_t *ctl_from_ptr(const CTL_CONTEXT *ptr)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(ptr, ctl_t, ctx);
|
|
|
|
}
|
|
|
|
|
2006-05-18 16:31:53 +02:00
|
|
|
/* Some typedefs that make it easier to abstract which type of context we're
|
|
|
|
* working with.
|
|
|
|
*/
|
|
|
|
typedef const void *(WINAPI *CreateContextFunc)(DWORD dwCertEncodingType,
|
|
|
|
const BYTE *pbCertEncoded, DWORD cbCertEncoded);
|
|
|
|
typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore,
|
|
|
|
const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
|
|
|
|
typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
|
|
|
|
DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
|
|
|
|
DWORD dwAddDisposition, const void **ppContext);
|
|
|
|
typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
|
|
|
|
const void *pPrevContext);
|
2006-05-26 04:43:30 +02:00
|
|
|
typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId);
|
2006-05-18 16:31:53 +02:00
|
|
|
typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
|
|
|
|
DWORD dwPropID, void *pvData, DWORD *pcbData);
|
|
|
|
typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
|
|
|
|
DWORD dwPropID, DWORD dwFlags, const void *pvData);
|
|
|
|
typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags,
|
|
|
|
BYTE *pbElement, DWORD *pcbElement);
|
2011-04-21 10:52:29 +02:00
|
|
|
typedef BOOL (WINAPI *DeleteContextFunc)(const void *contex);
|
2006-05-18 16:31:53 +02:00
|
|
|
|
|
|
|
/* An abstract context (certificate, CRL, or CTL) interface */
|
|
|
|
typedef struct _WINE_CONTEXT_INTERFACE
|
|
|
|
{
|
|
|
|
CreateContextFunc create;
|
|
|
|
AddContextToStoreFunc addContextToStore;
|
|
|
|
AddEncodedContextToStoreFunc addEncodedToStore;
|
|
|
|
EnumContextsInStoreFunc enumContextsInStore;
|
2006-05-26 04:43:30 +02:00
|
|
|
EnumPropertiesFunc enumProps;
|
2006-05-18 16:31:53 +02:00
|
|
|
GetContextPropertyFunc getProp;
|
|
|
|
SetContextPropertyFunc setProp;
|
|
|
|
SerializeElementFunc serialize;
|
|
|
|
DeleteContextFunc deleteFromStore;
|
2013-09-04 12:38:17 +02:00
|
|
|
} WINE_CONTEXT_INTERFACE;
|
2006-05-18 16:31:53 +02:00
|
|
|
|
2013-09-04 12:38:17 +02:00
|
|
|
extern const WINE_CONTEXT_INTERFACE *pCertInterface DECLSPEC_HIDDEN;
|
|
|
|
extern const WINE_CONTEXT_INTERFACE *pCRLInterface DECLSPEC_HIDDEN;
|
|
|
|
extern const WINE_CONTEXT_INTERFACE *pCTLInterface DECLSPEC_HIDDEN;
|
2006-05-18 16:31:53 +02:00
|
|
|
|
2007-08-16 19:46:04 +02:00
|
|
|
typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
|
|
|
|
DWORD dwFlags, const void *pvPara);
|
|
|
|
|
|
|
|
typedef struct _CONTEXT_FUNCS
|
|
|
|
{
|
2013-10-17 11:06:44 +02:00
|
|
|
/* Called to add a context to a store. If toReplace is not NULL,
|
|
|
|
* context replaces toReplace in the store, and access checks should not be
|
|
|
|
* performed. Otherwise context is a new context, and it should only be
|
|
|
|
* added if the store allows it. If ppStoreContext is not NULL, the added
|
|
|
|
* context should be returned in *ppStoreContext.
|
|
|
|
*/
|
2013-10-17 11:08:15 +02:00
|
|
|
BOOL (*addContext)(struct WINE_CRYPTCERTSTORE*,context_t*,context_t*,context_t**,BOOL);
|
2013-10-17 11:07:55 +02:00
|
|
|
context_t *(*enumContext)(struct WINE_CRYPTCERTSTORE *store, context_t *prev);
|
2013-10-15 16:53:38 +02:00
|
|
|
BOOL (*delete)(struct WINE_CRYPTCERTSTORE*,context_t*);
|
2013-09-04 12:38:27 +02:00
|
|
|
} CONTEXT_FUNCS;
|
2007-08-16 19:46:04 +02:00
|
|
|
|
|
|
|
typedef enum _CertStoreType {
|
|
|
|
StoreTypeMem,
|
|
|
|
StoreTypeCollection,
|
|
|
|
StoreTypeProvider,
|
2013-10-14 14:46:40 +02:00
|
|
|
StoreTypeEmpty
|
2007-08-16 19:46:04 +02:00
|
|
|
} CertStoreType;
|
|
|
|
|
|
|
|
#define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
|
|
|
|
|
|
|
|
/* A cert store is polymorphic through the use of function pointers. A type
|
|
|
|
* is still needed to distinguish collection stores from other types.
|
|
|
|
* On the function pointers:
|
|
|
|
* - closeStore is called when the store's ref count becomes 0
|
|
|
|
* - control is optional, but should be implemented by any store that supports
|
|
|
|
* persistence
|
|
|
|
*/
|
2013-10-11 16:12:06 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2013-10-14 14:45:28 +02:00
|
|
|
void (*addref)(struct WINE_CRYPTCERTSTORE*);
|
2013-10-14 14:45:43 +02:00
|
|
|
DWORD (*release)(struct WINE_CRYPTCERTSTORE*,DWORD);
|
2013-10-18 10:50:43 +02:00
|
|
|
void (*releaseContext)(struct WINE_CRYPTCERTSTORE*,context_t*);
|
2013-10-11 16:12:06 +02:00
|
|
|
BOOL (*control)(struct WINE_CRYPTCERTSTORE*,DWORD,DWORD,void const*);
|
2013-10-14 14:46:16 +02:00
|
|
|
CONTEXT_FUNCS certs;
|
|
|
|
CONTEXT_FUNCS crls;
|
|
|
|
CONTEXT_FUNCS ctls;
|
2013-10-11 16:12:06 +02:00
|
|
|
} store_vtbl_t;
|
|
|
|
|
2007-08-16 19:46:04 +02:00
|
|
|
typedef struct WINE_CRYPTCERTSTORE
|
|
|
|
{
|
|
|
|
DWORD dwMagic;
|
|
|
|
LONG ref;
|
|
|
|
DWORD dwOpenFlags;
|
|
|
|
CertStoreType type;
|
2013-10-11 16:12:06 +02:00
|
|
|
const store_vtbl_t *vtbl;
|
2013-09-04 12:38:36 +02:00
|
|
|
CONTEXT_PROPERTY_LIST *properties;
|
2013-09-04 12:38:51 +02:00
|
|
|
} WINECRYPT_CERTSTORE;
|
2007-08-16 19:46:04 +02:00
|
|
|
|
2007-08-17 20:59:28 +02:00
|
|
|
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
|
2013-10-11 16:12:06 +02:00
|
|
|
CertStoreType type, const store_vtbl_t*) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) DECLSPEC_HIDDEN;
|
2007-10-18 20:11:54 +02:00
|
|
|
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD unk1) DECLSPEC_HIDDEN;
|
2007-08-16 19:49:33 +02:00
|
|
|
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
|
|
|
|
WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo) DECLSPEC_HIDDEN;
|
|
|
|
WINECRYPT_CERTSTORE *CRYPT_ProvOpenStore(LPCSTR lpszStoreProvider,
|
2007-08-16 19:50:33 +02:00
|
|
|
DWORD dwEncodingType, HCRYPTPROV hCryptProv, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
const void *pvPara) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
const void *pvPara) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_FileOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
|
2011-04-21 10:52:29 +02:00
|
|
|
const void *pvPara) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
|
2013-09-04 12:38:51 +02:00
|
|
|
WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
|
2016-11-07 17:37:29 +01:00
|
|
|
|
|
|
|
void CRYPT_ImportSystemRootCertsToReg(void) DECLSPEC_HIDDEN;
|
|
|
|
BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags, const WINE_CONTEXT_INTERFACE *contextInterface,
|
|
|
|
HCERTSTORE memStore) DECLSPEC_HIDDEN;
|
|
|
|
|
2018-06-25 13:12:12 +02:00
|
|
|
DWORD CRYPT_IsCertificateSelfSigned(const CERT_CONTEXT *cert) DECLSPEC_HIDDEN;
|
2007-08-16 19:49:33 +02:00
|
|
|
|
2007-09-10 18:33:39 +02:00
|
|
|
/* Allocates and initializes a certificate chain engine, but without creating
|
|
|
|
* the root store. Instead, it uses root, and assumes the caller has done any
|
|
|
|
* checking necessary.
|
|
|
|
*/
|
2014-03-04 13:18:53 +01:00
|
|
|
HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE, DWORD, const CERT_CHAIN_ENGINE_CONFIG*) DECLSPEC_HIDDEN;
|
2007-09-10 18:33:39 +02:00
|
|
|
|
2006-03-03 19:48:52 +01:00
|
|
|
/* Helper function for store reading functions and
|
|
|
|
* CertAddSerializedElementToStore. Returns a context of the appropriate type
|
|
|
|
* if it can, or NULL otherwise. Doesn't validate any of the properties in
|
|
|
|
* the serialized context (for example, bad hashes are retained.)
|
|
|
|
* *pdwContentType is set to the type of the returned context.
|
|
|
|
*/
|
|
|
|
const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
|
2011-04-21 10:52:29 +02:00
|
|
|
DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType) DECLSPEC_HIDDEN;
|
2006-03-03 19:48:52 +01:00
|
|
|
|
2006-07-26 01:29:50 +02:00
|
|
|
/* Reads contexts serialized in the file into the memory store. Returns FALSE
|
|
|
|
* if the file is not of the expected format.
|
|
|
|
*/
|
2011-04-21 10:52:29 +02:00
|
|
|
BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store) DECLSPEC_HIDDEN;
|
2006-07-26 01:29:50 +02:00
|
|
|
|
2009-10-30 00:48:52 +01:00
|
|
|
/* Reads contexts serialized in the blob into the memory store. Returns FALSE
|
|
|
|
* if the file is not of the expected format.
|
|
|
|
*/
|
|
|
|
BOOL CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB *blob,
|
2011-04-21 10:52:29 +02:00
|
|
|
HCERTSTORE store) DECLSPEC_HIDDEN;
|
2009-10-30 00:48:52 +01:00
|
|
|
|
2007-10-23 15:30:30 +02:00
|
|
|
/* Fixes up the pointers in info, where info is assumed to be a
|
2006-07-18 08:02:57 +02:00
|
|
|
* CRYPT_KEY_PROV_INFO, followed by its container name, provider name, and any
|
|
|
|
* provider parameters, in a contiguous buffer, but where info's pointers are
|
|
|
|
* assumed to be invalid. Upon return, info's pointers point to the
|
|
|
|
* appropriate memory locations.
|
|
|
|
*/
|
2011-04-21 10:52:29 +02:00
|
|
|
void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info) DECLSPEC_HIDDEN;
|
2006-07-18 08:02:57 +02:00
|
|
|
|
2020-09-10 15:20:11 +02:00
|
|
|
struct store_CERT_KEY_CONTEXT
|
|
|
|
{
|
|
|
|
DWORD cbSize;
|
|
|
|
DWORD64 hCryptProv;
|
|
|
|
DWORD dwKeySpec;
|
|
|
|
};
|
|
|
|
void CRYPT_ConvertKeyContext(const struct store_CERT_KEY_CONTEXT *src, CERT_KEY_CONTEXT *dst) DECLSPEC_HIDDEN;
|
|
|
|
|
2008-11-14 18:59:00 +01:00
|
|
|
/**
|
|
|
|
* String functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
|
2011-04-21 10:52:29 +02:00
|
|
|
const CERT_NAME_BLOB *pName, DWORD dwStrType, LPWSTR psz, DWORD csz) DECLSPEC_HIDDEN;
|
2008-11-14 18:59:00 +01:00
|
|
|
|
2006-03-10 04:06:42 +01:00
|
|
|
/**
|
2006-05-22 22:59:52 +02:00
|
|
|
* Context functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Allocates a new data context, a context which owns properties directly.
|
|
|
|
* contextSize is the size of the public data type associated with context,
|
|
|
|
* which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
|
|
|
|
* Free with Context_Release.
|
|
|
|
*/
|
2013-10-21 15:58:56 +02:00
|
|
|
context_t *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl, struct WINE_CRYPTCERTSTORE*) DECLSPEC_HIDDEN;
|
2006-05-22 22:59:52 +02:00
|
|
|
|
2013-10-15 16:53:26 +02:00
|
|
|
/* Creates a new link context. The context refers to linked
|
2006-05-22 22:59:52 +02:00
|
|
|
* rather than owning its own properties. If addRef is TRUE (which ordinarily
|
|
|
|
* it should be) linked is addref'd.
|
|
|
|
* Free with Context_Release.
|
|
|
|
*/
|
2013-10-18 10:50:43 +02:00
|
|
|
context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked, struct WINE_CRYPTCERTSTORE*) DECLSPEC_HIDDEN;
|
2006-05-22 22:59:52 +02:00
|
|
|
|
2006-05-26 18:41:37 +02:00
|
|
|
/* Copies properties from fromContext to toContext. */
|
2013-10-08 16:24:44 +02:00
|
|
|
void Context_CopyProperties(const void *to, const void *from) DECLSPEC_HIDDEN;
|
2006-05-26 18:41:37 +02:00
|
|
|
|
2013-10-14 14:47:07 +02:00
|
|
|
void Context_AddRef(context_t*) DECLSPEC_HIDDEN;
|
2013-10-18 10:50:23 +02:00
|
|
|
void Context_Release(context_t *context) DECLSPEC_HIDDEN;
|
2013-10-18 10:50:43 +02:00
|
|
|
void Context_Free(context_t*) DECLSPEC_HIDDEN;
|
2006-05-22 22:59:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Context property list functions
|
|
|
|
*/
|
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
CONTEXT_PROPERTY_LIST *ContextPropertyList_Create(void) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
|
|
|
/* Searches for the property with ID id in the context. Returns TRUE if found,
|
|
|
|
* and copies the property's length and a pointer to its data to blob.
|
|
|
|
* Otherwise returns FALSE.
|
|
|
|
*/
|
2013-09-04 12:38:36 +02:00
|
|
|
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id,
|
2011-04-21 10:52:29 +02:00
|
|
|
PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id,
|
2011-04-21 10:52:29 +02:00
|
|
|
const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
void ContextPropertyList_RemoveProperty(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
DWORD ContextPropertyList_EnumPropIDs(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
void ContextPropertyList_Copy(CONTEXT_PROPERTY_LIST *to,
|
|
|
|
CONTEXT_PROPERTY_LIST *from) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2013-09-04 12:38:36 +02:00
|
|
|
void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
|
2006-03-10 04:06:42 +01:00
|
|
|
|
2015-03-13 20:12:07 +01:00
|
|
|
extern WINECRYPT_CERTSTORE empty_store DECLSPEC_HIDDEN;
|
2013-10-14 14:46:40 +02:00
|
|
|
void init_empty_store(void) DECLSPEC_HIDDEN;
|
|
|
|
|
2008-11-07 01:01:39 +01:00
|
|
|
/**
|
|
|
|
* Utilities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Align up to a DWORD_PTR boundary
|
|
|
|
*/
|
|
|
|
#define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
|
|
|
|
#define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((DWORD_PTR)(p)))
|
|
|
|
|
2010-01-29 01:39:26 +01:00
|
|
|
/* Check if the OID is a small int
|
|
|
|
*/
|
|
|
|
#define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0)
|
|
|
|
|
2019-01-28 15:38:38 +01:00
|
|
|
BOOL gnutls_initialize(void) DECLSPEC_HIDDEN;
|
|
|
|
void gnutls_uninitialize(void) DECLSPEC_HIDDEN;
|
|
|
|
|
2005-08-25 11:51:59 +02:00
|
|
|
#endif
|