diff --git a/dlls/crypt32/message.c b/dlls/crypt32/message.c index 5440a4cff5..b4198662c6 100644 --- a/dlls/crypt32/message.c +++ b/dlls/crypt32/message.c @@ -323,8 +323,40 @@ BOOL WINAPI CryptVerifyMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara, BYTE *pbHashedBlob, DWORD cbHashedBlob, BYTE *pbToBeHashed, DWORD *pcbToBeHashed, BYTE *pbComputedHash, DWORD *pcbComputedHash) { - FIXME("(%p, %p, %d, %p, %p, %p, %p): stub\n", pHashPara, pbHashedBlob, + HCRYPTMSG msg; + BOOL ret = FALSE; + + TRACE("(%p, %p, %d, %p, %p, %p, %p)\n", pHashPara, pbHashedBlob, cbHashedBlob, pbToBeHashed, pcbToBeHashed, pbComputedHash, pcbComputedHash); - return FALSE; + + if (pHashPara->cbSize != sizeof(CRYPT_HASH_MESSAGE_PARA)) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (GET_CMSG_ENCODING_TYPE(pHashPara->dwMsgEncodingType) != + PKCS_7_ASN_ENCODING) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + msg = CryptMsgOpenToDecode(pHashPara->dwMsgEncodingType, 0, 0, + pHashPara->hCryptProv, NULL, NULL); + if (msg) + { + ret = CryptMsgUpdate(msg, pbHashedBlob, cbHashedBlob, TRUE); + if (ret) + { + ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL); + if (ret && pcbToBeHashed) + ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, + pbToBeHashed, pcbToBeHashed); + if (ret && pcbComputedHash) + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, + pbComputedHash, pcbComputedHash); + } + CryptMsgClose(msg); + } + return ret; } diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c index e1d7cf071a..271bc2d341 100644 --- a/dlls/crypt32/tests/message.c +++ b/dlls/crypt32/tests/message.c @@ -210,19 +210,16 @@ static void test_verify_message_hash(void) ret = CryptVerifyMessageHash(NULL, NULL, 0, NULL, NULL, NULL, NULL); SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); para.dwMsgEncodingType = PKCS_7_ASN_ENCODING; SetLastError(0xdeadbeef); ret = CryptVerifyMessageHash(¶, NULL, 0, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); /* Verifying the hash of a detached message succeeds? */ @@ -233,11 +230,9 @@ static void test_verify_message_hash(void) /* As does verifying the hash of a regular message. */ ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), NULL, NULL, NULL, NULL); - todo_wine ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); ret = CryptVerifyMessageHash(¶, hashContent, sizeof(hashContent), NULL, &size, NULL, NULL); - todo_wine ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError()); if (ret) buf = CryptMemAlloc(size);