crypt32: Add support for enveloped messages (eterbug #5694).
authorAlexander Morozov <amorozov@etersoft.ru>
Fri, 6 Aug 2010 13:24:25 +0000 (17:24 +0400)
committerAlexander Morozov <amorozov@etersoft.ru>
Tue, 17 Aug 2010 14:42:41 +0000 (18:42 +0400)
dlls/crypt32/crypt32_private.h
dlls/crypt32/encode.c
dlls/crypt32/msg.c
dlls/crypt32/tests/message.c
dlls/crypt32/tests/msg.c

index 6616132b1dc90907d7e73eb21058dbc518707b24..533aaf6faad5ae082fce1d2d4d96efd9203b2751 100644 (file)
@@ -82,6 +82,24 @@ typedef struct _CRYPT_DIGESTED_DATA
 BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
  void *pvData, DWORD *pcbData);
 
+typedef struct _CRYPT_ENCRYPTED_CONTENT_INFO
+{
+    LPSTR                      contentType;
+    CRYPT_ALGORITHM_IDENTIFIER contentEncryptionAlgorithm;
+    CRYPT_DATA_BLOB            encryptedContent;
+} CRYPT_ENCRYPTED_CONTENT_INFO;
+
+typedef struct _CRYPT_ENVELOPED_DATA
+{
+    DWORD                          version;
+    DWORD                          cRecipientInfo;
+    PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo;
+    CRYPT_ENCRYPTED_CONTENT_INFO   encryptedContentInfo;
+} CRYPT_ENVELOPED_DATA;
+
+BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
+ void *pvData, DWORD *pcbData);
+
 typedef struct _CRYPT_SIGNED_INFO
 {
     DWORD                 version;
index 4c961c3996eb4a838b498b4d5ad7692c9eda7fe5..7eb24e7c79f7b2f2a8097aa602546985535e01c0 100644 (file)
@@ -4293,6 +4293,61 @@ BOOL CRYPT_AsnEncodeCMSSignedInfo(CRYPT_SIGNED_INFO *signedInfo, void *pvData,
     return ret;
 }
 
+static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo(DWORD dwCertEncodingType,
+ LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
+ PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
+{
+    const CMSG_KEY_TRANS_RECIPIENT_INFO *info = pvStructInfo;
+    struct AsnEncodeSequenceItem items[] = {
+     { &info->dwVersion, CRYPT_AsnEncodeInt, 0 },
+     { &info->RecipientId.u.IssuerSerialNumber,
+       CRYPT_AsnEncodeIssuerSerialNumber, 0 },
+     { &info->KeyEncryptionAlgorithm,
+       CRYPT_AsnEncodeAlgorithmIdWithNullParams, 0 },
+     { &info->EncryptedKey, CRYPT_AsnEncodeOctets, 0 },
+    };
+
+    return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
+     sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+     pcbEncoded);
+}
+
+static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType,
+ LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
+ PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
+{
+    const CRYPT_ENCRYPTED_CONTENT_INFO *info = pvStructInfo;
+    struct AsnEncodeTagSwappedItem swapped = { ASN_CONTEXT | 0,
+     &info->encryptedContent, CRYPT_AsnEncodeOctets };
+    struct AsnEncodeSequenceItem items[] = {
+     { info->contentType, CRYPT_AsnEncodeOid, 0 },
+     { &info->contentEncryptionAlgorithm,
+       CRYPT_AsnEncodeAlgorithmIdWithNullParams, 0 },
+     { &swapped, CRYPT_AsnEncodeSwapTag, 0 },
+    };
+
+    return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
+     sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+     pcbEncoded);
+}
+
+BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
+ void *pvData, DWORD *pcbData)
+{
+    struct DERSetDescriptor recipientInfosSet = { envelopedData->cRecipientInfo,
+     envelopedData->rgRecipientInfo, sizeof(CMSG_KEY_TRANS_RECIPIENT_INFO), 0,
+     CRYPT_AsnEncodeRecipientInfo };
+    struct AsnEncodeSequenceItem items[] = {
+     { &envelopedData->version, CRYPT_AsnEncodeInt, 0 },
+     { &recipientInfosSet, CRYPT_DEREncodeItemsAsSet, 0 },
+     { &envelopedData->encryptedContentInfo,
+       CRYPT_AsnEncodeEncryptedContentInfo, 0 },
+    };
+
+    return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
+     sizeof(items) / sizeof(items[0]), 0, NULL, pvData, pcbData);
+}
+
 static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
  LPCSTR lpszStructType)
 {
index d68ca6e3b980cbc80190f56ad53e66c665ddb4fd..7d19f4049ca2850b09c5b1d685703773fb1d4c2b 100644 (file)
@@ -1474,6 +1474,332 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
     return msg;
 }
 
+typedef struct _CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS
+{
+    DWORD                       cbSize;
+    HCRYPTPROV_LEGACY           hCryptProv;
+    CRYPT_ALGORITHM_IDENTIFIER  ContentEncryptionAlgorithm;
+    void                       *pvEncryptionAuxInfo;
+    DWORD                       cRecipients;
+    PCERT_INFO                 *rgpRecipientCert;
+    PCMSG_RECIPIENT_ENCODE_INFO rgCmsRecipients;
+    DWORD                       cCertEncoded;
+    PCERT_BLOB                  rgCertEncoded;
+    DWORD                       cCrlEncoded;
+    PCRL_BLOB                   rgCrlEncoded;
+    DWORD                       cAttrCertEncoded;
+    PCERT_BLOB                  rgAttrCertEncoded;
+    DWORD                       cUnprotectedAttr;
+    PCRYPT_ATTRIBUTE            rgUnprotectedAttr;
+} CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS, *PCMSG_ENVELOPED_ENCODE_INFO_WITH_CMS;
+
+typedef struct _CEnvelopedEncodeMsg
+{
+    CryptMsgBase                   base;
+    CRYPT_ALGORITHM_IDENTIFIER     algo;
+    HCRYPTPROV                     prov;
+    HCRYPTKEY                      key;
+    DWORD                          cRecipientInfo;
+    CMSG_KEY_TRANS_RECIPIENT_INFO *recipientInfo;
+    CRYPT_DATA_BLOB                data;
+} CEnvelopedEncodeMsg;
+
+static BOOL CRYPT_ConstructAlgorithmId(CRYPT_ALGORITHM_IDENTIFIER *out,
+ const CRYPT_ALGORITHM_IDENTIFIER *in)
+{
+    out->pszObjId = CryptMemAlloc(strlen(in->pszObjId) + 1);
+    if (out->pszObjId)
+    {
+        strcpy(out->pszObjId, in->pszObjId);
+        return CRYPT_ConstructBlob(&out->Parameters, &in->Parameters);
+    }
+    else
+        return FALSE;
+}
+
+static BOOL CRecipientInfo_Construct(CMSG_KEY_TRANS_RECIPIENT_INFO *info,
+ const CERT_INFO *cert, HCRYPTPROV prov, HCRYPTKEY key)
+{
+    HCRYPTKEY expKey;
+    BOOL ret = TRUE;
+
+    info->dwVersion = CMSG_KEY_TRANS_PKCS_1_5_VERSION;
+    info->RecipientId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
+    ret = CRYPT_ConstructBlob(&info->RecipientId.u.IssuerSerialNumber.Issuer,
+     &cert->Issuer);
+    if (ret)
+        ret = CRYPT_ConstructBlob(
+         &info->RecipientId.u.IssuerSerialNumber.SerialNumber,
+         &cert->SerialNumber);
+    if (ret)
+        ret = CRYPT_ConstructAlgorithmId(&info->KeyEncryptionAlgorithm,
+         &cert->SubjectPublicKeyInfo.Algorithm);
+    info->EncryptedKey.cbData = 0;
+    info->EncryptedKey.pbData = NULL;
+
+    if (ret)
+        ret = CryptImportPublicKeyInfo(prov, X509_ASN_ENCODING,
+         (PCERT_PUBLIC_KEY_INFO)&cert->SubjectPublicKeyInfo, &expKey);
+    if (ret)
+    {
+        BYTE *keyBlob;
+        DWORD size;
+
+        ret = CryptExportKey(key, expKey, SIMPLEBLOB, 0, NULL, &size);
+        keyBlob = CryptMemAlloc(size);
+        if (keyBlob)
+        {
+            ret = CryptExportKey(key, expKey, SIMPLEBLOB, 0, keyBlob, &size);
+            if (ret)
+            {
+                DWORD head = sizeof(BLOBHEADER) + sizeof(ALG_ID);
+
+                info->EncryptedKey.pbData = CryptMemAlloc(size - head);
+                if (info->EncryptedKey.pbData)
+                {
+                    DWORD i, k = 0;
+
+                    info->EncryptedKey.cbData = size - head;
+                    for (i = size - 1; i >= head; --i, ++k)
+                        info->EncryptedKey.pbData[k] = keyBlob[i];
+                }
+                else
+                    ret = FALSE;
+            }
+            CryptMemFree(keyBlob);
+        }
+        else
+            ret = FALSE;
+        CryptDestroyKey(expKey);
+    }
+    return ret;
+}
+
+static void CRecipientInfo_Free(CMSG_KEY_TRANS_RECIPIENT_INFO *info)
+{
+    CryptMemFree(info->RecipientId.u.IssuerSerialNumber.Issuer.pbData);
+    CryptMemFree(info->RecipientId.u.IssuerSerialNumber.SerialNumber.pbData);
+    CryptMemFree(info->KeyEncryptionAlgorithm.pszObjId);
+    CryptMemFree(info->KeyEncryptionAlgorithm.Parameters.pbData);
+    CryptMemFree(info->EncryptedKey.pbData);
+}
+
+static void CEnvelopedEncodeMsg_Close(HCRYPTMSG hCryptMsg)
+{
+    CEnvelopedEncodeMsg *msg = hCryptMsg;
+
+    CryptMemFree(msg->algo.pszObjId);
+    CryptMemFree(msg->algo.Parameters.pbData);
+    if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
+        CryptReleaseContext(msg->prov, 0);
+    CryptDestroyKey(msg->key);
+    if (msg->recipientInfo)
+    {
+        DWORD i;
+
+        for (i = 0; i < msg->cRecipientInfo; ++i)
+            CRecipientInfo_Free(&msg->recipientInfo[i]);
+        CryptMemFree(msg->recipientInfo);
+    }
+    CryptMemFree(msg->data.pbData);
+}
+
+static BOOL CEnvelopedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
+ DWORD dwIndex, void *pvData, DWORD *pcbData)
+{
+    CEnvelopedEncodeMsg *msg = hCryptMsg;
+    BOOL ret = FALSE;
+
+    switch (dwParamType)
+    {
+    case CMSG_BARE_CONTENT_PARAM:
+        if (msg->base.streamed)
+            SetLastError(E_INVALIDARG);
+        else
+        {
+            char oid_rsa_data[] = szOID_RSA_data;
+            CRYPT_ENVELOPED_DATA envelopedData = {
+             CMSG_ENVELOPED_DATA_PKCS_1_5_VERSION, msg->cRecipientInfo,
+             msg->recipientInfo, { oid_rsa_data, msg->algo, msg->data }
+            };
+
+            ret = CRYPT_AsnEncodePKCSEnvelopedData(&envelopedData, pvData,
+             pcbData);
+        }
+        break;
+    case CMSG_CONTENT_PARAM:
+    {
+        CRYPT_CONTENT_INFO info;
+
+        ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0, NULL,
+         &info.Content.cbData);
+        if (ret)
+        {
+            info.Content.pbData = CryptMemAlloc(info.Content.cbData);
+            if (info.Content.pbData)
+            {
+                ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0,
+                 info.Content.pbData, &info.Content.cbData);
+                if (ret)
+                {
+                    char oid_rsa_enveloped[] = szOID_RSA_envelopedData;
+
+                    info.pszObjId = oid_rsa_enveloped;
+                    ret = CryptEncodeObjectEx(X509_ASN_ENCODING,
+                     PKCS_CONTENT_INFO, &info, 0, NULL, pvData, pcbData);
+                }
+                CryptMemFree(info.Content.pbData);
+            }
+            else
+                ret = FALSE;
+        }
+        break;
+    }
+    default:
+        SetLastError(CRYPT_E_INVALID_MSG_TYPE);
+    }
+    return ret;
+}
+
+static BOOL CEnvelopedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
+ DWORD cbData, BOOL fFinal)
+{
+    CEnvelopedEncodeMsg *msg = hCryptMsg;
+    BOOL ret = FALSE;
+
+    if (msg->base.state == MsgStateFinalized)
+        SetLastError(CRYPT_E_MSG_ERROR);
+    else if (msg->base.streamed)
+    {
+        FIXME("streamed stub\n");
+        msg->base.state = fFinal ? MsgStateFinalized : MsgStateUpdated;
+        ret = TRUE;
+    }
+    else
+    {
+        if (!fFinal)
+        {
+            if (msg->base.open_flags & CMSG_DETACHED_FLAG)
+                SetLastError(E_INVALIDARG);
+            else
+                SetLastError(CRYPT_E_MSG_ERROR);
+        }
+        else
+        {
+            if (cbData)
+            {
+                DWORD dataLen = cbData;
+
+                msg->data.cbData = cbData;
+                msg->data.pbData = CryptMemAlloc(cbData);
+                if (msg->data.pbData)
+                {
+                    memcpy(msg->data.pbData, pbData, cbData);
+                    ret = CryptEncrypt(msg->key, 0, TRUE, 0, msg->data.pbData,
+                     &dataLen, msg->data.cbData);
+                    msg->data.cbData = dataLen;
+                    if (dataLen > cbData)
+                    {
+                        msg->data.pbData = CryptMemRealloc(msg->data.pbData,
+                         dataLen);
+                        if (msg->data.pbData)
+                        {
+                            dataLen = cbData;
+                            ret = CryptEncrypt(msg->key, 0, TRUE, 0,
+                             msg->data.pbData, &dataLen, msg->data.cbData);
+                        }
+                        else
+                            ret = FALSE;
+                    }
+                    if (!ret)
+                        CryptMemFree(msg->data.pbData);
+                }
+                else
+                    ret = FALSE;
+                if (!ret)
+                {
+                    msg->data.cbData = 0;
+                    msg->data.pbData = NULL;
+                }
+            }
+            else
+                ret = TRUE;
+            msg->base.state = MsgStateFinalized;
+        }
+    }
+    return ret;
+}
+
+static HCRYPTMSG CEnvelopedEncodeMsg_Open(DWORD dwFlags,
+ const void *pvMsgEncodeInfo, LPCSTR pszInnerContentObjID,
+ PCMSG_STREAM_INFO pStreamInfo)
+{
+    CEnvelopedEncodeMsg *msg;
+    const CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS *info = pvMsgEncodeInfo;
+    HCRYPTPROV prov;
+    ALG_ID algID;
+
+    if (info->cbSize != sizeof(CMSG_ENVELOPED_ENCODE_INFO) &&
+     info->cbSize != sizeof(CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS))
+    {
+        SetLastError(E_INVALIDARG);
+        return NULL;
+    }
+    if (info->cbSize == sizeof(CMSG_ENVELOPED_ENCODE_INFO_WITH_CMS))
+        FIXME("CMS fields unsupported\n");
+    if (!(algID = CertOIDToAlgId(info->ContentEncryptionAlgorithm.pszObjId)))
+    {
+        SetLastError(CRYPT_E_UNKNOWN_ALGO);
+        return NULL;
+    }
+    if (info->cRecipients && !info->rgpRecipientCert)
+    {
+        SetLastError(E_INVALIDARG);
+        return NULL;
+    }
+    if (info->hCryptProv)
+        prov = info->hCryptProv;
+    else
+    {
+        prov = CRYPT_GetProvForAlgId(algID);
+        if (!prov) return NULL;
+        dwFlags |= CMSG_CRYPT_RELEASE_CONTEXT_FLAG;
+    }
+    msg = CryptMemAlloc(sizeof(CEnvelopedEncodeMsg));
+    if (msg)
+    {
+        BOOL ret;
+        DWORD i;
+
+        CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
+         CEnvelopedEncodeMsg_Close, CEnvelopedEncodeMsg_GetParam,
+         CEnvelopedEncodeMsg_Update, CRYPT_DefaultMsgControl);
+        ret = CRYPT_ConstructAlgorithmId(&msg->algo,
+         &info->ContentEncryptionAlgorithm);
+        msg->prov = prov;
+        msg->data.cbData = 0;
+        msg->data.pbData = NULL;
+        msg->cRecipientInfo = info->cRecipients;
+        msg->recipientInfo = CryptMemAlloc(info->cRecipients *
+         sizeof(CMSG_KEY_TRANS_RECIPIENT_INFO));
+        if (!msg->recipientInfo)
+            ret = FALSE;
+        if (ret)
+            ret = CryptGenKey(prov, algID, CRYPT_EXPORTABLE, &msg->key);
+        for (i = 0; ret && i < msg->cRecipientInfo; ++i)
+            ret = CRecipientInfo_Construct(&msg->recipientInfo[i],
+             info->rgpRecipientCert[i], prov, msg->key);
+        if (!ret)
+        {
+            CryptMsgClose(msg);
+            msg = NULL;
+        }
+    }
+    if (!msg && (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG))
+        CryptReleaseContext(prov, 0);
+    return msg;
+}
+
 HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
  DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID,
  PCMSG_STREAM_INFO pStreamInfo)
@@ -1503,7 +1829,8 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
          pszInnerContentObjID, pStreamInfo);
         break;
     case CMSG_ENVELOPED:
-        FIXME("unimplemented for type CMSG_ENVELOPED\n");
+        msg = CEnvelopedEncodeMsg_Open(dwFlags, pvMsgEncodeInfo,
+         pszInnerContentObjID, pStreamInfo);
         break;
     case CMSG_SIGNED_AND_ENVELOPED:
     case CMSG_ENCRYPTED:
index 4a667442d44a9318546b9a6f006afd773913ea79..ca62a908444ef8e8a2f5172bb8666d8e8a66f67b 100644 (file)
@@ -1209,7 +1209,6 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 255;
     ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
      &encryptedBlobSize);
-    todo_wine
     ok(!ret && GetLastError() == CRYPT_E_UNKNOWN_ALGO,
      "expected CRYPT_E_UNKNOWN_ALGO, got %08x\n", GetLastError());
     ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
@@ -1221,9 +1220,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
      &encryptedBlobSize);
-    todo_wine
     ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
-    todo_wine
     ok(encryptedBlobSize == sizeof(encryptedMessage),
      "unexpected size of encrypted blob %d\n", encryptedBlobSize);
     encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1232,7 +1229,6 @@ static void test_encrypt_message(void)
         SetLastError(0xdeadbeef);
         ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, encryptedBlob,
          &encryptedBlobSize);
-        todo_wine
         ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
         ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize),
          "unexpected value\n");
@@ -1243,9 +1239,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, NULL,
      &encryptedBlobSize);
-    todo_wine
     ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
-    todo_wine
     ok(encryptedBlobSize == 431, "unexpected size of encrypted blob %d\n",
      encryptedBlobSize);
     encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1254,7 +1248,6 @@ static void test_encrypt_message(void)
         SetLastError(0xdeadbeef);
         ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, encryptedBlob,
          &encryptedBlobSize);
-        todo_wine
         ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
         CryptMemFree(encryptedBlob);
     }
@@ -1263,9 +1256,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 0, NULL, blob, sizeof(blob), NULL,
      &encryptedBlobSize);
-    todo_wine
     ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
-    todo_wine
     ok(encryptedBlobSize == 55, "unexpected size of encrypted blob %d\n",
      encryptedBlobSize);
     encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1274,7 +1265,6 @@ static void test_encrypt_message(void)
         SetLastError(0xdeadbeef);
         ret = CryptEncryptMessage(&para, 0, NULL, blob, sizeof(blob),
          encryptedBlob, &encryptedBlobSize);
-        todo_wine
         ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
         CryptMemFree(encryptedBlob);
     }
@@ -1283,9 +1273,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 2, certs, blob, sizeof(blob), NULL,
      &encryptedBlobSize);
-    todo_wine
     ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
-    todo_wine
     ok(encryptedBlobSize == 435, "unexpected size of encrypted blob %d\n",
      encryptedBlobSize);
     encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1294,7 +1282,6 @@ static void test_encrypt_message(void)
         SetLastError(0xdeadbeef);
         ret = CryptEncryptMessage(&para, 2, certs, blob, sizeof(blob),
          encryptedBlob, &encryptedBlobSize);
-        todo_wine
         ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
         CryptMemFree(encryptedBlob);
     }
index 31cbe0813646535e4cffd7734bf89ffd844c22f9..bf9380b4fe7d885b2b1afa64db055f34628de03f 100644 (file)
@@ -2043,7 +2043,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(!msg && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
 
@@ -2051,7 +2050,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO,
      "expected CRYPT_E_UNKNOWN_ALGO, got %08x\n", GetLastError());
 
@@ -2059,7 +2057,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     CryptMsgClose(msg);
 
@@ -2067,7 +2064,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(!msg && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
 
@@ -2080,7 +2076,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     CryptMsgClose(msg);
 
@@ -2091,7 +2086,6 @@ static void test_enveloped_msg_open(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     CryptMsgClose(msg);
 
@@ -2110,22 +2104,18 @@ static void test_enveloped_msg_update(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-        todo_wine
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
          "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        todo_wine
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
          "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
         CryptMsgClose(msg);
@@ -2133,22 +2123,18 @@ static void test_enveloped_msg_update(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-        todo_wine
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
          "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        todo_wine
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
          "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
         CryptMsgClose(msg);
@@ -2156,70 +2142,58 @@ static void test_enveloped_msg_update(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-        todo_wine
         ok(!ret && GetLastError() == E_INVALIDARG,
          "expected E_INVALIDARG, got %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-        todo_wine
         ok(!ret && GetLastError() == E_INVALIDARG,
          "expected E_INVALIDARG, got %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, &streamInfo);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, &streamInfo);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-        todo_wine
         ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
         CryptMsgClose(msg);
     }
@@ -2244,7 +2218,6 @@ static void test_enveloped_msg_encoding(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
-    todo_wine
     ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
     if (msg)
     {