2006-05-25 18:01:03 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Juan Lang
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdarg.h>
|
2009-11-19 01:21:09 +01:00
|
|
|
#define NONAMELESSUNION
|
2006-05-25 18:01:03 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wincrypt.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "crypt32_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
|
|
|
|
2013-10-14 14:47:30 +02:00
|
|
|
static void CRL_free(context_t *context)
|
|
|
|
{
|
|
|
|
crl_t *crl = (crl_t*)context;
|
|
|
|
|
|
|
|
CryptMemFree(crl->ctx.pbCrlEncoded);
|
|
|
|
LocalFree(crl->ctx.pCrlInfo);
|
|
|
|
}
|
|
|
|
|
2013-10-21 15:58:38 +02:00
|
|
|
static const context_vtbl_t crl_vtbl;
|
|
|
|
|
2021-07-15 18:25:17 +02:00
|
|
|
static char *copy_string(char *p, char **dst, const char *src)
|
|
|
|
{
|
|
|
|
size_t size = strlen(src) + 1;
|
|
|
|
|
|
|
|
*dst = memcpy(p, src, size);
|
|
|
|
return p + size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *copy_blob(char *p, DATA_BLOB *dst, const DATA_BLOB *src)
|
|
|
|
{
|
|
|
|
size_t size = src->cbData;
|
|
|
|
|
|
|
|
dst->cbData = size;
|
|
|
|
dst->pbData = memcpy(p, src->pbData, size);
|
|
|
|
return p + size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *copy_extension(char *p, CERT_EXTENSION *dst, const CERT_EXTENSION *src)
|
|
|
|
{
|
|
|
|
p = copy_string(p, &dst->pszObjId, src->pszObjId);
|
|
|
|
dst->fCritical = src->fCritical;
|
|
|
|
return copy_blob(p, &dst->Value, &src->Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CRL_INFO *clone_crl_info(const CRL_INFO *src)
|
|
|
|
{
|
|
|
|
size_t size = sizeof(CRL_INFO);
|
|
|
|
CRL_INFO *dst;
|
|
|
|
DWORD i, j;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (src->SignatureAlgorithm.pszObjId)
|
|
|
|
size += strlen(src->SignatureAlgorithm.pszObjId) + 1;
|
|
|
|
size += src->SignatureAlgorithm.Parameters.cbData;
|
|
|
|
size += src->Issuer.cbData;
|
|
|
|
for (i = 0; i < src->cCRLEntry; ++i)
|
|
|
|
{
|
|
|
|
const CRL_ENTRY *entry = &src->rgCRLEntry[i];
|
|
|
|
|
|
|
|
size += sizeof(CRL_ENTRY);
|
|
|
|
size += entry->SerialNumber.cbData;
|
|
|
|
for (j = 0; j < entry->cExtension; ++j)
|
|
|
|
{
|
|
|
|
const CERT_EXTENSION *ext = &entry->rgExtension[j];
|
|
|
|
|
|
|
|
size += sizeof(CERT_EXTENSION);
|
|
|
|
size += strlen(ext->pszObjId) + 1;
|
|
|
|
size += ext->Value.cbData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < src->cExtension; ++j)
|
|
|
|
{
|
|
|
|
const CERT_EXTENSION *ext = &src->rgExtension[j];
|
|
|
|
|
|
|
|
size += sizeof(CERT_EXTENSION);
|
|
|
|
size += strlen(ext->pszObjId) + 1;
|
|
|
|
size += ext->Value.cbData;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dst = LocalAlloc(LPTR, size)))
|
|
|
|
return NULL;
|
|
|
|
p = (char *)(dst + 1);
|
|
|
|
|
|
|
|
dst->dwVersion = src->dwVersion;
|
|
|
|
if (src->SignatureAlgorithm.pszObjId)
|
|
|
|
p = copy_string(p, &dst->SignatureAlgorithm.pszObjId, src->SignatureAlgorithm.pszObjId);
|
|
|
|
p = copy_blob(p, &dst->SignatureAlgorithm.Parameters, &src->SignatureAlgorithm.Parameters);
|
|
|
|
p = copy_blob(p, &dst->Issuer, &src->Issuer);
|
|
|
|
dst->ThisUpdate = src->ThisUpdate;
|
|
|
|
dst->NextUpdate = src->NextUpdate;
|
|
|
|
|
|
|
|
dst->cCRLEntry = src->cCRLEntry;
|
|
|
|
dst->rgCRLEntry = (CRL_ENTRY *)p;
|
|
|
|
p += src->cCRLEntry * sizeof(CRL_ENTRY);
|
|
|
|
|
|
|
|
dst->cExtension = src->cExtension;
|
|
|
|
dst->rgExtension = (CERT_EXTENSION *)p;
|
|
|
|
p += src->cExtension * sizeof(CERT_EXTENSION);
|
|
|
|
|
|
|
|
for (i = 0; i < src->cCRLEntry; ++i)
|
|
|
|
{
|
|
|
|
const CRL_ENTRY *src_entry = &src->rgCRLEntry[i];
|
|
|
|
CRL_ENTRY *dst_entry = &dst->rgCRLEntry[i];
|
|
|
|
|
|
|
|
p = copy_blob(p, &dst_entry->SerialNumber, &src_entry->SerialNumber);
|
|
|
|
dst_entry->RevocationDate = src_entry->RevocationDate;
|
|
|
|
dst_entry->cExtension = src_entry->cExtension;
|
|
|
|
dst_entry->rgExtension = (CERT_EXTENSION *)p;
|
|
|
|
p += src_entry->cExtension * sizeof(CERT_EXTENSION);
|
|
|
|
|
|
|
|
for (j = 0; j < src_entry->cExtension; ++j)
|
|
|
|
p = copy_extension(p, &dst_entry->rgExtension[j], &src_entry->rgExtension[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < src->cExtension; ++j)
|
|
|
|
p = copy_extension(p, &dst->rgExtension[j], &src->rgExtension[j]);
|
|
|
|
|
|
|
|
assert(p - (char *)dst == size);
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2013-10-17 11:06:44 +02:00
|
|
|
static context_t *CRL_clone(context_t *context, WINECRYPT_CERTSTORE *store, BOOL use_link)
|
2013-10-15 16:53:54 +02:00
|
|
|
{
|
2021-07-15 18:25:16 +02:00
|
|
|
crl_t *dst;
|
2013-10-15 16:53:54 +02:00
|
|
|
|
2013-10-21 15:58:38 +02:00
|
|
|
if(use_link) {
|
2021-07-15 18:25:16 +02:00
|
|
|
if (!(dst = (crl_t *)Context_CreateLinkContext(sizeof(CRL_CONTEXT), context, store)))
|
2013-10-21 15:58:38 +02:00
|
|
|
return NULL;
|
|
|
|
}else {
|
2021-07-15 18:25:16 +02:00
|
|
|
const crl_t *src = (const crl_t*)context;
|
2013-10-21 15:58:38 +02:00
|
|
|
|
2021-07-15 18:25:16 +02:00
|
|
|
if (!(dst = (crl_t *)Context_CreateDataContext(sizeof(CRL_CONTEXT), &crl_vtbl, store)))
|
2013-10-21 15:58:38 +02:00
|
|
|
return NULL;
|
2013-10-17 11:06:44 +02:00
|
|
|
|
2021-07-15 18:25:16 +02:00
|
|
|
Context_CopyProperties(&dst->ctx, &src->ctx);
|
2013-10-21 15:58:38 +02:00
|
|
|
|
2021-07-15 18:25:16 +02:00
|
|
|
dst->ctx.dwCertEncodingType = src->ctx.dwCertEncodingType;
|
|
|
|
dst->ctx.pbCrlEncoded = CryptMemAlloc(src->ctx.cbCrlEncoded);
|
|
|
|
memcpy(dst->ctx.pbCrlEncoded, src->ctx.pbCrlEncoded, src->ctx.cbCrlEncoded);
|
|
|
|
dst->ctx.cbCrlEncoded = src->ctx.cbCrlEncoded;
|
2013-10-21 15:58:38 +02:00
|
|
|
|
2021-07-15 18:25:17 +02:00
|
|
|
if (!(dst->ctx.pCrlInfo = clone_crl_info(src->ctx.pCrlInfo)))
|
|
|
|
{
|
2021-07-15 18:25:16 +02:00
|
|
|
CertFreeCRLContext(&dst->ctx);
|
2013-10-21 15:58:38 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-10-15 16:53:54 +02:00
|
|
|
|
2021-07-15 18:25:16 +02:00
|
|
|
dst->ctx.hCertStore = store;
|
|
|
|
return &dst->base;
|
2013-10-15 16:53:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-14 14:47:30 +02:00
|
|
|
static const context_vtbl_t crl_vtbl = {
|
2013-10-15 16:53:54 +02:00
|
|
|
CRL_free,
|
|
|
|
CRL_clone
|
2013-10-14 14:47:30 +02:00
|
|
|
};
|
|
|
|
|
2006-05-25 18:01:03 +02:00
|
|
|
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,
|
|
|
|
const BYTE* pbCrlEncoded, DWORD cbCrlEncoded)
|
|
|
|
{
|
2013-10-21 15:58:56 +02:00
|
|
|
crl_t *crl = NULL;
|
2006-05-25 18:01:03 +02:00
|
|
|
BOOL ret;
|
|
|
|
PCRL_INFO crlInfo = NULL;
|
2013-10-21 15:58:56 +02:00
|
|
|
BYTE *data = NULL;
|
2006-05-25 18:01:03 +02:00
|
|
|
DWORD size = 0;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%08x, %p, %d)\n", dwCertEncodingType, pbCrlEncoded,
|
2006-05-25 18:01:03 +02:00
|
|
|
cbCrlEncoded);
|
|
|
|
|
|
|
|
if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING)
|
|
|
|
{
|
|
|
|
SetLastError(E_INVALIDARG);
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-06-19 23:11:37 +02:00
|
|
|
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT_CRL_TO_BE_SIGNED,
|
|
|
|
pbCrlEncoded, cbCrlEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
|
2009-01-26 11:01:47 +01:00
|
|
|
&crlInfo, &size);
|
2013-10-21 15:58:56 +02:00
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
crl = (crl_t*)Context_CreateDataContext(sizeof(CRL_CONTEXT), &crl_vtbl, &empty_store);
|
|
|
|
if (!crl)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
data = CryptMemAlloc(cbCrlEncoded);
|
|
|
|
if (!data)
|
2006-05-25 18:01:03 +02:00
|
|
|
{
|
2013-10-21 15:58:56 +02:00
|
|
|
Context_Release(&crl->base);
|
|
|
|
return NULL;
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
|
2013-10-21 15:58:56 +02:00
|
|
|
memcpy(data, pbCrlEncoded, cbCrlEncoded);
|
|
|
|
crl->ctx.dwCertEncodingType = dwCertEncodingType;
|
|
|
|
crl->ctx.pbCrlEncoded = data;
|
|
|
|
crl->ctx.cbCrlEncoded = cbCrlEncoded;
|
|
|
|
crl->ctx.pCrlInfo = crlInfo;
|
|
|
|
crl->ctx.hCertStore = &empty_store;
|
|
|
|
|
|
|
|
return &crl->ctx;
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore,
|
|
|
|
DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded,
|
|
|
|
DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext)
|
|
|
|
{
|
|
|
|
PCCRL_CONTEXT crl = CertCreateCRLContext(dwCertEncodingType,
|
|
|
|
pbCrlEncoded, cbCrlEncoded);
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %08x, %p, %d, %08x, %p)\n", hCertStore, dwCertEncodingType,
|
2006-05-25 18:01:03 +02:00
|
|
|
pbCrlEncoded, cbCrlEncoded, dwAddDisposition, ppCrlContext);
|
|
|
|
|
|
|
|
if (crl)
|
|
|
|
{
|
|
|
|
ret = CertAddCRLContextToStore(hCertStore, crl, dwAddDisposition,
|
|
|
|
ppCrlContext);
|
|
|
|
CertFreeCRLContext(crl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef BOOL (*CrlCompareFunc)(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
|
|
|
DWORD dwFlags, const void *pvPara);
|
|
|
|
|
|
|
|
static BOOL compare_crl_any(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
|
|
|
DWORD dwFlags, const void *pvPara)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL compare_crl_issued_by(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
|
|
|
DWORD dwFlags, const void *pvPara)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (pvPara)
|
|
|
|
{
|
2009-01-26 11:01:47 +01:00
|
|
|
PCCERT_CONTEXT issuer = pvPara;
|
2006-05-25 18:01:03 +02:00
|
|
|
|
|
|
|
ret = CertCompareCertificateName(issuer->dwCertEncodingType,
|
2009-11-20 23:46:53 +01:00
|
|
|
&issuer->pCertInfo->Subject, &pCrlContext->pCrlInfo->Issuer);
|
2009-11-19 01:27:49 +01:00
|
|
|
if (ret && (dwFlags & CRL_FIND_ISSUED_BY_SIGNATURE_FLAG))
|
|
|
|
ret = CryptVerifyCertificateSignatureEx(0,
|
|
|
|
issuer->dwCertEncodingType,
|
|
|
|
CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL, (void *)pCrlContext,
|
|
|
|
CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, (void *)issuer, 0, NULL);
|
2009-11-19 01:54:49 +01:00
|
|
|
if (ret && (dwFlags & CRL_FIND_ISSUED_BY_AKI_FLAG))
|
|
|
|
{
|
2009-11-21 00:18:23 +01:00
|
|
|
PCERT_EXTENSION ext = CertFindExtension(
|
2009-11-19 01:54:49 +01:00
|
|
|
szOID_AUTHORITY_KEY_IDENTIFIER2, pCrlContext->pCrlInfo->cExtension,
|
|
|
|
pCrlContext->pCrlInfo->rgExtension);
|
|
|
|
|
2009-11-21 00:18:23 +01:00
|
|
|
if (ext)
|
2009-11-19 01:54:49 +01:00
|
|
|
{
|
2009-11-21 00:18:23 +01:00
|
|
|
CERT_AUTHORITY_KEY_ID2_INFO *info;
|
|
|
|
DWORD size;
|
2009-11-19 01:54:49 +01:00
|
|
|
|
2009-11-21 00:18:23 +01:00
|
|
|
if ((ret = CryptDecodeObjectEx(X509_ASN_ENCODING,
|
|
|
|
X509_AUTHORITY_KEY_ID2, ext->Value.pbData, ext->Value.cbData,
|
|
|
|
CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size)))
|
2009-11-19 01:54:49 +01:00
|
|
|
{
|
2009-11-21 00:18:23 +01:00
|
|
|
if (info->AuthorityCertIssuer.cAltEntry &&
|
|
|
|
info->AuthorityCertSerialNumber.cbData)
|
|
|
|
{
|
|
|
|
PCERT_ALT_NAME_ENTRY directoryName = NULL;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for (i = 0; !directoryName &&
|
|
|
|
i < info->AuthorityCertIssuer.cAltEntry; i++)
|
|
|
|
if (info->AuthorityCertIssuer.rgAltEntry[i].
|
|
|
|
dwAltNameChoice == CERT_ALT_NAME_DIRECTORY_NAME)
|
|
|
|
directoryName =
|
|
|
|
&info->AuthorityCertIssuer.rgAltEntry[i];
|
|
|
|
if (directoryName)
|
|
|
|
{
|
|
|
|
ret = CertCompareCertificateName(
|
|
|
|
issuer->dwCertEncodingType,
|
|
|
|
&issuer->pCertInfo->Subject,
|
|
|
|
&directoryName->u.DirectoryName);
|
|
|
|
if (ret)
|
|
|
|
ret = CertCompareIntegerBlob(
|
|
|
|
&issuer->pCertInfo->SerialNumber,
|
|
|
|
&info->AuthorityCertSerialNumber);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("no supported name type in authority key id2\n");
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (info->KeyId.cbData)
|
|
|
|
{
|
2009-12-08 19:18:27 +01:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
ret = CertGetCertificateContextProperty(issuer,
|
|
|
|
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
|
|
|
if (ret && size == info->KeyId.cbData)
|
2009-11-21 00:18:23 +01:00
|
|
|
{
|
2009-12-08 19:18:27 +01:00
|
|
|
LPBYTE buf = CryptMemAlloc(size);
|
|
|
|
|
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
CertGetCertificateContextProperty(issuer,
|
|
|
|
CERT_KEY_IDENTIFIER_PROP_ID, buf, &size);
|
|
|
|
ret = !memcmp(buf, info->KeyId.pbData, size);
|
|
|
|
CryptMemFree(buf);
|
|
|
|
}
|
2009-11-21 00:18:23 +01:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2009-11-19 01:54:49 +01:00
|
|
|
else
|
2009-11-21 00:18:23 +01:00
|
|
|
{
|
|
|
|
FIXME("unsupported value for AKI extension\n");
|
2009-11-19 01:54:49 +01:00
|
|
|
ret = FALSE;
|
2009-11-21 00:18:23 +01:00
|
|
|
}
|
|
|
|
LocalFree(info);
|
2009-11-19 01:54:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* else: a CRL without an AKI matches any cert */
|
|
|
|
}
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = TRUE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL compare_crl_existing(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
|
|
|
DWORD dwFlags, const void *pvPara)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (pvPara)
|
|
|
|
{
|
2009-01-26 11:01:47 +01:00
|
|
|
PCCRL_CONTEXT crl = pvPara;
|
2006-05-25 18:01:03 +02:00
|
|
|
|
|
|
|
ret = CertCompareCertificateName(pCrlContext->dwCertEncodingType,
|
|
|
|
&pCrlContext->pCrlInfo->Issuer, &crl->pCrlInfo->Issuer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = TRUE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-11-18 19:40:08 +01:00
|
|
|
static BOOL compare_crl_issued_for(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
|
|
|
DWORD dwFlags, const void *pvPara)
|
|
|
|
{
|
|
|
|
const CRL_FIND_ISSUED_FOR_PARA *para = pvPara;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = CertCompareCertificateName(para->pIssuerCert->dwCertEncodingType,
|
|
|
|
¶->pIssuerCert->pCertInfo->Issuer, &pCrlContext->pCrlInfo->Issuer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-25 18:01:03 +02:00
|
|
|
PCCRL_CONTEXT WINAPI CertFindCRLInStore(HCERTSTORE hCertStore,
|
|
|
|
DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
|
|
|
|
const void *pvFindPara, PCCRL_CONTEXT pPrevCrlContext)
|
|
|
|
{
|
|
|
|
PCCRL_CONTEXT ret;
|
|
|
|
CrlCompareFunc compare;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %d, %d, %d, %p, %p)\n", hCertStore, dwCertEncodingType,
|
2006-05-25 18:01:03 +02:00
|
|
|
dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext);
|
|
|
|
|
|
|
|
switch (dwFindType)
|
|
|
|
{
|
|
|
|
case CRL_FIND_ANY:
|
|
|
|
compare = compare_crl_any;
|
|
|
|
break;
|
|
|
|
case CRL_FIND_ISSUED_BY:
|
|
|
|
compare = compare_crl_issued_by;
|
|
|
|
break;
|
|
|
|
case CRL_FIND_EXISTING:
|
|
|
|
compare = compare_crl_existing;
|
|
|
|
break;
|
2009-11-18 19:40:08 +01:00
|
|
|
case CRL_FIND_ISSUED_FOR:
|
|
|
|
compare = compare_crl_issued_for;
|
|
|
|
break;
|
2006-05-25 18:01:03 +02:00
|
|
|
default:
|
2006-10-04 06:58:09 +02:00
|
|
|
FIXME("find type %08x unimplemented\n", dwFindType);
|
2006-05-25 18:01:03 +02:00
|
|
|
compare = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compare)
|
|
|
|
{
|
|
|
|
BOOL matches = FALSE;
|
|
|
|
|
|
|
|
ret = pPrevCrlContext;
|
|
|
|
do {
|
|
|
|
ret = CertEnumCRLsInStore(hCertStore, ret);
|
|
|
|
if (ret)
|
|
|
|
matches = compare(ret, dwFindType, dwFindFlags, pvFindPara);
|
|
|
|
} while (ret != NULL && !matches);
|
|
|
|
if (!ret)
|
|
|
|
SetLastError(CRYPT_E_NOT_FOUND);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(CRYPT_E_NOT_FOUND);
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-06-22 05:50:11 +02:00
|
|
|
PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore,
|
|
|
|
PCCERT_CONTEXT pIssuerContext, PCCRL_CONTEXT pPrevCrlContext, DWORD *pdwFlags)
|
|
|
|
{
|
|
|
|
static const DWORD supportedFlags = CERT_STORE_SIGNATURE_FLAG |
|
|
|
|
CERT_STORE_TIME_VALIDITY_FLAG | CERT_STORE_BASE_CRL_FLAG |
|
|
|
|
CERT_STORE_DELTA_CRL_FLAG;
|
|
|
|
PCCRL_CONTEXT ret;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %p, %p, %08x)\n", hCertStore, pIssuerContext, pPrevCrlContext,
|
2006-06-22 05:50:11 +02:00
|
|
|
*pdwFlags);
|
|
|
|
|
|
|
|
if (*pdwFlags & ~supportedFlags)
|
|
|
|
{
|
|
|
|
SetLastError(E_INVALIDARG);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (pIssuerContext)
|
|
|
|
ret = CertFindCRLInStore(hCertStore, pIssuerContext->dwCertEncodingType,
|
|
|
|
0, CRL_FIND_ISSUED_BY, pIssuerContext, pPrevCrlContext);
|
|
|
|
else
|
|
|
|
ret = CertFindCRLInStore(hCertStore, 0, 0, CRL_FIND_ANY, NULL,
|
|
|
|
pPrevCrlContext);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
if (*pdwFlags & CERT_STORE_TIME_VALIDITY_FLAG)
|
|
|
|
{
|
|
|
|
if (0 == CertVerifyCRLTimeValidity(NULL, ret->pCrlInfo))
|
|
|
|
*pdwFlags &= ~CERT_STORE_TIME_VALIDITY_FLAG;
|
|
|
|
}
|
|
|
|
if (*pdwFlags & CERT_STORE_SIGNATURE_FLAG)
|
|
|
|
{
|
|
|
|
if (CryptVerifyCertificateSignatureEx(0, ret->dwCertEncodingType,
|
|
|
|
CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL, (void *)ret,
|
|
|
|
CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, (void *)pIssuerContext, 0,
|
|
|
|
NULL))
|
|
|
|
*pdwFlags &= ~CERT_STORE_SIGNATURE_FLAG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-25 18:01:03 +02:00
|
|
|
PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pCrlContext);
|
2009-10-20 18:52:36 +02:00
|
|
|
if (pCrlContext)
|
2013-10-14 14:47:07 +02:00
|
|
|
Context_AddRef(&crl_from_ptr(pCrlContext)->base);
|
2006-05-25 18:01:03 +02:00
|
|
|
return pCrlContext;
|
|
|
|
}
|
|
|
|
|
2013-10-15 16:53:11 +02:00
|
|
|
BOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext)
|
2006-05-25 18:01:03 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pCrlContext);
|
|
|
|
|
|
|
|
if (pCrlContext)
|
2013-10-18 10:50:12 +02:00
|
|
|
Context_Release(&crl_from_ptr(pCrlContext)->base);
|
|
|
|
return TRUE;
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
|
|
|
|
DWORD dwPropId)
|
|
|
|
{
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %d)\n", pCRLContext, dwPropId);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
return ContextPropertyList_EnumPropIDs(crl_from_ptr(pCRLContext)->base.properties, dwPropId);
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
static BOOL CRLContext_SetProperty(crl_t *crl, DWORD dwPropId,
|
2008-01-02 12:22:16 +01:00
|
|
|
DWORD dwFlags, const void *pvData);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
static BOOL CRLContext_GetHashProp(crl_t *crl, DWORD dwPropId,
|
2006-05-25 18:01:03 +02:00
|
|
|
ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData,
|
|
|
|
DWORD *pcbData)
|
|
|
|
{
|
|
|
|
BOOL ret = CryptHashCertificate(0, algID, 0, toHash, toHashLen, pvData,
|
|
|
|
pcbData);
|
2008-12-23 04:32:41 +01:00
|
|
|
if (ret && pvData)
|
2006-05-25 18:01:03 +02:00
|
|
|
{
|
|
|
|
CRYPT_DATA_BLOB blob = { *pcbData, pvData };
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = CRLContext_SetProperty(crl, dwPropId, 0, &blob);
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
static BOOL CRLContext_GetProperty(crl_t *crl, DWORD dwPropId,
|
2008-01-02 12:22:16 +01:00
|
|
|
void *pvData, DWORD *pcbData)
|
2006-05-25 18:01:03 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
CRYPT_DATA_BLOB blob;
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
TRACE("(%p, %d, %p, %p)\n", crl, dwPropId, pvData, pcbData);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
if (crl->base.properties)
|
|
|
|
ret = ContextPropertyList_FindProperty(crl->base.properties, dwPropId, &blob);
|
2006-05-25 18:01:03 +02:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
if (!pvData)
|
|
|
|
*pcbData = blob.cbData;
|
|
|
|
else if (*pcbData < blob.cbData)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_MORE_DATA);
|
|
|
|
*pcbData = blob.cbData;
|
2007-05-15 03:04:51 +02:00
|
|
|
ret = FALSE;
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(pvData, blob.pbData, blob.cbData);
|
|
|
|
*pcbData = blob.cbData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Implicit properties */
|
|
|
|
switch (dwPropId)
|
|
|
|
{
|
|
|
|
case CERT_SHA1_HASH_PROP_ID:
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = CRLContext_GetHashProp(crl, dwPropId, CALG_SHA1,
|
|
|
|
crl->ctx.pbCrlEncoded, crl->ctx.cbCrlEncoded, pvData,
|
2006-05-25 18:01:03 +02:00
|
|
|
pcbData);
|
|
|
|
break;
|
|
|
|
case CERT_MD5_HASH_PROP_ID:
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = CRLContext_GetHashProp(crl, dwPropId, CALG_MD5,
|
|
|
|
crl->ctx.pbCrlEncoded, crl->ctx.cbCrlEncoded, pvData,
|
2006-05-25 18:01:03 +02:00
|
|
|
pcbData);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetLastError(CRYPT_E_NOT_FOUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("returning %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
|
|
|
|
DWORD dwPropId, void *pvData, DWORD *pcbData)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %d, %p, %p)\n", pCRLContext, dwPropId, pvData, pcbData);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
|
|
|
switch (dwPropId)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case CERT_CERT_PROP_ID:
|
|
|
|
case CERT_CRL_PROP_ID:
|
|
|
|
case CERT_CTL_PROP_ID:
|
|
|
|
SetLastError(E_INVALIDARG);
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
case CERT_ACCESS_STATE_PROP_ID:
|
|
|
|
if (!pvData)
|
|
|
|
{
|
|
|
|
*pcbData = sizeof(DWORD);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (*pcbData < sizeof(DWORD))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_MORE_DATA);
|
|
|
|
*pcbData = sizeof(DWORD);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-21 15:59:11 +02:00
|
|
|
ret = CertGetStoreProperty(pCRLContext->hCertStore, dwPropId, pvData, pcbData);
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = CRLContext_GetProperty(crl_from_ptr(pCRLContext), dwPropId, pvData, pcbData);
|
2006-05-25 18:01:03 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
static BOOL CRLContext_SetProperty(crl_t *crl, DWORD dwPropId,
|
2006-05-25 18:01:03 +02:00
|
|
|
DWORD dwFlags, const void *pvData)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
TRACE("(%p, %d, %08x, %p)\n", crl, dwPropId, dwFlags, pvData);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
if (!crl->base.properties)
|
2006-05-25 18:01:03 +02:00
|
|
|
ret = FALSE;
|
|
|
|
else if (!pvData)
|
|
|
|
{
|
2013-10-17 11:07:24 +02:00
|
|
|
ContextPropertyList_RemoveProperty(crl->base.properties, dwPropId);
|
2006-05-25 18:01:03 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (dwPropId)
|
|
|
|
{
|
|
|
|
case CERT_AUTO_ENROLL_PROP_ID:
|
|
|
|
case CERT_CTL_USAGE_PROP_ID: /* same as CERT_ENHKEY_USAGE_PROP_ID */
|
|
|
|
case CERT_DESCRIPTION_PROP_ID:
|
|
|
|
case CERT_FRIENDLY_NAME_PROP_ID:
|
|
|
|
case CERT_HASH_PROP_ID:
|
|
|
|
case CERT_KEY_IDENTIFIER_PROP_ID:
|
|
|
|
case CERT_MD5_HASH_PROP_ID:
|
|
|
|
case CERT_NEXT_UPDATE_LOCATION_PROP_ID:
|
|
|
|
case CERT_PUBKEY_ALG_PARA_PROP_ID:
|
|
|
|
case CERT_PVK_FILE_PROP_ID:
|
|
|
|
case CERT_SIGNATURE_HASH_PROP_ID:
|
|
|
|
case CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID:
|
|
|
|
case CERT_SUBJECT_NAME_MD5_HASH_PROP_ID:
|
|
|
|
case CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID:
|
|
|
|
case CERT_ENROLLMENT_PROP_ID:
|
|
|
|
case CERT_CROSS_CERT_DIST_POINTS_PROP_ID:
|
|
|
|
case CERT_RENEWAL_PROP_ID:
|
|
|
|
{
|
|
|
|
PCRYPT_DATA_BLOB blob = (PCRYPT_DATA_BLOB)pvData;
|
|
|
|
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = ContextPropertyList_SetProperty(crl->base.properties, dwPropId,
|
2006-05-25 18:01:03 +02:00
|
|
|
blob->pbData, blob->cbData);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CERT_DATE_STAMP_PROP_ID:
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = ContextPropertyList_SetProperty(crl->base.properties, dwPropId,
|
2009-01-26 11:01:47 +01:00
|
|
|
pvData, sizeof(FILETIME));
|
2006-05-25 18:01:03 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-04 06:58:09 +02:00
|
|
|
FIXME("%d: stub\n", dwPropId);
|
2006-05-25 18:01:03 +02:00
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("returning %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
|
|
|
|
DWORD dwPropId, DWORD dwFlags, const void *pvData)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %d, %08x, %p)\n", pCRLContext, dwPropId, dwFlags, pvData);
|
2006-05-25 18:01:03 +02:00
|
|
|
|
|
|
|
/* Handle special cases for "read-only"/invalid prop IDs. Windows just
|
|
|
|
* crashes on most of these, I'll be safer.
|
|
|
|
*/
|
|
|
|
switch (dwPropId)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case CERT_ACCESS_STATE_PROP_ID:
|
|
|
|
case CERT_CERT_PROP_ID:
|
|
|
|
case CERT_CRL_PROP_ID:
|
|
|
|
case CERT_CTL_PROP_ID:
|
|
|
|
SetLastError(E_INVALIDARG);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-10-17 11:07:24 +02:00
|
|
|
ret = CRLContext_SetProperty(crl_from_ptr(pCRLContext), dwPropId, dwFlags, pvData);
|
2006-05-25 18:01:03 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2006-05-26 18:48:13 +02:00
|
|
|
|
2009-11-19 01:21:09 +01:00
|
|
|
static BOOL compare_dist_point_name(const CRL_DIST_POINT_NAME *name1,
|
|
|
|
const CRL_DIST_POINT_NAME *name2)
|
|
|
|
{
|
|
|
|
BOOL match;
|
|
|
|
|
|
|
|
if (name1->dwDistPointNameChoice == name2->dwDistPointNameChoice)
|
|
|
|
{
|
|
|
|
match = TRUE;
|
|
|
|
if (name1->dwDistPointNameChoice == CRL_DIST_POINT_FULL_NAME)
|
|
|
|
{
|
|
|
|
if (name1->u.FullName.cAltEntry == name2->u.FullName.cAltEntry)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for (i = 0; match && i < name1->u.FullName.cAltEntry; i++)
|
|
|
|
{
|
|
|
|
const CERT_ALT_NAME_ENTRY *entry1 =
|
|
|
|
&name1->u.FullName.rgAltEntry[i];
|
|
|
|
const CERT_ALT_NAME_ENTRY *entry2 =
|
|
|
|
&name2->u.FullName.rgAltEntry[i];
|
|
|
|
|
|
|
|
if (entry1->dwAltNameChoice == entry2->dwAltNameChoice)
|
|
|
|
{
|
|
|
|
switch (entry1->dwAltNameChoice)
|
|
|
|
{
|
|
|
|
case CERT_ALT_NAME_URL:
|
2020-11-09 11:41:21 +01:00
|
|
|
match = !wcsicmp(entry1->u.pwszURL,
|
2009-11-19 01:21:09 +01:00
|
|
|
entry2->u.pwszURL);
|
|
|
|
break;
|
|
|
|
case CERT_ALT_NAME_DIRECTORY_NAME:
|
|
|
|
match = (entry1->u.DirectoryName.cbData ==
|
|
|
|
entry2->u.DirectoryName.cbData) &&
|
|
|
|
!memcmp(entry1->u.DirectoryName.pbData,
|
|
|
|
entry2->u.DirectoryName.pbData,
|
|
|
|
entry1->u.DirectoryName.cbData);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unimplemented for type %d\n",
|
|
|
|
entry1->dwAltNameChoice);
|
|
|
|
match = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
match = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
match = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
match = FALSE;
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL match_dist_point_with_issuing_dist_point(
|
|
|
|
const CRL_DIST_POINT *distPoint, const CRL_ISSUING_DIST_POINT *idp)
|
|
|
|
{
|
|
|
|
BOOL match;
|
|
|
|
|
|
|
|
/* While RFC 5280, section 4.2.1.13 recommends against segmenting
|
|
|
|
* CRL distribution points by reasons, it doesn't preclude doing so.
|
|
|
|
* "This profile RECOMMENDS against segmenting CRLs by reason code."
|
|
|
|
* If the issuing distribution point for this CRL is only valid for
|
|
|
|
* some reasons, only match if the reasons covered also match the
|
|
|
|
* reasons in the CRL distribution point.
|
|
|
|
*/
|
|
|
|
if (idp->OnlySomeReasonFlags.cbData)
|
|
|
|
{
|
|
|
|
if (idp->OnlySomeReasonFlags.cbData == distPoint->ReasonFlags.cbData)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
match = TRUE;
|
|
|
|
for (i = 0; match && i < distPoint->ReasonFlags.cbData; i++)
|
|
|
|
if (idp->OnlySomeReasonFlags.pbData[i] !=
|
|
|
|
distPoint->ReasonFlags.pbData[i])
|
|
|
|
match = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
match = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
match = TRUE;
|
|
|
|
if (match)
|
|
|
|
match = compare_dist_point_name(&idp->DistPointName,
|
|
|
|
&distPoint->DistPointName);
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
2006-06-21 01:06:27 +02:00
|
|
|
BOOL WINAPI CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert,
|
|
|
|
PCCRL_CONTEXT pCrl, DWORD dwFlags, void *pvReserved)
|
|
|
|
{
|
2009-11-19 01:21:09 +01:00
|
|
|
PCERT_EXTENSION ext;
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %p, %08x, %p)\n", pCert, pCrl, dwFlags, pvReserved);
|
2009-11-19 01:21:09 +01:00
|
|
|
|
|
|
|
if (!pCert)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if ((ext = CertFindExtension(szOID_ISSUING_DIST_POINT,
|
|
|
|
pCrl->pCrlInfo->cExtension, pCrl->pCrlInfo->rgExtension)))
|
|
|
|
{
|
|
|
|
CRL_ISSUING_DIST_POINT *idp;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if ((ret = CryptDecodeObjectEx(pCrl->dwCertEncodingType,
|
|
|
|
X509_ISSUING_DIST_POINT, ext->Value.pbData, ext->Value.cbData,
|
|
|
|
CRYPT_DECODE_ALLOC_FLAG, NULL, &idp, &size)))
|
|
|
|
{
|
|
|
|
if ((ext = CertFindExtension(szOID_CRL_DIST_POINTS,
|
|
|
|
pCert->pCertInfo->cExtension, pCert->pCertInfo->rgExtension)))
|
|
|
|
{
|
|
|
|
CRL_DIST_POINTS_INFO *distPoints;
|
|
|
|
|
|
|
|
if ((ret = CryptDecodeObjectEx(pCert->dwCertEncodingType,
|
|
|
|
X509_CRL_DIST_POINTS, ext->Value.pbData, ext->Value.cbData,
|
|
|
|
CRYPT_DECODE_ALLOC_FLAG, NULL, &distPoints, &size)))
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
for (i = 0; !ret && i < distPoints->cDistPoint; i++)
|
|
|
|
ret = match_dist_point_with_issuing_dist_point(
|
|
|
|
&distPoints->rgDistPoint[i], idp);
|
|
|
|
if (!ret)
|
|
|
|
SetLastError(CRYPT_E_NO_MATCH);
|
|
|
|
LocalFree(distPoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-19 20:48:53 +01:00
|
|
|
/* no CRL dist points extension in cert, can't match the CRL
|
|
|
|
* (which has an issuing dist point extension)
|
2009-11-19 01:21:09 +01:00
|
|
|
*/
|
2009-11-19 20:48:53 +01:00
|
|
|
ret = FALSE;
|
|
|
|
SetLastError(CRYPT_E_NO_MATCH);
|
2009-11-19 01:21:09 +01:00
|
|
|
}
|
|
|
|
LocalFree(idp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = TRUE;
|
|
|
|
return ret;
|
2006-06-21 01:06:27 +02:00
|
|
|
}
|
|
|
|
|
2007-04-09 21:28:22 +02:00
|
|
|
static PCRL_ENTRY CRYPT_FindCertificateInCRL(PCERT_INFO cert, const CRL_INFO *crl)
|
2006-06-21 01:06:27 +02:00
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
PCRL_ENTRY entry = NULL;
|
|
|
|
|
|
|
|
for (i = 0; !entry && i < crl->cCRLEntry; i++)
|
|
|
|
if (CertCompareIntegerBlob(&crl->rgCRLEntry[i].SerialNumber,
|
|
|
|
&cert->SerialNumber))
|
|
|
|
entry = &crl->rgCRLEntry[i];
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CertFindCertificateInCRL(PCCERT_CONTEXT pCert,
|
|
|
|
PCCRL_CONTEXT pCrlContext, DWORD dwFlags, void *pvReserved,
|
|
|
|
PCRL_ENTRY *ppCrlEntry)
|
|
|
|
{
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%p, %p, %08x, %p, %p)\n", pCert, pCrlContext, dwFlags, pvReserved,
|
2006-06-21 01:06:27 +02:00
|
|
|
ppCrlEntry);
|
|
|
|
|
|
|
|
*ppCrlEntry = CRYPT_FindCertificateInCRL(pCert->pCertInfo,
|
|
|
|
pCrlContext->pCrlInfo);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CertVerifyCRLRevocation(DWORD dwCertEncodingType,
|
|
|
|
PCERT_INFO pCertId, DWORD cCrlInfo, PCRL_INFO rgpCrlInfo[])
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
PCRL_ENTRY entry = NULL;
|
|
|
|
|
2006-10-04 06:58:09 +02:00
|
|
|
TRACE("(%08x, %p, %d, %p)\n", dwCertEncodingType, pCertId, cCrlInfo,
|
2006-06-21 01:06:27 +02:00
|
|
|
rgpCrlInfo);
|
|
|
|
|
|
|
|
for (i = 0; !entry && i < cCrlInfo; i++)
|
|
|
|
entry = CRYPT_FindCertificateInCRL(pCertId, rgpCrlInfo[i]);
|
|
|
|
return entry == NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-26 18:48:13 +02:00
|
|
|
LONG WINAPI CertVerifyCRLTimeValidity(LPFILETIME pTimeToVerify,
|
|
|
|
PCRL_INFO pCrlInfo)
|
|
|
|
{
|
|
|
|
FILETIME fileTime;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
if (!pTimeToVerify)
|
|
|
|
{
|
2007-10-18 20:14:12 +02:00
|
|
|
GetSystemTimeAsFileTime(&fileTime);
|
2006-05-26 18:48:13 +02:00
|
|
|
pTimeToVerify = &fileTime;
|
|
|
|
}
|
|
|
|
if ((ret = CompareFileTime(pTimeToVerify, &pCrlInfo->ThisUpdate)) >= 0)
|
|
|
|
{
|
|
|
|
ret = CompareFileTime(pTimeToVerify, &pCrlInfo->NextUpdate);
|
|
|
|
if (ret < 0)
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|