Commit 07297ea9 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32/tests: In more recent Windows versions, updating a data message with no content succeeds.

parent 14626a78
...@@ -365,6 +365,8 @@ static BOOL WINAPI nop_stream_output(const void *pvArg, BYTE *pb, DWORD cb, ...@@ -365,6 +365,8 @@ static BOOL WINAPI nop_stream_output(const void *pvArg, BYTE *pb, DWORD cb,
return TRUE; return TRUE;
} }
static const BYTE dataEmptyBareContent[] = { 0x04,0x00 };
static void test_data_msg_update(void) static void test_data_msg_update(void)
{ {
HCRYPTMSG msg; HCRYPTMSG msg;
...@@ -390,20 +392,36 @@ static void test_data_msg_update(void) ...@@ -390,20 +392,36 @@ static void test_data_msg_update(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
NULL); NULL);
/* Can't update a message with no data */ /* Starting with Vista, can update a message with no data. */
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, NULL, 0, TRUE); ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
/* This test returns FALSE on XP and earlier but TRUE on Vista, so can't be tested. todo_wine
* GetLastError is either E_INVALIDARG (NT) or unset (9x/Vista), so it doesn't ok(ret || broken(!ret), "CryptMsgUpdate failed: %08x\n", GetLastError());
* make sense to test this. if (ret)
*/ {
DWORD size;
/* Curiously, a valid update will now fail as well, presumably because of ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
* the last (invalid, but final) update. ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
*/ if (ret)
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); {
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, LPBYTE buf = CryptMemAlloc(size);
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
if (buf)
{
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, buf,
&size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
if (ret)
{
ok(size == sizeof(dataEmptyBareContent),
"unexpected size %d\n", size);
ok(!memcmp(buf, dataEmptyBareContent, size),
"unexpected value\n");
}
CryptMemFree(buf);
}
}
}
CryptMsgClose(msg); CryptMsgClose(msg);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
...@@ -510,7 +528,6 @@ static void test_data_msg_get_param(void) ...@@ -510,7 +528,6 @@ static void test_data_msg_get_param(void)
CryptMsgClose(msg); CryptMsgClose(msg);
} }
static const BYTE dataEmptyBareContent[] = { 0x04,0x00 };
static const BYTE dataEmptyContent[] = { static const BYTE dataEmptyContent[] = {
0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x02, 0x30,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x02,
0x04,0x00 }; 0x04,0x00 };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment