crypt32: Added cloning logic to context's vtbl.

This commit is contained in:
Jacek Caban 2013-10-15 16:53:54 +02:00 committed by Alexandre Julliard
parent 05f248e968
commit 6ab429363a
7 changed files with 71 additions and 41 deletions

View File

@ -117,8 +117,21 @@ static void Cert_free(context_t *context)
LocalFree(cert->ctx.pCertInfo); LocalFree(cert->ctx.pCertInfo);
} }
static context_t *Cert_clone(context_t *context, WINECRYPT_CERTSTORE *store)
{
cert_t *cert;
cert = (cert_t*)Context_CreateLinkContext(sizeof(CERT_CONTEXT), context);
if(!cert)
return NULL;
cert->ctx.hCertStore = store;
return &cert->base;
}
static const context_vtbl_t cert_vtbl = { static const context_vtbl_t cert_vtbl = {
Cert_free Cert_free,
Cert_clone
}; };
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,

View File

@ -76,7 +76,7 @@ static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store,
{ {
context_t *ret; context_t *ret;
ret = Context_CreateLinkContext(contextSize, child); ret = child->vtbl->clone(child, &store->hdr);
if (!ret) if (!ret)
return NULL; return NULL;
@ -210,8 +210,6 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert,
PCERT_CONTEXT context = PCERT_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT)); CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context; *ppStoreContext = context;
} }
CertFreeCertificateContext(childContext); CertFreeCertificateContext(childContext);
@ -287,8 +285,6 @@ static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
PCRL_CONTEXT context = PCRL_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT)); CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context; *ppStoreContext = context;
} }
CertFreeCRLContext(childContext); CertFreeCRLContext(childContext);
@ -363,8 +359,6 @@ static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
PCTL_CONTEXT context = PCTL_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT)); CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context; *ppStoreContext = context;
} }
CertFreeCTLContext(childContext); CertFreeCTLContext(childContext);

View File

@ -162,13 +162,13 @@ struct ContextList *ContextList_Create(
return list; return list;
} }
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store)
{ {
context_t *context; context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, toReplace); TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink)); context = context_from_ptr(toLink)->vtbl->clone(BASE_CONTEXT_FROM_CONTEXT(toLink), store);
if (context) if (context)
{ {
TRACE("adding %p\n", context); TRACE("adding %p\n", context);

View File

@ -37,8 +37,21 @@ static void CRL_free(context_t *context)
LocalFree(crl->ctx.pCrlInfo); LocalFree(crl->ctx.pCrlInfo);
} }
static context_t *CRL_clone(context_t *context, WINECRYPT_CERTSTORE *store)
{
crl_t *crl;
crl = (crl_t*)Context_CreateLinkContext(sizeof(CRL_CONTEXT), context);
if(!crl)
return NULL;
crl->ctx.hCertStore = store;
return &crl->base;
}
static const context_vtbl_t crl_vtbl = { static const context_vtbl_t crl_vtbl = {
CRL_free CRL_free,
CRL_clone
}; };
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,

View File

@ -159,12 +159,16 @@ void crypt_sip_free(void) DECLSPEC_HIDDEN;
void root_store_free(void) DECLSPEC_HIDDEN; void root_store_free(void) DECLSPEC_HIDDEN;
void default_chain_engine_free(void) DECLSPEC_HIDDEN; void default_chain_engine_free(void) DECLSPEC_HIDDEN;
/* (Internal) certificate store types and functions */
struct WINE_CRYPTCERTSTORE;
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
typedef struct _context_t context_t; typedef struct _context_t context_t;
typedef struct { typedef struct {
void (*free)(context_t*); void (*free)(context_t*);
struct _context_t *(*clone)(context_t*,struct WINE_CRYPTCERTSTORE*);
} context_vtbl_t; } context_vtbl_t;
typedef struct _context_t { typedef struct _context_t {
@ -257,9 +261,6 @@ extern const WINE_CONTEXT_INTERFACE *pCertInterface DECLSPEC_HIDDEN;
extern const WINE_CONTEXT_INTERFACE *pCRLInterface DECLSPEC_HIDDEN; extern const WINE_CONTEXT_INTERFACE *pCRLInterface DECLSPEC_HIDDEN;
extern const WINE_CONTEXT_INTERFACE *pCTLInterface DECLSPEC_HIDDEN; extern const WINE_CONTEXT_INTERFACE *pCTLInterface DECLSPEC_HIDDEN;
/* (Internal) certificate store types and functions */
struct WINE_CRYPTCERTSTORE;
typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv, typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara); DWORD dwFlags, const void *pvPara);
@ -454,7 +455,7 @@ struct ContextList;
struct ContextList *ContextList_Create( struct ContextList *ContextList_Create(
const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN; const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN;
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) DECLSPEC_HIDDEN; void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store) DECLSPEC_HIDDEN;
void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN; void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN;

View File

@ -39,8 +39,21 @@ static void CTL_free(context_t *context)
LocalFree(ctl->ctx.pCtlInfo); LocalFree(ctl->ctx.pCtlInfo);
} }
static context_t *CTL_clone(context_t *context, WINECRYPT_CERTSTORE *store)
{
ctl_t *ctl;
ctl = (ctl_t*)Context_CreateLinkContext(sizeof(CTL_CONTEXT), context);
if(!ctl)
return NULL;
ctl->ctx.hCertStore = store;
return &ctl->base;
}
static const context_vtbl_t ctl_vtbl = { static const context_vtbl_t ctl_vtbl = {
CTL_free CTL_free,
CTL_clone
}; };
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore, BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,

View File

@ -150,15 +150,13 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(ms->certs, cert, toReplace); context = ContextList_Add(ms->certs, cert, toReplace, store);
if (context) if (!context)
{ return FALSE;
context->hCertStore = store;
if (ppStoreContext) { if (ppStoreContext)
*ppStoreContext = CertDuplicateCertificateContext(context); *ppStoreContext = CertDuplicateCertificateContext(context);
} return TRUE;
}
return context != 0;
} }
static void *MemStore_enumCert(WINECRYPT_CERTSTORE *store, void *pPrev) static void *MemStore_enumCert(WINECRYPT_CERTSTORE *store, void *pPrev)
@ -194,14 +192,13 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
context = ContextList_Add(ms->crls, crl, toReplace); context = ContextList_Add(ms->crls, crl, toReplace, store);
if (context) if (!context)
{ return FALSE;
context->hCertStore = store;
if (ppStoreContext) if (ppStoreContext)
*ppStoreContext = CertDuplicateCRLContext(context); *ppStoreContext = CertDuplicateCRLContext(context);
} return TRUE;
return context != 0;
} }
static void *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, void *pPrev) static void *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, void *pPrev)
@ -237,14 +234,13 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
context = ContextList_Add(ms->ctls, ctl, toReplace); context = ContextList_Add(ms->ctls, ctl, toReplace, store);
if (context) if (!context)
{ return FALSE;
context->hCertStore = store;
if (ppStoreContext) if (ppStoreContext)
*ppStoreContext = CertDuplicateCTLContext(context); *ppStoreContext = CertDuplicateCTLContext(context);
} return TRUE;
return context != 0;
} }
static void *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev) static void *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev)