From 263f424c3b27a99553d7d564b9032db17018dd2e Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 28 Jun 2007 17:19:04 -0700 Subject: [PATCH] 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 e392b79cfe6..c92d6efa6f9 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 47e353a5c93..da534dadf56 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); }