Commit 1a059879 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Make a helper function to create initial candidate chain.

parent 192ed735
......@@ -569,6 +569,42 @@ static BOOL CRYPT_BuildSimpleChain(HCERTCHAINENGINE hChainEngine,
return ret;
}
static BOOL CRYPT_BuildCandidateChainFromCert(HCERTCHAINENGINE hChainEngine,
PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore,
PCertificateChain *ppChain)
{
PCERT_SIMPLE_CHAIN simpleChain = NULL;
BOOL ret;
/* FIXME: only simple chains are supported for now, as CTLs aren't
* supported yet.
*/
if ((ret = CRYPT_BuildSimpleChain(hChainEngine, pCertContext, pTime,
hAdditionalStore, &simpleChain)))
{
PCertificateChain chain = CryptMemAlloc(sizeof(CertificateChain));
if (chain)
{
chain->ref = 1;
chain->context.cbSize = sizeof(CERT_CHAIN_CONTEXT);
memcpy(&chain->context.TrustStatus, &simpleChain->TrustStatus,
sizeof(CERT_TRUST_STATUS));
chain->context.cChain = 1;
chain->context.rgpChain = CryptMemAlloc(sizeof(PCERT_SIMPLE_CHAIN));
chain->context.rgpChain[0] = simpleChain;
chain->context.cLowerQualityChainContext = 0;
chain->context.rgpLowerQualityChainContext = NULL;
chain->context.fHasRevocationFreshnessTime = FALSE;
chain->context.dwRevocationFreshnessTime = 0;
}
else
ret = FALSE;
*ppChain = chain;
}
return ret;
}
typedef struct _CERT_CHAIN_PARA_NO_EXTRA_FIELDS {
DWORD cbSize;
CERT_USAGE_MATCH RequestedUsage;
......@@ -588,8 +624,8 @@ BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine,
PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved,
PCCERT_CHAIN_CONTEXT* ppChainContext)
{
PCERT_SIMPLE_CHAIN simpleChain = NULL;
BOOL ret;
PCertificateChain chain;
TRACE("(%p, %p, %p, %p, %p, %08x, %p, %p)\n", hChainEngine, pCertContext,
pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, ppChainContext);
......@@ -605,30 +641,10 @@ BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine,
hChainEngine = CRYPT_GetDefaultChainEngine();
/* FIXME: what about HCCE_LOCAL_MACHINE? */
/* FIXME: pChainPara is for now ignored */
/* FIXME: only simple chains are supported for now, as CTLs aren't
* supported yet.
*/
if ((ret = CRYPT_BuildSimpleChain(hChainEngine, pCertContext, pTime,
hAdditionalStore, &simpleChain)))
{
PCertificateChain chain = CryptMemAlloc(sizeof(CertificateChain));
if (chain)
ret = CRYPT_BuildCandidateChainFromCert(hChainEngine, pCertContext, pTime,
hAdditionalStore, &chain);
if (ret)
{
chain->ref = 1;
chain->context.cbSize = sizeof(CERT_CHAIN_CONTEXT);
memcpy(&chain->context.TrustStatus, &simpleChain->TrustStatus,
sizeof(CERT_TRUST_STATUS));
chain->context.cChain = 1;
chain->context.rgpChain = CryptMemAlloc(sizeof(PCERT_SIMPLE_CHAIN));
chain->context.rgpChain[0] = simpleChain;
chain->context.cLowerQualityChainContext = 0;
chain->context.rgpLowerQualityChainContext = NULL;
chain->context.fHasRevocationFreshnessTime = FALSE;
chain->context.dwRevocationFreshnessTime = 0;
}
else
ret = FALSE;
if (ppChainContext)
*ppChainContext = (PCCERT_CHAIN_CONTEXT)chain;
else
......
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