Commit f94d49dc authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Implement CertSerializeCRLStoreElement.

parent 44c3d328
......@@ -30,7 +30,7 @@
@ stdcall CertDuplicateStore(ptr)
@ stdcall CertEnumCRLContextProperties(ptr long)
@ stdcall CertEnumCRLsInStore(ptr ptr)
@ stub CertEnumCTLContextProperties
@ stdcall CertEnumCTLContextProperties(ptr long)
@ stdcall CertEnumCTLsInStore(ptr ptr)
@ stdcall CertEnumCertificateContextProperties(ptr long)
@ stdcall CertEnumCertificatesInStore(long ptr)
......
......@@ -56,6 +56,7 @@ typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
typedef const void *(WINAPI *DuplicateContextFunc)(const void *context);
typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
const void *pPrevContext);
typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId);
typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
DWORD dwPropID, void *pvData, DWORD *pcbData);
typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
......@@ -73,6 +74,7 @@ typedef struct _WINE_CONTEXT_INTERFACE
AddEncodedContextToStoreFunc addEncodedToStore;
DuplicateContextFunc duplicate;
EnumContextsInStoreFunc enumContextsInStore;
EnumPropertiesFunc enumProps;
GetContextPropertyFunc getProp;
SetContextPropertyFunc setProp;
SerializeElementFunc serialize;
......
......@@ -36,45 +36,29 @@ typedef struct _WINE_CERT_PROP_HEADER
DWORD cb;
} WINE_CERT_PROP_HEADER, *PWINE_CERT_PROP_HEADER;
BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
{
FIXME("(%p, %08lx, %p, %p): stub\n", pCrlContext, dwFlags, pbElement,
pcbElement);
return FALSE;
}
BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
{
FIXME("(%p, %08lx, %p, %p): stub\n", pCtlContext, dwFlags, pbElement,
pcbElement);
return FALSE;
}
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
static BOOL CRYPT_SerializeStoreElement(const void *context,
const BYTE *encodedContext, DWORD cbEncodedContext, DWORD contextPropID,
PCWINE_CONTEXT_INTERFACE contextInterface, DWORD dwFlags, BYTE *pbElement,
DWORD *pcbElement)
{
BOOL ret;
TRACE("(%p, %08lx, %p, %p)\n", pCertContext, dwFlags, pbElement,
pcbElement);
TRACE("(%p, %p, %08lx, %p, %p)\n", context, contextInterface, dwFlags,
pbElement, pcbElement);
if (pCertContext)
if (context)
{
DWORD bytesNeeded = sizeof(WINE_CERT_PROP_HEADER) +
pCertContext->cbCertEncoded;
DWORD bytesNeeded = sizeof(WINE_CERT_PROP_HEADER) + cbEncodedContext;
DWORD prop = 0;
ret = TRUE;
do {
prop = CertEnumCertificateContextProperties(pCertContext, prop);
prop = contextInterface->enumProps(context, prop);
if (prop)
{
DWORD propSize = 0;
ret = CertGetCertificateContextProperty(pCertContext,
prop, NULL, &propSize);
ret = contextInterface->getProp(context, prop, NULL, &propSize);
if (ret)
bytesNeeded += sizeof(WINE_CERT_PROP_HEADER) + propSize;
}
......@@ -99,13 +83,13 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
prop = 0;
do {
prop = CertEnumCertificateContextProperties(pCertContext, prop);
prop = contextInterface->enumProps(context, prop);
if (prop)
{
DWORD propSize = 0;
ret = CertGetCertificateContextProperty(pCertContext,
prop, NULL, &propSize);
ret = contextInterface->getProp(context, prop, NULL,
&propSize);
if (ret)
{
if (bufSize < propSize)
......@@ -118,8 +102,8 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
}
if (buf)
{
ret = CertGetCertificateContextProperty(
pCertContext, prop, buf, &propSize);
ret = contextInterface->getProp(context, prop, buf,
&propSize);
if (ret)
{
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
......@@ -142,11 +126,11 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
CryptMemFree(buf);
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
hdr->propID = CERT_CERT_PROP_ID;
hdr->propID = contextPropID;
hdr->unknown = 1;
hdr->cb = pCertContext->cbCertEncoded;
hdr->cb = cbEncodedContext;
memcpy(pbElement + sizeof(WINE_CERT_PROP_HEADER),
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded);
encodedContext, cbEncodedContext);
}
}
else
......@@ -154,6 +138,30 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
return ret;
}
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
{
return CRYPT_SerializeStoreElement(pCertContext,
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded,
CERT_CERT_PROP_ID, pCertInterface, dwFlags, pbElement, pcbElement);
}
BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
{
return CRYPT_SerializeStoreElement(pCrlContext,
pCrlContext->pbCrlEncoded, pCrlContext->cbCrlEncoded,
CERT_CRL_PROP_ID, pCRLInterface, dwFlags, pbElement, pcbElement);
}
BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
{
return CRYPT_SerializeStoreElement(pCtlContext,
pCtlContext->pbCtlEncoded, pCtlContext->cbCtlEncoded,
CERT_CTL_PROP_ID, pCRLInterface, dwFlags, pbElement, pcbElement);
}
/* Looks for the property with ID propID in the buffer buf. Returns a pointer
* to its header if a valid header is found, NULL if not. Valid means the
* length of thte property won't overrun buf, and the unknown field is 1.
......
......@@ -47,6 +47,7 @@ static const WINE_CONTEXT_INTERFACE gCertInterface = {
(AddEncodedContextToStoreFunc)CertAddEncodedCertificateToStore,
(DuplicateContextFunc)CertDuplicateCertificateContext,
(EnumContextsInStoreFunc)CertEnumCertificatesInStore,
(EnumPropertiesFunc)CertEnumCertificateContextProperties,
(GetContextPropertyFunc)CertGetCertificateContextProperty,
(SetContextPropertyFunc)CertSetCertificateContextProperty,
(SerializeElementFunc)CertSerializeCertificateStoreElement,
......@@ -61,6 +62,7 @@ static const WINE_CONTEXT_INTERFACE gCRLInterface = {
(AddEncodedContextToStoreFunc)CertAddEncodedCRLToStore,
(DuplicateContextFunc)CertDuplicateCRLContext,
(EnumContextsInStoreFunc)CertEnumCRLsInStore,
(EnumPropertiesFunc)CertEnumCRLContextProperties,
(GetContextPropertyFunc)CertGetCRLContextProperty,
(SetContextPropertyFunc)CertSetCRLContextProperty,
(SerializeElementFunc)CertSerializeCRLStoreElement,
......@@ -75,6 +77,7 @@ static const WINE_CONTEXT_INTERFACE gCTLInterface = {
(AddEncodedContextToStoreFunc)CertAddEncodedCTLToStore,
(DuplicateContextFunc)CertDuplicateCTLContext,
(EnumContextsInStoreFunc)CertEnumCTLsInStore,
(EnumPropertiesFunc)CertEnumCTLContextProperties,
(GetContextPropertyFunc)CertGetCTLContextProperty,
(SetContextPropertyFunc)CertSetCTLContextProperty,
(SerializeElementFunc)CertSerializeCTLStoreElement,
......@@ -2240,6 +2243,13 @@ BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags,
return ret;
}
DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
DWORD dwPropId)
{
FIXME("(%p, %ld): stub\n", pCTLContext, dwPropId);
return 0;
}
BOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
DWORD dwPropId, void *pvData, DWORD *pcbData)
{
......
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