2 * Copyright 2006 Juan Lang
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
26 #include "wine/debug.h"
27 #include "crypt32_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
31 static void CRL_free(context_t
*context
)
33 crl_t
*crl
= (crl_t
*)context
;
35 CryptMemFree(crl
->ctx
.pbCrlEncoded
);
36 LocalFree(crl
->ctx
.pCrlInfo
);
39 static const context_vtbl_t crl_vtbl
;
41 static context_t
*CRL_clone(context_t
*context
, WINECRYPT_CERTSTORE
*store
, BOOL use_link
)
46 crl
= (crl_t
*)Context_CreateLinkContext(sizeof(CRL_CONTEXT
), context
, store
);
50 const crl_t
*cloned
= (const crl_t
*)context
;
54 crl
= (crl_t
*)Context_CreateDataContext(sizeof(CRL_CONTEXT
), &crl_vtbl
, store
);
58 Context_CopyProperties(&crl
->ctx
, &cloned
->ctx
);
60 crl
->ctx
.dwCertEncodingType
= cloned
->ctx
.dwCertEncodingType
;
61 crl
->ctx
.pbCrlEncoded
= CryptMemAlloc(cloned
->ctx
.cbCrlEncoded
);
62 memcpy(crl
->ctx
.pbCrlEncoded
, cloned
->ctx
.pbCrlEncoded
, cloned
->ctx
.cbCrlEncoded
);
63 crl
->ctx
.cbCrlEncoded
= cloned
->ctx
.cbCrlEncoded
;
65 /* FIXME: We don't need to decode the object here, we could just clone crl info. */
66 res
= CryptDecodeObjectEx(crl
->ctx
.dwCertEncodingType
, X509_CERT_CRL_TO_BE_SIGNED
,
67 crl
->ctx
.pbCrlEncoded
, crl
->ctx
.cbCrlEncoded
, CRYPT_DECODE_ALLOC_FLAG
, NULL
,
68 &crl
->ctx
.pCrlInfo
, &size
);
70 CertFreeCRLContext(&crl
->ctx
);
75 crl
->ctx
.hCertStore
= store
;
79 static const context_vtbl_t crl_vtbl
= {
84 PCCRL_CONTEXT WINAPI
CertCreateCRLContext(DWORD dwCertEncodingType
,
85 const BYTE
* pbCrlEncoded
, DWORD cbCrlEncoded
)
89 PCRL_INFO crlInfo
= NULL
;
93 TRACE("(%08x, %p, %d)\n", dwCertEncodingType
, pbCrlEncoded
,
96 if ((dwCertEncodingType
& CERT_ENCODING_TYPE_MASK
) != X509_ASN_ENCODING
)
98 SetLastError(E_INVALIDARG
);
101 ret
= CryptDecodeObjectEx(dwCertEncodingType
, X509_CERT_CRL_TO_BE_SIGNED
,
102 pbCrlEncoded
, cbCrlEncoded
, CRYPT_DECODE_ALLOC_FLAG
, NULL
,
107 crl
= (crl_t
*)Context_CreateDataContext(sizeof(CRL_CONTEXT
), &crl_vtbl
, &empty_store
);
111 data
= CryptMemAlloc(cbCrlEncoded
);
114 Context_Release(&crl
->base
);
118 memcpy(data
, pbCrlEncoded
, cbCrlEncoded
);
119 crl
->ctx
.dwCertEncodingType
= dwCertEncodingType
;
120 crl
->ctx
.pbCrlEncoded
= data
;
121 crl
->ctx
.cbCrlEncoded
= cbCrlEncoded
;
122 crl
->ctx
.pCrlInfo
= crlInfo
;
123 crl
->ctx
.hCertStore
= &empty_store
;
128 BOOL WINAPI
CertAddEncodedCRLToStore(HCERTSTORE hCertStore
,
129 DWORD dwCertEncodingType
, const BYTE
*pbCrlEncoded
, DWORD cbCrlEncoded
,
130 DWORD dwAddDisposition
, PCCRL_CONTEXT
*ppCrlContext
)
132 PCCRL_CONTEXT crl
= CertCreateCRLContext(dwCertEncodingType
,
133 pbCrlEncoded
, cbCrlEncoded
);
136 TRACE("(%p, %08x, %p, %d, %08x, %p)\n", hCertStore
, dwCertEncodingType
,
137 pbCrlEncoded
, cbCrlEncoded
, dwAddDisposition
, ppCrlContext
);
141 ret
= CertAddCRLContextToStore(hCertStore
, crl
, dwAddDisposition
,
143 CertFreeCRLContext(crl
);
150 typedef BOOL (*CrlCompareFunc
)(PCCRL_CONTEXT pCrlContext
, DWORD dwType
,
151 DWORD dwFlags
, const void *pvPara
);
153 static BOOL
compare_crl_any(PCCRL_CONTEXT pCrlContext
, DWORD dwType
,
154 DWORD dwFlags
, const void *pvPara
)
159 static BOOL
compare_crl_issued_by(PCCRL_CONTEXT pCrlContext
, DWORD dwType
,
160 DWORD dwFlags
, const void *pvPara
)
166 PCCERT_CONTEXT issuer
= pvPara
;
168 ret
= CertCompareCertificateName(issuer
->dwCertEncodingType
,
169 &issuer
->pCertInfo
->Subject
, &pCrlContext
->pCrlInfo
->Issuer
);
170 if (ret
&& (dwFlags
& CRL_FIND_ISSUED_BY_SIGNATURE_FLAG
))
171 ret
= CryptVerifyCertificateSignatureEx(0,
172 issuer
->dwCertEncodingType
,
173 CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL
, (void *)pCrlContext
,
174 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT
, (void *)issuer
, 0, NULL
);
175 if (ret
&& (dwFlags
& CRL_FIND_ISSUED_BY_AKI_FLAG
))
177 PCERT_EXTENSION ext
= CertFindExtension(
178 szOID_AUTHORITY_KEY_IDENTIFIER2
, pCrlContext
->pCrlInfo
->cExtension
,
179 pCrlContext
->pCrlInfo
->rgExtension
);
183 CERT_AUTHORITY_KEY_ID2_INFO
*info
;
186 if ((ret
= CryptDecodeObjectEx(X509_ASN_ENCODING
,
187 X509_AUTHORITY_KEY_ID2
, ext
->Value
.pbData
, ext
->Value
.cbData
,
188 CRYPT_DECODE_ALLOC_FLAG
, NULL
, &info
, &size
)))
190 if (info
->AuthorityCertIssuer
.cAltEntry
&&
191 info
->AuthorityCertSerialNumber
.cbData
)
193 PCERT_ALT_NAME_ENTRY directoryName
= NULL
;
196 for (i
= 0; !directoryName
&&
197 i
< info
->AuthorityCertIssuer
.cAltEntry
; i
++)
198 if (info
->AuthorityCertIssuer
.rgAltEntry
[i
].
199 dwAltNameChoice
== CERT_ALT_NAME_DIRECTORY_NAME
)
201 &info
->AuthorityCertIssuer
.rgAltEntry
[i
];
204 ret
= CertCompareCertificateName(
205 issuer
->dwCertEncodingType
,
206 &issuer
->pCertInfo
->Subject
,
207 &directoryName
->u
.DirectoryName
);
209 ret
= CertCompareIntegerBlob(
210 &issuer
->pCertInfo
->SerialNumber
,
211 &info
->AuthorityCertSerialNumber
);
215 FIXME("no supported name type in authority key id2\n");
219 else if (info
->KeyId
.cbData
)
223 ret
= CertGetCertificateContextProperty(issuer
,
224 CERT_KEY_IDENTIFIER_PROP_ID
, NULL
, &size
);
225 if (ret
&& size
== info
->KeyId
.cbData
)
227 LPBYTE buf
= CryptMemAlloc(size
);
231 CertGetCertificateContextProperty(issuer
,
232 CERT_KEY_IDENTIFIER_PROP_ID
, buf
, &size
);
233 ret
= !memcmp(buf
, info
->KeyId
.pbData
, size
);
244 FIXME("unsupported value for AKI extension\n");
250 /* else: a CRL without an AKI matches any cert */
258 static BOOL
compare_crl_existing(PCCRL_CONTEXT pCrlContext
, DWORD dwType
,
259 DWORD dwFlags
, const void *pvPara
)
265 PCCRL_CONTEXT crl
= pvPara
;
267 ret
= CertCompareCertificateName(pCrlContext
->dwCertEncodingType
,
268 &pCrlContext
->pCrlInfo
->Issuer
, &crl
->pCrlInfo
->Issuer
);
275 static BOOL
compare_crl_issued_for(PCCRL_CONTEXT pCrlContext
, DWORD dwType
,
276 DWORD dwFlags
, const void *pvPara
)
278 const CRL_FIND_ISSUED_FOR_PARA
*para
= pvPara
;
281 ret
= CertCompareCertificateName(para
->pIssuerCert
->dwCertEncodingType
,
282 ¶
->pIssuerCert
->pCertInfo
->Issuer
, &pCrlContext
->pCrlInfo
->Issuer
);
286 PCCRL_CONTEXT WINAPI
CertFindCRLInStore(HCERTSTORE hCertStore
,
287 DWORD dwCertEncodingType
, DWORD dwFindFlags
, DWORD dwFindType
,
288 const void *pvFindPara
, PCCRL_CONTEXT pPrevCrlContext
)
291 CrlCompareFunc compare
;
293 TRACE("(%p, %d, %d, %d, %p, %p)\n", hCertStore
, dwCertEncodingType
,
294 dwFindFlags
, dwFindType
, pvFindPara
, pPrevCrlContext
);
299 compare
= compare_crl_any
;
301 case CRL_FIND_ISSUED_BY
:
302 compare
= compare_crl_issued_by
;
304 case CRL_FIND_EXISTING
:
305 compare
= compare_crl_existing
;
307 case CRL_FIND_ISSUED_FOR
:
308 compare
= compare_crl_issued_for
;
311 FIXME("find type %08x unimplemented\n", dwFindType
);
317 BOOL matches
= FALSE
;
319 ret
= pPrevCrlContext
;
321 ret
= CertEnumCRLsInStore(hCertStore
, ret
);
323 matches
= compare(ret
, dwFindType
, dwFindFlags
, pvFindPara
);
324 } while (ret
!= NULL
&& !matches
);
326 SetLastError(CRYPT_E_NOT_FOUND
);
330 SetLastError(CRYPT_E_NOT_FOUND
);
336 PCCRL_CONTEXT WINAPI
CertGetCRLFromStore(HCERTSTORE hCertStore
,
337 PCCERT_CONTEXT pIssuerContext
, PCCRL_CONTEXT pPrevCrlContext
, DWORD
*pdwFlags
)
339 static const DWORD supportedFlags
= CERT_STORE_SIGNATURE_FLAG
|
340 CERT_STORE_TIME_VALIDITY_FLAG
| CERT_STORE_BASE_CRL_FLAG
|
341 CERT_STORE_DELTA_CRL_FLAG
;
344 TRACE("(%p, %p, %p, %08x)\n", hCertStore
, pIssuerContext
, pPrevCrlContext
,
347 if (*pdwFlags
& ~supportedFlags
)
349 SetLastError(E_INVALIDARG
);
353 ret
= CertFindCRLInStore(hCertStore
, pIssuerContext
->dwCertEncodingType
,
354 0, CRL_FIND_ISSUED_BY
, pIssuerContext
, pPrevCrlContext
);
356 ret
= CertFindCRLInStore(hCertStore
, 0, 0, CRL_FIND_ANY
, NULL
,
360 if (*pdwFlags
& CERT_STORE_TIME_VALIDITY_FLAG
)
362 if (0 == CertVerifyCRLTimeValidity(NULL
, ret
->pCrlInfo
))
363 *pdwFlags
&= ~CERT_STORE_TIME_VALIDITY_FLAG
;
365 if (*pdwFlags
& CERT_STORE_SIGNATURE_FLAG
)
367 if (CryptVerifyCertificateSignatureEx(0, ret
->dwCertEncodingType
,
368 CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL
, (void *)ret
,
369 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT
, (void *)pIssuerContext
, 0,
371 *pdwFlags
&= ~CERT_STORE_SIGNATURE_FLAG
;
377 PCCRL_CONTEXT WINAPI
CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext
)
379 TRACE("(%p)\n", pCrlContext
);
381 Context_AddRef(&crl_from_ptr(pCrlContext
)->base
);
385 BOOL WINAPI
CertFreeCRLContext(PCCRL_CONTEXT pCrlContext
)
387 TRACE("(%p)\n", pCrlContext
);
390 Context_Release(&crl_from_ptr(pCrlContext
)->base
);
394 DWORD WINAPI
CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext
,
397 TRACE("(%p, %d)\n", pCRLContext
, dwPropId
);
399 return ContextPropertyList_EnumPropIDs(crl_from_ptr(pCRLContext
)->base
.properties
, dwPropId
);
402 static BOOL
CRLContext_SetProperty(crl_t
*crl
, DWORD dwPropId
,
403 DWORD dwFlags
, const void *pvData
);
405 static BOOL
CRLContext_GetHashProp(crl_t
*crl
, DWORD dwPropId
,
406 ALG_ID algID
, const BYTE
*toHash
, DWORD toHashLen
, void *pvData
,
409 BOOL ret
= CryptHashCertificate(0, algID
, 0, toHash
, toHashLen
, pvData
,
413 CRYPT_DATA_BLOB blob
= { *pcbData
, pvData
};
415 ret
= CRLContext_SetProperty(crl
, dwPropId
, 0, &blob
);
420 static BOOL
CRLContext_GetProperty(crl_t
*crl
, DWORD dwPropId
,
421 void *pvData
, DWORD
*pcbData
)
424 CRYPT_DATA_BLOB blob
;
426 TRACE("(%p, %d, %p, %p)\n", crl
, dwPropId
, pvData
, pcbData
);
428 if (crl
->base
.properties
)
429 ret
= ContextPropertyList_FindProperty(crl
->base
.properties
, dwPropId
, &blob
);
435 *pcbData
= blob
.cbData
;
436 else if (*pcbData
< blob
.cbData
)
438 SetLastError(ERROR_MORE_DATA
);
439 *pcbData
= blob
.cbData
;
444 memcpy(pvData
, blob
.pbData
, blob
.cbData
);
445 *pcbData
= blob
.cbData
;
450 /* Implicit properties */
453 case CERT_SHA1_HASH_PROP_ID
:
454 ret
= CRLContext_GetHashProp(crl
, dwPropId
, CALG_SHA1
,
455 crl
->ctx
.pbCrlEncoded
, crl
->ctx
.cbCrlEncoded
, pvData
,
458 case CERT_MD5_HASH_PROP_ID
:
459 ret
= CRLContext_GetHashProp(crl
, dwPropId
, CALG_MD5
,
460 crl
->ctx
.pbCrlEncoded
, crl
->ctx
.cbCrlEncoded
, pvData
,
464 SetLastError(CRYPT_E_NOT_FOUND
);
467 TRACE("returning %d\n", ret
);
471 BOOL WINAPI
CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext
,
472 DWORD dwPropId
, void *pvData
, DWORD
*pcbData
)
476 TRACE("(%p, %d, %p, %p)\n", pCRLContext
, dwPropId
, pvData
, pcbData
);
481 case CERT_CERT_PROP_ID
:
482 case CERT_CRL_PROP_ID
:
483 case CERT_CTL_PROP_ID
:
484 SetLastError(E_INVALIDARG
);
487 case CERT_ACCESS_STATE_PROP_ID
:
490 *pcbData
= sizeof(DWORD
);
493 else if (*pcbData
< sizeof(DWORD
))
495 SetLastError(ERROR_MORE_DATA
);
496 *pcbData
= sizeof(DWORD
);
501 ret
= CertGetStoreProperty(pCRLContext
->hCertStore
, dwPropId
, pvData
, pcbData
);
505 ret
= CRLContext_GetProperty(crl_from_ptr(pCRLContext
), dwPropId
, pvData
, pcbData
);
510 static BOOL
CRLContext_SetProperty(crl_t
*crl
, DWORD dwPropId
,
511 DWORD dwFlags
, const void *pvData
)
515 TRACE("(%p, %d, %08x, %p)\n", crl
, dwPropId
, dwFlags
, pvData
);
517 if (!crl
->base
.properties
)
521 ContextPropertyList_RemoveProperty(crl
->base
.properties
, dwPropId
);
528 case CERT_AUTO_ENROLL_PROP_ID
:
529 case CERT_CTL_USAGE_PROP_ID
: /* same as CERT_ENHKEY_USAGE_PROP_ID */
530 case CERT_DESCRIPTION_PROP_ID
:
531 case CERT_FRIENDLY_NAME_PROP_ID
:
532 case CERT_HASH_PROP_ID
:
533 case CERT_KEY_IDENTIFIER_PROP_ID
:
534 case CERT_MD5_HASH_PROP_ID
:
535 case CERT_NEXT_UPDATE_LOCATION_PROP_ID
:
536 case CERT_PUBKEY_ALG_PARA_PROP_ID
:
537 case CERT_PVK_FILE_PROP_ID
:
538 case CERT_SIGNATURE_HASH_PROP_ID
:
539 case CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID
:
540 case CERT_SUBJECT_NAME_MD5_HASH_PROP_ID
:
541 case CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
:
542 case CERT_ENROLLMENT_PROP_ID
:
543 case CERT_CROSS_CERT_DIST_POINTS_PROP_ID
:
544 case CERT_RENEWAL_PROP_ID
:
546 PCRYPT_DATA_BLOB blob
= (PCRYPT_DATA_BLOB
)pvData
;
548 ret
= ContextPropertyList_SetProperty(crl
->base
.properties
, dwPropId
,
549 blob
->pbData
, blob
->cbData
);
552 case CERT_DATE_STAMP_PROP_ID
:
553 ret
= ContextPropertyList_SetProperty(crl
->base
.properties
, dwPropId
,
554 pvData
, sizeof(FILETIME
));
557 FIXME("%d: stub\n", dwPropId
);
561 TRACE("returning %d\n", ret
);
565 BOOL WINAPI
CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext
,
566 DWORD dwPropId
, DWORD dwFlags
, const void *pvData
)
570 TRACE("(%p, %d, %08x, %p)\n", pCRLContext
, dwPropId
, dwFlags
, pvData
);
572 /* Handle special cases for "read-only"/invalid prop IDs. Windows just
573 * crashes on most of these, I'll be safer.
578 case CERT_ACCESS_STATE_PROP_ID
:
579 case CERT_CERT_PROP_ID
:
580 case CERT_CRL_PROP_ID
:
581 case CERT_CTL_PROP_ID
:
582 SetLastError(E_INVALIDARG
);
585 ret
= CRLContext_SetProperty(crl_from_ptr(pCRLContext
), dwPropId
, dwFlags
, pvData
);
586 TRACE("returning %d\n", ret
);
590 static BOOL
compare_dist_point_name(const CRL_DIST_POINT_NAME
*name1
,
591 const CRL_DIST_POINT_NAME
*name2
)
595 if (name1
->dwDistPointNameChoice
== name2
->dwDistPointNameChoice
)
598 if (name1
->dwDistPointNameChoice
== CRL_DIST_POINT_FULL_NAME
)
600 if (name1
->u
.FullName
.cAltEntry
== name2
->u
.FullName
.cAltEntry
)
604 for (i
= 0; match
&& i
< name1
->u
.FullName
.cAltEntry
; i
++)
606 const CERT_ALT_NAME_ENTRY
*entry1
=
607 &name1
->u
.FullName
.rgAltEntry
[i
];
608 const CERT_ALT_NAME_ENTRY
*entry2
=
609 &name2
->u
.FullName
.rgAltEntry
[i
];
611 if (entry1
->dwAltNameChoice
== entry2
->dwAltNameChoice
)
613 switch (entry1
->dwAltNameChoice
)
615 case CERT_ALT_NAME_URL
:
616 match
= !wcsicmp(entry1
->u
.pwszURL
,
619 case CERT_ALT_NAME_DIRECTORY_NAME
:
620 match
= (entry1
->u
.DirectoryName
.cbData
==
621 entry2
->u
.DirectoryName
.cbData
) &&
622 !memcmp(entry1
->u
.DirectoryName
.pbData
,
623 entry2
->u
.DirectoryName
.pbData
,
624 entry1
->u
.DirectoryName
.cbData
);
627 FIXME("unimplemented for type %d\n",
628 entry1
->dwAltNameChoice
);
645 static BOOL
match_dist_point_with_issuing_dist_point(
646 const CRL_DIST_POINT
*distPoint
, const CRL_ISSUING_DIST_POINT
*idp
)
650 /* While RFC 5280, section 4.2.1.13 recommends against segmenting
651 * CRL distribution points by reasons, it doesn't preclude doing so.
652 * "This profile RECOMMENDS against segmenting CRLs by reason code."
653 * If the issuing distribution point for this CRL is only valid for
654 * some reasons, only match if the reasons covered also match the
655 * reasons in the CRL distribution point.
657 if (idp
->OnlySomeReasonFlags
.cbData
)
659 if (idp
->OnlySomeReasonFlags
.cbData
== distPoint
->ReasonFlags
.cbData
)
664 for (i
= 0; match
&& i
< distPoint
->ReasonFlags
.cbData
; i
++)
665 if (idp
->OnlySomeReasonFlags
.pbData
[i
] !=
666 distPoint
->ReasonFlags
.pbData
[i
])
675 match
= compare_dist_point_name(&idp
->DistPointName
,
676 &distPoint
->DistPointName
);
680 BOOL WINAPI
CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert
,
681 PCCRL_CONTEXT pCrl
, DWORD dwFlags
, void *pvReserved
)
686 TRACE("(%p, %p, %08x, %p)\n", pCert
, pCrl
, dwFlags
, pvReserved
);
691 if ((ext
= CertFindExtension(szOID_ISSUING_DIST_POINT
,
692 pCrl
->pCrlInfo
->cExtension
, pCrl
->pCrlInfo
->rgExtension
)))
694 CRL_ISSUING_DIST_POINT
*idp
;
697 if ((ret
= CryptDecodeObjectEx(pCrl
->dwCertEncodingType
,
698 X509_ISSUING_DIST_POINT
, ext
->Value
.pbData
, ext
->Value
.cbData
,
699 CRYPT_DECODE_ALLOC_FLAG
, NULL
, &idp
, &size
)))
701 if ((ext
= CertFindExtension(szOID_CRL_DIST_POINTS
,
702 pCert
->pCertInfo
->cExtension
, pCert
->pCertInfo
->rgExtension
)))
704 CRL_DIST_POINTS_INFO
*distPoints
;
706 if ((ret
= CryptDecodeObjectEx(pCert
->dwCertEncodingType
,
707 X509_CRL_DIST_POINTS
, ext
->Value
.pbData
, ext
->Value
.cbData
,
708 CRYPT_DECODE_ALLOC_FLAG
, NULL
, &distPoints
, &size
)))
713 for (i
= 0; !ret
&& i
< distPoints
->cDistPoint
; i
++)
714 ret
= match_dist_point_with_issuing_dist_point(
715 &distPoints
->rgDistPoint
[i
], idp
);
717 SetLastError(CRYPT_E_NO_MATCH
);
718 LocalFree(distPoints
);
723 /* no CRL dist points extension in cert, can't match the CRL
724 * (which has an issuing dist point extension)
727 SetLastError(CRYPT_E_NO_MATCH
);
737 static PCRL_ENTRY
CRYPT_FindCertificateInCRL(PCERT_INFO cert
, const CRL_INFO
*crl
)
740 PCRL_ENTRY entry
= NULL
;
742 for (i
= 0; !entry
&& i
< crl
->cCRLEntry
; i
++)
743 if (CertCompareIntegerBlob(&crl
->rgCRLEntry
[i
].SerialNumber
,
744 &cert
->SerialNumber
))
745 entry
= &crl
->rgCRLEntry
[i
];
749 BOOL WINAPI
CertFindCertificateInCRL(PCCERT_CONTEXT pCert
,
750 PCCRL_CONTEXT pCrlContext
, DWORD dwFlags
, void *pvReserved
,
751 PCRL_ENTRY
*ppCrlEntry
)
753 TRACE("(%p, %p, %08x, %p, %p)\n", pCert
, pCrlContext
, dwFlags
, pvReserved
,
756 *ppCrlEntry
= CRYPT_FindCertificateInCRL(pCert
->pCertInfo
,
757 pCrlContext
->pCrlInfo
);
761 BOOL WINAPI
CertVerifyCRLRevocation(DWORD dwCertEncodingType
,
762 PCERT_INFO pCertId
, DWORD cCrlInfo
, PCRL_INFO rgpCrlInfo
[])
765 PCRL_ENTRY entry
= NULL
;
767 TRACE("(%08x, %p, %d, %p)\n", dwCertEncodingType
, pCertId
, cCrlInfo
,
770 for (i
= 0; !entry
&& i
< cCrlInfo
; i
++)
771 entry
= CRYPT_FindCertificateInCRL(pCertId
, rgpCrlInfo
[i
]);
772 return entry
== NULL
;
775 LONG WINAPI
CertVerifyCRLTimeValidity(LPFILETIME pTimeToVerify
,
783 GetSystemTimeAsFileTime(&fileTime
);
784 pTimeToVerify
= &fileTime
;
786 if ((ret
= CompareFileTime(pTimeToVerify
, &pCrlInfo
->ThisUpdate
)) >= 0)
788 ret
= CompareFileTime(pTimeToVerify
, &pCrlInfo
->NextUpdate
);