crypt32(8/10): Implement getting the type of a decode message
Juan Lang
juan.lang at gmail.com
Mon Jul 9 13:52:04 CDT 2007
--Juan
-------------- next part --------------
From 4c1acb17dbefc535bd3c7dc9ba3ac3fad5086cdc Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Mon, 9 Jul 2007 11:22:08 -0700
Subject: [PATCH] Implement getting the type of a decode message
---
dlls/crypt32/msg.c | 31 ++++++++++++++++++++++++++++---
dlls/crypt32/tests/msg.c | 14 --------------
2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index dbe14b5..63f6671 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -269,9 +269,34 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG
static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
DWORD dwIndex, void *pvData, DWORD *pcbData)
{
- FIXME("(%p, %d, %d, %p, %p): stub\n", hCryptMsg, dwParamType, dwIndex,
- pvData, pcbData);
- return FALSE;
+ CDecodeMsg *msg = (CDecodeMsg *)hCryptMsg;
+ BOOL ret = FALSE;
+
+ switch (dwParamType)
+ {
+ case CMSG_TYPE_PARAM:
+ if (!pvData)
+ {
+ *pcbData = sizeof(DWORD);
+ ret = TRUE;
+ }
+ else if (*pcbData < sizeof(DWORD))
+ {
+ *pcbData = sizeof(DWORD);
+ SetLastError(ERROR_MORE_DATA);
+ }
+ else
+ {
+ *pcbData = sizeof(DWORD);
+ *(DWORD *)pvData = msg->type;
+ ret = TRUE;
+ }
+ break;
+ default:
+ FIXME("unimplemented for parameter %d\n", dwParamType);
+ SetLastError(CRYPT_E_INVALID_MSG_TYPE);
+ }
+ return ret;
}
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 76fa9cb..966c330 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -155,14 +155,12 @@ static void test_msg_get_param(void)
/* For decoded messages, the type is always available */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
/* For this (empty) message, the type isn't set */
ok(value == 0, "Expected type 0, got %d\n", value);
- }
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
@@ -171,10 +169,8 @@ static void test_msg_get_param(void)
/* For explicitly typed messages, the type is known. */
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_DATA, "Expected CMSG_DATA, got %d\n", value);
- }
for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++)
{
size = 0;
@@ -188,10 +184,8 @@ static void test_msg_get_param(void)
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value);
- }
for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++)
{
size = 0;
@@ -205,10 +199,8 @@ static void test_msg_get_param(void)
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value);
- }
for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++)
{
size = 0;
@@ -222,10 +214,8 @@ static void test_msg_get_param(void)
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value);
- }
for (i = CMSG_CONTENT_PARAM; i <= CMSG_CMS_SIGNER_INFO_PARAM; i++)
{
size = 0;
@@ -240,20 +230,16 @@ static void test_msg_get_param(void)
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value);
- }
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
- todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == 1000, "Expected 1000, got %d\n", value);
- }
CryptMsgClose(msg);
}
--
1.4.1
More information about the wine-patches
mailing list