crypt32(3/3): Implement querying computed hash of a decoded hash
message
Juan Lang
juan.lang at gmail.com
Wed Jul 18 12:15:26 CDT 2007
--Juan
-------------- next part --------------
From e6fa69837e83cb26694b382e68d5a5b69e3498d9 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Wed, 18 Jul 2007 09:51:15 -0700
Subject: [PATCH] Implement querying computed hash of a decoded hash message
---
dlls/crypt32/msg.c | 34 ++++++++++++++++++++++++++++++++++
dlls/crypt32/tests/msg.c | 2 --
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 7565741..c3d7b96 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -594,6 +594,7 @@ typedef struct _CDecodeMsg
CryptMsgBase base;
DWORD type;
HCRYPTPROV crypt_prov;
+ HCRYPTHASH hash;
CRYPT_DATA_BLOB msg_data;
PCONTEXT_PROPERTY_LIST properties;
} CDecodeMsg;
@@ -604,6 +605,7 @@ static void CDecodeMsg_Close(HCRYPTMSG h
if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
CryptReleaseContext(msg->crypt_prov, 0);
+ CryptDestroyHash(msg->hash);
CryptMemFree(msg->msg_data.pbData);
ContextPropertyList_Free(msg->properties);
}
@@ -835,6 +837,37 @@ static BOOL CDecodeMsg_GetParam(HCRYPTMS
SetLastError(CRYPT_E_INVALID_MSG_TYPE);
break;
}
+ case CMSG_COMPUTED_HASH_PARAM:
+ if (!msg->hash)
+ {
+ CRYPT_ALGORITHM_IDENTIFIER *hashAlgoID = NULL;
+ DWORD size = 0;
+ ALG_ID algID = 0;
+
+ CryptMsgGetParam(msg, CMSG_HASH_ALGORITHM_PARAM, 0, NULL, &size);
+ hashAlgoID = CryptMemAlloc(size);
+ ret = CryptMsgGetParam(msg, CMSG_HASH_ALGORITHM_PARAM, 0,
+ hashAlgoID, &size);
+ if (ret)
+ algID = CertOIDToAlgId(hashAlgoID->pszObjId);
+ ret = CryptCreateHash(msg->crypt_prov, algID, 0, 0, &msg->hash);
+ if (ret)
+ {
+ CRYPT_DATA_BLOB content;
+
+ ret = ContextPropertyList_FindProperty(msg->properties,
+ CMSG_CONTENT_PARAM, &content);
+ if (ret)
+ ret = CryptHashData(msg->hash, content.pbData,
+ content.cbData, 0);
+ }
+ CryptMemFree(hashAlgoID);
+ }
+ else
+ ret = TRUE;
+ if (ret)
+ ret = CryptGetHashParam(msg->hash, HP_HASHVAL, pvData, pcbData, 0);
+ break;
default:
{
CRYPT_DATA_BLOB blob;
@@ -877,6 +910,7 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DW
msg->crypt_prov = CRYPT_GetDefaultProvider();
msg->base.open_flags &= ~CMSG_CRYPT_RELEASE_CONTEXT_FLAG;
}
+ msg->hash = 0;
msg->msg_data.cbData = 0;
msg->msg_data.pbData = NULL;
msg->properties = ContextPropertyList_Create();
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 4a42bbd..086c16e 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1258,7 +1258,6 @@ static void test_decode_msg_get_param(vo
check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0);
check_algid_param("empty hash hash algo id", msg, CMSG_HASH_ALGORITHM_PARAM,
&hashID);
- todo_wine
check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
emptyHashParam, sizeof(emptyHashParam));
CryptMsgClose(msg);
@@ -1270,7 +1269,6 @@ static void test_decode_msg_get_param(vo
sizeof(hashParam));
check_algid_param("hash hash algo id", msg, CMSG_HASH_ALGORITHM_PARAM,
&hashID);
- todo_wine
check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
hashParam, sizeof(hashParam));
size = strlen(szOID_RSA_data) + 1;
--
1.4.1
More information about the wine-patches
mailing list