[Wine-patches] [eter-1.0.12 2/3] crypt32: Add support for CryptDllConvertPublicKeyInfo (eterbug #5665).
Alexander Morozov
amorozov на etersoft.ru
Чт Июн 24 17:50:39 MSD 2010
----------- следующая часть -----------
From eed7d0147fc6950727208d4a4425af7b906fbca9 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 23 Jun 2010 14:39:01 +0400
Subject: [eter-1.0.12 2/3] crypt32: Add support for CryptDllConvertPublicKeyInfo (eterbug #5665).
---
dlls/crypt32/encode.c | 37 ++++++++++++++++++++++++++++++++-----
include/wincrypt.h | 1 +
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index 14d193f..be51384 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -4682,13 +4682,18 @@ typedef BOOL (WINAPI *ImportPublicKeyInfoExFunc)(HCRYPTPROV hCryptProv,
DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg,
DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey);
+typedef BOOL (WINAPI *ConvertPublicKeyInfoFunc)(DWORD dwCertEncodingType,
+ PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags,
+ BYTE **ppbData, DWORD *dwDataLen);
+
BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv,
DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg,
DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
{
- static HCRYPTOIDFUNCSET set = NULL;
- BOOL ret;
+ static HCRYPTOIDFUNCSET set = NULL, convSet = NULL;
+ BOOL ret = FALSE;
ImportPublicKeyInfoExFunc importFunc = NULL;
+ ConvertPublicKeyInfoFunc convertFunc = NULL;
HCRYPTOIDFUNCADDR hFunc = NULL;
TRACE_(crypt)("(%08lx, %08x, %p, %08x, %08x, %p, %p)\n", hCryptProv,
@@ -4699,9 +4704,31 @@ BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv,
CryptGetOIDFunctionAddress(set, dwCertEncodingType,
pInfo->Algorithm.pszObjId, 0, (void **)&importFunc, &hFunc);
if (!importFunc)
- importFunc = CRYPT_ImportRsaPublicKeyInfoEx;
- ret = importFunc(hCryptProv, dwCertEncodingType, pInfo, aiKeyAlg, dwFlags,
- pvAuxInfo, phKey);
+ {
+ if (!convSet)
+ convSet = CryptInitOIDFunctionSet(
+ CRYPT_OID_CONVERT_PUBLIC_KEY_INFO_FUNC, 0);
+ CryptGetOIDFunctionAddress(convSet, dwCertEncodingType,
+ pInfo->Algorithm.pszObjId, 0, (void **)&convertFunc, &hFunc);
+ if (!convertFunc)
+ importFunc = CRYPT_ImportRsaPublicKeyInfoEx;
+ }
+ if (importFunc)
+ ret = importFunc(hCryptProv, dwCertEncodingType, pInfo, aiKeyAlg,
+ dwFlags, pvAuxInfo, phKey);
+ if (convertFunc)
+ {
+ LPBYTE pubKey = NULL;
+ DWORD pubKeySize = 0;
+
+ ret = convertFunc(dwCertEncodingType, pInfo, aiKeyAlg, dwFlags, &pubKey,
+ &pubKeySize);
+ if (ret)
+ {
+ ret = CryptImportKey(hCryptProv, pubKey, pubKeySize, 0, 0, phKey);
+ CryptMemFree(pubKey);
+ }
+ }
if (hFunc)
CryptFreeOIDFunctionAddress(hFunc, 0);
return ret;
diff --git a/include/wincrypt.h b/include/wincrypt.h
index 75017fe..3d9cb05 100644
--- a/include/wincrypt.h
+++ b/include/wincrypt.h
@@ -2258,6 +2258,7 @@ static const WCHAR CERT_TRUST_PUB_AUTHENTICODE_FLAGS_VALUE_NAME[] =
#define CRYPT_OID_IMPORT_PRIVATE_KEY_INFO_FUNC "CryptDllImportPrivateKeyInfoEx"
#define CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC \
"CertDllVerifyCertificateChainPolicy"
+#define CRYPT_OID_CONVERT_PUBLIC_KEY_INFO_FUNC "CryptDllConvertPublicKeyInfo"
#define URL_OID_GET_OBJECT_URL_FUNC "UrlDllGetObjectUrl"
#define TIME_VALID_OID_GET_OBJECT_FUNC "TimeValidDllGetObject"
--
1.6.5.8
Подробная информация о списке рассылки Wine-patches