crypt32: Use signed message data type for decoded signed messages.

This commit is contained in:
Juan Lang 2007-08-20 17:42:31 -07:00 committed by Alexandre Julliard
parent 7748905743
commit 5e9299d980
1 changed files with 37 additions and 35 deletions

View File

@ -1278,8 +1278,8 @@ typedef struct _CDecodeMsg
DWORD type; DWORD type;
HCRYPTPROV crypt_prov; HCRYPTPROV crypt_prov;
union { union {
HCRYPTHASH hash; HCRYPTHASH hash;
CRYPT_SIGNED_INFO *signedInfo; CSignedMsgData signed_data;
} u; } u;
CRYPT_DATA_BLOB msg_data; CRYPT_DATA_BLOB msg_data;
PCONTEXT_PROPERTY_LIST properties; PCONTEXT_PROPERTY_LIST properties;
@ -1298,7 +1298,8 @@ static void CDecodeMsg_Close(HCRYPTMSG hCryptMsg)
CryptDestroyHash(msg->u.hash); CryptDestroyHash(msg->u.hash);
break; break;
case CMSG_SIGNED: case CMSG_SIGNED:
LocalFree(msg->u.signedInfo); if (msg->u.signed_data.info)
LocalFree(msg->u.signed_data.info);
break; break;
} }
CryptMemFree(msg->msg_data.pbData); CryptMemFree(msg->msg_data.pbData);
@ -1433,7 +1434,7 @@ static BOOL CDecodeMsg_DecodeSignedContent(CDecodeMsg *msg,
CRYPT_DECODE_ALLOC_FLAG, NULL, (CRYPT_SIGNED_INFO *)&signedInfo, CRYPT_DECODE_ALLOC_FLAG, NULL, (CRYPT_SIGNED_INFO *)&signedInfo,
&size); &size);
if (ret) if (ret)
msg->u.signedInfo = signedInfo; msg->u.signed_data.info = signedInfo;
return ret; return ret;
} }
/* Decodes the content in blob as the type given, and updates the value /* Decodes the content in blob as the type given, and updates the value
@ -1778,16 +1779,17 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType,
ret = CRYPT_CopyParam(pvData, pcbData, &msg->type, sizeof(msg->type)); ret = CRYPT_CopyParam(pvData, pcbData, &msg->type, sizeof(msg->type));
break; break;
case CMSG_CONTENT_PARAM: case CMSG_CONTENT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
if (!strcmp(msg->u.signedInfo->content.pszObjId, szOID_RSA_data)) if (!strcmp(msg->u.signed_data.info->content.pszObjId,
szOID_RSA_data))
{ {
CRYPT_DATA_BLOB *blob; CRYPT_DATA_BLOB *blob;
DWORD size; DWORD size;
ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING,
msg->u.signedInfo->content.Content.pbData, msg->u.signed_data.info->content.Content.pbData,
msg->u.signedInfo->content.Content.cbData, msg->u.signed_data.info->content.Content.cbData,
CRYPT_DECODE_ALLOC_FLAG, NULL, (LPBYTE)&blob, &size); CRYPT_DECODE_ALLOC_FLAG, NULL, (LPBYTE)&blob, &size);
if (ret) if (ret)
{ {
@ -1798,93 +1800,93 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType,
} }
else else
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
msg->u.signedInfo->content.Content.pbData, msg->u.signed_data.info->content.Content.pbData,
msg->u.signedInfo->content.Content.cbData); msg->u.signed_data.info->content.Content.cbData);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_INNER_CONTENT_TYPE_PARAM: case CMSG_INNER_CONTENT_TYPE_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
msg->u.signedInfo->content.pszObjId, msg->u.signed_data.info->content.pszObjId,
strlen(msg->u.signedInfo->content.pszObjId) + 1); strlen(msg->u.signed_data.info->content.pszObjId) + 1);
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_SIGNER_COUNT_PARAM: case CMSG_SIGNER_COUNT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
&msg->u.signedInfo->cSignerInfo, sizeof(DWORD)); &msg->u.signed_data.info->cSignerInfo, sizeof(DWORD));
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_SIGNER_INFO_PARAM: case CMSG_SIGNER_INFO_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
if (dwIndex >= msg->u.signedInfo->cSignerInfo) if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
ret = CRYPT_CopySignerInfo(pvData, pcbData, ret = CRYPT_CopySignerInfo(pvData, pcbData,
&msg->u.signedInfo->rgSignerInfo[dwIndex]); &msg->u.signed_data.info->rgSignerInfo[dwIndex]);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_SIGNER_CERT_INFO_PARAM: case CMSG_SIGNER_CERT_INFO_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
if (dwIndex >= msg->u.signedInfo->cSignerInfo) if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
ret = CRYPT_CopySignerCertInfo(pvData, pcbData, ret = CRYPT_CopySignerCertInfo(pvData, pcbData,
&msg->u.signedInfo->rgSignerInfo[dwIndex]); &msg->u.signed_data.info->rgSignerInfo[dwIndex]);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_CERT_COUNT_PARAM: case CMSG_CERT_COUNT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
&msg->u.signedInfo->cCertEncoded, sizeof(DWORD)); &msg->u.signed_data.info->cCertEncoded, sizeof(DWORD));
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_CERT_PARAM: case CMSG_CERT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
if (dwIndex >= msg->u.signedInfo->cCertEncoded) if (dwIndex >= msg->u.signed_data.info->cCertEncoded)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
msg->u.signedInfo->rgCertEncoded[dwIndex].pbData, msg->u.signed_data.info->rgCertEncoded[dwIndex].pbData,
msg->u.signedInfo->rgCertEncoded[dwIndex].cbData); msg->u.signed_data.info->rgCertEncoded[dwIndex].cbData);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_CRL_COUNT_PARAM: case CMSG_CRL_COUNT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
&msg->u.signedInfo->cCrlEncoded, sizeof(DWORD)); &msg->u.signed_data.info->cCrlEncoded, sizeof(DWORD));
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_CRL_PARAM: case CMSG_CRL_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
if (dwIndex >= msg->u.signedInfo->cCrlEncoded) if (dwIndex >= msg->u.signed_data.info->cCrlEncoded)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
ret = CRYPT_CopyParam(pvData, pcbData, ret = CRYPT_CopyParam(pvData, pcbData,
msg->u.signedInfo->rgCrlEncoded[dwIndex].pbData, msg->u.signed_data.info->rgCrlEncoded[dwIndex].pbData,
msg->u.signedInfo->rgCrlEncoded[dwIndex].cbData); msg->u.signed_data.info->rgCrlEncoded[dwIndex].cbData);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_ATTR_CERT_COUNT_PARAM: case CMSG_ATTR_CERT_COUNT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
{ {
DWORD attrCertCount = 0; DWORD attrCertCount = 0;
@ -1895,7 +1897,7 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType,
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break; break;
case CMSG_ATTR_CERT_PARAM: case CMSG_ATTR_CERT_PARAM:
if (msg->u.signedInfo) if (msg->u.signed_data.info)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);