Juan Lang : crypt32:
Implement getting bare content for data messages opened to encode.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jun 29 08:14:41 CDT 2007
Module: wine
Branch: master
Commit: 263f424c3b27a99553d7d564b9032db17018dd2e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=263f424c3b27a99553d7d564b9032db17018dd2e
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Jun 28 17:19:04 2007 -0700
crypt32: Implement getting bare content for data messages opened to encode.
---
dlls/crypt32/msg.c | 20 +++++++++++++++++++-
dlls/crypt32/tests/msg.c | 15 +++++----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index e392b79..c92d6ef 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -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);
}
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 47e353a..da534da 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -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);
}
More information about the wine-cvs
mailing list