crypt32: Implement CertFindCertificateInStore for CERT_FIND_SIGNATURE_HASH.

This commit is contained in:
Juan Lang 2008-08-08 10:44:46 -07:00 committed by Alexandre Julliard
parent e763923b07
commit a1e14feeac
1 changed files with 29 additions and 0 deletions

View File

@ -1143,6 +1143,32 @@ static BOOL compare_existing_cert(PCCERT_CONTEXT pCertContext, DWORD dwType,
pCertContext->pCertInfo, toCompare->pCertInfo); pCertContext->pCertInfo, toCompare->pCertInfo);
} }
static BOOL compare_cert_by_signature_hash(PCCERT_CONTEXT pCertContext, DWORD dwType,
DWORD dwFlags, const void *pvPara)
{
const CRYPT_HASH_BLOB *hash = (const CRYPT_HASH_BLOB *)pvPara;
DWORD size = 0;
BOOL ret;
ret = CertGetCertificateContextProperty(pCertContext,
CERT_SIGNATURE_HASH_PROP_ID, NULL, &size);
if (ret && size == hash->cbData)
{
LPBYTE buf = CryptMemAlloc(size);
if (buf)
{
CertGetCertificateContextProperty(pCertContext,
CERT_SIGNATURE_HASH_PROP_ID, buf, &size);
ret = !memcmp(buf, hash->pbData, size);
CryptMemFree(buf);
}
}
else
ret = FALSE;
return ret;
}
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore,
DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara,
PCCERT_CONTEXT pPrevCertContext) PCCERT_CONTEXT pPrevCertContext)
@ -1179,6 +1205,9 @@ PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore,
case CERT_COMPARE_EXISTING: case CERT_COMPARE_EXISTING:
compare = compare_existing_cert; compare = compare_existing_cert;
break; break;
case CERT_COMPARE_SIGNATURE_HASH:
compare = compare_cert_by_signature_hash;
break;
default: default:
FIXME("find type %08x unimplemented\n", dwType); FIXME("find type %08x unimplemented\n", dwType);
compare = NULL; compare = NULL;