From 7e10d48c60a36dd266ef3e00f8ee8981278a13c7 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 30 Jul 2007 12:06:23 -0700 Subject: [PATCH] crypt32: Implement getting the signer cert info from a decoded signed message. --- dlls/crypt32/msg.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index aca6a03f2cc..7e5a08060c7 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -1697,6 +1697,38 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData, return ret; } +static BOOL CRYPT_CopySignerCertInfo(void *pvData, DWORD *pcbData, + const CMSG_SIGNER_INFO *in) +{ + DWORD size = sizeof(CERT_INFO); + BOOL ret; + + size += in->Issuer.cbData; + size += in->SerialNumber.cbData; + if (!pvData) + { + *pcbData = size; + ret = TRUE; + } + else if (*pcbData < size) + { + *pcbData = size; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + LPBYTE nextData = (BYTE *)pvData + sizeof(CERT_INFO); + CERT_INFO *out = (CERT_INFO *)pvData; + + memset(out, 0, sizeof(CERT_INFO)); + CRYPT_CopyBlob(&out->Issuer, &in->Issuer, &nextData); + CRYPT_CopyBlob(&out->SerialNumber, &in->SerialNumber, &nextData); + ret = TRUE; + } + return ret; +} + static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData) { @@ -1747,6 +1779,18 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, else SetLastError(CRYPT_E_INVALID_MSG_TYPE); break; + case CMSG_SIGNER_CERT_INFO_PARAM: + if (msg->u.signedInfo) + { + if (dwIndex >= msg->u.signedInfo->cSignerInfo) + SetLastError(CRYPT_E_INVALID_INDEX); + else + ret = CRYPT_CopySignerCertInfo(pvData, pcbData, + &msg->u.signedInfo->rgSignerInfo[dwIndex]); + } + else + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + break; case CMSG_CERT_COUNT_PARAM: if (msg->u.signedInfo) ret = CRYPT_CopyParam(pvData, pcbData,