Commit 6fcca28b authored by Alexander Morozov's avatar Alexander Morozov Committed by Alexandre Julliard

crypt32: Add a stub enveloped message implementation.

parent ec00d6dc
...@@ -1461,6 +1461,101 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, ...@@ -1461,6 +1461,101 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
return msg; 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;
HCRYPTPROV prov;
} CEnvelopedEncodeMsg;
static void CEnvelopedEncodeMsg_Close(HCRYPTMSG hCryptMsg)
{
CEnvelopedEncodeMsg *msg = hCryptMsg;
if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
CryptReleaseContext(msg->prov, 0);
}
static BOOL CEnvelopedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
DWORD dwIndex, void *pvData, DWORD *pcbData)
{
FIXME("(%p, %d, %d, %p, %p): stub\n", hCryptMsg, dwParamType, dwIndex,
pvData, pcbData);
return FALSE;
}
static BOOL CEnvelopedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
DWORD cbData, BOOL fFinal)
{
FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData, fFinal);
return FALSE;
}
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_GetDefaultProvider();
dwFlags &= ~CMSG_CRYPT_RELEASE_CONTEXT_FLAG;
}
msg = CryptMemAlloc(sizeof(CEnvelopedEncodeMsg));
if (msg)
{
CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
CEnvelopedEncodeMsg_Close, CEnvelopedEncodeMsg_GetParam,
CEnvelopedEncodeMsg_Update, CRYPT_DefaultMsgControl);
msg->prov = prov;
}
if (!msg && (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG))
CryptReleaseContext(prov, 0);
return msg;
}
HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, DWORD dwMsgType, const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID,
PCMSG_STREAM_INFO pStreamInfo) PCMSG_STREAM_INFO pStreamInfo)
...@@ -1490,7 +1585,8 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, ...@@ -1490,7 +1585,8 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
pszInnerContentObjID, pStreamInfo); pszInnerContentObjID, pStreamInfo);
break; break;
case CMSG_ENVELOPED: case CMSG_ENVELOPED:
FIXME("unimplemented for type CMSG_ENVELOPED\n"); msg = CEnvelopedEncodeMsg_Open(dwFlags, pvMsgEncodeInfo,
pszInnerContentObjID, pStreamInfo);
break; break;
case CMSG_SIGNED_AND_ENVELOPED: case CMSG_SIGNED_AND_ENVELOPED:
case CMSG_ENCRYPTED: case CMSG_ENCRYPTED:
......
...@@ -2043,7 +2043,6 @@ static void test_enveloped_msg_open(void) ...@@ -2043,7 +2043,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(!msg && GetLastError() == E_INVALIDARG, ok(!msg && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError()); "expected E_INVALIDARG, got %08x\n", GetLastError());
...@@ -2051,7 +2050,6 @@ static void test_enveloped_msg_open(void) ...@@ -2051,7 +2050,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(!msg && ok(!msg &&
(GetLastError() == CRYPT_E_UNKNOWN_ALGO || (GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
GetLastError() == E_INVALIDARG), /* Win9x */ GetLastError() == E_INVALIDARG), /* Win9x */
...@@ -2061,7 +2059,6 @@ static void test_enveloped_msg_open(void) ...@@ -2061,7 +2059,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2073,7 +2070,6 @@ static void test_enveloped_msg_open(void) ...@@ -2073,7 +2070,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(!msg && GetLastError() == E_INVALIDARG, ok(!msg && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError()); "expected E_INVALIDARG, got %08x\n", GetLastError());
} }
...@@ -2086,7 +2082,6 @@ static void test_enveloped_msg_open(void) ...@@ -2086,7 +2082,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
CryptMsgClose(msg); CryptMsgClose(msg);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
...@@ -2096,7 +2091,6 @@ static void test_enveloped_msg_open(void) ...@@ -2096,7 +2091,6 @@ static void test_enveloped_msg_open(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError()); ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
CryptMsgClose(msg); CryptMsgClose(msg);
CryptReleaseContext(envelopedInfo.hCryptProv, 0); CryptReleaseContext(envelopedInfo.hCryptProv, 0);
...@@ -2117,7 +2111,6 @@ static void test_enveloped_msg_update(void) ...@@ -2117,7 +2111,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2142,7 +2135,6 @@ static void test_enveloped_msg_update(void) ...@@ -2142,7 +2135,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2169,7 +2161,6 @@ static void test_enveloped_msg_update(void) ...@@ -2169,7 +2161,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2189,7 +2180,6 @@ static void test_enveloped_msg_update(void) ...@@ -2189,7 +2180,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
CMSG_ENVELOPED, &envelopedInfo, NULL, NULL); CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2211,7 +2201,6 @@ static void test_enveloped_msg_update(void) ...@@ -2211,7 +2201,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, &streamInfo); &envelopedInfo, NULL, &streamInfo);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2230,7 +2219,6 @@ static void test_enveloped_msg_update(void) ...@@ -2230,7 +2219,6 @@ static void test_enveloped_msg_update(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, &streamInfo); &envelopedInfo, NULL, &streamInfo);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
...@@ -2269,15 +2257,16 @@ static void test_enveloped_msg_encoding(void) ...@@ -2269,15 +2257,16 @@ static void test_enveloped_msg_encoding(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
&envelopedInfo, NULL, NULL); &envelopedInfo, NULL, NULL);
todo_wine
ok(msg != NULL || ok(msg != NULL ||
broken(!msg), /* Win9x */ broken(!msg), /* Win9x */
"CryptMsgOpenToEncode failed: %08x\n", GetLastError()); "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
if (msg) if (msg)
{ {
todo_wine
check_param("enveloped empty bare content", msg, check_param("enveloped empty bare content", msg,
CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent, CMSG_BARE_CONTENT_PARAM, envelopedEmptyBareContent,
sizeof(envelopedEmptyBareContent)); sizeof(envelopedEmptyBareContent));
todo_wine
check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM, check_param("enveloped empty content", msg, CMSG_CONTENT_PARAM,
envelopedEmptyContent, sizeof(envelopedEmptyContent)); envelopedEmptyContent, sizeof(envelopedEmptyContent));
CryptMsgClose(msg); CryptMsgClose(msg);
......
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