Module: wine Branch: master Commit: 656d960dd4b01e1ef1f293e1214f8b1629c7c2e6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=656d960dd4b01e1ef1f293e121...
Author: Juan Lang juan.lang@gmail.com Date: Mon Jul 9 11:20:34 2007 -0700
crypt32: Add a stub decode message implementation.
---
dlls/crypt32/msg.c | 43 +++++++++++++++++++++++++++++++++++++++++-- dlls/crypt32/tests/msg.c | 15 +++++---------- 2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 7c7a8e0..dbe14b5 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -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) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 2b0bc18..be1963e 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -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); }