wintrust: Implement CryptSIPGetSignedDataMsg.

This commit is contained in:
Juan Lang 2007-08-10 10:53:00 -07:00 committed by Alexandre Julliard
parent 3a50b1fea6
commit 25f0fb929d
2 changed files with 63 additions and 2 deletions

View File

@ -5,6 +5,7 @@ VPATH = @srcdir@
MODULE = wintrust.dll
IMPORTLIB = libwintrust.$(IMPLIBEXT)
IMPORTS = crypt32 user32 advapi32 kernel32
DELAYIMPORTS = imagehlp
C_SRCS = \
crypt.c \

View File

@ -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;
}
/***********************************************************************