mirror of
https://github.com/reactos/wine.git
synced 2024-12-01 15:40:43 +00:00
crypt32: Partially implement updating hash messages.
This commit is contained in:
parent
5cb26d8e58
commit
739cc08b3b
@ -354,8 +354,38 @@ static BOOL CHashEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
|
|||||||
static BOOL CHashEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
|
static BOOL CHashEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
|
||||||
DWORD cbData, BOOL fFinal)
|
DWORD cbData, BOOL fFinal)
|
||||||
{
|
{
|
||||||
FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData, fFinal);
|
CHashEncodeMsg *msg = (CHashEncodeMsg *)hCryptMsg;
|
||||||
return FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
TRACE("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal);
|
||||||
|
|
||||||
|
if (msg->base.finalized)
|
||||||
|
SetLastError(CRYPT_E_MSG_ERROR);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fFinal)
|
||||||
|
msg->base.finalized = TRUE;
|
||||||
|
if (msg->base.streamed)
|
||||||
|
{
|
||||||
|
/* Doesn't do anything, as stream output is never called, and you
|
||||||
|
* can't get the content.
|
||||||
|
*/
|
||||||
|
ret = CryptHashData(msg->hash, pbData, cbData, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(msg->base.open_flags & CMSG_DETACHED_FLAG) && !fFinal)
|
||||||
|
SetLastError(CRYPT_E_MSG_ERROR);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = CryptHashData(msg->hash, pbData, cbData, 0);
|
||||||
|
/* Still a stub, as content isn't modified */
|
||||||
|
FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData,
|
||||||
|
fFinal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HCRYPTMSG CHashEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo,
|
static HCRYPTMSG CHashEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo,
|
||||||
|
@ -701,25 +701,20 @@ static void test_hash_msg_update(void)
|
|||||||
* updates..
|
* updates..
|
||||||
*/
|
*/
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
/* including non-final updates with no data.. */
|
/* including non-final updates with no data.. */
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
/* and final updates with no data. */
|
/* and final updates with no data. */
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
/* But no updates are allowed after the final update. */
|
/* But no updates are allowed after the final update. */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
||||||
todo_wine
|
|
||||||
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
||||||
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
||||||
todo_wine
|
|
||||||
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
||||||
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
@ -730,19 +725,16 @@ static void test_hash_msg_update(void)
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
todo_wine
|
|
||||||
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
||||||
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
||||||
/* Final updates (including empty ones) are allowed. */
|
/* Final updates (including empty ones) are allowed. */
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
/* And, of course, streaming mode allows non-final updates */
|
/* And, of course, streaming mode allows non-final updates */
|
||||||
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
|
||||||
NULL, &streamInfo);
|
NULL, &streamInfo);
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
/* Setting pfnStreamOutput to NULL results in no error. (In what appears
|
/* Setting pfnStreamOutput to NULL results in no error. (In what appears
|
||||||
@ -752,7 +744,6 @@ static void test_hash_msg_update(void)
|
|||||||
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
|
||||||
NULL, &streamInfo);
|
NULL, &streamInfo);
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
}
|
}
|
||||||
@ -794,7 +785,6 @@ static void test_hash_msg_get_param(void)
|
|||||||
/* By getting the hash, further updates are not allowed */
|
/* By getting the hash, further updates are not allowed */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
|
||||||
todo_wine
|
|
||||||
ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
|
ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
|
||||||
"Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
|
"Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
|
||||||
/* The version is also available, and should be zero for this message. */
|
/* The version is also available, and should be zero for this message. */
|
||||||
@ -837,6 +827,13 @@ static void test_hash_msg_get_param(void)
|
|||||||
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
|
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
|
||||||
if (size == sizeof(buf))
|
if (size == sizeof(buf))
|
||||||
ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n");
|
ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n");
|
||||||
|
/* After updating the hash, further updates aren't allowed on streamed
|
||||||
|
* messages either.
|
||||||
|
*/
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
|
||||||
|
ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
|
||||||
|
"Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user