From 163e8d6256224fa4e6bc65a3f7ddc434b97bfdf8 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 20 Aug 2007 17:33:04 -0700 Subject: [PATCH] crypt32: Add a mostly stub control function for decode messages. --- dlls/crypt32/msg.c | 43 +++++++++++++++++++++++++++++++++++++++- dlls/crypt32/tests/msg.c | 8 -------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 02377b6592d..79c8f9b1a3a 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -1926,6 +1926,47 @@ static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, return ret; } +static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags, + DWORD dwCtrlType, const void *pvCtrlPara) +{ + CDecodeMsg *msg = (CDecodeMsg *)hCryptMsg; + BOOL ret = FALSE; + + switch (dwCtrlType) + { + case CMSG_CTRL_VERIFY_SIGNATURE: + switch (msg->type) + { + case CMSG_SIGNED: + FIXME("CMSG_CTRL_VERIFY_SIGNATURE: stub\n"); + break; + default: + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + } + break; + case CMSG_CTRL_DECRYPT: + switch (msg->type) + { + default: + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + } + break; + case CMSG_CTRL_VERIFY_HASH: + switch (msg->type) + { + case CMSG_HASHED: + FIXME("CMSG_CTRL_VERIFY_HASH: stub\n"); + break; + default: + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + } + break; + default: + SetLastError(CRYPT_E_CONTROL_TYPE); + } + return ret; +} + HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo) @@ -1945,7 +1986,7 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, { CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, CDecodeMsg_Close, CDecodeMsg_GetParam, CDecodeMsg_Update, - CRYPT_DefaultMsgControl); + CDecodeMsg_Control); msg->type = dwMsgType; if (hCryptProv) msg->crypt_prov = hCryptProv; diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 729aee63716..e705824a643 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -2197,18 +2197,15 @@ static void test_msg_control(void) /* Bad control type */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, 0, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 1, 0, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); /* Can't verify the hash of an indeterminate-type message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); /* Crashes @@ -2216,7 +2213,6 @@ static void test_msg_control(void) */ /* Can't decrypt an indeterminate-type message */ ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); CryptMsgClose(msg); @@ -2234,7 +2230,6 @@ static void test_msg_control(void) */ /* Can't verify the signature of a hash message */ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), @@ -2252,7 +2247,6 @@ static void test_msg_control(void) /* Can't decrypt an indeterminate-type message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); CryptMsgClose(msg); @@ -2262,13 +2256,11 @@ static void test_msg_control(void) /* Can't verify the hash of a signed message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); /* Can't decrypt a signed message */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); - todo_wine ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); /* Crash