crypt32: Implement querying computed hash of a decoded hash message.
This commit is contained in:
parent
22e7c2f38e
commit
74bd61203d
|
@ -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 hCryptMsg)
|
|||
|
||||
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(HCRYPTMSG hCryptMsg, DWORD dwParamType,
|
|||
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(DWORD dwMsgEncodingType, DWORD dwFlags,
|
|||
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();
|
||||
|
|
|
@ -1224,7 +1224,6 @@ static void test_decode_msg_get_param(void)
|
|||
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(void)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue