crypt32: Improve CERT_KEY_IDENTIFIER_PROP_ID support (eterbug #5694).
authorAlexander Morozov <amorozov@etersoft.ru>
Wed, 1 Sep 2010 15:42:25 +0000 (19:42 +0400)
committerAlexander Morozov <amorozov@etersoft.ru>
Wed, 1 Sep 2010 15:42:25 +0000 (19:42 +0400)
dlls/crypt32/cert.c

index 0346e04302320a295761b31af98ad076f8b1e8de..08621b385508c34fc17b4b485e48bf3a83b4f6a4 100644 (file)
@@ -338,7 +338,37 @@ static BOOL CertContext_GetProperty(void *context, DWORD dwPropId,
                 }
             }
             else
-                SetLastError(ERROR_INVALID_DATA);
+            {
+                DWORD size;
+
+                ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT,
+                 pCertContext->pbCertEncoded, pCertContext->cbCertEncoded, 0,
+                 NULL, NULL, &size);
+                if (ret)
+                {
+                    CERT_PUBLIC_KEY_INFO *info =
+                     &pCertContext->pCertInfo->SubjectPublicKeyInfo;
+
+                    ret = CryptEncodeObject(X509_ASN_ENCODING,
+                     X509_PUBLIC_KEY_INFO, info, NULL, &size);
+                    if (ret)
+                    {
+                        PBYTE encoded = CryptMemAlloc(size);
+
+                        if (encoded)
+                        {
+                            ret = CryptEncodeObject(X509_ASN_ENCODING,
+                             X509_PUBLIC_KEY_INFO, info, encoded, &size);
+                            if (ret)
+                                ret = CertContext_GetHashProp(context, dwPropId,
+                                 CALG_SHA1, encoded, size, pvData, pcbData);
+                            CryptMemFree(encoded);
+                        }
+                    }
+                }
+                else
+                    SetLastError(ERROR_INVALID_DATA);
+            }
             break;
         }
         default: