crypt32(16/17): Implement getting bare content for data messages
opened to encode
Juan Lang
juan.lang at gmail.com
Thu Jun 28 19:34:08 CDT 2007
--Juan
-------------- next part --------------
From f6130144db40db2dfaede4a389c8fea2786dddc7 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 28 Jun 2007 17:19:04 -0700
Subject: [PATCH] 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 be0fa08..7a57c62 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -113,14 +113,32 @@ static BOOL CDataEncodeMsg_Update(HCRYPT
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);
}
--
1.4.1
More information about the wine-patches
mailing list