crypt32: Use helper function to encode public keys for hashing.
This is necessary because the publicly callable form embeds the asn.1 NULL value when the parameters are empty, whereas the hash value expects that it's missing.
This commit is contained in:
parent
c97e442a28
commit
d8ca5bc348
|
@ -1855,13 +1855,19 @@ BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid,
|
|||
hCryptProv = CRYPT_GetDefaultProvider();
|
||||
if (!Algid)
|
||||
Algid = CALG_MD5;
|
||||
if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING)
|
||||
{
|
||||
SetLastError(ERROR_FILE_NOT_FOUND);
|
||||
return FALSE;
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
BYTE *buf;
|
||||
DWORD size = 0;
|
||||
|
||||
ret = CryptEncodeObjectEx(dwCertEncodingType, X509_PUBLIC_KEY_INFO,
|
||||
pInfo, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
|
||||
ret = CRYPT_AsnEncodePubKeyInfoNoNull(dwCertEncodingType,
|
||||
X509_PUBLIC_KEY_INFO, pInfo, CRYPT_ENCODE_ALLOC_FLAG, NULL,
|
||||
(LPBYTE)&buf, &size);
|
||||
if (ret)
|
||||
{
|
||||
ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash);
|
||||
|
|
|
@ -113,6 +113,10 @@ BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
|
|||
DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara,
|
||||
CRYPT_DIGESTED_DATA *digestedData, DWORD *pcbDigestedData);
|
||||
|
||||
BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
|
||||
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
||||
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded);
|
||||
|
||||
/* The following aren't defined in wincrypt.h, as they're "reserved" */
|
||||
#define CERT_CERT_PROP_ID 32
|
||||
#define CERT_CRL_PROP_ID 33
|
||||
|
|
|
@ -464,7 +464,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
|
||||
BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
|
||||
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
|
||||
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue