Commit 6ab42936 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Added cloning logic to context's vtbl.

parent 05f248e9
......@@ -117,8 +117,21 @@ static void Cert_free(context_t *context)
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 = {
Cert_free
Cert_free,
Cert_clone
};
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,
......
......@@ -76,7 +76,7 @@ static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store,
{
context_t *ret;
ret = Context_CreateLinkContext(contextSize, child);
ret = child->vtbl->clone(child, &store->hdr);
if (!ret)
return NULL;
......@@ -210,8 +210,6 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert,
PCERT_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context;
}
CertFreeCertificateContext(childContext);
......@@ -287,8 +285,6 @@ static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
PCRL_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context;
}
CertFreeCRLContext(childContext);
......@@ -363,8 +359,6 @@ static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
PCTL_CONTEXT context =
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT));
if (context)
context->hCertStore = store;
*ppStoreContext = context;
}
CertFreeCTLContext(childContext);
......
......@@ -162,13 +162,13 @@ struct ContextList *ContextList_Create(
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;
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)
{
TRACE("adding %p\n", context);
......
......@@ -37,8 +37,21 @@ static void CRL_free(context_t *context)
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 = {
CRL_free
CRL_free,
CRL_clone
};
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,
......
......@@ -159,12 +159,16 @@ void crypt_sip_free(void) DECLSPEC_HIDDEN;
void root_store_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_t context_t;
typedef struct {
void (*free)(context_t*);
struct _context_t *(*clone)(context_t*,struct WINE_CRYPTCERTSTORE*);
} context_vtbl_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 *pCTLInterface DECLSPEC_HIDDEN;
/* (Internal) certificate store types and functions */
struct WINE_CRYPTCERTSTORE;
typedef struct WINE_CRYPTCERTSTORE * (*StoreOpenFunc)(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara);
......@@ -454,7 +455,7 @@ struct ContextList;
struct ContextList *ContextList_Create(
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;
......
......@@ -39,8 +39,21 @@ static void CTL_free(context_t *context)
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 = {
CTL_free
CTL_free,
CTL_clone
};
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,
......
......@@ -150,15 +150,13 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(ms->certs, cert, toReplace);
if (context)
{
context->hCertStore = store;
if (ppStoreContext) {
context = ContextList_Add(ms->certs, cert, toReplace, store);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCertificateContext(context);
}
}
return context != 0;
return TRUE;
}
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);
context = ContextList_Add(ms->crls, crl, toReplace);
if (context)
{
context->hCertStore = store;
context = ContextList_Add(ms->crls, crl, toReplace, store);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCRLContext(context);
}
return context != 0;
return TRUE;
}
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);
context = ContextList_Add(ms->ctls, ctl, toReplace);
if (context)
{
context->hCertStore = store;
context = ContextList_Add(ms->ctls, ctl, toReplace, store);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCTLContext(context);
}
return context != 0;
return TRUE;
}
static void *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment