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: Hash and sign data when updating signed messages.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 4e2b3ab9e18ad79f47fb568ef2212cbaff9c664c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4e2b3ab9e18ad79f47fb568ef…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:56:12 2007 -0700 crypt32: Hash and sign data when updating signed messages. --- dlls/crypt32/msg.c | 239 +++++++++++++++++++++++++++++++++++++++++++++- dlls/crypt32/tests/msg.c | 6 +- 2 files changed, 239 insertions(+), 6 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=4e2b3ab9e18ad79f47fb5…
1
0
0
0
Juan Lang : crypt32: More parameter checking for opening signed encoded messages.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 0b0df876b2f306d298ca6bc93877cbb3dcd69072 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0b0df876b2f306d298ca6bc93…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:35:17 2007 -0700 crypt32: More parameter checking for opening signed encoded messages. --- dlls/crypt32/msg.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index c134e68..ce2ac3d 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -567,6 +567,17 @@ typedef struct _CMSG_SIGNED_ENCODE_INFO_WITH_CMS static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer) { + if (signer->cbSize != sizeof(CMSG_SIGNER_ENCODE_INFO) && + signer->cbSize != sizeof(CMSG_SIGNER_ENCODE_INFO_WITH_CMS)) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (signer->cbSize == sizeof(CMSG_SIGNER_ENCODE_INFO_WITH_CMS)) + { + FIXME("CMSG_SIGNER_ENCODE_INFO with CMS fields unsupported\n"); + return FALSE; + } if (!signer->pCertInfo->SerialNumber.cbData) { SetLastError(E_INVALIDARG);
1
0
0
0
Juan Lang : crypt32: Add tests for opening non-detached signed messages, and clarify detached open.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 19e63d900484fe49fddbaf02cb872b7a60709a07 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=19e63d900484fe49fddbaf02c…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:34:14 2007 -0700 crypt32: Add tests for opening non-detached signed messages, and clarify detached open. --- dlls/crypt32/tests/msg.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 94864c1..44c3098 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -1110,10 +1110,10 @@ static void test_signed_msg_update(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); - /* CMSG_SIGNED allows non-final updates. */ + /* Detached CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); - /* CMSG_SIGNED also allows non-final updates with no data. */ + /* Detached CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* The final update requires a private key in the hCryptProv, in order to @@ -1139,10 +1139,10 @@ static void test_signed_msg_update(void) msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); - /* CMSG_SIGNED allows non-final updates. */ + /* Detached CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); - /* CMSG_SIGNED also allows non-final updates with no data. */ + /* Detached CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* Now that the private key exists, the final update can succeed (even @@ -1161,6 +1161,26 @@ static void test_signed_msg_update(void) "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); CryptMsgClose(msg); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + /* Non-detached messages don't allow non-final updates.. */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + /* but they do allow final ones. */ + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); + ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + CryptMsgClose(msg); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + /* They also allow final updates with no data. */ + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); + CryptMsgClose(msg); + CryptDestroyKey(key); CryptReleaseContext(signer.hCryptProv, 0); CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL,
1
0
0
0
Juan Lang : crypt32: Add a partial stub for updating a signed encoded message.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: d11ddebc763bbccb5b07f952085fdb5d342f5ec7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d11ddebc763bbccb5b07f9520…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:33:09 2007 -0700 crypt32: Add a partial stub for updating a signed encoded message. --- dlls/crypt32/msg.c | 42 ++++++++++++++++++++++++++++++++++++++---- dlls/crypt32/tests/msg.c | 7 ------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 08b3ce8..c134e68 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -592,12 +592,15 @@ static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer) typedef struct _CSignedEncodeMsg { - CryptMsgBase base; + CryptMsgBase base; + CRYPT_DATA_BLOB data; } CSignedEncodeMsg; static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) { - FIXME("(%p)\n", hCryptMsg); + CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; + + CryptMemFree(msg->data.pbData); } static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, @@ -611,8 +614,37 @@ static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal) { - FIXME("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal); - return FALSE; + CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; + BOOL ret = FALSE; + + if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG)) + { + FIXME("streamed / detached update unimplemented\n"); + ret = TRUE; + } + else + { + if (!fFinal) + SetLastError(CRYPT_E_MSG_ERROR); + else + { + if (cbData) + { + msg->data.pbData = CryptMemAlloc(cbData); + if (msg->data.pbData) + { + memcpy(msg->data.pbData, pbData, cbData); + msg->data.cbData = cbData; + ret = TRUE; + } + } + else + ret = TRUE; + if (ret) + FIXME("non-streamed final update: partial stub\n"); + } + } + return ret; } static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, @@ -644,6 +676,8 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, CSignedEncodeMsg_Close, CSignedEncodeMsg_GetParam, CSignedEncodeMsg_Update); + msg->data.cbData = 0; + msg->data.pbData = NULL; } return msg; } diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 8ef97e8..94864c1 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -1112,11 +1112,9 @@ static void test_signed_msg_update(void) ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); /* CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* The final update requires a private key in the hCryptProv, in order to * generate the signature. @@ -1143,17 +1141,14 @@ static void test_signed_msg_update(void) ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); /* CMSG_SIGNED allows non-final updates. */ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* CMSG_SIGNED also allows non-final updates with no data. */ ret = CryptMsgUpdate(msg, NULL, 0, FALSE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); /* Now that the private key exists, the final update can succeed (even * 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); @@ -1282,7 +1277,6 @@ static void test_signed_msg_encoding(void) check_param("detached signed empty content", msg, CMSG_CONTENT_PARAM, signedEmptyContent, sizeof(signedEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); todo_wine check_param("detached signed hash", msg, CMSG_COMPUTED_HASH_PARAM, @@ -1312,7 +1306,6 @@ static void test_signed_msg_encoding(void) check_param("signed empty content", msg, CMSG_CONTENT_PARAM, signedEmptyContent, sizeof(signedEmptyContent)); ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE); - todo_wine ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); todo_wine check_param("signed bare content", msg, CMSG_BARE_CONTENT_PARAM,
1
0
0
0
Juan Lang : crypt32: Add tests for signed message encoding.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 014f282b724eeaa8609677c0b621e4f33ea917c6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=014f282b724eeaa8609677c0b…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:29:06 2007 -0700 crypt32: Add tests for signed message encoding. --- dlls/crypt32/tests/msg.c | 166 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 160 insertions(+), 6 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=014f282b724eeaa860967…
1
0
0
0
Juan Lang : crypt32: Add tests for updating signed encoded messages.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: cc4005829da1ab4837985fad419de6e3741f4791 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=cc4005829da1ab4837985fad4…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 17:26:14 2007 -0700 crypt32: Add tests for updating signed encoded messages. --- dlls/crypt32/tests/msg.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 116 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index d2d9488..250ac9f 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -1061,9 +1061,125 @@ static void test_signed_msg_open(void) PROV_RSA_FULL, CRYPT_DELETEKEYSET); } +static const BYTE privKey[] = { + 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x32, 0x00, + 0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x79, 0x10, 0x1c, 0xd0, 0x6b, 0x10, + 0x18, 0x30, 0x94, 0x61, 0xdc, 0x0e, 0xcb, 0x96, 0x4e, 0x21, 0x3f, 0x79, 0xcd, + 0xa9, 0x17, 0x62, 0xbc, 0xbb, 0x61, 0x4c, 0xe0, 0x75, 0x38, 0x6c, 0xf3, 0xde, + 0x60, 0x86, 0x03, 0x97, 0x65, 0xeb, 0x1e, 0x6b, 0xdb, 0x53, 0x85, 0xad, 0x68, + 0x21, 0xf1, 0x5d, 0xe7, 0x1f, 0xe6, 0x53, 0xb4, 0xbb, 0x59, 0x3e, 0x14, 0x27, + 0xb1, 0x83, 0xa7, 0x3a, 0x54, 0xe2, 0x8f, 0x65, 0x8e, 0x6a, 0x4a, 0xcf, 0x3b, + 0x1f, 0x65, 0xff, 0xfe, 0xf1, 0x31, 0x3a, 0x37, 0x7a, 0x8b, 0xcb, 0xc6, 0xd4, + 0x98, 0x50, 0x36, 0x67, 0xe4, 0xa1, 0xe8, 0x7e, 0x8a, 0xc5, 0x23, 0xf2, 0x77, + 0xf5, 0x37, 0x61, 0x49, 0x72, 0x59, 0xe8, 0x3d, 0xf7, 0x60, 0xb2, 0x77, 0xca, + 0x78, 0x54, 0x6d, 0x65, 0x9e, 0x03, 0x97, 0x1b, 0x61, 0xbd, 0x0c, 0xd8, 0x06, + 0x63, 0xe2, 0xc5, 0x48, 0xef, 0xb3, 0xe2, 0x6e, 0x98, 0x7d, 0xbd, 0x4e, 0x72, + 0x91, 0xdb, 0x31, 0x57, 0xe3, 0x65, 0x3a, 0x49, 0xca, 0xec, 0xd2, 0x02, 0x4e, + 0x22, 0x7e, 0x72, 0x8e, 0xf9, 0x79, 0x84, 0x82, 0xdf, 0x7b, 0x92, 0x2d, 0xaf, + 0xc9, 0xe4, 0x33, 0xef, 0x89, 0x5c, 0x66, 0x99, 0xd8, 0x80, 0x81, 0x47, 0x2b, + 0xb1, 0x66, 0x02, 0x84, 0x59, 0x7b, 0xc3, 0xbe, 0x98, 0x45, 0x4a, 0x3d, 0xdd, + 0xea, 0x2b, 0xdf, 0x4e, 0xb4, 0x24, 0x6b, 0xec, 0xe7, 0xd9, 0x0c, 0x45, 0xb8, + 0xbe, 0xca, 0x69, 0x37, 0x92, 0x4c, 0x38, 0x6b, 0x96, 0x6d, 0xcd, 0x86, 0x67, + 0x5c, 0xea, 0x54, 0x94, 0xa4, 0xca, 0xa4, 0x02, 0xa5, 0x21, 0x4d, 0xae, 0x40, + 0x8f, 0x9d, 0x51, 0x83, 0xf2, 0x3f, 0x33, 0xc1, 0x72, 0xb4, 0x1d, 0x94, 0x6e, + 0x7d, 0xe4, 0x27, 0x3f, 0xea, 0xff, 0xe5, 0x9b, 0xa7, 0x5e, 0x55, 0x8e, 0x0d, + 0x69, 0x1c, 0x7a, 0xff, 0x81, 0x9d, 0x53, 0x52, 0x97, 0x9a, 0x76, 0x79, 0xda, + 0x93, 0x32, 0x16, 0xec, 0x69, 0x51, 0x1a, 0x4e, 0xc3, 0xf1, 0x72, 0x80, 0x78, + 0x5e, 0x66, 0x4a, 0x8d, 0x85, 0x2f, 0x3f, 0xb2, 0xa7 }; + +static void test_signed_msg_update(void) +{ + HCRYPTMSG msg; + BOOL ret; + CMSG_SIGNED_ENCODE_INFO signInfo = { sizeof(signInfo), 0 }; + CMSG_SIGNER_ENCODE_INFO signer = { sizeof(signer), 0 }; + CERT_INFO certInfo = { 0 }; + HCRYPTKEY key; + char oid_rsa_md5[] = szOID_RSA_MD5; + + certInfo.SerialNumber.cbData = sizeof(serialNum); + certInfo.SerialNumber.pbData = serialNum; + certInfo.Issuer.cbData = sizeof(encodedCommonName); + certInfo.Issuer.pbData = encodedCommonName; + signer.pCertInfo = &certInfo; + signer.HashAlgorithm.pszObjId = oid_rsa_md5; + signInfo.cSigners = 1; + signInfo.rgSigners = &signer; + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + PROV_RSA_FULL, CRYPT_NEWKEYSET); + if (!ret && GetLastError() == NTE_EXISTS) + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + PROV_RSA_FULL, 0); + ok(ret, "CryptAcquireContextW failed: %x\n", GetLastError()); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, + CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + /* CMSG_SIGNED allows non-final updates. */ + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* CMSG_SIGNED also allows non-final updates with no data. */ + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* The final update requires a private key in the hCryptProv, in order to + * generate the signature. + */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(!ret && GetLastError() == NTE_BAD_KEYSET, + "Expected NTE_BAD_KEYSET, got %x\n", GetLastError()); + ret = CryptImportKey(signer.hCryptProv, (LPBYTE)privKey, sizeof(privKey), + 0, 0, &key); + ok(ret, "CryptImportKey failed: %08x\n", GetLastError()); + /* The final update should be able to succeed now that a key exists, but + * the previous (invalid) final update prevents it. + */ + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + CryptMsgClose(msg); + + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, + CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + /* CMSG_SIGNED allows non-final updates. */ + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* CMSG_SIGNED also allows non-final updates with no data. */ + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* Now that the private key exists, the final update can succeed (even + * 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); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + CryptMsgClose(msg); + + CryptDestroyKey(key); + CryptReleaseContext(signer.hCryptProv, 0); + CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, + CRYPT_DELETEKEYSET); +} + static void test_signed_msg(void) { test_signed_msg_open(); + test_signed_msg_update(); } static CRYPT_DATA_BLOB b4 = { 0, NULL };
1
0
0
0
Juan Lang : crypt32: Check for and fail on indefinite-length encoding.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 45652e08029970f6991e0aab7c365eb6b2bb6343 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=45652e08029970f6991e0aab7…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 15:30:20 2007 -0700 crypt32: Check for and fail on indefinite-length encoding. --- dlls/crypt32/decode.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index 29687ef..8a062ce 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -193,6 +193,12 @@ static BOOL WINAPI CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, ret = TRUE; } } + else if (pbEncoded[1] == 0x80) + { + FIXME("unimplemented for indefinite-length encoding\n"); + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } else { BYTE lenLen = GET_LEN_BYTES(pbEncoded[1]);
1
0
0
0
Juan Lang : crypt32: Introduce function to encode an array of items as a set.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: dc28f99d22841cd529ec35b3307a5823dd3977ea URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dc28f99d22841cd529ec35b33…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Jul 23 15:29:15 2007 -0700 crypt32: Introduce function to encode an array of items as a set. --- dlls/crypt32/encode.c | 126 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 89 insertions(+), 37 deletions(-) diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c index a7cb661..e2fcc99 100644 --- a/dlls/crypt32/encode.c +++ b/dlls/crypt32/encode.c @@ -1210,6 +1210,91 @@ static BOOL WINAPI CRYPT_DEREncodeSet(DWORD dwCertEncodingType, return ret; } +struct DERSetDescriptor +{ + DWORD cItems; + const void *items; + size_t itemSize; + off_t itemOffset; + CryptEncodeObjectExFunc encode; +}; + +static BOOL WINAPI CRYPT_DEREncodeItemsAsSet(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + const struct DERSetDescriptor *desc = + (const struct DERSetDescriptor *)pvStructInfo; + CRYPT_SET_OF setOf = { 0, NULL }; + BOOL ret = TRUE; + DWORD i; + + if (desc->cItems) + { + setOf.rgValue = CryptMemAlloc(setOf.cValue * sizeof(CRYPT_DER_BLOB)); + if (!setOf.rgValue) + ret = FALSE; + else + { + setOf.cValue = desc->cItems; + memset(setOf.rgValue, 0, setOf.cValue * sizeof(CRYPT_DER_BLOB)); + } + } + for (i = 0; ret && i < setOf.cValue; i++) + { + ret = desc->encode(dwCertEncodingType, lpszStructType, + (const BYTE *)desc->items + i * desc->itemSize + desc->itemOffset, + 0, NULL, NULL, &setOf.rgValue[i].cbData); + if (ret) + { + setOf.rgValue[i].pbData = CryptMemAlloc(setOf.rgValue[i].cbData); + if (!setOf.rgValue[i].pbData) + ret = FALSE; + else + ret = desc->encode(dwCertEncodingType, lpszStructType, + (const BYTE *)desc->items + i * desc->itemSize + + desc->itemOffset, 0, NULL, setOf.rgValue[i].pbData, + &setOf.rgValue[i].cbData); + } + /* Some functions propagate their errors through the size */ + if (!ret) + *pcbEncoded = setOf.rgValue[i].cbData; + } + if (ret) + { + DWORD bytesNeeded = 0, lenBytes; + BOOL ret; + + for (i = 0; i < setOf.cValue; i++) + bytesNeeded += setOf.rgValue[i].cbData; + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (!pbEncoded) + *pcbEncoded = bytesNeeded; + else if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + qsort(setOf.rgValue, setOf.cValue, sizeof(CRYPT_DER_BLOB), + BLOBComp); + *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SETOF; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + for (i = 0; i < setOf.cValue; i++) + { + memcpy(pbEncoded, setOf.rgValue[i].pbData, + setOf.rgValue[i].cbData); + pbEncoded += setOf.rgValue[i].cbData; + } + } + } + for (i = 0; i < setOf.cValue; i++) + CryptMemFree(setOf.rgValue[i].pbData); + CryptMemFree(setOf.rgValue); + return ret; +} + static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn, CryptEncodeObjectExFunc nameValueEncodeFunc, BYTE *pbEncoded, DWORD *pcbEncoded) @@ -1394,55 +1479,22 @@ static BOOL WINAPI CRYPT_AsnEncodePKCSAttributes(DWORD dwCertEncodingType, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { BOOL ret = FALSE; - CRYPT_SET_OF setOf = { 0, NULL }; __TRY { - DWORD i; const CRYPT_ATTRIBUTES *attributes = (const CRYPT_ATTRIBUTES *)pvStructInfo; + struct DERSetDescriptor desc = { attributes->cAttr, attributes->rgAttr, + sizeof(CRYPT_ATTRIBUTE), 0, CRYPT_AsnEncodePKCSAttribute }; - ret = TRUE; - if (attributes->cAttr) - { - setOf.cValue = attributes->cAttr; - setOf.rgValue = CryptMemAlloc(attributes->cAttr * - sizeof(CRYPT_DER_BLOB)); - if (!setOf.rgValue) - ret = FALSE; - else - memset(setOf.rgValue, 0, setOf.cValue * sizeof(CRYPT_DER_BLOB)); - } - for (i = 0; ret && i < attributes->cAttr; i++) - { - ret = CRYPT_AsnEncodePKCSAttribute(dwCertEncodingType, NULL, - &attributes->rgAttr[i], 0, NULL, NULL, &setOf.rgValue[i].cbData); - if (ret) - { - setOf.rgValue[i].pbData = - CryptMemAlloc(setOf.rgValue[i].cbData); - if (!setOf.rgValue[i].pbData) - ret = FALSE; - else - { - ret = CRYPT_AsnEncodePKCSAttribute(dwCertEncodingType, NULL, - &attributes->rgAttr[i], 0, NULL, setOf.rgValue[i].pbData, - &setOf.rgValue[i].cbData); - } - } - } - if (ret) - ret = CRYPT_DEREncodeSet(X509_ASN_ENCODING, NULL, &setOf, dwFlags, - pEncodePara, pbEncoded, pcbEncoded); - for (i = 0; i < setOf.cValue; i++) - CryptMemFree(setOf.rgValue[i].pbData); + ret = CRYPT_DEREncodeItemsAsSet(X509_ASN_ENCODING, lpszStructType, + &desc, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } __EXCEPT_PAGE_FAULT { SetLastError(STATUS_ACCESS_VIOLATION); } __ENDTRY - CryptMemFree(setOf.rgValue); return ret; }
1
0
0
0
Juan Lang : crypt32: Add stub encoded signed message.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 223bad2312bc22dff601bbe9240ea33afbb36d40 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=223bad2312bc22dff601bbe92…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Fri Jul 20 17:31:11 2007 -0700 crypt32: Add stub encoded signed message. --- dlls/crypt32/msg.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/crypt32/tests/msg.c | 19 +++----- 2 files changed, 123 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 67a4024..08b3ce8 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -535,6 +535,119 @@ static HCRYPTMSG CHashEncodeMsg_Open(DWORD dwFlags, const void *pvMsgEncodeInfo, return (HCRYPTMSG)msg; } +typedef struct _CMSG_SIGNER_ENCODE_INFO_WITH_CMS +{ + DWORD cbSize; + PCERT_INFO pCertInfo; + HCRYPTPROV hCryptProv; + DWORD dwKeySpec; + CRYPT_ALGORITHM_IDENTIFIER HashAlgorithm; + void *pvHashAuxInfo; + DWORD cAuthAttr; + PCRYPT_ATTRIBUTE rgAuthAttr; + DWORD cUnauthAttr; + PCRYPT_ATTRIBUTE rgUnauthAttr; + CERT_ID SignerId; + CRYPT_ALGORITHM_IDENTIFIER HashEncryptionAlgorithm; + void *pvHashEncryptionAuxInfo; +} CMSG_SIGNER_ENCODE_INFO_WITH_CMS, *PCMSG_SIGNER_ENCODE_INFO_WITH_CMS; + +typedef struct _CMSG_SIGNED_ENCODE_INFO_WITH_CMS +{ + DWORD cbSize; + DWORD cSigners; + PCMSG_SIGNER_ENCODE_INFO_WITH_CMS rgSigners; + DWORD cCertEncoded; + PCERT_BLOB rgCertEncoded; + DWORD cCrlEncoded; + PCRL_BLOB rgCrlEncoded; + DWORD cAttrCertEncoded; + PCERT_BLOB rgAttrCertEncoded; +} CMSG_SIGNED_ENCODE_INFO_WITH_CMS, *PCMSG_SIGNED_ENCODE_INFO_WITH_CMS; + +static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer) +{ + if (!signer->pCertInfo->SerialNumber.cbData) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (!signer->pCertInfo->Issuer.cbData) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (!signer->hCryptProv) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + if (!CertOIDToAlgId(signer->HashAlgorithm.pszObjId)) + { + SetLastError(CRYPT_E_UNKNOWN_ALGO); + return FALSE; + } + return TRUE; +} + +typedef struct _CSignedEncodeMsg +{ + CryptMsgBase base; +} CSignedEncodeMsg; + +static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) +{ + FIXME("(%p)\n", hCryptMsg); +} + +static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, + DWORD dwIndex, void *pvData, DWORD *pcbData) +{ + FIXME("(%p, %d, %d, %p, %p)\n", hCryptMsg, dwParamType, dwIndex, pvData, + pcbData); + return FALSE; +} + +static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, + DWORD cbData, BOOL fFinal) +{ + FIXME("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal); + return FALSE; +} + +static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, + const void *pvMsgEncodeInfo, LPSTR pszInnerContentObjID, + PCMSG_STREAM_INFO pStreamInfo) +{ + const CMSG_SIGNED_ENCODE_INFO_WITH_CMS *info = + (const CMSG_SIGNED_ENCODE_INFO_WITH_CMS *)pvMsgEncodeInfo; + DWORD i; + CSignedEncodeMsg *msg; + + if (info->cbSize != sizeof(CMSG_SIGNED_ENCODE_INFO) && + info->cbSize != sizeof(CMSG_SIGNED_ENCODE_INFO_WITH_CMS)) + { + SetLastError(E_INVALIDARG); + return NULL; + } + if (info->cbSize == sizeof(CMSG_SIGNED_ENCODE_INFO_WITH_CMS)) + { + FIXME("CMSG_SIGNED_ENCODE_INFO with CMS fields unsupported\n"); + return NULL; + } + for (i = 0; i < info->cSigners; i++) + if (!CRYPT_IsValidSigner(&info->rgSigners[i])) + return NULL; + msg = CryptMemAlloc(sizeof(CSignedEncodeMsg)); + if (msg) + { + CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, + CSignedEncodeMsg_Close, CSignedEncodeMsg_GetParam, + CSignedEncodeMsg_Update); + } + return msg; +} + static inline const char *MSG_TYPE_STR(DWORD type) { switch (type) @@ -577,6 +690,9 @@ HCRYPTMSG WINAPI CryptMsgOpenToEncode(DWORD dwMsgEncodingType, DWORD dwFlags, pszInnerContentObjID, pStreamInfo); break; case CMSG_SIGNED: + msg = CSignedEncodeMsg_Open(dwFlags, pvMsgEncodeInfo, + pszInnerContentObjID, pStreamInfo); + break; case CMSG_ENVELOPED: FIXME("unimplemented for type %s\n", MSG_TYPE_STR(dwMsgType)); break; diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 893f49d..d2d9488 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -989,13 +989,11 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); signInfo.cbSize = sizeof(signInfo); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); @@ -1009,7 +1007,6 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); certInfo.SerialNumber.cbData = sizeof(serialNum); @@ -1017,7 +1014,6 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); certInfo.Issuer.cbData = sizeof(encodedCommonName); @@ -1025,7 +1021,6 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); @@ -1037,17 +1032,18 @@ static void test_signed_msg_open(void) SetLastError(0xdeadbeef); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); /* The signer's hash algorithm must also be set. */ signer.HashAlgorithm.pszObjId = oid_rsa_md5; SetLastError(0xdeadbeef); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, - NULL, NULL); - todo_wine - ok(!msg && GetLastError() == ERROR_INVALID_PARAMETER, - "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); + /* Crashes in advapi32 in wine, don't do it */ + if (0) { + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, + &signInfo, NULL, NULL); + ok(!msg && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); + } /* The signer's hCryptProv must also be valid. */ ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); @@ -1057,7 +1053,6 @@ static void test_signed_msg_open(void) ok(ret, "CryptAcquireContextW failed: %x\n", GetLastError()); msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, NULL, NULL); - todo_wine ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg);
1
0
0
0
Juan Lang : crypt32: Add tests for opening signed message to encode.
by Alexandre Julliard
24 Jul '07
24 Jul '07
Module: wine Branch: master Commit: 725d440d3c361df68c16711aa02c96120065e31e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=725d440d3c361df68c16711aa…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Fri Jul 20 17:29:34 2007 -0700 crypt32: Add tests for opening signed message to encode. --- dlls/crypt32/tests/msg.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 04be05e..893f49d 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -971,6 +971,106 @@ static void test_hash_msg(void) test_hash_msg_encoding(); } +static const WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e', + 'm','p',0 }; +static BYTE serialNum[] = { 1 }; +static BYTE encodedCommonName[] = { 0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03, + 0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 }; + +static void test_signed_msg_open(void) +{ + HCRYPTMSG msg; + BOOL ret; + CMSG_SIGNED_ENCODE_INFO signInfo = { 0 }; + CMSG_SIGNER_ENCODE_INFO signer = { sizeof(signer), 0 }; + CERT_INFO certInfo = { 0 }; + static char oid_rsa_md5[] = szOID_RSA_MD5; + + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + signInfo.cbSize = sizeof(signInfo); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + + signInfo.cSigners = 1; + signInfo.rgSigners = &signer; + /* With signer.pCertInfo unset, attempting to open this message this + * crashes. + */ + signer.pCertInfo = &certInfo; + /* The cert info must contain a serial number and an issuer. */ + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + certInfo.SerialNumber.cbData = sizeof(serialNum); + certInfo.SerialNumber.pbData = serialNum; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + certInfo.Issuer.cbData = sizeof(encodedCommonName); + certInfo.Issuer.pbData = encodedCommonName; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %x\n", GetLastError()); + + /* The signer's hCryptProv must be set to something. Whether it's usable + * or not will be checked after the hash algorithm is checked (see next + * test.) + */ + signer.hCryptProv = 1; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO, + "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError()); + /* The signer's hash algorithm must also be set. */ + signer.HashAlgorithm.pszObjId = oid_rsa_md5; + SetLastError(0xdeadbeef); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(!msg && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError()); + /* The signer's hCryptProv must also be valid. */ + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + PROV_RSA_FULL, CRYPT_NEWKEYSET); + if (!ret && GetLastError() == NTE_EXISTS) + ret = CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, + PROV_RSA_FULL, 0); + ok(ret, "CryptAcquireContextW failed: %x\n", GetLastError()); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + todo_wine + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + + CryptReleaseContext(signer.hCryptProv, 0); + CryptAcquireContextW(&signer.hCryptProv, cspNameW, MS_DEF_PROV_W, + PROV_RSA_FULL, CRYPT_DELETEKEYSET); +} + +static void test_signed_msg(void) +{ + test_signed_msg_open(); +} + static CRYPT_DATA_BLOB b4 = { 0, NULL }; static const struct update_accum a4 = { 1, &b4 }; @@ -1261,5 +1361,6 @@ START_TEST(msg) /* Message-type specific tests */ test_data_msg(); test_hash_msg(); + test_signed_msg(); test_decode_msg(); }
1
0
0
0
← Newer
1
...
30
31
32
33
34
35
36
...
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