crypt32: Add support for 3rd party CSPs to CertGetPublicKeyLength.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-11-02 17:07:03 +03:00 committed by Alexandre Julliard
parent 41e0a38f7c
commit 99a2514fda
1 changed files with 22 additions and 1 deletions

View File

@ -1317,9 +1317,30 @@ DWORD WINAPI CertGetPublicKeyLength(DWORD dwCertEncodingType,
}
else
{
PCCRYPT_OID_INFO info;
DWORD size;
PBYTE buf;
BOOL ret = CryptDecodeObjectEx(dwCertEncodingType,
BOOL ret;
info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, pPublicKey->Algorithm.pszObjId, 0);
if (info)
{
HCRYPTKEY key;
TRACE("public key algid %#x (%s)\n", info->u.Algid, debugstr_a(pPublicKey->Algorithm.pszObjId));
ret = CryptImportPublicKeyInfo(I_CryptGetDefaultCryptProv(0), dwCertEncodingType, pPublicKey, &key);
if (ret)
{
size = sizeof(len);
ret = CryptGetKeyParam(key, KP_KEYLEN, (BYTE *)&len, &size, 0);
CryptDestroyKey(key);
return len;
}
/* fallback to RSA */
}
ret = CryptDecodeObjectEx(dwCertEncodingType,
RSA_CSP_PUBLICKEYBLOB, pPublicKey->PublicKey.pbData,
pPublicKey->PublicKey.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
&size);