crypt32: Simplify the CertComparePublicKeyInfo implementation.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-10-25 14:50:35 +03:00 committed by Alexandre Julliard
parent 98fad7df79
commit b81c0c3e47
1 changed files with 11 additions and 22 deletions

View File

@ -1267,32 +1267,21 @@ BOOL WINAPI CertComparePublicKeyInfo(DWORD dwCertEncodingType,
ret = FALSE; ret = FALSE;
if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB, if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB,
pPublicKey1->PublicKey.pbData, pPublicKey1->PublicKey.cbData, pPublicKey1->PublicKey.pbData, pPublicKey1->PublicKey.cbData,
0, NULL, &length)) CRYPT_DECODE_ALLOC_FLAG, &pblob1, &length))
{
pblob1 = CryptMemAlloc(length);
if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB,
pPublicKey1->PublicKey.pbData, pPublicKey1->PublicKey.cbData,
0, pblob1, &length))
{ {
if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB, if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB,
pPublicKey2->PublicKey.pbData, pPublicKey2->PublicKey.cbData, pPublicKey2->PublicKey.pbData, pPublicKey2->PublicKey.cbData,
0, NULL, &length)) CRYPT_DECODE_ALLOC_FLAG, &pblob2, &length))
{
pblob2 = CryptMemAlloc(length);
if (CryptDecodeObject(dwCertEncodingType, RSA_CSP_PUBLICKEYBLOB,
pPublicKey2->PublicKey.pbData, pPublicKey2->PublicKey.cbData,
0, pblob2, &length))
{ {
/* The RSAPUBKEY structure directly follows the BLOBHEADER */ /* The RSAPUBKEY structure directly follows the BLOBHEADER */
RSAPUBKEY *pk1 = (LPVOID)(pblob1 + 1), RSAPUBKEY *pk1 = (LPVOID)(pblob1 + 1),
*pk2 = (LPVOID)(pblob2 + 1); *pk2 = (LPVOID)(pblob2 + 1);
ret = (pk1->bitlen == pk2->bitlen) && (pk1->pubexp == pk2->pubexp) ret = (pk1->bitlen == pk2->bitlen) && (pk1->pubexp == pk2->pubexp)
&& !memcmp(pk1 + 1, pk2 + 1, pk1->bitlen/8); && !memcmp(pk1 + 1, pk2 + 1, pk1->bitlen/8);
LocalFree(pblob2);
} }
CryptMemFree(pblob2); LocalFree(pblob1);
}
}
CryptMemFree(pblob1);
} }
break; break;