Alexander Morozov : crypt32: Initialize HashEncryptionAlgorithm.

Alexandre Julliard julliard at winehq.org
Thu Sep 16 14:09:08 CDT 2010


Module: wine
Branch: master
Commit: 190c3518d66df44cfa464d8dc1ca3fd50ff6c361
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=190c3518d66df44cfa464d8dc1ca3fd50ff6c361

Author: Alexander Morozov <amorozov at etersoft.ru>
Date:   Thu Sep 16 18:48:30 2010 +0400

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 886b724..6b2d8b6 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 8e214e7..f2977cd 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(&para, 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(&para, 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(&para, 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(&para, 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(&para, 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(&para, 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);




More information about the wine-cvs mailing list