From 190c3518d66df44cfa464d8dc1ca3fd50ff6c361 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 16 Sep 2010 18:48:30 +0400 Subject: [PATCH] crypt32: Initialize HashEncryptionAlgorithm. --- dlls/crypt32/msg.c | 17 +++++++++++++++-- dlls/crypt32/tests/message.c | 12 ------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 886b7245e79..6b2d8b6391d 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -809,9 +809,16 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info, &info->SignerId.u.IssuerSerialNumber.SerialNumber, &in->pCertInfo->SerialNumber); info->SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER; + info->HashEncryptionAlgorithm.pszObjId = + in->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId; + if (ret) + ret = CRYPT_ConstructBlob(&info->HashEncryptionAlgorithm.Parameters, + &in->pCertInfo->SubjectPublicKeyInfo.Algorithm.Parameters); } else { + const CRYPT_ALGORITHM_IDENTIFIER *pEncrAlg; + /* Implicitly in->cbSize == sizeof(CMSG_SIGNER_ENCODE_INFO_WITH_CMS). * See CRYPT_IsValidSigner. */ @@ -845,6 +852,13 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info, ret = CRYPT_ConstructBlob(&info->SignerId.u.KeyId, &in->SignerId.u.KeyId); } + pEncrAlg = in->HashEncryptionAlgorithm.pszObjId ? + &in->HashEncryptionAlgorithm : + &in->pCertInfo->SubjectPublicKeyInfo.Algorithm; + info->HashEncryptionAlgorithm.pszObjId = pEncrAlg->pszObjId; + if (ret) + ret = CRYPT_ConstructBlob(&info->HashEncryptionAlgorithm.Parameters, + &pEncrAlg->Parameters); } /* Assumption: algorithm IDs will point to static strings, not * stack-based ones, so copying the pointer values is safe. @@ -853,8 +867,6 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info, if (ret) ret = CRYPT_ConstructBlob(&info->HashAlgorithm.Parameters, &in->HashAlgorithm.Parameters); - memset(&info->HashEncryptionAlgorithm, 0, - sizeof(info->HashEncryptionAlgorithm)); if (ret) ret = CRYPT_ConstructAttributes(&info->AuthAttrs, (CRYPT_ATTRIBUTES *)&in->cAuthAttr); @@ -876,6 +888,7 @@ static void CSignerInfo_Free(CMSG_CMS_SIGNER_INFO *info) else CryptMemFree(info->SignerId.u.KeyId.pbData); CryptMemFree(info->HashAlgorithm.Parameters.pbData); + CryptMemFree(info->HashEncryptionAlgorithm.Parameters.pbData); CryptMemFree(info->EncryptedHash.pbData); for (i = 0; i < info->AuthAttrs.cAttr; i++) { diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c index 8e214e7802d..f2977cd2911 100644 --- a/dlls/crypt32/tests/message.c +++ b/dlls/crypt32/tests/message.c @@ -1024,10 +1024,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, TRUE, 0, NULL, NULL, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedHashForEmptyMessage), "unexpected size %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedHashForEmptyMessage, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1044,10 +1042,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedEmptyMessage, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1065,10 +1061,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedHash), "unexpected size of signed blob %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedHash, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1089,10 +1083,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedHashWithCert), "unexpected size of signed blob %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedHashWithCert, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1120,10 +1112,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedHashWithCRL), "unexpected size of signed blob %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedHashWithCRL, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); @@ -1145,10 +1135,8 @@ static void test_sign_message(void) ret = CryptSignMessage(¶, FALSE, 1, toSign, signSize, signedBlob, &signedBlobSize); ok(ret, "CryptSignMessage failed: %08x\n", GetLastError()); - todo_wine ok(signedBlobSize == sizeof(signedData), "unexpected size of signed blob %d\n", signedBlobSize); - todo_wine ok(!memcmp(signedBlob, signedData, signedBlobSize), "unexpected value\n"); CryptMemFree(signedBlob); -- 2.11.4.GIT