[Wine-devel] Eter's patch is applied to winehq repo 12/08/10
builder на builder.office.etersoft.ru
builder на builder.office.etersoft.ru
Ср Дек 8 20:20:23 MSK 2010
New Etersoft's patches since last build time:
commit 02ab124cd2c602571cf165d751ea96f71c51b605
Author: Alexander Morozov <amorozov на etersoft.ru>
crypt32: Implement CryptEncryptMessage.
---
commit 02ab124cd2c602571cf165d751ea96f71c51b605
Author: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed Dec 8 14:51:42 2010 +0300
crypt32: Implement CryptEncryptMessage.
diff --git a/dlls/crypt32/message.c b/dlls/crypt32/message.c
index 51b874e..e5b6f2a 100644
--- a/dlls/crypt32/message.c
+++ b/dlls/crypt32/message.c
@@ -536,8 +536,61 @@ BOOL WINAPI CryptEncryptMessage(PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptPara,
const BYTE *pbToBeEncrypted, DWORD cbToBeEncrypted, BYTE *pbEncryptedBlob,
DWORD *pcbEncryptedBlob)
{
- FIXME("(%p, %d, %p, %p, %d, %p, %p): stub\n", pEncryptPara, cRecipientCert,
+ BOOL ret = TRUE;
+ DWORD i;
+ PCERT_INFO *certInfo = NULL;
+ CMSG_ENVELOPED_ENCODE_INFO envelopedInfo;
+ HCRYPTMSG msg = 0;
+
+ TRACE("(%p, %d, %p, %p, %d, %p, %p)\n", pEncryptPara, cRecipientCert,
rgpRecipientCert, pbToBeEncrypted, cbToBeEncrypted, pbEncryptedBlob,
pcbEncryptedBlob);
- return FALSE;
+
+ if (pEncryptPara->cbSize != sizeof(CRYPT_ENCRYPT_MESSAGE_PARA) ||
+ GET_CMSG_ENCODING_TYPE(pEncryptPara->dwMsgEncodingType) !=
+ PKCS_7_ASN_ENCODING)
+ {
+ *pcbEncryptedBlob = 0;
+ SetLastError(E_INVALIDARG);
+ return FALSE;
+ }
+
+ memset(&envelopedInfo, 0, sizeof(envelopedInfo));
+ envelopedInfo.cbSize = sizeof(envelopedInfo);
+ envelopedInfo.hCryptProv = pEncryptPara->hCryptProv;
+ envelopedInfo.ContentEncryptionAlgorithm =
+ pEncryptPara->ContentEncryptionAlgorithm;
+ envelopedInfo.pvEncryptionAuxInfo = pEncryptPara->pvEncryptionAuxInfo;
+
+ if (cRecipientCert)
+ {
+ certInfo = CryptMemAlloc(sizeof(PCERT_INFO) * cRecipientCert);
+ if (certInfo)
+ {
+ for (i = 0; i < cRecipientCert; ++i)
+ certInfo[i] = rgpRecipientCert[i]->pCertInfo;
+ envelopedInfo.cRecipients = cRecipientCert;
+ envelopedInfo.rgpRecipientCert = certInfo;
+ }
+ else
+ ret = FALSE;
+ }
+
+ if (ret)
+ msg = CryptMsgOpenToEncode(pEncryptPara->dwMsgEncodingType, 0,
+ CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
+ if (msg)
+ {
+ ret = CryptMsgUpdate(msg, pbToBeEncrypted, cbToBeEncrypted, TRUE);
+ if (ret)
+ ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, pbEncryptedBlob,
+ pcbEncryptedBlob);
+ CryptMsgClose(msg);
+ }
+ else
+ ret = FALSE;
+
+ CryptMemFree(certInfo);
+ if (!ret) *pcbEncryptedBlob = 0;
+ return ret;
}
diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c
index 69049b1..37ae6fd 100644
--- a/dlls/crypt32/tests/message.c
+++ b/dlls/crypt32/tests/message.c
@@ -1225,10 +1225,8 @@ static void test_encrypt_message(void)
encryptedBlobSize = 255;
ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
- todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
- todo_wine
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
para.cbSize = sizeof(para);
para.dwMsgEncodingType = X509_ASN_ENCODING;
@@ -1236,23 +1234,19 @@ static void test_encrypt_message(void)
encryptedBlobSize = 255;
ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
- todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
- todo_wine
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
SetLastError(0xdeadbeef);
encryptedBlobSize = 255;
ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
- todo_wine
ok(!ret &&
(GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
GetLastError() == E_INVALIDARG), /* Win9x */
"expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n",
GetLastError());
- todo_wine
ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
para.hCryptProv = hCryptProv;
@@ -1262,7 +1256,6 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, NULL,
&encryptedBlobSize);
- todo_wine
ok(ret ||
broken(!ret) /* Win9x */,
"CryptEncryptMessage failed: %08x\n", GetLastError());
@@ -1274,9 +1267,7 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(¶, 0, NULL, NULL, 0, encryptedBlob,
&encryptedBlobSize);
- todo_wine
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
- todo_wine
ok(encryptedBlobSize == sizeof(encryptedMessage),
"unexpected size of encrypted blob %d\n", encryptedBlobSize);
ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize),
@@ -1289,7 +1280,6 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(¶, 2, certs, NULL, 0, NULL,
&encryptedBlobSize);
- todo_wine
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
if (ret)
{
@@ -1299,7 +1289,6 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(¶, 2, certs, NULL, 0, encryptedBlob,
&encryptedBlobSize);
- todo_wine
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
CryptMemFree(encryptedBlob);
}
@@ -1309,7 +1298,6 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob), NULL,
&encryptedBlobSize);
- todo_wine
ok(ret ||
broken(!ret) /* Win9x */,
"CryptEncryptMessage failed: %08x\n", GetLastError());
@@ -1321,13 +1309,11 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(¶, 0, NULL, blob, sizeof(blob),
encryptedBlob, &encryptedBlobSize);
- todo_wine
ok(ret ||
broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
"CryptEncryptMessage failed: %08x\n", GetLastError());
if (ret)
{
- todo_wine
ok(encryptedBlobSize == 55,
"unexpected size of encrypted blob %d\n", encryptedBlobSize);
}
@@ -1339,7 +1325,6 @@ static void test_encrypt_message(void)
encryptedBlobSize = 0;
ret = CryptEncryptMessage(¶, 2, certs, blob, sizeof(blob), NULL,
&encryptedBlobSize);
- todo_wine
ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
if (ret)
{
@@ -1349,7 +1334,6 @@ static void test_encrypt_message(void)
SetLastError(0xdeadbeef);
ret = CryptEncryptMessage(¶, 2, certs, blob, sizeof(blob),
encryptedBlob, &encryptedBlobSize);
- todo_wine
ok(ret ||
broken(!ret), /* some Win95 and some NT4 */
"CryptEncryptMessage failed: %08x\n", GetLastError());
Подробная информация о списке рассылки Wine-devel