Commit 263f424c authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Implement getting bare content for data messages opened to encode.

parent d1f37934
......@@ -112,14 +112,32 @@ static BOOL CDataEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
static BOOL CDataEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
DWORD dwIndex, void *pvData, DWORD *pcbData)
{
CDataEncodeMsg *msg = (CDataEncodeMsg *)hCryptMsg;
BOOL ret = FALSE;
switch (dwParamType)
{
case CMSG_CONTENT_PARAM:
case CMSG_BARE_CONTENT_PARAM:
FIXME("stub\n");
break;
case CMSG_BARE_CONTENT_PARAM:
if (!pvData)
{
*pcbData = msg->bare_content_len;
ret = TRUE;
}
else if (*pcbData < msg->bare_content_len)
{
*pcbData = msg->bare_content_len;
SetLastError(ERROR_MORE_DATA);
}
else
{
*pcbData = msg->bare_content_len;
memcpy(pvData, msg->bare_content, msg->bare_content_len);
ret = TRUE;
}
break;
default:
SetLastError(CRYPT_E_INVALID_MSG_TYPE);
}
......
......@@ -384,12 +384,11 @@ static void test_data_msg_get_param(void)
/* Content and bare content are always gettable */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
todo_wine {
todo_wine
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
size = 0;
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
}
/* But for this type of message, the signer and hash aren't applicable,
* and the type isn't available.
*/
......@@ -425,38 +424,34 @@ static void test_data_msg_encoding(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
NULL);
todo_wine {
check_param("data empty bare content", msg, CMSG_BARE_CONTENT_PARAM,
dataEmptyBareContent, sizeof(dataEmptyBareContent));
todo_wine
check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent,
sizeof(dataEmptyContent));
}
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
todo_wine {
check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM,
dataBareContent, sizeof(dataBareContent));
todo_wine
check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent,
sizeof(dataContent));
}
CryptMsgClose(msg);
/* Same test, but with CMSG_BARE_CONTENT_FLAG set */
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_BARE_CONTENT_FLAG,
CMSG_DATA, NULL, NULL, NULL);
todo_wine {
check_param("data empty bare content", msg, CMSG_BARE_CONTENT_PARAM,
dataEmptyBareContent, sizeof(dataEmptyBareContent));
todo_wine
check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent,
sizeof(dataEmptyContent));
}
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
todo_wine {
check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM,
dataBareContent, sizeof(dataBareContent));
todo_wine
check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent,
sizeof(dataContent));
}
CryptMsgClose(msg);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment