crypt32: Add a mostly stub control function for decode messages.

This commit is contained in:
Juan Lang 2007-08-20 17:33:04 -07:00 committed by Alexandre Julliard
parent 31c414f4b4
commit 163e8d6256
2 changed files with 42 additions and 9 deletions

View File

@ -1926,6 +1926,47 @@ static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
return ret; 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, HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo,
PCMSG_STREAM_INFO pStreamInfo) PCMSG_STREAM_INFO pStreamInfo)
@ -1945,7 +1986,7 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
{ {
CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
CDecodeMsg_Close, CDecodeMsg_GetParam, CDecodeMsg_Update, CDecodeMsg_Close, CDecodeMsg_GetParam, CDecodeMsg_Update,
CRYPT_DefaultMsgControl); CDecodeMsg_Control);
msg->type = dwMsgType; msg->type = dwMsgType;
if (hCryptProv) if (hCryptProv)
msg->crypt_prov = hCryptProv; msg->crypt_prov = hCryptProv;

View File

@ -2197,18 +2197,15 @@ static void test_msg_control(void)
/* Bad control type */ /* Bad control type */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, 0, NULL); ret = CryptMsgControl(msg, 0, 0, NULL);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE,
"Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 1, 0, NULL); ret = CryptMsgControl(msg, 1, 0, NULL);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE, ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE,
"Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError());
/* Can't verify the hash of an indeterminate-type message */ /* Can't verify the hash of an indeterminate-type message */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
/* Crashes /* Crashes
@ -2216,7 +2213,6 @@ static void test_msg_control(void)
*/ */
/* Can't decrypt an indeterminate-type message */ /* Can't decrypt an indeterminate-type message */
ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
CryptMsgClose(msg); CryptMsgClose(msg);
@ -2234,7 +2230,6 @@ static void test_msg_control(void)
*/ */
/* Can't verify the signature of a hash message */ /* Can't verify the signature of a hash message */
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent), CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent),
@ -2252,7 +2247,6 @@ static void test_msg_control(void)
/* Can't decrypt an indeterminate-type message */ /* Can't decrypt an indeterminate-type message */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
CryptMsgClose(msg); CryptMsgClose(msg);
@ -2262,13 +2256,11 @@ static void test_msg_control(void)
/* Can't verify the hash of a signed message */ /* Can't verify the hash of a signed message */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
/* Can't decrypt a signed message */ /* Can't decrypt a signed message */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara); ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError()); "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
/* Crash /* Crash