From 5928c698ae57f6db41b1b0b1bbf3ecf2ac1c5cd4 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Tue, 23 Oct 2007 12:59:43 -0700 Subject: [PATCH] crypt32: Implement CertVerifyRevocation. --- dlls/crypt32/cert.c | 77 ++++++++++++++++++++++++++++++++++++++- dlls/crypt32/tests/cert.c | 6 --- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index a95c2a58c42..976589b7edc 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -1231,13 +1231,86 @@ PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore, return ret; } +typedef struct _OLD_CERT_REVOCATION_STATUS { + DWORD cbSize; + DWORD dwIndex; + DWORD dwError; + DWORD dwReason; +} OLD_CERT_REVOCATION_STATUS, *POLD_CERT_REVOCATION_STATUS; + +typedef BOOL (WINAPI *CertVerifyRevocationFunc)(DWORD, DWORD, DWORD, + void **, DWORD, PCERT_REVOCATION_PARA, PCERT_REVOCATION_STATUS); + BOOL WINAPI CertVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, DWORD cContext, void *rgpvContext[], DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus) { - FIXME("(%08x, %d, %d, %p, %08x, %p, %p): stub\n", dwEncodingType, dwRevType, + BOOL ret; + + TRACE("(%08x, %d, %d, %p, %08x, %p, %p)\n", dwEncodingType, dwRevType, cContext, rgpvContext, dwFlags, pRevPara, pRevStatus); - return FALSE; + + if (pRevStatus->cbSize != sizeof(OLD_CERT_REVOCATION_STATUS) && + pRevStatus->cbSize != sizeof(CERT_REVOCATION_STATUS)) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (cContext) + { + static HCRYPTOIDFUNCSET set = NULL; + DWORD size; + + if (!set) + set = CryptInitOIDFunctionSet(CRYPT_OID_VERIFY_REVOCATION_FUNC, 0); + ret = CryptGetDefaultOIDDllList(set, dwEncodingType, NULL, &size); + if (ret) + { + if (size == 1) + { + /* empty list */ + SetLastError(CRYPT_E_NO_REVOCATION_DLL); + ret = FALSE; + } + else + { + LPWSTR dllList = CryptMemAlloc(size * sizeof(WCHAR)), ptr; + + if (dllList) + { + ret = CryptGetDefaultOIDDllList(set, dwEncodingType, + dllList, &size); + if (ret) + { + for (ptr = dllList; ret && *ptr; + ptr += lstrlenW(ptr) + 1) + { + CertVerifyRevocationFunc func; + HCRYPTOIDFUNCADDR hFunc; + + ret = CryptGetDefaultOIDFunctionAddress(set, + dwEncodingType, ptr, 0, (void **)&func, &hFunc); + if (ret) + { + ret = func(dwEncodingType, dwRevType, cContext, + rgpvContext, dwFlags, pRevPara, pRevStatus); + CryptFreeOIDFunctionAddress(hFunc, 0); + } + } + } + CryptMemFree(dllList); + } + else + { + SetLastError(ERROR_OUTOFMEMORY); + ret = FALSE; + } + } + } + } + else + ret = TRUE; + return ret; } PCRYPT_ATTRIBUTE WINAPI CertFindAttribute(LPCSTR pszObjId, DWORD cAttr, diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index 3bea543ba03..3c6aaa4179d 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -2587,27 +2587,21 @@ static void testVerifyRevocation(void) */ SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status); - todo_wine ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); status.cbSize = sizeof(status); ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status); - todo_wine ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); ret = CertVerifyRevocation(0, 2, 0, NULL, 0, NULL, &status); - todo_wine ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); ret = CertVerifyRevocation(2, 0, 0, NULL, 0, NULL, &status); - todo_wine ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError()); SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 0, 1, (void **)&cert, 0, NULL, &status); - todo_wine ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL, "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError()); SetLastError(0xdeadbeef); ret = CertVerifyRevocation(0, 2, 1, (void **)&cert, 0, NULL, &status); - todo_wine ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL, "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError());