crypt32: Implement CertAddCTLContextToStore.

This commit is contained in:
Juan Lang 2008-08-29 07:59:37 -07:00 committed by Alexandre Julliard
parent 08f37c62be
commit 07de224b54
3 changed files with 85 additions and 13 deletions

View File

@ -29,6 +29,91 @@
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
#define CtlContext_CopyProperties(to, from) \
Context_CopyProperties((to), (from), sizeof(CTL_CONTEXT))
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,
PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
PCCTL_CONTEXT* ppStoreContext)
{
PWINECRYPT_CERTSTORE store = (PWINECRYPT_CERTSTORE)hCertStore;
BOOL ret = TRUE;
PCCTL_CONTEXT toAdd = NULL, existing = NULL;
TRACE("(%p, %p, %08x, %p)\n", hCertStore, pCtlContext, dwAddDisposition,
ppStoreContext);
if (dwAddDisposition != CERT_STORE_ADD_ALWAYS)
{
existing = CertFindCTLInStore(hCertStore, 0, 0, CTL_FIND_EXISTING,
pCtlContext, NULL);
}
switch (dwAddDisposition)
{
case CERT_STORE_ADD_ALWAYS:
toAdd = CertDuplicateCTLContext(pCtlContext);
break;
case CERT_STORE_ADD_NEW:
if (existing)
{
TRACE("found matching CTL, not adding\n");
SetLastError(CRYPT_E_EXISTS);
ret = FALSE;
}
else
toAdd = CertDuplicateCTLContext(pCtlContext);
break;
case CERT_STORE_ADD_NEWER:
if (existing)
{
LONG newer = CompareFileTime(&existing->pCtlInfo->ThisUpdate,
&pCtlContext->pCtlInfo->ThisUpdate);
if (newer < 0)
toAdd = CertDuplicateCTLContext(pCtlContext);
else
{
TRACE("existing CTL is newer, not adding\n");
SetLastError(CRYPT_E_EXISTS);
ret = FALSE;
}
}
else
toAdd = CertDuplicateCTLContext(pCtlContext);
break;
case CERT_STORE_ADD_REPLACE_EXISTING:
toAdd = CertDuplicateCTLContext(pCtlContext);
break;
case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES:
toAdd = CertDuplicateCTLContext(pCtlContext);
if (existing)
CtlContext_CopyProperties(toAdd, existing);
break;
case CERT_STORE_ADD_USE_EXISTING:
if (existing)
CtlContext_CopyProperties(existing, pCtlContext);
break;
default:
FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
ret = FALSE;
}
if (toAdd)
{
if (store)
ret = store->ctls.addContext(store, (void *)toAdd,
(void *)existing, (const void **)ppStoreContext);
else if (ppStoreContext)
*ppStoreContext = CertDuplicateCTLContext(toAdd);
CertFreeCTLContext(toAdd);
}
CertFreeCTLContext(existing);
TRACE("returning %d\n", ret);
return ret;
}
BOOL WINAPI CertAddEncodedCTLToStore(HCERTSTORE hCertStore,
DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded,
DWORD dwAddDisposition, PCCTL_CONTEXT *ppCtlContext)

View File

@ -1091,15 +1091,6 @@ PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore,
return ret;
}
BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore,
PCCTL_CONTEXT pCtlContext, DWORD dwAddDisposition,
PCCTL_CONTEXT* ppStoreContext)
{
FIXME("(%p, %p, %08x, %p): stub\n", hCertStore, pCtlContext,
dwAddDisposition, ppStoreContext);
return TRUE;
}
HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore)
{
WINECRYPT_CERTSTORE *hcs = (WINECRYPT_CERTSTORE *)hCertStore;

View File

@ -333,7 +333,6 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
todo_wine
ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
CertCloseStore(store, 0);
@ -350,7 +349,6 @@ static void testAddCTLToStore(void)
signedCTLWithCTLInnerContentAndBadSig,
sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_NEW,
NULL);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_EXISTS,
"expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
CertCloseStore(store, 0);
@ -376,7 +374,6 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
todo_wine
ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
CertCloseStore(store, 0);
@ -401,7 +398,6 @@ static void testAddCTLToStore(void)
if (ctl)
numCTLs++;
} while (ctl);
todo_wine
ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
CertCloseStore(store, 0);
}