wintrust(1/7): Implement CryptSIPGetSignedDataMsg
Juan Lang
juan.lang at gmail.com
Fri Aug 10 16:40:01 CDT 2007
--Juan
-------------- next part --------------
From da66e3a148d1c54e1534a55fca503e4915f37b2d Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Fri, 10 Aug 2007 10:53:00 -0700
Subject: [PATCH] Implement CryptSIPGetSignedDataMsg
---
dlls/wintrust/Makefile.in | 1 +
dlls/wintrust/crypt.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/dlls/wintrust/Makefile.in b/dlls/wintrust/Makefile.in
index d547dc4..720cd33 100644
--- a/dlls/wintrust/Makefile.in
+++ b/dlls/wintrust/Makefile.in
@@ -5,6 +5,7 @@ VPATH = @srcdir@
MODULE = wintrust.dll
IMPORTLIB = libwintrust.$(IMPLIBEXT)
IMPORTS = crypt32 user32 advapi32 kernel32
+DELAYIMPORTS = imagehlp
C_SRCS = \
crypt.c \
diff --git a/dlls/wintrust/crypt.c b/dlls/wintrust/crypt.c
index bb473f1..119052b 100644
--- a/dlls/wintrust/crypt.c
+++ b/dlls/wintrust/crypt.c
@@ -25,6 +25,7 @@ #include "winbase.h"
#include "wintrust.h"
#include "mscat.h"
#include "mssip.h"
+#include "imagehlp.h"
#include "wine/debug.h"
@@ -200,10 +201,69 @@ BOOL WINAPI CryptSIPCreateIndirectData(S
BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pdwEncodingType,
DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
{
- FIXME("(%p %p %d %p %p) stub\n", pSubjectInfo, pdwEncodingType, dwIndex,
+ BOOL ret;
+ WIN_CERTIFICATE *pCert = NULL;
+
+ TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
pcbSignedDataMsg, pbSignedDataMsg);
- return FALSE;
+ if (!pbSignedDataMsg)
+ {
+ WIN_CERTIFICATE cert;
+
+ /* app hasn't passed buffer, just get the length */
+ ret = ImageGetCertificateHeader(pSubjectInfo->hFile, dwIndex, &cert);
+ if (ret)
+ *pcbSignedDataMsg = cert.dwLength;
+ }
+ else
+ {
+ DWORD len;
+
+ ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, NULL, &len);
+ if (!ret)
+ goto error;
+ pCert = HeapAlloc(GetProcessHeap(), 0, len);
+ if (!pCert)
+ {
+ ret = FALSE;
+ goto error;
+ }
+ ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, pCert,
+ &len);
+ if (!ret)
+ goto error;
+ if (!pbSignedDataMsg)
+ *pcbSignedDataMsg = pCert->dwLength;
+ else if (*pcbSignedDataMsg < pCert->dwLength)
+ {
+ *pcbSignedDataMsg = pCert->dwLength;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ ret = FALSE;
+ }
+ else
+ {
+ memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
+ switch (pCert->wCertificateType)
+ {
+ case WIN_CERT_TYPE_X509:
+ *pdwEncodingType = X509_ASN_ENCODING;
+ break;
+ case WIN_CERT_TYPE_PKCS_SIGNED_DATA:
+ *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
+ break;
+ default:
+ FIXME("don't know what to do for encoding type %d\n",
+ pCert->wCertificateType);
+ *pdwEncodingType = 0;
+ }
+ }
+ }
+
+error:
+ HeapFree(GetProcessHeap(), 0, pCert);
+ TRACE("returning %d\n", ret);
+ return ret;
}
/***********************************************************************
--
1.4.1
More information about the wine-patches
mailing list