winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2007
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
957 discussions
Start a n
N
ew thread
Juan Lang : crypt32: Implement getting a hash message's hash value.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: bb1246a51c5c8509ebfbcca324b7ad907739a67f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bb1246a51c5c8509ebfbcca32…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:44:59 2007 -0700 crypt32: Implement getting a hash message's hash value. --- dlls/crypt32/msg.c | 18 ++++++++++++++++-- dlls/crypt32/tests/msg.c | 41 ++++------------------------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 1918713..2a401b8 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -332,9 +332,23 @@ static void CHashEncodeMsg_Close(HCRYPTMSG hCryptMsg) static BOOL CHashEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData) { - FIXME("(%p, %d, %d, %p, %p): stub\n", hCryptMsg, dwParamType, dwIndex, + CHashEncodeMsg *msg = (CHashEncodeMsg *)hCryptMsg; + BOOL ret = FALSE; + + TRACE("(%p, %d, %d, %p, %p)\n", hCryptMsg, dwParamType, dwIndex, pvData, pcbData); - return FALSE; + + switch (dwParamType) + { + case CMSG_COMPUTED_HASH_PARAM: + ret = CryptGetHashParam(msg->hash, HP_HASHVAL, (BYTE *)pvData, pcbData, + 0); + break; + default: + FIXME("%d: stub\n", dwParamType); + ret = FALSE; + } + return ret; } static BOOL CHashEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 7f03516..96e901b 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -776,24 +776,22 @@ static void test_hash_msg_get_param(void) /* The hash is also available. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(size == sizeof(buf), "Unexpected size %d\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); - } if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(size == sizeof(buf), "Unexpected size %d\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } - /* Oddly, the hash doesn't seem to change even after an update */ + /* The hash doesn't seem to change even after an update, which matches + * how rsaenh behaves - an update can't happen after the has is retrieved. + */ ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); /* So is the version. */ size = 0; @@ -829,61 +827,30 @@ static void test_hash_msg_get_param(void) /* The hash is still available. */ size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(size == sizeof(buf), "Unexpected size %d\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); /* An empty update has no effect on the hash */ CryptMsgUpdate(msg, NULL, 0, FALSE); size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(size == sizeof(buf), "Unexpected size %d\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); - /* A non-empty update doesn't appear to either? */ + /* A non-empty update doesn't either - see above comments. */ CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); size = 0; ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(size == sizeof(buf), "Unexpected size %d\n", size); ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } - if (size == sizeof(buf)) - ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); - CryptMsgClose(msg); - /* A detached message similarly has a non-updating hash */ - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, - CMSG_HASHED, &hashInfo, NULL, NULL); - size = 0; - ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(buf), "Unexpected size %d\n", size); - ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } - if (size == sizeof(buf)) - ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); - CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - size = 0; - ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); - todo_wine { - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - ok(size == sizeof(buf), "Unexpected size %d\n", size); - ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); - ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); - } if (size == sizeof(buf)) ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); CryptMsgClose(msg);
1
0
0
0
Juan Lang : crypt32: Add tests for getting hash message params.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: 1745d8a7285a9555ef3617c96fadc8b4c8dadb25 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1745d8a7285a9555ef3617c96…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:42:46 2007 -0700 crypt32: Add tests for getting hash message params. --- dlls/crypt32/tests/msg.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 143 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 354852b..7f03516 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -747,10 +747,153 @@ static void test_hash_msg_update(void) CryptMsgClose(msg); } +static const BYTE emptyHashParam[] = { +0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,0xe9,0x80,0x09,0x98,0xec,0xf8,0x42, +0x7e }; + +static void test_hash_msg_get_param(void) +{ + HCRYPTMSG msg; + BOOL ret; + static char oid_rsa_md5[] = szOID_RSA_MD5; + CMSG_HASHED_ENCODE_INFO hashInfo = { sizeof(hashInfo), 0, + { oid_rsa_md5, { 0, NULL } }, NULL }; + DWORD size, value; + CMSG_STREAM_INFO streamInfo = { 0, nop_stream_output, NULL }; + BYTE buf[16]; + + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + /* Content and bare content are always gettable for non-streamed messages */ + size = 0; + ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + /* The hash is also available. */ + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + + CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + /* Oddly, the hash doesn't seem to change even after an update */ + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + /* So is the version. */ + size = 0; + ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size); + todo_wine + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + size = sizeof(value); + ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, (LPBYTE)&value, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(value == 0, "Expected version 0, got %d\n", value); + } + /* As usual, the type isn't available. */ + ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE, + "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError()); + CryptMsgClose(msg); + + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, &streamInfo); + /* Streamed messages don't allow you to get the content or bare content. */ + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size); + todo_wine { + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + } + /* The hash is still available. */ + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + /* An empty update has no effect on the hash */ + CryptMsgUpdate(msg, NULL, 0, FALSE); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + /* A non-empty update doesn't appear to either? */ + CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + CryptMsgClose(msg); + /* A detached message similarly has a non-updating hash */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_HASHED, &hashInfo, NULL, NULL); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + size = 0; + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size); + todo_wine { + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + ok(size == sizeof(buf), "Unexpected size %d\n", size); + ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size); + ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); + } + if (size == sizeof(buf)) + ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n"); + CryptMsgClose(msg); +} + static void test_hash_msg(void) { test_hash_msg_open(); test_hash_msg_update(); + test_hash_msg_get_param(); } static CRYPT_DATA_BLOB b4 = { 0, NULL };
1
0
0
0
Juan Lang : crypt32: Add a stub hash message implementation.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: 3c15f98b77d9f1f9dd671b16c8b0e8744a8b241c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3c15f98b77d9f1f9dd671b16c…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:32:00 2007 -0700 crypt32: Add a stub hash message implementation. --- dlls/crypt32/msg.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- dlls/crypt32/tests/msg.c | 5 --- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 299b97e..1918713 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -313,6 +313,78 @@ static HCRYPTMSG CDataEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo, return (HCRYPTMSG)msg; } +typedef struct _CHashEncodeMsg +{ + CryptMsgBase base; + HCRYPTPROV prov; + HCRYPTHASH hash; +} CHashEncodeMsg; + +static void CHashEncodeMsg_Close(HCRYPTMSG hCryptMsg) +{ + CHashEncodeMsg *msg = (CHashEncodeMsg *)hCryptMsg; + + CryptDestroyHash(msg->hash); + if (msg->base.open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG) + CryptReleaseContext(msg->prov, 0); +} + +static BOOL CHashEncodeMsg_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 CHashEncodeMsg_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 CHashEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo, + LPSTR pszInnerContentObjID, PCMSG_STREAM_INFO pStreamInfo) +{ + CHashEncodeMsg *msg; + const CMSG_HASHED_ENCODE_INFO *info = + (const CMSG_HASHED_ENCODE_INFO *)pvMsgEncodeInfo; + HCRYPTPROV prov; + ALG_ID algID; + + if (info->cbSize != sizeof(CMSG_HASHED_ENCODE_INFO)) + { + SetLastError(E_INVALIDARG); + return NULL; + } + if (!(algID = CertOIDToAlgId(info->HashAlgorithm.pszObjId))) + { + SetLastError(CRYPT_E_UNKNOWN_ALGO); + return NULL; + } + if (info->hCryptProv) + prov = info->hCryptProv; + else + { + prov = CRYPT_GetDefaultProvider(); + dwFlags &= ~CMSG_CRYPT_RELEASE_CONTEXT_FLAG; + } + msg = CryptMemAlloc(sizeof(CHashEncodeMsg)); + if (msg) + { + CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, + CHashEncodeMsg_Close, CHashEncodeMsg_GetParam, CHashEncodeMsg_Update); + msg->prov = prov; + if (!CryptCreateHash(prov, algID, 0, 0, &msg->hash)) + { + CryptMsgClose(msg); + msg = NULL; + } + } + return (HCRYPTMSG)msg; +} + static inline const char *MSG_TYPE_STR(DWORD type) { switch (type) @@ -350,9 +422,12 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, msg = CDataEncodeMsg_Open(dwFlags, pvMsgEncodeInfo, pszInnerContentObjID, pStreamInfo); break; + case CMSG_HASHED: + msg = CHashEncodeMsg_Open(dwFlags, pvMsgEncodeInfo, + pszInnerContentObjID, pStreamInfo); + break; case CMSG_SIGNED: case CMSG_ENVELOPED: - case CMSG_HASHED: FIXME("unimplemented for type %s\n", MSG_TYPE_STR(dwMsgType)); break; case CMSG_SIGNED_AND_ENVELOPED: diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 24ef5c6..354852b 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -663,30 +663,25 @@ static void test_hash_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); hashInfo.cbSize = sizeof(hashInfo); SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_HASHED, &hashInfo, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_HASHED, &hashInfo, NULL, &streamInfo); - todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); }
1
0
0
0
Juan Lang : crypt32: Test opening hash messages to encode with streaming.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: e6c339d076e38d169e042306519db4c1ae7b58e7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e6c339d076e38d169e0423065…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:29:03 2007 -0700 crypt32: Test opening hash messages to encode with streaming. --- dlls/crypt32/tests/msg.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index f5b2fc5..24ef5c6 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -658,6 +658,7 @@ static void test_hash_msg_open(void) HCRYPTMSG msg; CMSG_HASHED_ENCODE_INFO hashInfo = { 0 }; static char oid_rsa_md5[] = szOID_RSA_MD5; + CMSG_STREAM_INFO streamInfo = { 0, nop_stream_output, NULL }; SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, @@ -678,6 +679,16 @@ static void test_hash_msg_open(void) todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_HASHED, &hashInfo, NULL, NULL); + todo_wine + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_HASHED, &hashInfo, NULL, &streamInfo); + todo_wine + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); } static void test_hash_msg_update(void)
1
0
0
0
Juan Lang : crypt32: Add tests for updating hash messages opened to encode.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: ad975f672bf713da7c2af4d97f4ca68f191ca2c8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ad975f672bf713da7c2af4d97…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:26:47 2007 -0700 crypt32: Add tests for updating hash messages opened to encode. --- dlls/crypt32/tests/msg.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 60bfe0b..f5b2fc5 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -680,9 +680,71 @@ static void test_hash_msg_open(void) CryptMsgClose(msg); } +static void test_hash_msg_update(void) +{ + HCRYPTMSG msg; + BOOL ret; + static char oid_rsa_md5[] = szOID_RSA_MD5; + CMSG_HASHED_ENCODE_INFO hashInfo = { sizeof(hashInfo), 0, + { oid_rsa_md5, { 0, NULL } }, NULL }; + CMSG_STREAM_INFO streamInfo = { 0, nop_stream_output, NULL }; + + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_HASHED, &hashInfo, NULL, NULL); + /* Detached hashed messages opened in non-streaming mode allow non-final + * updates.. + */ + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* including non-final updates with no data.. */ + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* and final updates with no data. */ + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* But no updates are allowed after the final update. */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\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 %x\n", GetLastError()); + CryptMsgClose(msg); + /* Non-detached messages, in contrast, don't allow non-final updates in + * non-streaming mode. + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + /* Final updates (including empty ones) are allowed. */ + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); + /* And, of course, streaming mode allows non-final updates */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, &streamInfo); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); +} + static void test_hash_msg(void) { test_hash_msg_open(); + test_hash_msg_update(); } static CRYPT_DATA_BLOB b4 = { 0, NULL };
1
0
0
0
Juan Lang : crypt32: Add open tests for hash messages.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: b12072b72d7fad907ae204ca6bb0423f092aa840 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b12072b72d7fad907ae204ca6…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:20:55 2007 -0700 crypt32: Add open tests for hash messages. --- dlls/crypt32/tests/msg.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 4898c6e..60bfe0b 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -653,6 +653,38 @@ static void test_data_msg(void) test_data_msg_encoding(); } +static void test_hash_msg_open(void) +{ + HCRYPTMSG msg; + CMSG_HASHED_ENCODE_INFO hashInfo = { 0 }; + static char oid_rsa_md5[] = szOID_RSA_MD5; + + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + hashInfo.cbSize = sizeof(hashInfo); + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, + "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); + hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5; + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + todo_wine + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); +} + +static void test_hash_msg(void) +{ + test_hash_msg_open(); +} + static CRYPT_DATA_BLOB b4 = { 0, NULL }; static const struct update_accum a4 = { 1, &b4 }; @@ -832,5 +864,6 @@ START_TEST(msg) /* Message-type specific tests */ test_data_msg(); + test_hash_msg(); test_decode_msg(); }
1
0
0
0
Juan Lang : crypt32: Implement streamed encoding of definite-length data messages.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: afaba37ed71ba3d4fc15cb7fb0d47f8ba869da00 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=afaba37ed71ba3d4fc15cb7fb…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:20:20 2007 -0700 crypt32: Implement streamed encoding of definite-length data messages. --- dlls/crypt32/msg.c | 156 ++++++++++++++++++++++++++++++++++++++++----- dlls/crypt32/tests/msg.c | 25 +++++++- 2 files changed, 161 insertions(+), 20 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 63f6671..299b97e 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -19,8 +19,11 @@ #include "windef.h" #include "winbase.h" #include "wincrypt.h" +#include "snmp.h" #include "wine/debug.h" +#include "wine/exception.h" +#include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); @@ -74,6 +77,7 @@ typedef struct _CDataEncodeMsg CryptMsgBase base; DWORD bare_content_len; LPBYTE bare_content; + BOOL begun; } CDataEncodeMsg; static const BYTE empty_data_content[] = { 0x04,0x00 }; @@ -86,6 +90,71 @@ static void CDataEncodeMsg_Close(HCRYPTMSG hCryptMsg) LocalFree(msg->bare_content); } +static WINAPI BOOL CRYPT_EncodeContentLength(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + const CDataEncodeMsg *msg = (const CDataEncodeMsg *)pvStructInfo; + DWORD lenBytes; + BOOL ret = TRUE; + + /* Trick: report bytes needed based on total message length, even though + * the message isn't available yet. The caller will use the length + * reported here to encode its length. + */ + CRYPT_EncodeLen(msg->base.stream_info.cbContent, NULL, &lenBytes); + if (!pbEncoded) + *pcbEncoded = 1 + lenBytes + msg->base.stream_info.cbContent; + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, 1 + lenBytes))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_OCTETSTRING; + CRYPT_EncodeLen(msg->base.stream_info.cbContent, pbEncoded, + &lenBytes); + } + } + return ret; +} + +static BOOL CRYPT_EncodeDataContentInfoHeader(CDataEncodeMsg *msg, + CRYPT_DATA_BLOB *header) +{ + BOOL ret; + + if (msg->base.streamed && msg->base.stream_info.cbContent == 0xffffffff) + { + FIXME("unimplemented for indefinite-length encoding\n"); + header->cbData = 0; + header->pbData = NULL; + ret = TRUE; + } + else + { + struct AsnConstructedItem constructed = { 0, msg, + CRYPT_EncodeContentLength }; + struct AsnEncodeSequenceItem items[2] = { + { szOID_RSA_data, CRYPT_AsnEncodeOid, 0 }, + { &constructed, CRYPT_AsnEncodeConstructed, 0 }, + }; + + ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, + sizeof(items) / sizeof(items[0]), CRYPT_ENCODE_ALLOC_FLAG, NULL, + (LPBYTE)&header->pbData, &header->cbData); + if (ret) + { + /* Trick: subtract the content length from the reported length, + * as the actual content hasn't come yet. + */ + header->cbData -= msg->base.stream_info.cbContent; + } + } + return ret; +} + static BOOL CDataEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal) { @@ -94,30 +163,80 @@ static BOOL CDataEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, if (msg->base.finalized) SetLastError(CRYPT_E_MSG_ERROR); - else if (!fFinal) + else if (msg->base.streamed) { - if (msg->base.open_flags & CMSG_DETACHED_FLAG) - SetLastError(E_INVALIDARG); - else - SetLastError(CRYPT_E_MSG_ERROR); + if (fFinal) + msg->base.finalized = TRUE; + __TRY + { + if (!msg->begun) + { + CRYPT_DATA_BLOB header; + + msg->begun = TRUE; + ret = CRYPT_EncodeDataContentInfoHeader(msg, &header); + if (ret) + { + ret = msg->base.stream_info.pfnStreamOutput( + msg->base.stream_info.pvArg, header.pbData, header.cbData, + FALSE); + LocalFree(header.pbData); + } + } + if (!fFinal) + ret = msg->base.stream_info.pfnStreamOutput( + msg->base.stream_info.pvArg, (BYTE *)pbData, cbData, + FALSE); + else + { + if (msg->base.stream_info.cbContent == 0xffffffff) + { + BYTE indefinite_trailer[6] = { 0 }; + + ret = msg->base.stream_info.pfnStreamOutput( + msg->base.stream_info.pvArg, (BYTE *)pbData, cbData, + FALSE); + if (ret) + ret = msg->base.stream_info.pfnStreamOutput( + msg->base.stream_info.pvArg, indefinite_trailer, + sizeof(indefinite_trailer), TRUE); + } + else + ret = msg->base.stream_info.pfnStreamOutput( + msg->base.stream_info.pvArg, (BYTE *)pbData, cbData, TRUE); + } + } + __EXCEPT_PAGE_FAULT + { + SetLastError(STATUS_ACCESS_VIOLATION); + } + __ENDTRY; } else { - msg->base.finalized = TRUE; - if (!cbData) - SetLastError(E_INVALIDARG); + if (!fFinal) + { + if (msg->base.open_flags & CMSG_DETACHED_FLAG) + SetLastError(E_INVALIDARG); + else + SetLastError(CRYPT_E_MSG_ERROR); + } else { - CRYPT_DATA_BLOB blob = { cbData, (LPBYTE)pbData }; - - /* data messages don't allow non-final updates, don't bother - * checking whether data already exist, they can't. - */ - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, - &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &msg->bare_content, - &msg->bare_content_len); - if (ret && msg->base.streamed) - FIXME("stream info unimplemented\n"); + msg->base.finalized = TRUE; + if (!cbData) + SetLastError(E_INVALIDARG); + else + { + CRYPT_DATA_BLOB blob = { cbData, (LPBYTE)pbData }; + + /* non-streamed data messages don't allow non-final updates, + * don't bother checking whether data already exist, they can't. + */ + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, + &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &msg->bare_content, + &msg->bare_content_len); + } } } return ret; @@ -189,6 +308,7 @@ static HCRYPTMSG CDataEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo, CDataEncodeMsg_Close, CDataEncodeMsg_GetParam, CDataEncodeMsg_Update); msg->bare_content_len = sizeof(empty_data_content); msg->bare_content = (LPBYTE)empty_data_content; + msg->begun = FALSE; } return (HCRYPTMSG)msg; } diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 1e987d2..4898c6e 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -336,6 +336,7 @@ static void test_data_msg_update(void) { HCRYPTMSG msg; BOOL ret; + CMSG_STREAM_INFO streamInfo = { 0 }; msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, NULL); @@ -383,6 +384,28 @@ static void test_data_msg_update(void) ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); CryptMsgClose(msg); + + /* Calling update after opening with an empty stream info (with a bogus + * output function) yields an error: + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + &streamInfo); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* Calling update with a valid output function succeeds, even if the data + * exceeds the size specified in the stream info. + */ + streamInfo.pfnStreamOutput = nop_stream_output; + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + &streamInfo); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); } static void test_data_msg_get_param(void) @@ -600,7 +623,6 @@ static void test_data_msg_encoding(void) CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); CryptMsgClose(msg); - todo_wine check_updates("bogus data message with definite length", &a1, &accum); free_updates(&accum); /* A valid definite-length encoding: */ @@ -609,7 +631,6 @@ static void test_data_msg_encoding(void) NULL, &streamInfo); CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); CryptMsgClose(msg); - todo_wine check_updates("data message with definite length", &a2, &accum); free_updates(&accum); /* An indefinite-length encoding: */
1
0
0
0
Juan Lang : crypt32: Make some encoding functions available outside encode. c.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: 48afa16386c47a27b9b230dfb726959418c9d28a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=48afa16386c47a27b9b230dfb…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Thu Jul 12 14:09:00 2007 -0700 crypt32: Make some encoding functions available outside encode.c. --- dlls/crypt32/crypt32_private.h | 39 +++++++++++++++++++++++++++++++++++++++ dlls/crypt32/encode.c | 36 +++++++----------------------------- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 7a1aa32..17f7172 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -38,6 +38,45 @@ #define ASN_UNIVERSALSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1c) #define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e) +BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded); + +typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, + DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *); + +struct AsnEncodeSequenceItem +{ + const void *pvStructInfo; + CryptEncodeObjectExFunc encodeFunc; + DWORD size; /* used during encoding, not for your use */ +}; + +BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, + struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); + +struct AsnConstructedItem +{ + BYTE tag; + const void *pvStructInfo; + CryptEncodeObjectExFunc encodeFunc; +}; + +BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); + +BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); + +/* Helper function to check *pcbEncoded, set it to the required size, and + * optionally to allocate memory. Assumes pbEncoded is not NULL. + * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a + * pointer to the newly allocated memory. + */ +BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, + BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded); + /* The following aren't defined in wincrypt.h, as they're "reserved" */ #define CERT_CERT_PROP_ID 32 #define CERT_CRL_PROP_ID 33 diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c index aacef31..d5427a0 100644 --- a/dlls/crypt32/encode.c +++ b/dlls/crypt32/encode.c @@ -51,15 +51,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt); typedef BOOL (WINAPI *CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, BYTE *, DWORD *); -typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, - DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *); /* Prototypes for built-in encoders. They follow the Ex style prototypes. * The dwCertEncodingType and lpszStructType are ignored by the built-in * functions, but the parameters are retained to simplify CryptEncodeObjectEx, * since it must call functions in external DLLs that follow these signatures. */ -static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, +BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, @@ -134,14 +132,8 @@ BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, return ret; } -/* Helper function to check *pcbEncoded, set it to the required size, and - * optionally to allocate memory. Assumes pbEncoded is not NULL. - * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a - * pointer to the newly allocated memory. - */ -static BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, - PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded, - DWORD bytesNeeded) +BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, + BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded) { BOOL ret = TRUE; @@ -167,7 +159,7 @@ static BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, return ret; } -static BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) +BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) { DWORD bytesNeeded, significantBytes = 0; @@ -209,14 +201,7 @@ static BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) return TRUE; } -struct AsnEncodeSequenceItem -{ - const void *pvStructInfo; - CryptEncodeObjectExFunc encodeFunc; - DWORD size; /* used during encoding, not for your use */ -}; - -static BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, +BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -270,14 +255,7 @@ static BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, return ret; } -struct AsnConstructedItem -{ - BYTE tag; - const void *pvStructInfo; - CryptEncodeObjectExFunc encodeFunc; -}; - -static BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, +BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -798,7 +776,7 @@ static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, return ret; } -static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, +BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) {
1
0
0
0
Detlef Riekenberg : printui: Parse args for PrintUIEntryW.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: d97a3b3385e0be836b1975809457d28fc3bc15ab URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d97a3b3385e0be836b1975809…
Author: Detlef Riekenberg <wine.dev(a)web.de> Date: Thu Jul 12 20:56:45 2007 +0200 printui: Parse args for PrintUIEntryW. --- dlls/printui/Makefile.in | 2 +- dlls/printui/printui.c | 217 +++++++++++++++++++++++++++++++++++++++- dlls/printui/printui_private.h | 72 +++++++++++++ 3 files changed, 288 insertions(+), 3 deletions(-) diff --git a/dlls/printui/Makefile.in b/dlls/printui/Makefile.in index 2cb44b9..a69fd98 100644 --- a/dlls/printui/Makefile.in +++ b/dlls/printui/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = printui.dll -IMPORTS = kernel32 +IMPORTS = shell32 kernel32 C_SRCS = \ printui.c diff --git a/dlls/printui/printui.c b/dlls/printui/printui.c index 06cbaa2..c25aadb 100644 --- a/dlls/printui/printui.c +++ b/dlls/printui/printui.c @@ -1,7 +1,7 @@ /* * Implementation of the Printer User Interface Dialogs * - * Copyright 2006 Detlef Riekenberg + * Copyright 2006-2007 Detlef Riekenberg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,14 +30,190 @@ #include "winreg.h" #include "winver.h" #include "winnls.h" +#include "shellapi.h" #include "wine/unicode.h" #include "wine/debug.h" +#include "printui_private.h" WINE_DEFAULT_DEBUG_CHANNEL(printui); HINSTANCE PRINTUI_hInstance = NULL; +/* ################################# */ + +/* Must be in order with OPT_* */ +static const WCHAR optionsW[OPT_MAX+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0}; + +/* Must be in order with FLAG_* */ +static const WCHAR flagsW[FLAG_MAX+1]={'q','w','y','z','Z',0}; + + +/* ################################ + * get_next_wstr() [Internal] + * + * Get the next WSTR, when available + * + */ + +static LPWSTR get_next_wstr(context_t * cx) +{ + LPWSTR ptr; + + ptr = cx->pNextCharW; + if (ptr && ptr[0]) { + cx->pNextCharW = NULL; + return ptr; + } + + /* Get the next Parameter, when available */ + if (cx->next_arg < cx->argc) { + ptr = cx->argv[cx->next_arg]; + cx->next_arg++; + cx->pNextCharW = NULL; + return ptr; + } + return NULL; +} + + +/* ################################ + * get_next_wchar() [Internal] + * + * Get the next WCHAR from the Commandline or from the File (@ Filename) + * + * ToDo: Support Parameter from a File ( "@Filename" ) + * + */ + +static WCHAR get_next_wchar(context_t * cx, BOOL use_next_parameter) +{ + WCHAR c; + + /* Try the next WCHAR in the actual Parameter */ + if (cx->pNextCharW) { + c = *cx->pNextCharW; + if (c) { + cx->pNextCharW++; + return c; + } + /* We reached the end of the Parameter */ + cx->pNextCharW = NULL; + } + + /* Get the next Parameter, when available and allowed */ + if ((cx->pNextCharW == NULL) && (cx->next_arg < cx->argc) && (use_next_parameter)) { + cx->pNextCharW = cx->argv[cx->next_arg]; + cx->next_arg++; + } + + if (cx->pNextCharW) { + c = *cx->pNextCharW; + if (c) { + cx->pNextCharW++; + } + else + { + /* We reached the end of the Parameter */ + cx->pNextCharW = NULL; + } + return c; + } + return '\0'; +} + +/* ################################ */ +static BOOL parse_rundll(context_t * cx) +{ + LPWSTR ptr; + DWORD index; + WCHAR txtW[2]; + WCHAR c; + + + c = get_next_wchar(cx, TRUE); + txtW[1] = '\0'; + + while (c) + { + + while ( (c == ' ') || (c == '\t')) + { + c = get_next_wchar(cx, TRUE); + } + txtW[0] = c; + + if (c == '@') { + /* read commands from a File */ + ptr = get_next_wstr(cx); + FIXME("redir not supported: %s\n", debugstr_w(ptr)); + return FALSE; + } + else if (c == '/') { + c = get_next_wchar(cx, FALSE); + while ( c ) + { + txtW[0] = c; + ptr = strchrW(optionsW, c); + if (ptr) { + index = ptr - optionsW; + cx->options[index] = get_next_wstr(cx); + TRACE(" opt: %s %s\n", debugstr_w(txtW), debugstr_w(cx->options[index])); + c = 0; + } + else + { + ptr = strchrW(flagsW, c); + if (ptr) { + index = ptr - flagsW; + cx->flags[index] = TRUE; + TRACE("flag: %s\n", debugstr_w(txtW)); + } + else + { + cx->command = c; + cx->subcommand = '\0'; + TRACE(" cmd: %s\n", debugstr_w(txtW)); + } + + /* help has priority over all commands */ + if (c == '?') { + return TRUE; + } + + c = get_next_wchar(cx, FALSE); + + /* Some commands use two wchar */ + if ((cx->command == 'd') || (cx->command == 'g') || (cx->command == 'i') || + (cx->command == 'S') || (cx->command == 'X') ){ + cx->subcommand = c; + txtW[0] = c; + TRACE(" sub: %s\n", debugstr_w(txtW)); + c = get_next_wchar(cx, FALSE); + } + } + } + c = get_next_wchar(cx, TRUE); + + } + else + { + /* The commands 'S' and 'X' have additional Parameter */ + if ((cx->command == 'S') || (cx->command == 'X')) { + + /* the actual WCHAR is the start from the extra Parameter */ + cx->pNextCharW--; + TRACE("%d extra Parameter, starting with %s\n", 1 + (cx->argc - cx->next_arg), debugstr_w(cx->pNextCharW)); + return TRUE; + } + FIXME("0x%x: %s is unknown\n", c, debugstr_wn(&c, 1)); + return FALSE; + } + + } + return TRUE; +} + /***************************************************** * DllMain */ @@ -66,5 +242,42 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) */ void WINAPI PrintUIEntryW(HWND hWnd, HINSTANCE hInst, LPCWSTR pCommand, DWORD nCmdShow) { - FIXME("(%p, %p, %s, 0x%x) stub\n", hWnd, hInst, debugstr_w(pCommand), nCmdShow); + context_t cx; + BOOL res = FALSE; + + TRACE("(%p, %p, %s, 0x%x)\n", hWnd, hInst, debugstr_w(pCommand), nCmdShow); + + memset(&cx, 0, sizeof(context_t)); + cx.hWnd = hWnd; + cx.nCmdShow = nCmdShow; + + if ((pCommand) && (pCommand[0])) { + /* result is allocated with GlobalAlloc() */ + cx.argv = CommandLineToArgvW(pCommand, &cx.argc); + TRACE("got %d args at %p\n", cx.argc, cx.argv); + + res = parse_rundll(&cx); + } + + if (res && cx.command) { + switch (cx.command) + { + + default: + { + WCHAR txtW[3]; + txtW[0] = cx.command; + txtW[1] = cx.subcommand; + txtW[2] = '\0'; + FIXME("command not implemented: %s\n", debugstr_w(txtW)); + } + } + } + + if ((res == FALSE) || (cx.command == '\0')) { + FIXME("dialog: Printer / The operation was not successful\n"); + } + + GlobalFree(cx.argv); + } diff --git a/dlls/printui/printui_private.h b/dlls/printui/printui_private.h new file mode 100644 index 0000000..56143b7 --- /dev/null +++ b/dlls/printui/printui_private.h @@ -0,0 +1,72 @@ +/* + * Implementation of the Printer User Interface Dialogs: private Header + * + * Copyright 2007 Detlef Riekenberg + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_PRINTUI_PRIVATE__ +#define __WINE_PRINTUI_PRIVATE__ + +/* Index for Options with an argument */ +/* Must be in order with optionsW */ +typedef enum _OPT_INDEX { + OPT_A = 0, + OPT_B, + OPT_C, + OPT_F, + OPT_H, + OPT_J, + OPT_L, + OPT_M, + OPT_N, + OPT_R, + OPT_T, + OPT_V, + OPT_MAX +} OPT_INDEX; + +/* Index for Flags without an argument */ +/* Must be in order with flagsW */ +typedef enum _FLAG_INDEX { + FLAG_Q = 0, + FLAG_W, + FLAG_Y, + FLAG_Z, + FLAG_ZZ, + FLAG_MAX +} FLAG_INDEX; + + +typedef struct tag_context { + HWND hWnd; + DWORD nCmdShow; + LPWSTR * argv; + LPWSTR pNextCharW; + int argc; + int next_arg; + WCHAR command; + WCHAR subcommand; + LPWSTR options[OPT_MAX]; + BOOL flags[FLAG_MAX]; +} context_t; + + +/* ## DLL-wide Globals ## */ +extern HINSTANCE PRINTUI_hInstance; + + +#endif
1
0
0
0
Damjan Jovanovic : ntdll: Use the win16 current directory for win16 processes.
by Alexandre Julliard
13 Jul '07
13 Jul '07
Module: wine Branch: master Commit: 9e07d6787f70b239ce28b1d012a04ce8d178e7c1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9e07d6787f70b239ce28b1d01…
Author: Damjan Jovanovic <damjan.jov(a)gmail.com> Date: Thu Jul 12 07:27:25 2007 +0200 ntdll: Use the win16 current directory for win16 processes. --- dlls/ntdll/env.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index fd6f185..cc2a1f5 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -29,6 +29,7 @@ #include "winternl.h" #include "wine/unicode.h" #include "wine/debug.h" +#include "thread.h" #include "ntdll_misc.h" WINE_DEFAULT_DEBUG_CHANNEL(environ); @@ -431,7 +432,13 @@ NTSTATUS WINAPI RtlCreateProcessParameters( RTL_USER_PROCESS_PARAMETERS **result RtlAcquirePebLock(); cur_params = NtCurrentTeb()->Peb->ProcessParameters; if (!DllPath) DllPath = &cur_params->DllPath; - if (!CurrentDirectoryName) CurrentDirectoryName = &cur_params->CurrentDirectory.DosPath; + if (!CurrentDirectoryName) + { + if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */ + CurrentDirectoryName = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir.DosPath; + else + CurrentDirectoryName = &cur_params->CurrentDirectory.DosPath; + } if (!CommandLine) CommandLine = ImagePathName; if (!Environment) Environment = cur_params->Environment; if (!WindowTitle) WindowTitle = &empty_str;
1
0
0
0
← Newer
1
...
59
60
61
62
63
64
65
...
96
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Results per page:
10
25
50
100
200