Juan Lang : crypt32: Implement getting the type of a decode message.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jul 10 08:02:39 CDT 2007
Module: wine
Branch: master
Commit: 8ca755915b6f677d51837b5e00658617474bd68e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8ca755915b6f677d51837b5e00658617474bd68e
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Jul 9 11:22:08 2007 -0700
crypt32: 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 hCryptMsg, const BYTE *pbData,
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 be1963e..80ba79c 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);
}
More information about the wine-cvs
mailing list