crypt32(5/21): Add a couple tests that show you can't get the hash
from an encoded hash message, and fix encoded hash messages to match
Juan Lang
juan.lang at gmail.com
Tue Aug 21 09:22:04 CDT 2007
--Juan
-------------- next part --------------
From c4a4641c81cc4681333d0af136c50b6b07da93a9 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Mon, 20 Aug 2007 17:33:44 -0700
Subject: [PATCH] Add a couple tests that show you can't get the hash from an encoded hash
message, and fix encoded hash messages to match
---
dlls/crypt32/msg.c | 2 +-
dlls/crypt32/tests/msg.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 79c8f9b..036f2f7 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -464,7 +464,7 @@ static BOOL CHashEncodeMsg_GetParam(HCRY
}
break;
default:
- ret = FALSE;
+ SetLastError(CRYPT_E_INVALID_MSG_TYPE);
}
return ret;
}
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index e705824..b373470 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -788,6 +788,11 @@ static void test_hash_msg_get_param(void
size = 0;
ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+ /* For an encoded hash message, the hash data aren't available */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
+ ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
+ "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
/* The hash is also available. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
@@ -801,6 +806,11 @@ static void test_hash_msg_get_param(void
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
"Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
+ /* Even after a final update, the hash data aren't available */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
+ ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
+ "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
/* The version is also available, and should be zero for this message. */
size = 0;
ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size);
--
1.4.1
More information about the wine-patches
mailing list