crypt32(3/3): Implement querying computed hash of a decoded hash
message (try 2)
Juan Lang
juan.lang at gmail.com
Thu Jul 19 09:34:16 CDT 2007
--Juan
-------------- next part --------------
From 7c31734a2da7640b77525baf7cbe75d2e2dfbf31 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 19 Jul 2007 07:32:10 -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 0ecc62b..04be05e 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1224,7 +1224,6 @@ static void test_decode_msg_get_param(vo
ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0);
check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0);
- todo_wine
check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
emptyHashParam, sizeof(emptyHashParam));
CryptMsgClose(msg);
@@ -1234,7 +1233,6 @@ static void test_decode_msg_get_param(vo
sizeof(msgData));
check_param("hash hash data", msg, CMSG_HASH_DATA_PARAM, hashParam,
sizeof(hashParam));
- 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