Commit f8755d84 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

rsaenh: Don't fail on signature verification if the signed hash lacks the OID.

parent 74159467
......@@ -4472,16 +4472,21 @@ BOOL WINAPI RSAENH_CPVerifySignature(HCRYPTPROV hProv, HCRYPTHASH hHash, CONST B
goto cleanup;
}
if (!build_hash_signature(pbConstructed, dwSigLen, aiAlgid, abHashValue, dwHashLen, dwFlags)) {
if (build_hash_signature(pbConstructed, dwSigLen, aiAlgid, abHashValue, dwHashLen, dwFlags) &&
!memcmp(pbDecrypted, pbConstructed, dwSigLen)) {
res = TRUE;
goto cleanup;
}
if (memcmp(pbDecrypted, pbConstructed, dwSigLen)) {
SetLastError(NTE_BAD_SIGNATURE);
if (!(dwFlags & CRYPT_NOHASHOID) &&
build_hash_signature(pbConstructed, dwSigLen, aiAlgid, abHashValue, dwHashLen, dwFlags|CRYPT_NOHASHOID) &&
!memcmp(pbDecrypted, pbConstructed, dwSigLen)) {
res = TRUE;
goto cleanup;
}
res = TRUE;
SetLastError(NTE_BAD_SIGNATURE);
cleanup:
HeapFree(GetProcessHeap(), 0, pbConstructed);
HeapFree(GetProcessHeap(), 0, pbDecrypted);
......
......@@ -1771,15 +1771,14 @@ static void test_verify_signature(void) {
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID);
/* It seems that CPVerifySignature doesn't care about the OID at all. */
result = CryptVerifySignature(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, 0);
ok(result, "%08x\n", GetLastError());
if (!result) return;
/* Next test fails on WinXP SP2. It seems that CPVerifySignature doesn't care about
* the OID at all. */
/*result = CryptVerifySignature(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, 0);
ok(!result && GetLastError()==NTE_BAD_SIGNATURE, "%08lx\n", GetLastError());
if (result) return;*/
result = CryptVerifySignature(hHash, abSignatureMD2NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID);
ok(result, "%08x\n", GetLastError());
if (!result) return;
CryptDestroyHash(hHash);
......@@ -1795,6 +1794,10 @@ static void test_verify_signature(void) {
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureMD4NoOID, 128, hPubSignKey, NULL, 0);
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureMD4NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID);
ok(result, "%08x\n", GetLastError());
if (!result) return;
......@@ -1813,6 +1816,10 @@ static void test_verify_signature(void) {
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureMD5NoOID, 128, hPubSignKey, NULL, 0);
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureMD5NoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID);
ok(result, "%08x\n", GetLastError());
if (!result) return;
......@@ -1831,6 +1838,10 @@ static void test_verify_signature(void) {
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureSHANoOID, 128, hPubSignKey, NULL, 0);
ok(result, "%08x\n", GetLastError());
if (!result) return;
result = CryptVerifySignature(hHash, abSignatureSHANoOID, 128, hPubSignKey, NULL, CRYPT_NOHASHOID);
ok(result, "%08x\n", GetLastError());
if (!result) return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment