Juan Lang : crypt32: Partially implement updating hash messages.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jul 13 08:30:25 CDT 2007
Module: wine
Branch: master
Commit: 739cc08b3bb95b7f5a320c946f2ecb002e734f36
URL: http://source.winehq.org/git/wine.git/?a=commit;h=739cc08b3bb95b7f5a320c946f2ecb002e734f36
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Jul 12 14:49:23 2007 -0700
crypt32: Partially implement updating hash messages.
---
dlls/crypt32/msg.c | 34 ++++++++++++++++++++++++++++++++--
dlls/crypt32/tests/msg.c | 17 +++++++----------
2 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 2a401b8..dac881c 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -354,8 +354,38 @@ static BOOL CHashEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
static BOOL CHashEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
DWORD cbData, BOOL fFinal)
{
- FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData, fFinal);
- return FALSE;
+ CHashEncodeMsg *msg = (CHashEncodeMsg *)hCryptMsg;
+ 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,
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 3e1ed81..c41a4bf 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -701,25 +701,20 @@ static void test_hash_msg_update(void)
* updates..
*/
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* including non-final updates with no data.. */
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* and final updates with no data. */
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* But no updates are allowed after the final update. */
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
- todo_wine
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
- todo_wine
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
CryptMsgClose(msg);
@@ -730,19 +725,16 @@ static void test_hash_msg_update(void)
NULL, NULL);
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
- todo_wine
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
/* Final updates (including empty ones) are allowed. */
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
CryptMsgClose(msg);
/* And, of course, streaming mode allows non-final updates */
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
NULL, &streamInfo);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
CryptMsgClose(msg);
/* 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,
NULL, &streamInfo);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
- todo_wine
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
CryptMsgClose(msg);
}
@@ -794,7 +785,6 @@ static void test_hash_msg_get_param(void)
/* By getting the hash, further updates are not allowed */
SetLastError(0xdeadbeef);
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
- todo_wine
ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
"Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
/* 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());
if (size == sizeof(buf))
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);
}
More information about the wine-cvs
mailing list