Module: wine Branch: master Commit: 25f0fb929d8c0fc0bd045906b988079111961572 URL: http://source.winehq.org/git/wine.git/?a=commit;h=25f0fb929d8c0fc0bd045906b9...
Author: Juan Lang juan.lang@gmail.com Date: Fri Aug 10 10:53:00 2007 -0700
wintrust: 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 "wintrust.h" #include "mscat.h" #include "mssip.h" +#include "imagehlp.h"
#include "wine/debug.h"
@@ -200,10 +201,69 @@ BOOL WINAPI CryptSIPCreateIndirectData(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pcb 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; }
/***********************************************************************