Commit 656d960d authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Add a stub decode message implementation.

parent e557d363
......@@ -244,11 +244,43 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags,
return msg;
}
typedef struct _CDecodeMsg
{
CryptMsgBase base;
DWORD type;
HCRYPTPROV crypt_prov;
} CDecodeMsg;
static void CDecodeMsg_Close(HCRYPTMSG hCryptMsg)
{
CDecodeMsg *msg = (CDecodeMsg *)hCryptMsg;
if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
CryptReleaseContext(msg->crypt_prov, 0);
}
static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
DWORD cbData, BOOL fFinal)
{
FIXME("(%p, %p, %d, %d): stub\n", hCryptMsg, pbData, cbData, fFinal);
return FALSE;
}
static BOOL CDecodeMsg_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;
}
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
DWORD dwMsgType, HCRYPTPROV hCryptProv, PCERT_INFO pRecipientInfo,
PCMSG_STREAM_INFO pStreamInfo)
{
FIXME("(%08x, %08x, %08x, %08lx, %p, %p): stub\n", dwMsgEncodingType,
CDecodeMsg *msg;
TRACE("(%08x, %08x, %08x, %08lx, %p, %p)\n", dwMsgEncodingType,
dwFlags, dwMsgType, hCryptProv, pRecipientInfo, pStreamInfo);
if (GET_CMSG_ENCODING_TYPE(dwMsgEncodingType) != PKCS_7_ASN_ENCODING)
......@@ -256,7 +288,14 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
SetLastError(E_INVALIDARG);
return NULL;
}
return NULL;
msg = CryptMemAlloc(sizeof(CDecodeMsg));
if (msg)
{
CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
CDecodeMsg_Close, CDecodeMsg_GetParam, CDecodeMsg_Update);
msg->type = dwMsgType;
}
return msg;
}
HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg)
......
......@@ -95,7 +95,6 @@ static void test_msg_open_to_decode(void)
/* The message type can be explicit... */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
......@@ -125,7 +124,6 @@ static void test_msg_open_to_decode(void)
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
}
CryptMsgClose(msg);
/* And even though the stream info parameter "must be set to NULL" for
......@@ -133,7 +131,6 @@ static void test_msg_open_to_decode(void)
*/
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
&streamInfo);
todo_wine
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
CryptMsgClose(msg);
}
......@@ -154,7 +151,6 @@ static void test_msg_get_param(void)
/* Decoded messages */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
todo_wine
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
/* For decoded messages, the type is always available */
size = 0;
......@@ -171,7 +167,6 @@ static void test_msg_get_param(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
NULL);
todo_wine
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
/* For explicitly typed messages, the type is known. */
size = sizeof(value);
......@@ -190,10 +185,10 @@ static void test_msg_get_param(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value);
}
......@@ -207,10 +202,10 @@ static void test_msg_get_param(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value);
}
......@@ -224,10 +219,10 @@ static void test_msg_get_param(void)
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value);
}
......@@ -242,20 +237,20 @@ static void test_msg_get_param(void)
/* Explicitly typed messages get their types set, even if they're invalid */
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL,
NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value);
}
CryptMsgClose(msg);
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL);
todo_wine {
ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
size = sizeof(value);
ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, (LPBYTE)&value, &size);
todo_wine {
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ok(value == 1000, "Expected 1000, got %d\n", value);
}
......
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